Class Deck

java.lang.Object
moe.maika.ygofm.gamedata.Deck

public class Deck extends Object
Implementation of a deck of cards in Forbidden Memories. A deck must be exactly 40 cards and cannot contain more than 3 copies of a single card. Deck sorts that are done on the Build Deck screen before duels are also implemented to facilitate RNG manipulation simulations.
  • Field Details

    • DECK_SIZE

      public static final int DECK_SIZE
      The size of a deck in Forbidden Memories.
      See Also:
    • CARD_ID_ORDER

      public static final Comparator<Card> CARD_ID_ORDER
    • ALPHABETICAL_ORDER

      public static final Comparator<Card> ALPHABETICAL_ORDER
    • MAX_ORDER

      public static final Comparator<Card> MAX_ORDER
    • ATTACK_ORDER

      public static final Comparator<Card> ATTACK_ORDER
    • DEFENSE_ORDER

      public static final Comparator<Card> DEFENSE_ORDER
    • TYPE_ORDER

      public static final Comparator<Card> TYPE_ORDER
    • JAPANESE_ALPHABETICAL_ORDER

      public static final Comparator<Card> JAPANESE_ALPHABETICAL_ORDER
    • JAPANESE_MAX_ORDER

      public static final Comparator<Card> JAPANESE_MAX_ORDER
    • JAPANESE_ATTACK_ORDER

      public static final Comparator<Card> JAPANESE_ATTACK_ORDER
    • JAPANESE_DEFENSE_ORDER

      public static final Comparator<Card> JAPANESE_DEFENSE_ORDER
    • JAPANESE_TYPE_ORDER

      public static final Comparator<Card> JAPANESE_TYPE_ORDER
  • Constructor Details

    • Deck

      public Deck()
      Creates a new deck with no cards.
    • Deck

      public Deck(Collection<Card> composition)
      Creates a new deck with the given composition of cards. The composition must contain exactly 40 cards.
      Parameters:
      composition - the cards of the deck
    • Deck

      public Deck(Deck toCopy)
      Creates a copy of another deck
      Parameters:
      toCopy - the deck to copy
  • Method Details

    • get

      public Card get(int index)
      Gets the card in the deck at the given index.
      Parameters:
      index - the index of the card in the deck
      Returns:
      the card at the given index
    • getRange

      public List<Card> getRange(int start, int end)
      Gets the range of cards in the deck from the given start index to the given end index.
      Parameters:
      start - the start index, inclusive
      end - the end index, exclusive
      Returns:
    • toList

      public List<Card> toList()
      Converts this deck to a list of cards.
      Returns:
      a list of cards in the deck in the same order
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • sort

      public void sort(Comparator<? super Card> comparator)
      Sorts the deck according to the given deck sort. The deck in modified in place.
      Parameters:
      comparator - the deck sort
    • shuffle

      public void shuffle(RNG seed, Comparator<? super Card> deckOrderBeforeDuel)
      Shuffles the deck, with its current order as the starting point. Use this method for player decks.
      Parameters:
      seed - the RNG seed
      deckOrderBeforeDuel - the sort order of the deck on the Build Deck screen before the duel
    • shuffle

      public void shuffle(RNG seed)
      Shuffles the deck, with its current order as the starting point. Use this shuffle method for AI decks.
      Parameters:
      seed - the RNG seed
    • startsWith

      public boolean startsWith(List<Card> cards)
      Determines whether the deck starts with the given sequence of cards.
      Parameters:
      cards - the sequence of cards
      Returns:
      true if the deck starts with the given sequence of cards
    • createDuelistDeck

      public static Deck createDuelistDeck(Duelist duelist, RNG seed)
      Creates an AI duelist's deck.
      Parameters:
      duelist - the duelist whose deck to create
      seed - the RNG seed
      Returns:
      an unshuffled AI deck
    • getAllSorts

      public static List<Comparator<Card>> getAllSorts()
      Gets all the deck sorts available in Forbidden Memories.
      Returns:
      a list of all deck sorts
    • toString

      public String toString()
      Overrides:
      toString in class Object