game-village-politics-frontend/app/mock/catalog.ts

42 lines
2.5 KiB
TypeScript

import type { BuildingType, Cost, Resource, Resources } 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 {
footprint: [number, 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 GRID = { w: 10, h: 5 }
export const START_RESOURCES: Resources = { wood: 500, clay: 500, iron: 500, food: 100 }
export const CATALOG: Record<BuildingType, CatalogEntry> = {
headquarters: { footprint: [3, 3], max_per_village: 1, cost: { wood: 90, clay: 80, iron: 70 }, seconds: 20, workers: 2, production: null },
storage: { footprint: [2, 2], max_per_village: null, cost: { wood: 60, clay: 50, iron: 40 }, seconds: 15, workers: 1, production: null, capacity: 1000 },
farm: { footprint: [2, 2], max_per_village: null, cost: { wood: 45, clay: 40, iron: 30 }, seconds: 15, workers: 2, production: { resource: 'food', per_hour: 20 } },
timber_camp: { footprint: [2, 2], max_per_village: null, cost: { wood: 50, clay: 60, iron: 40 }, seconds: 12, workers: 2, production: { resource: 'wood', per_hour: 30 } },
clay_pit: { footprint: [2, 2], max_per_village: null, cost: { wood: 65, clay: 50, iron: 40 }, seconds: 12, workers: 2, production: { resource: 'clay', per_hour: 30 } },
iron_mine: { footprint: [2, 2], max_per_village: null, cost: { wood: 75, clay: 65, iron: 70 }, seconds: 14, workers: 2, production: { resource: 'iron', per_hour: 30 } },
hiding_place: { footprint: [1, 1], max_per_village: null, cost: { wood: 50, clay: 60, iron: 50 }, seconds: 10, workers: 0, production: null },
wall: { footprint: [0, 0], max_per_village: 1, cost: { wood: 50, clay: 100, iron: 20 }, seconds: 20, workers: 1, production: null },
rally_point: { footprint: [1, 1], max_per_village: 1, cost: { wood: 10, clay: 40, iron: 30 }, seconds: 10, workers: 0, production: null },
}
export const BUILDING_TYPES = Object.keys(CATALOG) as BuildingType[]
export const atLevel = (base: number, level: number) => base * (level + 1)