Struct LobbyState

Source
pub struct LobbyState {
Show 15 fields id: LobbyId, server: Arc<SyncedServerState>, pub configs: ConfigSet, game_started: bool, pub(crate) round: u64, pub(crate) phase: LobbyPhase, pub(crate) paused: Sender<bool>, pub(crate) pause_requested: bool, pub clients: Clients, pub matchups: Vec<(PlayerId, PlayerId, bool)>, pub(crate) hist_lightsaber_options: Vec<LightsaberOptions>, pub(crate) hist_unit_options: Vec<[UnitType; 3]>, pub(crate) prev_matchups: Matchups, pub on_game_start: TxRx<bool>, pub(super) game_start_timer_id: u32,
}
Expand description

The state of a lobby. The game may not have started yet, or it could be in-progress already.

Fields§

§id: LobbyId§server: Arc<SyncedServerState>§configs: ConfigSet§game_started: bool§round: u64§phase: LobbyPhase§paused: Sender<bool>§pause_requested: bool§clients: Clients§matchups: Vec<(PlayerId, PlayerId, bool)>

Matchups. 3rd field is true if 2nd field is a ghost.

§hist_lightsaber_options: Vec<LightsaberOptions>

Contains a history of all previous lightsaber options

§hist_unit_options: Vec<[UnitType; 3]>

Contains a history of all previous unit options

§prev_matchups: Matchups

Is initialized when the game is started

§on_game_start: TxRx<bool>§game_start_timer_id: u32

Implementations§

Source§

impl LobbyState

Source

pub async fn consider_starting_game(&mut self)

Source

pub fn could_start_timer_for_game_start(&self) -> bool

Source

pub async fn start_game_now(&mut self)

Source§

impl LobbyState

Source

pub async fn message_from( &mut self, player_id: &PlayerId, msg: RxMessage, original_message: String, )

handles non-chat messages sent by playing clients

Source§

impl LobbyState

Source

pub fn new( id: LobbyId, clients: Clients, configs: ConfigSet, server: Arc<SyncedServerState>, ) -> Self

Source

pub fn id(&self) -> LobbyId

Source

pub fn paused(&self) -> bool

Source§

impl LobbyState

Source

pub async fn player_join<F, Fut>( &mut self, player: Player, player_identification: F, ) -> Result<(PlayerId, ReconnectToken), PlayerJoinError>
where F: FnOnce() -> Fut, Fut: Future<Output = (PlayerId, ReconnectToken)>,

Source

pub async fn client_leave( &mut self, name: &str, player_id: Option<PlayerId>, ) -> bool

Source

pub fn spectator_join( &mut self, spectator: Spectator, ) -> Result<(), SpectatorJoinError>

Source§

impl LobbyState

Source

pub fn min_players(&self) -> usize

Source

pub fn max_players(&self) -> usize

Source

pub fn game_started(&self) -> bool

Source

pub(super) fn set_game_started(&mut self)

Source§

impl LobbyState

Source

pub async fn broadcast_chat_message(&mut self, name: &str, message: &str)

Source§

impl LobbyState

Source

pub fn character_taken(&self, character: PlayerCharacter) -> bool

Source

pub fn available_characters(&self) -> Vec<PlayerCharacter>

Source

pub async fn broadcast_lobby_info(&mut self)

Source

pub async fn broadcast_gamestate(&mut self)

Trait Implementations§

Source§

impl Debug for LobbyState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V