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

208 lines
7.4 KiB
JavaScript

// Buildings that can be raised in a city. Build costs are fixed and grow only
// with the level, with no level cap; upkeep is 1% of that cost, so it follows
// the level too.
import { EFFECT_PRODUCTION, EFFECT_RESEARCH, EFFECT_CULTURE, effect } from "./effects.js";
import { formatNumber, formatPercent } from "../text_format.js";
import { AIR_DEFENSE } from "./combat.js";
import { SATELLITE } from "./intelligence.js";
// Extra production lines a barracks or shipyard level adds. Shared by the
// simulation and the descriptions so the two never disagree.
export const PARALLEL_LINES_PER_LEVEL = 1;
// Buildings whose benefit is a rule rather than a stat effect. Kept as ids so
// the simulation and the UI can name them without magic strings.
export const BUILDING_MECHANIC = {
// Units: one more parallel training line per level.
PARALLEL_TRAINING: "parallel_training",
// Buildings: one more parallel construction line per level.
PARALLEL_BUILDING: "parallel_building",
// Cuts civilian deaths from bombing, and is very hard to knock down.
CIVILIAN_SHELTER: "civilian_shelter",
// Fires on hostile aircraft and missiles that enter a two-tile corridor.
AIR_DEFENSE: "air_defense",
// Flat production per head for the city's region, per adjacent sea tile.
PORT_PRODUCTION: "port_production",
// Lets people fly in from any other city with an airport.
AIR_IMMIGRATION: "air_immigration",
// Unlocks the Nuclear Weapons research for the nation that raises one.
NUCLEAR_ENRICHMENT: "nuclear_enrichment",
// Each level lets the nation launch one spy satellite (see INTELLIGENCE.md).
SPACE_LAUNCH: "space_launch",
};
export const BUILDINGS = [
{
id: "barracks",
name: "Barracks",
get description() {
return `Enables training infantry units. Each level allows ${PARALLEL_LINES_PER_LEVEL} more parallel training.`;
},
baseCost: 10_000_000,
costAlpha: 1.1,
refundFraction: 0.5,
effects: [],
mechanic: "parallel_training",
icon: "icon_barracks.svg",
},
{
id: "shelters",
name: "Wartime shelters",
get description() {
return `Each level shelters another ${formatPercent(this.civilianProtectionPerLevel)} of the city's people from bombing, up to all of them. Extremely hard to destroy. Does not protect other buildings.`;
},
baseCost: 100_000_000,
costAlpha: 2,
refundFraction: 0.5,
effects: [],
mechanic: "civilian_shelter",
civilianProtectionPerLevel: 0.1,
// Multiplies the odds of the city losing a level of this building to a
// bombardment: at a tenth of the normal chance it is very hard to destroy.
destructionResistance: 0.1,
// A bunker survives a nuclear blast that flattens everything around it.
nuclearProof: true,
icon: "icon_shelters.svg",
},
{
id: "aa_building",
advanced: true,
name: "Air defense",
get description() {
return `Fires on hostile aircraft and missiles that come within ${AIR_DEFENSE.rangeTiles} tiles of this city.`;
},
baseCost: 1_000_000_000,
costAlpha: 2,
refundFraction: 0.5,
effects: [],
mechanic: "air_defense",
// Cheap to keep ready; the cost is in the ammunition it fires (see the
// combat consumption rules).
materialUpkeep: { steel: 0.5, energy: 500, hightech: 0 },
icon: "icon_aa_building.svg",
},
{
id: "research_lab",
advanced: true,
name: "Research lab",
description: "Applies science to industry and government. Produces research points for the whole nation.",
baseCost: 100_000_000,
costAlpha: 1.65,
refundFraction: 0.5,
effects: [effect(EFFECT_RESEARCH, 1.0, 0.9)],
icon: "icon_research_lab.svg",
},
{
id: "university",
advanced: true,
name: "University",
description: "Higher education produces research and a little culture for the whole nation.",
baseCost: 100_000_000,
costAlpha: 1.7,
refundFraction: 0.5,
effects: [effect(EFFECT_RESEARCH, 2.0, 0.8), effect(EFFECT_CULTURE, 0.5, 0.7)],
icon: "icon_university.svg",
},
{
id: "museum",
name: "Museum",
description: "Preserves the nation's heritage, raising its culture output across the country.",
baseCost: 50_000_000,
costAlpha: 1.6,
refundFraction: 0.5,
effects: [effect(EFFECT_CULTURE, 1.5, 0.85)],
icon: "icon_museum.svg",
},
{
id: "cinema_studio",
name: "Cinema studio",
description: "Mass media spreads the nation's culture, raising its culture output across the country.",
baseCost: 50_000_000,
costAlpha: 1.75,
refundFraction: 0.5,
effects: [effect(EFFECT_CULTURE, 3.0, 0.7)],
icon: "icon_cinema_studio.svg",
},
{
id: "port",
name: "Port",
get description() {
return `Warm water port. Adds ${formatNumber(this.productionPerSeaTilePerLevel)} production per person per adjacent sea tile per level, and brings in extra food.`;
},
baseCost: 20_000_000,
costAlpha: 1.7,
refundFraction: 0.5,
effects: [],
// Every person in the city's region produces this much more, for each sea
// tile next to the city, per port level.
mechanic: "port_production",
productionPerSeaTilePerLevel: 1000,
// The region also grows this much more food, as a fraction of its output,
// for each sea tile beside the city, per port level.
foodPerSeaTilePerLevel: 0.05,
icon: "icon_port.svg",
coastal: true,
},
{
id: "airport",
advanced: true,
name: "Airport",
description: "An airfield with a control tower. Lets the city train aircraft and serves as a home airbase for them to land and refuel. Immigration can reach this city from any other city in the world with an airport. The effect scales with airport level.",
baseCost: 250_000_000,
costAlpha: 1.7,
refundFraction: 0.5,
effects: [effect(EFFECT_PRODUCTION, 0.05, 0.8)],
mechanic: "air_immigration",
icon: "icon_airport.svg",
},
{
id: "shipyard",
name: "Shipyard",
get description() {
return `Naval yards that build warships. Only a coastal city can raise one, and it must already have a port. Each level adds ${PARALLEL_LINES_PER_LEVEL} parallel building queue.`;
},
baseCost: 150_000_000,
costAlpha: 1.65,
refundFraction: 0.5,
effects: [],
mechanic: "parallel_building",
icon: "icon_shipyard.svg",
coastal: true,
requiresBuilding: "port",
},
{
id: "uranium_enrichment_center",
advanced: true,
name: "Uranium enrichment centre",
description: "Uranium centrifuges. Raising one unlocks the Nuclear Weapons research for the whole nation.",
baseCost: 2_000_000_000,
costAlpha: 2,
refundFraction: 0.5,
effects: [],
mechanic: "nuclear_enrichment",
nuclear: true,
materialUpkeep: { steel: 3, energy: 4000, hightech: 1 },
icon: "icon_uranium_enrichment.svg",
},
{
id: "space_launch_center",
advanced: true,
name: "Space launch centre",
get description() {
return `A rocket complex. Each level lets the nation launch ${SATELLITE.perLaunchCentreLevel} spy satellite, which uncovers a random patch of the world every ${SATELLITE.revealEveryDays} days. Extremely expensive.`;
},
baseCost: 10_000_000_000,
costAlpha: 2,
refundFraction: 0.5,
effects: [],
mechanic: "space_launch",
materialUpkeep: { steel: 5, energy: 8000, hightech: 4 },
icon: "icon_space_launch_center.svg",
},
];
export function buildingById(id) {
return BUILDINGS.find((b) => b.id === id) || null;
}