pub struct TacticalMatch { /* private fields */ }Implementations§
Source§impl TacticalMatch
impl TacticalMatch
pub fn new( config: Config, roster: Vec<PlayerSetup>, ) -> Result<TacticalMatch, RuleError>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Start a fresh match with the same validated config, roster and spawns.
Restores round one/buy time, starting money, health, pistol loadouts and
initial bomb ownership. Clears scores, loss streaks, interactions, outcome
history and queued events, then queues exactly one Event::RoundStarted.
Repeated calls produce the same state and reuse existing roster/event
storage. Disconnected players are restored too; use a new match if the
roster has changed.
This is an authority operation, not a local menu pause. The caller owns resetting its clock, pending input, feedback and external game entities.
use ferravex_play::rounds::{Config, Event, Phase, PlayerSetup, TacticalMatch, Team};
let mut game = TacticalMatch::new(Config::default(), vec![
PlayerSetup { id: 1, team: Team::Attack, spawn: [0.0; 3] },
PlayerSetup { id: 2, team: Team::Defend, spawn: [1.0, 0.0, 0.0] },
]).unwrap();
game.forfeit(Team::Attack);
game.reset();
game.reset(); // No stale win events or duplicate start notifications.
assert_eq!(game.summary().phase, Phase::Buy);
assert_eq!(game.summary().last_outcome, None);
assert_eq!(game.pop_event(), Some(Event::RoundStarted(1)));
assert_eq!(game.pop_event(), None);Sourcepub fn summary(&self) -> RoundSummary
pub fn summary(&self) -> RoundSummary
Read round, countdown and outcome information without consuming events.
The result is a detached value. Countdown rounding is presentation only; phase transitions still occur exclusively through the rules’ mutations. The latest outcome survives event draining and the start of another round.
use ferravex_play::rounds::{
Config, Phase, PlayerSetup, RoundOutcome, TacticalMatch, Team, WinReason,
};
let mut game = TacticalMatch::new(Config::default(), vec![
PlayerSetup { id: 1, team: Team::Attack, spawn: [0.0; 3] },
PlayerSetup { id: 2, team: Team::Defend, spawn: [1.0, 0.0, 0.0] },
]).unwrap();
game.tick(0.25).unwrap();
let menu = game.summary();
assert_eq!(menu.remaining_seconds, 9.75);
assert_eq!(menu.countdown_seconds, Some(10));
game.forfeit(Team::Attack);
while game.pop_event().is_some() {}
let result = game.summary();
assert_eq!(result.phase, Phase::Finished);
assert_eq!(result.countdown_seconds, None);
assert_eq!(result.match_winner, Some(Team::Defend));
assert_eq!(result.last_outcome, Some(RoundOutcome {
round: 1, winner: Team::Defend, reason: WinReason::Forfeit,
}));
assert_eq!(menu.phase, Phase::Buy); // Earlier snapshots remain unchanged.Sourcepub fn disconnect(&mut self, id: u16) -> Result<(), RuleError>
pub fn disconnect(&mut self, id: u16) -> Result<(), RuleError>
Remove a disconnected player’s live contribution without inventing a killer. Stable roster slots remain dead until a later authority roster reset.
Sourcepub fn forfeit(&mut self, team: Team)
pub fn forfeit(&mut self, team: Team)
Authority-only disconnect forfeit. A client action cannot invoke this. Ends the match immediately so disconnected roster slots cannot resurrect on the next round and prevent elimination indefinitely.
pub fn phase(&self) -> Phase
pub fn remaining(&self) -> f32
pub fn round(&self) -> u32
pub fn score(&self) -> [u16; 2]
pub fn bomb(&self) -> Bomb
pub fn players(&self) -> &[Player]
pub fn player(&self, id: u16) -> Option<&Player>
pub fn interaction_progress(&self) -> Option<(u16, f32)>
pub fn pop_event(&mut self) -> Option<Event>
Sourcepub fn set_position(
&mut self,
id: u16,
position: [f32; 3],
) -> Result<(), RuleError>
pub fn set_position( &mut self, id: u16, position: [f32; 3], ) -> Result<(), RuleError>
Integrate movement on the authoritative host, then provide its accepted position. Moving >15 cm from interaction origin interrupts plant/defuse.
pub fn act(&mut self, id: u16, action: Action) -> Result<(), RuleError>
Sourcepub fn damage(
&mut self,
attacker: u16,
victim: u16,
amount: u16,
) -> Result<(), RuleError>
pub fn damage( &mut self, attacker: u16, victim: u16, amount: u16, ) -> Result<(), RuleError>
Apply a server-confirmed hit. Clients must never supply unvalidated hit results.
Sourcepub fn tick(&mut self, dt: f32) -> Result<(), RuleError>
pub fn tick(&mut self, dt: f32) -> Result<(), RuleError>
Splits elapsed time at every phase/interaction deadline. Large steps produce the same rule transitions as small steps. Bomb expiry wins exact defuse ties. Zero time and valid ticks after match completion are no-ops; invalid deltas are rejected even after completion.