Struct TacticalMatch

Source
pub struct TacticalMatch { /* private fields */ }

Implementations§

Source§

impl TacticalMatch

Source

pub fn new( config: Config, roster: Vec<PlayerSetup>, ) -> Result<TacticalMatch, RuleError>

Source

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);
Source

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

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.

Source

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.

Source

pub fn phase(&self) -> Phase

Source

pub fn remaining(&self) -> f32

Source

pub fn round(&self) -> u32

Source

pub fn score(&self) -> [u16; 2]

Source

pub fn bomb(&self) -> Bomb

Source

pub fn players(&self) -> &[Player]

Source

pub fn player(&self, id: u16) -> Option<&Player>

Source

pub fn interaction_progress(&self) -> Option<(u16, f32)>

Source

pub fn pop_event(&mut self) -> Option<Event>

Source

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.

Source

pub fn act(&mut self, id: u16, action: Action) -> Result<(), RuleError>

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.