diff --git a/src/buildings.ts b/src/buildings.ts index 7e3f9ff..9c99b50 100644 --- a/src/buildings.ts +++ b/src/buildings.ts @@ -22,8 +22,8 @@ export default { 'iron': 100, 'food': 100, } - } - } + }, + }, }, 'woodcutter': { name: 'Woodcutter', @@ -40,9 +40,13 @@ export default { const prod = getEmptyResources(); const outputPerMinute = 5 * (self.level * self.level); prod.wood = outputPerMinute; + + const intakePerMinute = Math.ceil(self.level / 5); + prod.food = -intakePerMinute; + return prod; - } - } + }, + }, }, 'mine': { name: 'Mine', @@ -59,9 +63,13 @@ export default { const prod = getEmptyResources(); const outputPerMinute = 5 * (self.level * self.level); prod.iron = outputPerMinute; + + const intakePerMinute = Math.ceil(self.level / 5); + prod.food = -intakePerMinute; + return prod; - } - } + }, + }, }, 'pit': { name: 'Pit', @@ -78,9 +86,32 @@ export default { const prod = getEmptyResources(); const outputPerMinute = 5 * (self.level * self.level); prod.stone = outputPerMinute; + + const intakePerMinute = Math.ceil(self.level / 5); + prod.food = -intakePerMinute; + return prod; - } - } + }, + }, + }, + 'field': { + name: 'Field', + cost: (level: number) => { + return { + wood: level * 10, + stone: level * 10, + iron: level * 10, + food: 0, + }; + }, + behavior: { + production: (V: VillageState, self: Building) => { + const prod = getEmptyResources(); + const outputPerMinute = 5 * (self.level * self.level); + prod.food = outputPerMinute; + return prod; + }, + }, }, 'warehouse': { name: 'Warehouse', @@ -101,8 +132,8 @@ export default { 'stone': capacity, 'iron': capacity, 'food': 0, - } - } + }; + }, }, }, 'granary': { @@ -124,8 +155,8 @@ export default { 'stone': 0, 'iron': 0, 'food': capacity, - } - } + }; + }, }, }, }; diff --git a/src/village.ts b/src/village.ts index e5e45ee..beb7e36 100644 --- a/src/village.ts +++ b/src/village.ts @@ -1,4 +1,5 @@ import { writable } from "svelte/store"; + import buildings from "./buildings"; import { createBuilding } from "./create"; import type { Building } from "./types"; @@ -19,12 +20,16 @@ export interface VillageState { const village = writable({ buildings: [ createBuilding(buildings.townhall), + createBuilding(buildings.woodcutter), + createBuilding(buildings.pit), + createBuilding(buildings.mine), + createBuilding(buildings.field), ], resources: { - wood: 100, - stone: 100, - iron: 100, - food: 0, + wood: 60, + stone: 60, + iron: 60, + food: 50, culture: 0, }, });