Expand description
Gameplay events: facts the engine reports the moment something happens, such as a room placed, a star reached or a fire started, for a host to feed achievements, analytics or sound.
The engine pushes each event into Simulation::gameplay,
a ring of at most GAMEPLAY_RING_CAP. Drain it after each frame. If a
host never drains, the oldest events go and
GameplayEvents::dropped counts them. Events carry only enums and
bounded integers: no names, money or free text.
CATALOG_JSON is the contract: every event’s name, payload fields and
meaning, versioned. check_event checks a drained event against it.
use verticopolis_engine::clock::GameMode;
use verticopolis_engine::facilities::Kind;
use verticopolis_engine::gameplay::GameplayEvent;
use verticopolis_engine::sim::Simulation;
let mut sim = Simulation::new_game(1, GameMode::Classic);
sim.build(Kind::Lobby, 1, 100);
let events = sim.gameplay.drain();
assert_eq!(events[0], GameplayEvent::TowerFounded { mode: GameMode::Classic });
assert_eq!(events[1].name(), "facility_placed");
println!("{}", events[1].to_json());Structs§
- Gameplay
Events - The events waiting for the host to drain them. Never saved.
Enums§
- Emergency
Decision - What took effect when an offer was answered.
- Emergency
Kind - Which offer an
GameplayEvent::EmergencyResolvedanswered. - Emergency
Source - Who answered an offer.
- Gameplay
Event - One gameplay event.
CATALOG_JSONholds the full meaning of each, under itsname. - Removal
Method - How a player removed something, in
GameplayEvent::FacilityRemovedandSimulation::remove_facility.
Constants§
- GAMEPLAY_
RING_ CAP - The most events the ring holds between two drains.
Statics§
- CATALOG_
JSON - The gameplay event catalog as JSON: every event’s name, cardinality, payload fields and meaning. The conformance suite holds the engine to it.
Functions§
- check_
catalog - Checks a catalog’s shape and its payload rule: every field is an enum the catalog defines or a bounded integer, so no free text, money or name can enter an event.
- check_
event - Checks one drained event (as
GameplayEvent::to_jsonwrites it) against a catalog: a known name, exactly the catalog’s fields, each enum value listed and each integer in range.