diff --git a/public/img/buildings/bakery.png b/public/img/buildings/bakery.png new file mode 100644 index 0000000..3433e32 Binary files /dev/null and b/public/img/buildings/bakery.png differ diff --git a/public/img/buildings/blacksmith.png b/public/img/buildings/blacksmith.png new file mode 100644 index 0000000..f3b4325 Binary files /dev/null and b/public/img/buildings/blacksmith.png differ diff --git a/public/img/buildings/sawmill.png b/public/img/buildings/sawmill.png new file mode 100644 index 0000000..db10438 Binary files /dev/null and b/public/img/buildings/sawmill.png differ diff --git a/public/img/buildings/stonecutter.png b/public/img/buildings/stonecutter.png new file mode 100644 index 0000000..edc80e4 Binary files /dev/null and b/public/img/buildings/stonecutter.png differ diff --git a/src/data/buildings.ts b/src/data/buildings.ts index 80409d1..3d27f64 100644 --- a/src/data/buildings.ts +++ b/src/data/buildings.ts @@ -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 [ { 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', name: 'World Wonder', diff --git a/src/village.ts b/src/village.ts index 68e33a7..1278435 100644 --- a/src/village.ts +++ b/src/village.ts @@ -117,7 +117,7 @@ function getInitialState() { state.buildings.push(townhall); // Create all the resource buildings. - const resourceBuildingTypes: Array = shuffle([ + const resourceBuildingTypes = shuffle([ 'woodcutter', 'woodcutter', 'woodcutter', 'woodcutter', 'mine', 'mine', 'mine', 'mine', 'pit', 'pit', 'pit', 'pit',