Files
Battle-for-Tismo/shared/data/units.js
T
adrien 1a9d48cdc9 Added aircraft sorties, artillery bombardment and local testing mode
- aircraft attack orders fly a sortie to the target, bomb once, return to a
  friendly airport and re-arm (two-day cooldown, charged per aircraft); rebasing
  is bounded by fuel rather than the 10-tile combat radius
- artillery and warships open a sustained hourly bombardment on a standing
  target, drawn as a red dashed line and ring while either endpoint is selected
- a game launched from localhost can enable a testing mode whose train and build
  rows offer free, instant orders; the server only honours them for a loopback
  admin in a testing game
- an open city panel now unlocks aircraft as soon as an airport finishes
2026-09-18 21:55:30 +02:00

130 lines
3.1 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",
name: "Modern infantry",
maxHp: 500,
cost: 100_000_000,
upkeep: 5000,
moveable: true,
speed: 0.5,
military: true,
attack: 100,
defense: 40,
range: 1,
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",
name: "Artillery",
maxHp: 400,
cost: 300_000_000,
upkeep: 12_000,
moveable: true,
speed: 0.25,
military: 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",
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 10-tile reach needs 4 hours aloft for the round trip, leaving
// an hour of reserve.
air: true,
enduranceHours: 5,
missionRange: 10,
requiresBuilding: "airport",
icon: "icon_jet_fighter.svg",
},
{
id: "bomber",
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: 2,
traversableTerrains: ["Land", "Sea", "Ice"],
air: true,
enduranceHours: 2,
missionRange: 5,
strike: true,
requiresBuilding: "airport",
icon: "icon_bomber.svg",
},
{
id: "battleship",
name: "Battleship",
maxHp: 800,
cost: 600_000_000,
upkeep: 30_000,
moveable: true,
speed: 0.5,
military: true,
attack: 400,
defense: 120,
range: 2,
traversableTerrains: ["Sea"],
requiresBuilding: "shipyard",
icon: "icon_battleship.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",
];
export function protoUnitById(id) {
return PROTO_UNITS.find((u) => u.id === id) || null;
}