70 lines
4.3 KiB
TypeScript
70 lines
4.3 KiB
TypeScript
import type { BuildingType, Cost, Resource, Resources, UnitType } from '~/types/game'
|
|
|
|
// Placeholder numbers so the PoC has something to show. They scale linearly with the
|
|
// level on purpose: the real values and formulas belong to the backend
|
|
// (config/game/buildings.php and app/Game/), not to the client.
|
|
|
|
export interface CatalogEntry {
|
|
/** Building space an instance takes (0 for the wall). */
|
|
space: number
|
|
max_per_village: number | null
|
|
/** Level 0 values. Level n costs, takes, needs and produces (n + 1) times as much. */
|
|
cost: Cost
|
|
seconds: number
|
|
workers: number
|
|
production: { resource: Resource; per_hour: number } | null
|
|
capacity?: number
|
|
}
|
|
|
|
export const MAX_LEVEL = 30
|
|
export const BUILDERS = 2
|
|
export const BASE_TRICKLE = 5
|
|
export const VILLAGER_UPKEEP = 1
|
|
export const DEMOLISH_REFUND = 0.5
|
|
export const DEFAULT_PRIORITY = 5
|
|
export const MAX_SPACE = 50
|
|
export const START_RESOURCES: Resources = { wood: 500, clay: 500, iron: 500, food: 100 }
|
|
|
|
export const CATALOG: Record<BuildingType, CatalogEntry> = {
|
|
headquarters: { space: 9, max_per_village: 1, cost: { wood: 90, clay: 80, iron: 70 }, seconds: 20, workers: 2, production: null },
|
|
storage: { space: 4, max_per_village: null, cost: { wood: 60, clay: 50, iron: 40 }, seconds: 15, workers: 1, production: null, capacity: 1000 },
|
|
farm: { space: 4, max_per_village: null, cost: { wood: 45, clay: 40, iron: 30 }, seconds: 15, workers: 2, production: { resource: 'food', per_hour: 20 } },
|
|
timber_camp: { space: 4, max_per_village: null, cost: { wood: 50, clay: 60, iron: 40 }, seconds: 12, workers: 2, production: { resource: 'wood', per_hour: 30 } },
|
|
clay_pit: { space: 4, max_per_village: null, cost: { wood: 65, clay: 50, iron: 40 }, seconds: 12, workers: 2, production: { resource: 'clay', per_hour: 30 } },
|
|
iron_mine: { space: 4, max_per_village: null, cost: { wood: 75, clay: 65, iron: 70 }, seconds: 14, workers: 2, production: { resource: 'iron', per_hour: 30 } },
|
|
hiding_place: { space: 1, max_per_village: null, cost: { wood: 50, clay: 60, iron: 50 }, seconds: 10, workers: 0, production: null },
|
|
wall: { space: 0, max_per_village: 1, cost: { wood: 50, clay: 100, iron: 20 }, seconds: 20, workers: 1, production: null },
|
|
rally_point: { space: 1, max_per_village: 1, cost: { wood: 10, clay: 40, iron: 30 }, seconds: 10, workers: 0, production: null },
|
|
barracks: { space: 6, max_per_village: null, cost: { wood: 200, clay: 170, iron: 90 }, seconds: 30, workers: 3, production: null },
|
|
stable: { space: 6, max_per_village: null, cost: { wood: 270, clay: 240, iron: 260 }, seconds: 40, workers: 3, production: null },
|
|
workshop: { space: 6, max_per_village: null, cost: { wood: 300, clay: 240, iron: 260 }, seconds: 50, workers: 4, production: null },
|
|
academy: { space: 9, max_per_village: 1, cost: { wood: 1500, clay: 2500, iron: 1000 }, seconds: 60, workers: 5, production: null },
|
|
}
|
|
|
|
export const BUILDING_TYPES = Object.keys(CATALOG) as BuildingType[]
|
|
|
|
export const atLevel = (base: number, level: number) => base * (level + 1)
|
|
|
|
export interface UnitEntry {
|
|
building: BuildingType
|
|
cost: Cost
|
|
/** Food per hour, and villagers taken per unit. */
|
|
upkeep: number
|
|
/** Seconds per unit, short so the mock shows progress. */
|
|
seconds: number
|
|
requires: Partial<Record<BuildingType, number>>
|
|
}
|
|
|
|
export const UNITS: Record<UnitType, UnitEntry> = {
|
|
spear: { building: 'barracks', cost: { wood: 50, clay: 30, iron: 10 }, upkeep: 1, seconds: 10, requires: {} },
|
|
sword: { building: 'barracks', cost: { wood: 30, clay: 30, iron: 70 }, upkeep: 1, seconds: 15, requires: {} },
|
|
archer: { building: 'barracks', cost: { wood: 100, clay: 30, iron: 60 }, upkeep: 1, seconds: 18, requires: { barracks: 3 } },
|
|
light_cavalry: { building: 'stable', cost: { wood: 125, clay: 100, iron: 250 }, upkeep: 3, seconds: 18, requires: {} },
|
|
heavy_cavalry: { building: 'stable', cost: { wood: 200, clay: 150, iron: 600 }, upkeep: 4, seconds: 36, requires: { stable: 5 } },
|
|
ram: { building: 'workshop', cost: { wood: 300, clay: 200, iron: 200 }, upkeep: 4, seconds: 48, requires: {} },
|
|
catapult: { building: 'workshop', cost: { wood: 320, clay: 400, iron: 100 }, upkeep: 6, seconds: 72, requires: { workshop: 2 } },
|
|
nobleman: { building: 'academy', cost: { wood: 40000, clay: 50000, iron: 50000 }, upkeep: 10, seconds: 108, requires: {} },
|
|
}
|
|
|
|
export const UNIT_TYPES = Object.keys(UNITS) as UnitType[]
|