Skip to main content
Verticopolis engineGitHub

Module gameplay

Module gameplay 

Source
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§

GameplayEvents
The events waiting for the host to drain them. Never saved.

Enums§

EmergencyDecision
What took effect when an offer was answered.
EmergencyKind
Which offer an GameplayEvent::EmergencyResolved answered.
EmergencySource
Who answered an offer.
GameplayEvent
One gameplay event. CATALOG_JSON holds the full meaning of each, under its name.
RemovalMethod
How a player removed something, in GameplayEvent::FacilityRemoved and Simulation::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_json writes it) against a catalog: a known name, exactly the catalog’s fields, each enum value listed and each integer in range.