# Class Deck

java.lang.Object
it.polimi.ingsw.is25am31.model.cards.Deck

public class Deck extends Object
The `Deck` class represents a collection of cards used within the game. It contains both the full deck and the initial sub decks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Deck(int level)`
  Creates 4 sub decks of 2 level 2 cards and 1 level 1 card if the game level is 2, otherwise creates a deck of 8 test flight cards.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Card`
  `drawCard()`
  `List<Card>`
  `getSubDeck(int index)`
  `boolean`
  `isEmpty()`
  `void`
  `mergeSubDecks()`
  Merges the sub decks in the main deck.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Deck

    public Deck(int level)
    Creates 4 sub decks of 2 level 2 cards and 1 level 1 card if the game level is 2, otherwise creates a deck of 8 test flight cards.
    Parameters:
      `level` - Level of the game, used to create the right deck for a specified level.

- ## Method Details

  - ### mergeSubDecks

    public void mergeSubDecks()
    Merges the sub decks in the main deck.

  - ### drawCard

    public Card drawCard() throws NoCardsLeftException
    Returns:
      The first card of the deck.
    Throws:
      `NoCardsLeftException` - if there are no cards left in the deck (this condition should never occur in normal conditions).

  - ### getSubDeck

    public List<Card> getSubDeck(int index)
    Parameters:
      `index` - Index of the required sub deck.
    Returns:
      Sub deck in the specified index.

  - ### isEmpty

    public boolean isEmpty()
    Returns:
      `true` If deck has no more cards in it, `false` otherwise.