Files
Battle-for-Tismo/shared/data/improvements.js
T

107 lines
3.4 KiB
JavaScript

// Player-buildable tile improvements. A tile carries at most one, laid down on
// land the civilisation controls: a road or a railway, the latter twice as fast
// again as a road. Both are bought outright and then cost an hourly maintenance
// for every tile of the network a nation holds.
import { resourceBuildingById } from "./resources.js";
export const TRANSPORT_IMPROVEMENTS = [
{
id: "road",
name: "Road",
// The texture the client draws the tile with.
texture: "road",
// Travel multiplier once a unit is on the tile. Unimproved grass is 1.0, so
// a road moves twice as fast and a railway twice as fast again (50% faster
// than a road).
movementCostMultiplier: 0.5,
buildCost: 50_000_000,
maintenance: 100_000,
icon: "icon_road.svg",
},
{
id: "railway",
name: "Railway",
texture: "rail",
movementCostMultiplier: 0.25,
buildCost: 150_000_000,
maintenance: 300_000,
icon: "icon_railway.svg",
},
];
export const TRANSPORT_BY_ID = Object.fromEntries(
TRANSPORT_IMPROVEMENTS.map((improvement) => [improvement.id, improvement])
);
export function transportImprovement(id) {
return TRANSPORT_BY_ID[id] || null;
}
// Player-buildable military tile improvements. Unlike transport, these take
// construction time (the same GDP-scaled formula as buildings and units) and
// cost an hourly maintenance. A tile may carry one of these plus a road or
// railway. `defense` is the extra fraction of base defense granted to units
// stationed there against melee and artillery fire.
export const TILE_IMPROVEMENTS = [
{
id: "fortifications",
name: "Fortifications",
description:
"Earthworks and bunkers. Holds a permanent area of control, shelters its garrison and takes damage in combat.",
buildCost: 200_000_000,
maintenance: 10_000,
vision: 2,
defense: { melee: 2.0, artillery: 4.0 },
permanentControl: true,
takesCombatDamage: true,
// Earthworks and bunkers shrug off a nuclear blast.
nuclearProof: true,
icon: "icon_fortifications.svg",
},
{
id: "radar_tower",
advanced: true,
name: "Radar tower",
get description() {
return `Watches ${this.vision} tiles out. A ranged hit damages it and an enemy walking onto it captures it.`;
},
buildCost: 60_000_000,
maintenance: 1000,
vision: 5,
takesRangedDamage: true,
capturable: true,
icon: "icon_radar_tower.svg",
},
{
id: "coastal_cannon",
advanced: true,
name: "Coastal cannon",
get description() {
return `Automatically fires on hostile naval units within ${this.range} tiles. Only a coastal tile can carry one.`;
},
buildCost: 120_000_000,
maintenance: 2000,
range: 2,
automatic: true,
takesDamage: true,
coastal: true,
icon: "icon_coastal_cannon.svg",
},
];
export const TILE_IMPROVEMENT_BY_ID = Object.fromEntries(
TILE_IMPROVEMENTS.map((improvement) => [improvement.id, improvement])
);
// A tile-owned building is either a military improvement or a resource
// producer. Both share the tile-improvement maps, the tile-works construction
// queue and the hourly upkeep, so the lookup folds the two catalogues together.
export function tileImprovementById(id) {
return TILE_IMPROVEMENT_BY_ID[id] || resourceBuildingById(id) || null;
}
export function isResourceTileBuilding(proto) {
return !!(proto && proto.resource && proto.outputPerDay !== undefined);
}