Struct Player

Source
pub struct Player {
Show 20 fields pub(crate) con: Option<Connection>, name: String, pub role: PlayerRole, pub(super) reconnect_token: ReconnectToken, pub character: Option<PlayerCharacter>, pub ready: bool, pub player_in_matchup: PlayerInMatchup, pub lives: i64, pub fights_won: u64, pub red_lightsabers: Vec<f64>, pub green_lightsabers: Vec<f64>, pub blue_lightsabers: Vec<f64>, pub unit_bank: Vec<UnitType>, pub unit_placement: Vec<PlacedUnit>, pub(crate) lightsaber_choice: Result<LightsaberType, Option<OwnedSemaphorePermit>>, pub(crate) lightsaber_choice_allowed: bool, pub(crate) unit_choice: Result<UnitType, Option<OwnedSemaphorePermit>>, pub(crate) unit_choice_allowed: bool, pub(crate) new_placement: Result<(Vec<PlacedUnit>, Vec<UnitType>), Option<OwnedSemaphorePermit>>, pub(crate) new_placement_allowed: bool,
}

Fields§

§con: Option<Connection>

Some(_) as long as the player is connected, None after a disconnect and before a reconnect.

§name: String§role: PlayerRole§reconnect_token: ReconnectToken§character: Option<PlayerCharacter>

Some(_) after game start

§ready: bool§player_in_matchup: PlayerInMatchup

Either Player1 or Player2. Controls which coordinates this player should use (from 0,0 for Player1)

§lives: i64§fights_won: u64§red_lightsabers: Vec<f64>§green_lightsabers: Vec<f64>§blue_lightsabers: Vec<f64>§unit_bank: Vec<UnitType>§unit_placement: Vec<PlacedUnit>§lightsaber_choice: Result<LightsaberType, Option<OwnedSemaphorePermit>>§lightsaber_choice_allowed: bool§unit_choice: Result<UnitType, Option<OwnedSemaphorePermit>>§unit_choice_allowed: bool§new_placement: Result<(Vec<PlacedUnit>, Vec<UnitType>), Option<OwnedSemaphorePermit>>§new_placement_allowed: bool

Implementations§

Source§

impl Player

Source

pub fn new(name: String, role: PlayerRole, con: Connection) -> Self

Source

pub fn name(&self) -> &str

Source

pub fn reconnect_token(&self) -> &ReconnectToken

Source§

impl Player

Source

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

Trait Implementations§

Source§

impl Debug for Player

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Player

§

impl !RefUnwindSafe for Player

§

impl Send for Player

§

impl Sync for Player

§

impl Unpin for Player

§

impl !UnwindSafe for Player

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