Skip to main content
Verticopolis engine

verticopolis_engine/catalog/
halo.rs

1//! The catalog's view of a venue's cross-floor halo ([`crate::rules::Halo`]),
2//! which the placement range rings draw (#1980).
3
4use serde::Serialize;
5
6use crate::clock::GameMode;
7use crate::facilities::{Kind, FACILITIES};
8
9/// A venue's halo: who feels it, over how many floors and how hard.
10#[derive(Clone, Debug, PartialEq, Serialize)]
11#[serde(rename_all = "camelCase")]
12pub struct HaloEntry {
13    /// `lift` (an amenity) or `drain` (a nuisance).
14    pub effect: &'static str,
15    /// How far it reaches: a room `d` floors away feels `max * (1 - d /
16    /// floors)`, and none at `floors` or beyond.
17    pub floors: f64,
18    /// The hourly bonus or drain on the venue's own floor.
19    pub max: f64,
20    /// How far a lift raises a capped room's ceiling at full strength, or
21    /// null for a drain.
22    pub cap_lift: Option<f64>,
23    /// The kinds that feel it, in catalog order.
24    pub felt_by: Vec<&'static str>,
25    /// Felt only in the venue's open hours (its `openHours`).
26    pub open_hours_only: bool,
27    /// Scaled by the household's size, largest for the biggest family.
28    pub family_scaled: bool,
29}
30
31pub(super) fn halo_entry(mode: GameMode, kind: Kind) -> Option<HaloEntry> {
32    let h = mode.halo_of(kind)?;
33    Some(HaloEntry {
34        effect: h.effect.as_str(),
35        floors: h.floors,
36        max: h.max,
37        cap_lift: h.cap_lift_max(),
38        felt_by: FACILITIES
39            .iter()
40            .filter(|f| h.felt_by(f.kind))
41            .map(|f| f.key)
42            .collect(),
43        open_hours_only: h.open_hours_only,
44        family_scaled: h.family_scaled,
45    })
46}