Class DeckCreateRequest

java.lang.Object
net.demilich.metastone.game.decks.DeckCreateRequest
All Implemented Interfaces:
Serializable, Cloneable

public class DeckCreateRequest extends Object implements Serializable, Cloneable
Represents a request to create a game with the specified deck list.

A deck list can be specified in a community format using fromDeckList(String) and converted to a deck usable by the engine using toGameDeck(). Alternatively, the hero class and card IDs can be specified using fromCardIds(String, String...).

See Also:
  • Field Details

    • NAME_MAX_LENGTH

      public static final int NAME_MAX_LENGTH
      The maximum number of characters that can be specified in a name.
      See Also:
  • Constructor Details

    • DeckCreateRequest

      public DeckCreateRequest()
  • Method Details

    • fromDeckList

      public static DeckCreateRequest fromDeckList(String deckList) throws DeckListParsingException
      Creates a deck list from a specified community format.

      In this format, a deck is in one of two formats:

      • A community decklist format, which is a plain text list of cards.
      • A varint format, which is a Base 64-encoded list of numbers that correspond to specific cards (deprecated).

      A community decklist format looks like:

         Name: Name of the deck
         Class: The color corresponding to the champion.
         Format: The game format this deck belongs to, indicating which cards it can use
         1x Card Name
         2x Card Name
         3x Card Name
       
      The specification for these lines:
      • Name: The name of the deck that will appear in the client. This does not have to be a unique name. The name will begin after the first space in the line, if there is one. Whitespace is removed from the end and beginning of the name. The name is read until the end of the line. Names must be NAME_MAX_LENGTH characters long or fewer.
      • Class: The color corresponding to the champion. Each champion has a color specified in the CardDesc.heroClass field of a Spellsource.CardTypeMessage.CardType.CLASS. You can find the appropriate, all-capitals color by searching for CLASS cards in the CardCatalogue.
      • Format: A format consisting of a set of CardSet (strings) in the DeckFormat.formats() map.
      • A list of cards. These are each in the form number, followed immediately by an x character, followed by whitespace, followed by the case-sensitive card name in the CardDesc.name field. Whenever two cards share a name, the one that is collectible is preferred; otherwise, the chosen card is arbitrary and will not produce a warning.
      Parameters:
      deckList - A community format deck list
      Returns:
      A request on which toGameDeck() can be called to get an actual deck, or which can be passed to certain network services to create decks for users.
      Throws:
      DeckListParsingException - that contains a list of more detailed exceptions as to why the deck failed to parse or any other errors related to it. This ensures you will see all the errors related to deck list parsing, not just one error.
    • fromCardIds

      public static DeckCreateRequest fromCardIds(String heroClass, String... cardIds)
    • fromCardIds

      public static DeckCreateRequest fromCardIds(String heroClass, List<String> cardIds)
    • getUserId

      public String getUserId()
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getHeroClass

      public String getHeroClass()
    • setHeroClass

      public void setHeroClass(String heroClass)
    • getInventoryIds

      public List<String> getInventoryIds()
    • setInventoryIds

      public void setInventoryIds(List<String> inventoryIds)
    • withUserId

      public DeckCreateRequest withUserId(String userId)
    • withName

      public DeckCreateRequest withName(String name)
    • withHeroClass

      public DeckCreateRequest withHeroClass(String heroClass)
    • withInventoryIds

      public DeckCreateRequest withInventoryIds(List<String> inventoryIds)
    • getCardIds

      public List<String> getCardIds()
    • setCardIds

      public void setCardIds(List<String> cardIds)
    • withCardIds

      public DeckCreateRequest withCardIds(List<String> cardIds)
    • isDraft

      public boolean isDraft()
    • setDraft

      public void setDraft(boolean draft)
    • withDraft

      public DeckCreateRequest withDraft(boolean draft)
    • clone

      public DeckCreateRequest clone()
      Overrides:
      clone in class Object
    • toGameDeck

      public GameDeck toGameDeck()
    • getHeroCardId

      public String getHeroCardId()
    • setHeroCardId

      public void setHeroCardId(String heroCardId)
    • withHeroCardId

      public DeckCreateRequest withHeroCardId(String heroCardId)
    • isValid

      public boolean isValid()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFormat

      public String getFormat()
    • setFormat

      public void setFormat(String format)
    • withFormat

      public DeckCreateRequest withFormat(String format)
    • empty

      public static DeckCreateRequest empty(String userId, String name, String heroClass)
    • isStandardDeck

      public boolean isStandardDeck()
    • setStandardDeck

      public DeckCreateRequest setStandardDeck(boolean standardDeck)