pub struct TurnState {
pub turn_number: u32,
pub active_player: PlayerId,
pub phase: PhaseType,
pub priority_player: PlayerId,
pub num_players: u32,
pub combat_attackers_declared: bool,
pub combat_blockers_declared: bool,
pub combat_block_assignments: Vec<(CardId, CardId)>,
pub drawn_for_turn: bool,
}Expand description
Tracks the current turn state: whose turn, which phase, turn number.
Fields§
§turn_number: u32§active_player: PlayerId§phase: PhaseType§priority_player: PlayerId§num_players: u32§combat_attackers_declared: bool§combat_blockers_declared: bool§combat_block_assignments: Vec<(CardId, CardId)>Authoritative blocker -> attacker assignments for the current combat.
drawn_for_turn: boolImplementations§
Source§impl TurnState
impl TurnState
pub fn new(active_player: PlayerId, num_players: u32) -> Self
Sourcepub fn advance_phase(&mut self) -> bool
pub fn advance_phase(&mut self) -> bool
Advance to the next phase. Returns true if the turn ended (wrapped to Untap).
Sourcepub fn next_player_turn(&mut self, player_order: &[PlayerId])
pub fn next_player_turn(&mut self, player_order: &[PlayerId])
Advance to the next player’s turn (for multiplayer).
Sourcepub fn advance_turn(
&mut self,
extra_turns: &mut VecDeque<ExtraTurn>,
player_order: &[PlayerId],
) -> Option<(PlayerId, bool)>
pub fn advance_turn( &mut self, extra_turns: &mut VecDeque<ExtraTurn>, player_order: &[PlayerId], ) -> Option<(PlayerId, bool)>
Advance to the next turn, consuming an extra turn if available.
Returns Some((player, skip_untap)) if the advancing player needs
their skip_next_untap flag set on PlayerState; None otherwise.
Mirrors Java’s PhaseHandler.handleNextTurn().
pub fn is_main_phase(&self) -> bool
pub fn is_combat(&self) -> bool
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TurnState
impl<'de> Deserialize<'de> for TurnState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TurnState
impl RefUnwindSafe for TurnState
impl Send for TurnState
impl Sync for TurnState
impl Unpin for TurnState
impl UnsafeUnpin for TurnState
impl UnwindSafe for TurnState
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.