예제 #1
0
  /**
   * Initializes a new game.
   *
   * @param numHouseSets the number of house sets (each set is 4 houses of each suit)
   * @param numDecks the number of standard 52 card deck
   * @param withJokerRule <code>true</code> for the Joker Rule to be added, otherwise <code>false
   *     </code>
   * @param withNumCardRule <code>true</code> for the NumCard Rule to be added, otherwise <code>
   *     false</code>
   */
  public void startNewGame(int numHouseSets, int numDecks) {
    this.playersHandCard = null;
    this.playerScore = 0;
    this.started = true;
    this.gameOver = false;
    this.gameOverMessage = "";

    this.houses = new House[numHouseSets * CardSuit.values().length];
    int j = 0;
    for (int i = 0; i < numHouseSets; i++) {
      for (CardSuit suit : CardSuit.values()) {
        this.houses[j] = createNewHouse(suit, jokerRule, sixCardsRule);
        j++;
      }
    }

    int jokerSet = 0;
    if (jokerRule) jokerSet = 1;
    this.dealer = new CardDeck(numDecks, jokerSet);

    dealer.shuffle();
    dealer.shuffle();
    dealer.shuffle();
    try {
      deal();
    } catch (HoCException e) {
      System.err.println("WTF??? The game just started!!!");
      e.printStackTrace();
    }

    for (EngineListener lstnr : listeners) {
      lstnr.newGameStarted();
    }
  }
  /** @return the image associated with the card */
  public ImageIcon getImage() {
    String cardName =
        "/edu/psu/ist412/view/graphics/" + value.toString() + suit.toString() + ".png";

    return new ImageIcon(getClass().getResource(cardName));
  }