diff --git a/src/data/buildings.ts b/src/data/buildings.ts index de61db6..45b333a 100644 --- a/src/data/buildings.ts +++ b/src/data/buildings.ts @@ -3,6 +3,26 @@ import { getEmptyResources } from "../utils"; import type { VillageState } from "../village"; +function getStandardTimeToBuild(level: number) { + return Math.round(Math.pow(level, 1 / 1.2) + 1); +} + + +function getResourceBuildingCost(level: number, initial: number) { + return initial * level * (level - 1); +} + + +function getStorageBuildingCost(level: number, initial: number) { + return initial * Math.round( (level + level * level) / 3); +} + + +function getUnitBuildingCost(level: number, initial: number) { + return initial * Math.round( (level + level * level) / 2); +} + + export default [ { type: 'townhall', @@ -17,6 +37,7 @@ export default [ food: 0, }; }, + timeToBuild: getStandardTimeToBuild, behavior: { storage: (_V: VillageState, _self: BuildingType) => { return { @@ -35,12 +56,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 10, - stone: level * 10, - iron: level * 10, - food: 0, + wood: getResourceBuildingCost(level, 6), + stone: getResourceBuildingCost(level, 10), + iron: getResourceBuildingCost(level, 14), + food: getResourceBuildingCost(level, 10), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { production: (V: VillageState, self: BuildingType) => { const prod = getEmptyResources(); @@ -61,12 +83,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 10, - stone: level * 10, - iron: level * 10, - food: 0, + wood: getResourceBuildingCost(level, 10), + stone: getResourceBuildingCost(level, 14), + iron: getResourceBuildingCost(level, 6), + food: getResourceBuildingCost(level, 10), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { production: (V: VillageState, self: BuildingType) => { const prod = getEmptyResources(); @@ -87,12 +110,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 10, - stone: level * 10, - iron: level * 10, - food: 0, + wood: getResourceBuildingCost(level, 14), + stone: getResourceBuildingCost(level, 6), + iron: getResourceBuildingCost(level, 10), + food: getResourceBuildingCost(level, 10), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { production: (V: VillageState, self: BuildingType) => { const prod = getEmptyResources(); @@ -113,12 +137,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 10, - stone: level * 10, - iron: level * 10, - food: 0, + wood: getResourceBuildingCost(level, 14), + stone: getResourceBuildingCost(level, 14), + iron: getResourceBuildingCost(level, 12), + food: getResourceBuildingCost(level, 0), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { production: (V: VillageState, self: BuildingType) => { const prod = getEmptyResources(); @@ -134,12 +159,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 10, - stone: level * 10, - iron: level * 10, - food: 0, + wood: getStorageBuildingCost(level, 15), + stone: getStorageBuildingCost(level, 20), + iron: getStorageBuildingCost(level, 10), + food: getStorageBuildingCost(level, 15), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { storage: (V: VillageState, self: BuildingType) => { const x = self.level; @@ -159,12 +185,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 10, - stone: level * 10, - iron: level * 10, - food: 0, + wood: getStorageBuildingCost(level, 12), + stone: getStorageBuildingCost(level, 22), + iron: getStorageBuildingCost(level, 10), + food:getStorageBuildingCost(level, 6), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { storage: (V: VillageState, self: BuildingType) => { const x = self.level; @@ -184,12 +211,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 100, - stone: level * 100, - iron: level * 100, - food: 0, + wood: getUnitBuildingCost(level, 75), + stone: getUnitBuildingCost(level, 90), + iron: getUnitBuildingCost(level, 50), + food: getUnitBuildingCost(level, 45), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { production: (V: VillageState, self: BuildingType) => { const prod = getEmptyResources(); @@ -209,12 +237,13 @@ export default [ maxLevel: 20, cost: (level: number) => { return { - wood: level * 100, - stone: level * 100, - iron: level * 100, - food: 0, + wood: getUnitBuildingCost(level, 60), + stone: getUnitBuildingCost(level, 30), + iron: getUnitBuildingCost(level, 90), + food: getUnitBuildingCost(level, 40), }; }, + timeToBuild: getStandardTimeToBuild, behavior: { production: (V: VillageState, self: BuildingType) => { const prod = getEmptyResources(); diff --git a/src/data/units.ts b/src/data/units.ts index fbeb2ad..2f2bee0 100644 --- a/src/data/units.ts +++ b/src/data/units.ts @@ -3,9 +3,9 @@ export default [ type: 'philosopher', name: 'Philosopher', cost: { - wood: 20, - stone: 50, - iron: 0, + wood: 25, + stone: 55, + iron: 5, food: 0, }, behavior: { diff --git a/src/moves/build.ts b/src/moves/build.ts index bef574f..d4a7083 100644 --- a/src/moves/build.ts +++ b/src/moves/build.ts @@ -29,7 +29,7 @@ export default function build(V: VillageState, buildingType: string, tile: Hex) newBuilding.tile = tile; newBuilding.level = 0; newBuilding.state.upgrade.isUpgrading = true; - newBuilding.state.upgrade.remainingTime = 1000 * (newBuilding.level + 1); + newBuilding.state.upgrade.remainingTime = 1000 * newBuilding.timeToBuild(newBuilding.level + 1); V.buildings.push(newBuilding); V.villageTiles[tile.y][tile.x] = newBuilding.id; diff --git a/src/moves/upgradeBuilding.ts b/src/moves/upgradeBuilding.ts index 756d563..225563e 100644 --- a/src/moves/upgradeBuilding.ts +++ b/src/moves/upgradeBuilding.ts @@ -28,7 +28,7 @@ export default function upgradeBuilding(V: VillageState, buildingId: number) { V.resources.food -= cost.food; building.state.upgrade.isUpgrading = true; - building.state.upgrade.remainingTime = 1000 * (building.level + 1); + building.state.upgrade.remainingTime = 1000 * building.timeToBuild(building.level + 1); return true; } diff --git a/src/quests.ts b/src/quests.ts index 88f0d0c..a32f7f1 100644 --- a/src/quests.ts +++ b/src/quests.ts @@ -12,14 +12,11 @@ export function createQuest(level: number): QuestType { Object.keys(reward).forEach(r => { const resource = r as keyof ResourcesType; reward[resource] = random( - duration * 5 - level * 10, - duration * 5 + level * 10, + Math.round((duration * 5 - level * 10) * (1 + level / 3)), + Math.round((duration * 5 + level * 10) * (1 + level / 3)), ); - if (resource === 'food') { - reward[resource] = Math.round(reward[resource] / 3); - } - else if (resource === 'culture') { + if (resource === 'culture') { reward[resource] = Math.round(reward[resource] / 20); } }); diff --git a/src/types.ts b/src/types.ts index 71c27c3..3545510 100644 --- a/src/types.ts +++ b/src/types.ts @@ -26,6 +26,7 @@ export interface BuildingSource { autoBuilt?: boolean; maxLevel: number; cost: (level: number) => CostType; + timeToBuild: (level: number) => number; behavior: { production?: Function; storage?: Function;