Add buildings that improve resource production.

This commit is contained in:
Adrian 2024-11-14 14:53:26 +01:00
parent 933796bb4a
commit 83adff2603
6 changed files with 114 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

View File

@ -24,6 +24,11 @@ function getUnitBuildingCost(level: number, initial: number) {
} }
function getMultiplierBuildingCost(level: number, initial: number) {
return initial * Math.round( (level + level * level) / 3);
}
export default [ export default [
{ {
type: 'townhall', type: 'townhall',
@ -353,6 +358,114 @@ export default [
}, },
}, },
}, },
{
type: 'sawmill',
name: 'Sawmill',
maxLevel: 5,
unique: true,
requiredTownhallLevel: 7,
cost: (level: number) => {
return {
wood: getMultiplierBuildingCost(level, 440),
stone: getMultiplierBuildingCost(level, 610),
iron: getMultiplierBuildingCost(level, 870),
food: getMultiplierBuildingCost(level, 700),
};
},
timeToBuild: (level: number) => getStandardTimeToBuild(level) * 3,
behavior: {
production: (V: VillageState, self: BuildingType) => {
const resourceProd = V.buildings
.filter(b => b.type === 'woodcutter')
.map(f => f.behavior.production?.(V, f).wood)
.reduce((acc, f) => acc + f, 0);
const prod = getEmptyResources();
prod.wood = resourceProd * self.level * 0.05;
return prod;
},
},
},
{
type: 'stonecutter',
name: 'Stonecutter',
maxLevel: 5,
unique: true,
requiredTownhallLevel: 7,
cost: (level: number) => {
return {
wood: getMultiplierBuildingCost(level, 870),
stone: getMultiplierBuildingCost(level, 440),
iron: getMultiplierBuildingCost(level, 610),
food: getMultiplierBuildingCost(level, 700),
};
},
timeToBuild: (level: number) => getStandardTimeToBuild(level) * 3,
behavior: {
production: (V: VillageState, self: BuildingType) => {
const resourceProd = V.buildings
.filter(b => b.type === 'pit')
.map(f => f.behavior.production?.(V, f).stone)
.reduce((acc, f) => acc + f, 0);
const prod = getEmptyResources();
prod.stone = resourceProd * self.level * 0.05;
return prod;
},
},
},
{
type: 'blacksmith',
name: 'Blacksmith',
maxLevel: 5,
unique: true,
requiredTownhallLevel: 7,
cost: (level: number) => {
return {
wood: getMultiplierBuildingCost(level, 610),
stone: getMultiplierBuildingCost(level, 870),
iron: getMultiplierBuildingCost(level, 440),
food: getMultiplierBuildingCost(level, 700),
};
},
timeToBuild: (level: number) => getStandardTimeToBuild(level) * 3,
behavior: {
production: (V: VillageState, self: BuildingType) => {
const resourceProd = V.buildings
.filter(b => b.type === 'mine')
.map(f => f.behavior.production?.(V, f).iron)
.reduce((acc, f) => acc + f, 0);
const prod = getEmptyResources();
prod.iron = resourceProd * self.level * 0.05;
return prod;
},
},
},
{
type: 'bakery',
name: 'Bakery',
maxLevel: 5,
unique: true,
requiredTownhallLevel: 7,
cost: (level: number) => {
return {
wood: getMultiplierBuildingCost(level, 670),
stone: getMultiplierBuildingCost(level, 740),
iron: getMultiplierBuildingCost(level, 670),
food: getMultiplierBuildingCost(level, 520),
};
},
timeToBuild: (level: number) => getStandardTimeToBuild(level) * 3,
behavior: {
production: (V: VillageState, self: BuildingType) => {
const fields = V.buildings.filter(b => b.type === 'field');
const fieldFoodProd = fields
.map(f => f.behavior.production?.(V, f).food)
.reduce((acc, f) => acc + f, 0);
const prod = getEmptyResources();
prod.food = fieldFoodProd * self.level * 0.05;
return prod;
},
},
},
{ {
type: 'wonder', type: 'wonder',
name: 'World Wonder', name: 'World Wonder',

View File

@ -117,7 +117,7 @@ function getInitialState() {
state.buildings.push(townhall); state.buildings.push(townhall);
// Create all the resource buildings. // Create all the resource buildings.
const resourceBuildingTypes: Array<string> = shuffle([ const resourceBuildingTypes = shuffle([
'woodcutter', 'woodcutter', 'woodcutter', 'woodcutter', 'woodcutter', 'woodcutter', 'woodcutter', 'woodcutter',
'mine', 'mine', 'mine', 'mine', 'mine', 'mine', 'mine', 'mine',
'pit', 'pit', 'pit', 'pit', 'pit', 'pit', 'pit', 'pit',