pub struct Zone {
pub zone_type: ZoneType,
pub owner: PlayerId,
pub cards: Vec<CardId>,
pub cards_added_this_turn: Vec<(ZoneType, CardId)>,
pub cards_added_last_turn: Vec<(ZoneType, CardId)>,
pub melded_cards: Vec<CardId>,
pub triggers_enabled: bool,
}Expand description
A game zone owned by a specific player. Each player has their own Hand, Library, Graveyard, etc. Battlefield and Stack are shared but cards still track their controller.
Mirrors Java’s Zone.java.
Fields§
§zone_type: ZoneType§owner: PlayerId§cards: Vec<CardId>§cards_added_this_turn: Vec<(ZoneType, CardId)>Cards added this turn, keyed by their origin zone.
cards_added_last_turn: Vec<(ZoneType, CardId)>Cards added last turn, keyed by their origin zone.
melded_cards: Vec<CardId>Cards that have been melded (combined into a single permanent).
Only meaningful when zone_type == Battlefield.
triggers_enabled: boolWhether entering-the-battlefield triggers are active.
Mirrors Java’s PlayerZoneBattlefield.trigger field.
Only meaningful when zone_type == Battlefield.
Implementations§
Source§impl Zone
impl Zone
pub fn new(zone_type: ZoneType, owner: PlayerId) -> Self
pub fn add(&mut self, card: CardId)
pub fn add_to_top(&mut self, card: CardId)
pub fn add_to_bottom(&mut self, card: CardId)
pub fn remove(&mut self, card: CardId) -> bool
Sourcepub fn remove_all_cards(&mut self)
pub fn remove_all_cards(&mut self)
Remove all cards from the zone.
Mirrors Java’s Zone.removeAllCards().
Sourcepub fn reorder(&mut self, card: CardId, index: usize)
pub fn reorder(&mut self, card: CardId, index: usize)
Reorder a card to a specific index.
Mirrors Java’s Zone.reorder().
pub fn contains(&self, card: CardId) -> bool
Sourcepub fn is(&self, zone_type: ZoneType) -> bool
pub fn is(&self, zone_type: ZoneType) -> bool
Check if this zone is the given type.
Mirrors Java’s Zone.is().
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn get(&self, index: usize) -> Option<CardId>
pub fn get(&self, index: usize) -> Option<CardId>
Get the card at the given index.
Mirrors Java’s Zone.get().
Sourcepub fn take_top(&mut self) -> Option<CardId>
pub fn take_top(&mut self) -> Option<CardId>
Take the top card (last element = top of library).
Sourcepub fn reset_cards_added_this_turn(&mut self)
pub fn reset_cards_added_this_turn(&mut self)
Reset turn tracking: move this-turn data to last-turn.
Mirrors Java’s Zone.resetCardsAddedThisTurn().
Sourcepub fn iterator(&self) -> impl Iterator<Item = &CardId>
pub fn iterator(&self) -> impl Iterator<Item = &CardId>
Provides an iterator over the cards in this zone.
Mirrors Java’s Zone.iterator().
Sourcepub fn shuffle(&mut self, rng: &mut dyn GameRng)
pub fn shuffle(&mut self, rng: &mut dyn GameRng)
Shuffle the cards in this zone using the provided RNG.
Mirrors Java’s Zone.shuffle().
All game randomness must flow through the game’s RNG for deterministic replay and parity testing.
Sourcepub fn add_to_melded(&mut self, card: CardId)
pub fn add_to_melded(&mut self, card: CardId)
Add a card to the melded cards list.
Mirrors Java’s PlayerZoneBattlefield.addToMelded().
Sourcepub fn remove_from_melded(&mut self, card: CardId)
pub fn remove_from_melded(&mut self, card: CardId)
Remove a card from the melded cards list.
Mirrors Java’s PlayerZoneBattlefield.removeFromMelded().
Sourcepub fn get_cards(&self, _filter: bool) -> &[CardId]
pub fn get_cards(&self, _filter: bool) -> &[CardId]
Get the cards in this zone.
The _filter parameter is ignored for non-battlefield zones (they always
return the full list). Battlefield filtering is handled by
PlayerZoneBattlefield::get_cards().
Mirrors Java’s Zone.getCards(boolean).
Sourcepub fn get_cards_added_this_turn(&self, origin: ZoneType) -> Vec<CardId>
pub fn get_cards_added_this_turn(&self, origin: ZoneType) -> Vec<CardId>
Get cards that were added to this zone this turn from the given origin zone.
Mirrors Java’s Zone.getCardsAddedThisTurn(ZoneType).
Sourcepub fn get_cards_added_last_turn(&self, origin: ZoneType) -> Vec<CardId>
pub fn get_cards_added_last_turn(&self, origin: ZoneType) -> Vec<CardId>
Get cards that were added to this zone last turn from the given origin zone.
Mirrors Java’s Zone.getCardsAddedLastTurn(ZoneType).
Sourcepub fn is_card_added_this_turn(&self, card: CardId, origin: ZoneType) -> bool
pub fn is_card_added_this_turn(&self, card: CardId, origin: ZoneType) -> bool
Check whether a specific card was added to this zone this turn from
the given origin zone.
Mirrors Java’s Zone.isCardAddedThisTurn(Card, ZoneType).
Sourcepub fn get_lki_copy(&self) -> Zone
pub fn get_lki_copy(&self) -> Zone
Create a shallow copy of this zone for last-known-information purposes.
The returned zone has the same type, owner, and card list.
Mirrors Java’s Zone.getLKICopy().