Function prune_bridges_over_budget

Source
pub fn prune_bridges_over_budget(
    config: &GameConfig,
    cores: &mut CoresState,
    extra: i64,
) -> usize
Expand description

Drops the bridges that no longer fit max_bridges, and reports how many went.

The budget only ever shrinks one way: BL-01 Extra Span leaving the Bridge socket takes its +1 with it. The bridge it paid for has to go too, or the stone is a ratchet — socket it, build the extra bridge, put another Bridge stone in its place and keep both. Core levels only rise, so this is the one direction that needs cleaning up, and it mirrors UnslotLaw dropping the bridges of the law it unslots.

The bridges that go are the tail of the list. Inside one session that is the newest first, but character_law_bridges is read back ordered by law id rather than by creation time, so after a reconnect it is simply the last in that order. Deterministic either way, and deliberately not shown to the player as “your newest bridge”.