101 lines
6.3 KiB
TypeScript
101 lines
6.3 KiB
TypeScript
import type { BuildingType, Cost, Resource, Resources, TravelMode, 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 1 values. Level n costs, takes, needs and produces n 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
|
|
/** Building space at headquarters level 1, and what each level above adds. */
|
|
export const MAX_SPACE = 40
|
|
export const SPACE_PER_HQ_LEVEL = 5
|
|
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 },
|
|
watchtower: { space: 2, max_per_village: 1, cost: { wood: 1200, clay: 1400, iron: 1000 }, seconds: 40, workers: 1, 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 },
|
|
hospital: { space: 4, max_per_village: null, cost: { wood: 160, clay: 200, iron: 120 }, seconds: 30, workers: 2, 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 * Math.max(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>>
|
|
/** Seconds per map field, short so marches finish while you watch. */
|
|
speed: number
|
|
/** Resources one unit carries home. */
|
|
carry: number
|
|
attack: number
|
|
defense: number
|
|
}
|
|
|
|
export const UNITS: Record<UnitType, UnitEntry> = {
|
|
spear: { building: 'barracks', cost: { wood: 50, clay: 30, iron: 10 }, upkeep: 1, seconds: 10, requires: {}, speed: 6, carry: 25, attack: 10, defense: 15 },
|
|
sword: { building: 'barracks', cost: { wood: 30, clay: 30, iron: 70 }, upkeep: 1, seconds: 15, requires: {}, speed: 7, carry: 15, attack: 25, defense: 50 },
|
|
archer: { building: 'barracks', cost: { wood: 100, clay: 30, iron: 60 }, upkeep: 1, seconds: 18, requires: { barracks: 3 }, speed: 6, carry: 10, attack: 15, defense: 45 },
|
|
scout: { building: 'stable', cost: { wood: 50, clay: 50, iron: 20 }, upkeep: 2, seconds: 9, requires: {}, speed: 2, carry: 0, attack: 0, defense: 0 },
|
|
light_cavalry: { building: 'stable', cost: { wood: 125, clay: 100, iron: 250 }, upkeep: 3, seconds: 18, requires: {}, speed: 3, carry: 80, attack: 130, defense: 30 },
|
|
heavy_cavalry: { building: 'stable', cost: { wood: 200, clay: 150, iron: 600 }, upkeep: 4, seconds: 36, requires: { stable: 5 }, speed: 4, carry: 50, attack: 150, defense: 200 },
|
|
ram: { building: 'workshop', cost: { wood: 300, clay: 200, iron: 200 }, upkeep: 4, seconds: 48, requires: {}, speed: 10, carry: 0, attack: 2, defense: 20 },
|
|
catapult: { building: 'workshop', cost: { wood: 320, clay: 400, iron: 100 }, upkeep: 6, seconds: 72, requires: { workshop: 2 }, speed: 10, carry: 0, attack: 100, defense: 100 },
|
|
nobleman: { building: 'academy', cost: { wood: 40000, clay: 50000, iron: 50000 }, upkeep: 10, seconds: 108, requires: {}, speed: 12, carry: 0, attack: 30, defense: 100 },
|
|
}
|
|
|
|
export const UNIT_TYPES = Object.keys(UNITS) as UnitType[]
|
|
|
|
/** Defence of one drafted villager. */
|
|
export const MILITIA_DEFENSE = 5
|
|
|
|
// Rally point placeholders: travel modes, spotting radius, recall window, barbarian stock.
|
|
|
|
export const TRAVEL_MODES: { mode: TravelMode; speed: number; visibility: number }[] = [
|
|
{ mode: 'sneaky', speed: 0.5, visibility: 0 },
|
|
{ mode: 'cautious', speed: 0.8, visibility: 4 },
|
|
{ mode: 'normal', speed: 1, visibility: 15 },
|
|
{ mode: 'fast', speed: 1.25, visibility: 30 },
|
|
{ mode: 'forced', speed: 1.5, visibility: 60 },
|
|
]
|
|
export const DEFAULT_MODE: TravelMode = 'normal'
|
|
/** Fields around a village within which incoming groups are spotted; a watchtower adds its level. */
|
|
export const DETECTION = 2
|
|
/** Seconds after sending during which a command can be called back. */
|
|
export const CANCEL_WINDOW = 600
|
|
/** Wood, clay and iron each in every barbarian village; it never runs out. */
|
|
export const BARBARIAN_STOCK = 1000
|