pub struct PlayerZone {
pub zone: Zone,
pub player: PlayerId,
}Expand description
A zone owned by a specific player.
Mirrors Java’s PlayerZone which extends Zone.
In Rust, we use composition rather than inheritance:
PlayerZone wraps a Zone and adds player-specific behavior.
Note: The engine’s GameState stores zones as HashMap<ZoneKey, Zone>.
PlayerZone provides the ported Java API for zone-level card filtering;
callers that need card-state filtering (keywords, may-play) should use
GameState methods which have access to CardInstance data.
Fields§
§zone: Zone§player: PlayerIdImplementations§
Source§impl PlayerZone
impl PlayerZone
pub fn new(zone_type: ZoneType, player: PlayerId) -> Self
pub fn get_player(&self) -> PlayerId
Sourcepub fn test(&self, card: CardId) -> bool
pub fn test(&self, card: CardId) -> bool
Test whether a card in this zone passes a containment check.
Mirrors Java’s inner OwnCardsActivationFilter.test().
Sourcepub fn get_cards_player_can_activate(&self, who: PlayerId) -> Vec<CardId>
pub fn get_cards_player_can_activate(&self, who: PlayerId) -> Vec<CardId>
Get cards the given player can potentially activate from this zone.
Mirrors Java’s PlayerZone.getCardsPlayerCanActivate().
This performs zone-level filtering:
- Battlefield/Hand: owner sees all their cards
- Library: only the top card is visible
- Other zones: all cards returned (card-level keyword filtering
like Flashback/Retrace requires
GameStateaccess)
Methods from Deref<Target = Zone>§
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().
Trait Implementations§
Source§impl Clone for PlayerZone
impl Clone for PlayerZone
Source§fn clone(&self) -> PlayerZone
fn clone(&self) -> PlayerZone
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more