Files
Battle-for-Tismo/shared/data/units.js
T
adrien e7ee5dbf0e Added the resource economy, its works and their icons
- Five resources (energy, steel, food, luxury, high-tech) with per-city stores, a world market, delivery and material upkeep.
- Resource-producing tile works built outside cities; every nation opens with the works its economy needs.
- Real game-icons.net art replacing the dummy icons for the new resources and works, with the credits updated.
2026-09-22 05:27:11 +02:00

189 lines
4.7 KiB
JavaScript

// Unit archetypes. `military` units fight, capture cities and may enter an
// enemy military unit's tile. `attack` is the damage dealt per combat round and
// `defense` the damage absorbed per round; a defender's defense is doubled (the
// 100% defensive bonus). `range` is how many tiles away the unit can strike
// (1 is melee).
export const PROTO_UNITS = [
{
id: "modern_infantry",
population: 1_000,
name: "Modern infantry",
maxHp: 500,
cost: 100_000_000,
upkeep: 5000,
moveable: true,
speed: 0.5,
military: true,
// Marks the unit for the infantry research effects (weapons, body armour).
infantry: true,
attack: 100,
defense: 40,
range: 1,
requiresBuilding: "barracks",
traversableTerrains: ["Land"],
icon: "icon_modern_infantry.svg",
},
{
id: "worker",
name: "Worker",
maxHp: 100,
cost: 0,
upkeep: 0,
moveable: true,
speed: 0.5,
military: false,
attack: 0,
defense: 0,
range: 1,
traversableTerrains: ["Land"],
icon: "icon_settler.svg",
},
{
id: "artillery",
materialUpkeep: { steel: 2, energy: 2000, hightech: 0 },
name: "Artillery",
maxHp: 400,
cost: 300_000_000,
upkeep: 12_000,
moveable: true,
speed: 0.25,
military: true,
// Marks the unit for the artillery research effect.
artillery: true,
attack: 250,
// Barely armoured: nearly every hit gets through.
defense: 5,
// Outranges infantry, so melee units cannot strike back from two tiles.
range: 2,
traversableTerrains: ["Land"],
icon: "icon_artillery.svg",
},
{
id: "jet_fighter",
materialUpkeep: { steel: 5, energy: 5000, hightech: 1 },
advanced: true,
name: "Jet fighter",
maxHp: 300,
cost: 400_000_000,
upkeep: 20_000,
moveable: true,
speed: 5,
military: true,
attack: 300,
defense: 20,
range: 1,
traversableTerrains: ["Land", "Sea", "Ice"],
// Aircraft only operate near a friendly airport: `enduranceHours` is how
// long they may stay aloft and `missionRange` the furthest they may be
// ordered from home. Both are per-type so a future plane can differ. The
// fighter's 25-tile strike reach needs ten hours aloft for the round trip;
// `missionRange` is the looser ceiling.
air: true,
enduranceHours: 10,
missionRange: 80,
requiresBuilding: "airport",
icon: "icon_jet_fighter.svg",
},
{
id: "bomber",
materialUpkeep: { steel: 8, energy: 8000, hightech: 2 },
advanced: true,
name: "Bomber",
maxHp: 350,
cost: 500_000_000,
upkeep: 25_000,
moveable: true,
speed: 5,
military: true,
attack: 450,
defense: 10,
// A bomber strikes from `range` tiles away and never joins the melee.
range: 0,
traversableTerrains: ["Land", "Sea", "Ice"],
// The bomber's 50-tile strike reach needs twenty hours aloft for the round
// trip; `missionRange` is the looser ceiling.
air: true,
enduranceHours: 20,
missionRange: 100,
strike: true,
requiresBuilding: "airport",
icon: "icon_bomber.svg",
},
{
id: "battleship",
advanced: true,
name: "Battleship",
maxHp: 800,
cost: 600_000_000,
upkeep: 30_000,
moveable: true,
speed: 0.5,
military: true,
attack: 400,
defense: 120,
range: 2,
naval: true,
traversableTerrains: ["Sea"],
requiresBuilding: "shipyard",
icon: "icon_battleship.svg",
},
{
id: "mobile_radar",
advanced: true,
name: "Mobile radar",
maxHp: 200,
cost: 50_000_000,
upkeep: 5000,
moveable: true,
speed: 0.5,
military: false,
attack: 0,
defense: 0,
range: 0,
// Watches four tiles out, cannot fight, is taken by any unit that walks
// onto it, and a lone one is destroyed outright by a single ranged hit.
vision: 4,
capturable: true,
destroyedByRangedAlone: true,
traversableTerrains: ["Land"],
icon: "icon_radar.svg",
},
{
id: "launch",
name: "Launch",
maxHp: 150,
cost: 20_000_000,
upkeep: 2000,
moveable: true,
speed: 0.5,
military: false,
attack: 0,
defense: 0,
range: 0,
// Transports one infantry unit and is defenceless on its own.
transportCapacity: 1,
transportKind: "infantry",
capturable: true,
naval: true,
traversableTerrains: ["Sea"],
requiresBuilding: "port",
icon: "icon_launch.svg",
},
];
// Only units in this list can be trained from the city screen.
export const TRAINABLE_UNIT_IDS = [
"modern_infantry",
"artillery",
"jet_fighter",
"bomber",
"battleship",
"mobile_radar",
"launch",
];
export function protoUnitById(id) {
return PROTO_UNITS.find((u) => u.id === id) || null;
}