Class CardZone

All Implemented Interfaces:
Serializable, Cloneable, Comparable<EntityZone<? extends Entity>>, Iterable<Card>, Collection<Card>, List<Card>, CardList

public final class CardZone extends EntityZone<Card> implements CardList
This class is a CardList that represents the Spellsource.ZonesMessage.Zones.HAND and Spellsource.ZonesMessage.Zones.DECK. It is implemented as an EntityZone because it represents an in-game zone; i.e., an entity can only be in one zone at once.
See Also:
  • Constructor Details

    • CardZone

      public CardZone(int player, com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones zone, Map<Integer,Entity> lookup)
    • CardZone

      public CardZone(int player, com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones zone, CardList cardsCopy, Map<Integer,Entity> lookup)
  • Method Details

    • addCard

      public CardList addCard(Card card)
      Description copied from interface: CardList
      Adds the card fluently.
      Specified by:
      addCard in interface CardList
      Parameters:
      card - The card
      Returns:
      This instance.
    • addAll

      public CardList addAll(CardList cardList)
      Description copied from interface: CardList
      Adds all the cards from the given list.
      Specified by:
      addAll in interface CardList
      Parameters:
      cardList - The cards to add.
      Returns:
      This instance.
    • clone

      public CardZone clone()
      Creates a new zone and adds a clone of all the cards to it. Skips checks on the zone to prevent entities from being in two places at once.
      Specified by:
      clone in interface CardList
      Overrides:
      clone in class EntityZone<Card>
      Returns:
      The cloned CardZone.
      See Also:
    • contains

      public boolean contains(Card card)
      Description copied from interface: CardList
      Checks if the list has the specific reference to a card. Does not use the card's Entity.id or its Card.getCardId(), which may be more helpful.
      Specified by:
      contains in interface CardList
      Parameters:
      card - The card instance to check.
      Returns:
      true if the specific instance is inside this list.
      See Also:
    • getCount

      public int getCount()
      Description copied from interface: CardList
      Gets the size of this list.
      Specified by:
      getCount in interface CardList
      Returns:
      The list size.
    • peekFirst

      public Card peekFirst()
      Description copied from interface: CardList
      Gets the first card in this instance.
      Specified by:
      peekFirst in interface CardList
      Returns:
      The first card in this instance.
    • remove

      public boolean remove(Card card)
      Description copied from interface: CardList
      Removes the specified card instance by reference.
      Specified by:
      remove in interface CardList
      Parameters:
      card - The card to remove.
      Returns:
      true if the card was removed.
    • removeAll

      @Deprecated public void removeAll() throws Exception
      Deprecated.
      Description copied from interface: CardList
      Removes all the cards from this instance.
      Specified by:
      removeAll in interface CardList
      Throws:
      Exception
    • removeFirst

      public Card removeFirst()
      Removes the first card in this instance and sets its location to EntityLocation.UNASSIGNED, so that it can be added to another zone.
      Specified by:
      removeFirst in interface CardList
      Returns:
      The card that was removed.
    • replace

      public boolean replace(Card oldCard, Card newCard)
      Replaces a card in this zone, setting the old card's Entity.entityLocation to EntityLocation.UNASSIGNED so that it can be added to another zone.
      Specified by:
      replace in interface CardList
      Parameters:
      oldCard - The card to find and replace.
      newCard - The new card to replace it with.
      Returns:
      true if the old card was found and replaced. false if the old card was not found and not replaced. (You'll never find the old card and not replace it).
    • shuffle

      public CardList shuffle(XORShiftRandom random)
      Description copied from interface: CardList
      Shuffles the instance with the given random number generator.
      Specified by:
      shuffle in interface CardList
      Parameters:
      random - A XORShiftRandom instance.
    • toList

      public List<Card> toList()
      Description copied from interface: CardList
      Gets a List that references the contents of this instance.
      Specified by:
      toList in interface CardList
      Returns:
      A List whose contents are the same objects as this instance.
    • stream

      public Stream<Card> stream()
      Description copied from interface: CardList
      Gets the Stream API representation of this card list.
      Specified by:
      stream in interface CardList
      Specified by:
      stream in interface Collection<Card>
      Returns:
      The backing list's Collection.stream().