Skip to main content
Verticopolis engine

verticopolis_engine/facilities/
pools.rs

1//! The pooled build caps: kinds that share one cap per tower (`Tower::cap_reason`).
2
3use super::Kind;
4
5#[doc(hidden)]
6pub struct Pool {
7    pub kinds: &'static [Kind],
8    pub cap: i64,
9    pub label: &'static str,
10}
11
12#[doc(hidden)]
13/// `POOLED_CAPS`.
14pub static POOLED_CAPS: [Pool; 2] = [
15    Pool {
16        kinds: &[
17            Kind::ElevatorStandard,
18            Kind::ElevatorService,
19            Kind::ElevatorExpress,
20        ],
21        cap: 24,
22        label: "elevator shafts",
23    },
24    Pool {
25        kinds: &[Kind::Stairs, Kind::Escalator],
26        cap: 64,
27        label: "stairs/escalators",
28    },
29];
30
31/// The elevator shafts a Modern tower may hold, all three kinds together:
32/// twice SimTower's 24, so a lot of several towers can give each its own
33/// banks (owner, 2026-11-15).
34pub const MODERN_ELEVATOR_SHAFT_CAP: i64 = 48;
35
36/// Modern's transport pools: the same two pools as [`POOLED_CAPS`], with
37/// room for [`MODERN_ELEVATOR_SHAFT_CAP`] elevator shafts.
38pub static MODERN_POOLED_CAPS: [Pool; 2] = [
39    Pool {
40        kinds: POOLED_CAPS[0].kinds,
41        cap: MODERN_ELEVATOR_SHAFT_CAP,
42        label: POOLED_CAPS[0].label,
43    },
44    Pool {
45        kinds: POOLED_CAPS[1].kinds,
46        cap: POOLED_CAPS[1].cap,
47        label: POOLED_CAPS[1].label,
48    },
49];
50
51/// The transport pools `mode` enforces, in [`POOLED_CAPS`] order.
52pub fn transport_pools(mode: crate::clock::GameMode) -> &'static [Pool; 2] {
53    if mode.builds_more_elevator_shafts() {
54        &MODERN_POOLED_CAPS
55    } else {
56        &POOLED_CAPS
57    }
58}
59
60/// The most transports, of every kind together, a tower in `mode` may hold.
61pub fn transport_cap(mode: crate::clock::GameMode) -> i64 {
62    transport_pools(mode).iter().map(|p| p.cap).sum()
63}
64
65/// Classic's party hall and theater pool (#1932): the 1994 save keeps one
66/// table of 16 records shared by every party hall and theater, so the two
67/// kinds share one cap of 16. Modern keeps a cap of 16 for each.
68pub static CLASSIC_VENUE_POOL: Pool = Pool {
69    kinds: &[Kind::Cinema, Kind::PartyHall],
70    cap: 16,
71    label: "party halls and theaters",
72};
73
74/// Every pooled cap `mode` enforces: the transport pools, then Classic's
75/// venue pool.
76pub fn pools_for(mode: crate::clock::GameMode) -> impl Iterator<Item = &'static Pool> {
77    let venues = mode.shares_venue_cap().then_some(&CLASSIC_VENUE_POOL);
78    transport_pools(mode).iter().chain(venues)
79}