Skip to main content

PhaseHandler

Struct PhaseHandler 

Source
pub struct PhaseHandler {
    pub n_upkeeps_this_turn: i32,
    pub n_upkeeps_this_game: i32,
    pub n_combats_this_turn: i32,
    pub n_mains_this_turn: i32,
    pub n_end_of_turns_this_turn: i32,
    pub planar_dice_special_action_this_turn: i32,
    pub skip_damage_steps: bool,
    pub repeat_cleanup: bool,
    pub give_priority_to_player: bool,
    /* private fields */
}
Expand description

Tracks phase-specific state for a game. Mirrors Java’s PhaseHandler fields.

Fields§

§n_upkeeps_this_turn: i32§n_upkeeps_this_game: i32§n_combats_this_turn: i32§n_mains_this_turn: i32§n_end_of_turns_this_turn: i32§planar_dice_special_action_this_turn: i32§skip_damage_steps: bool§repeat_cleanup: bool§give_priority_to_player: bool

Implementations§

Source§

impl PhaseHandler

Source

pub fn new() -> Self

Source

pub fn get_phase(&self) -> Option<PhaseType>

Source

pub fn set_phase(&mut self, phase: PhaseType)

Source

pub fn get_turn(&self) -> i32

Source

pub fn is_player_turn(&self, player: PlayerId) -> bool

Source

pub fn get_player_turn(&self) -> Option<PlayerId>

Source

pub fn set_player_turn(&mut self, player: PlayerId)

Source

pub fn get_previous_player_turn(&self) -> Option<PlayerId>

Source

pub fn get_priority_player(&self) -> Option<PlayerId>

Source

pub fn set_priority(&mut self, player: PlayerId)

Source

pub fn reset_priority(&mut self)

Source

pub fn is_first_combat(&self) -> bool

Source

pub fn get_num_combat(&self) -> i32

Source

pub fn get_num_upkeep(&self) -> i32

Source

pub fn is_first_upkeep(&self) -> bool

Source

pub fn is_first_upkeep_this_game(&self) -> bool

Source

pub fn get_num_main(&self) -> i32

Source

pub fn before_first_post_combat_main_end(&self) -> bool

Source

pub fn skipped_declare_blockers(&self) -> bool

Source

pub fn get_num_end_of_turn(&self) -> i32

Source

pub fn is(&self, phase: PhaseType) -> bool

Source

pub fn is_phase_player(&self, phase: PhaseType, player: PlayerId) -> bool

Source

pub fn add_extra_turn( &mut self, player: PlayerId, player_order: &[PlayerId], ) -> &ExtraTurn

Add an extra turn for the given player. Mirrors Java’s PhaseHandler.addExtraTurn().

Source

pub fn add_extra_phase( &mut self, after_phase: PhaseType, extra_phase_list: &[PhaseType], next_phase: PhaseType, )

Add extra phase(s) after the given phase. Mirrors Java’s PhaseHandler.addExtraPhase().

Source

pub fn get_next_turn(&self, player_order: &[PlayerId]) -> Option<PlayerId>

Source

pub fn restart(&mut self)

Reset the phase handler for a game restart (e.g. Karn Liberated). Mirrors Java’s PhaseHandler.restart().

Source

pub fn on_stack_resolved(&mut self)

Called when the stack resolves — re-enable priority. Mirrors Java’s PhaseHandler.onStackResolved().

Source

pub fn get_planar_dice_special_action_this_turn(&self) -> i32

Source

pub fn inc_planar_dice_special_action_this_turn(&mut self)

Source

pub fn get_extra_turn_for_player(&self, player: PlayerId) -> i32

Get the continuous extra turn count for a player. Mirrors Java’s PhaseHandler.getExtraTurnForPlayer().

Source

pub fn handle_next_turn(&mut self, player_order: &[PlayerId]) -> PlayerId

Advance to the next turn. Returns the player who gets the next turn. Mirrors Java’s PhaseHandler.handleNextTurn().

Source

pub fn end_combat_phase_by_effect(&mut self)

Source

pub fn end_turn_by_effect(&mut self)

Source

pub fn debug_print_state(&self, has_priority: bool) -> String

Source

pub fn in_combat(&self) -> bool

Returns true if a combat is currently in progress. Mirrors Java’s PhaseHandler.inCombat().

Source

pub fn end_combat(&mut self)

End the current combat. Mirrors Java’s PhaseHandler.endCombat().

Source

pub fn setup_first_turn(&mut self, goes_first: PlayerId)

Set up the first turn of the game for the given player. Mirrors Java’s PhaseHandler.setupFirstTurn().

Source

pub fn start_first_turn(&mut self, goes_first: PlayerId)

Start the first turn and enter the main game loop. Mirrors Java’s PhaseHandler.startFirstTurn(). In Rust, the actual loop is driven by GameLoop::run_turn_state_machine().

Source

pub fn dev_advance_to_phase(&mut self, target_phase: PhaseType) -> bool

Dev mode: advance to a target phase, running phase transitions. Mirrors Java’s PhaseHandler.devAdvanceToPhase().

Source

pub fn dev_mode_set( &mut self, phase: Option<PhaseType>, player: Option<PlayerId>, end_combat: bool, cturn: i32, )

Dev mode: set the phase and player directly. Mirrors Java’s PhaseHandler.devModeSet().

Trait Implementations§

Source§

impl Clone for PhaseHandler

Source§

fn clone(&self) -> PhaseHandler

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PhaseHandler

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PhaseHandler

Source§

fn default() -> Self

Returns the “default value” for a type. 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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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