/// <summary> /// Resets the game and all the players hands /// </summary> internal void resetGame() { isGameOver = false; // create a new deck myDeck = new Deck(theDeckSize); myDeck.shuffle(); // set the trump card trumpCard = myDeck[0]; // set game state and current attacking and defending players isAttacking = true; currentPlayer = 0; attackingPlayer = 0; defendingPlayer = 1; myBout.clear(); discardPile.clear(); foreach (GenericPlayer p in myPlayers) { p.myHand.clear(); } }
/// <summary> /// Default Constructor for the game of durak /// </summary> /// <param name="numberOfPlayers"></param> /// <param name="deckSize"></param> /// <param name="difficulty"></param> /// <param name="isAllAI"></param> internal DurakGame(int numberOfPlayers = MIN_PLAYERS, Deck.DeckSize deckSize = Deck.DeckSize.THIRTY_SIX, ComputerPlayer.AIDifficulty difficulty = ComputerPlayer.AIDifficulty.Basic, bool isAllAI = false) { // validate the number of players if (numberOfPlayers < MIN_PLAYERS || numberOfPlayers > MAX_PLAYERS) { throw new ArgumentException("Number of players entered must be between " + MIN_PLAYERS + " and " + MAX_PLAYERS + " you entered " + numberOfPlayers.ToString(), "numberOfPlayers"); } theDeckSize = deckSize; this.numberOfPlayers = numberOfPlayers; isAiGame = isAllAI; // If its an AI game load only AI's if (isAiGame) { for (int i = 0; i < numberOfPlayers; ++i) { switch (difficulty) { case ComputerPlayer.AIDifficulty.Basic: myPlayers.Add(new BasicAI(this)); break; case ComputerPlayer.AIDifficulty.Advanced: // add stuff here throw new ArgumentOutOfRangeException("Advanced AI not implement yet"); break; case ComputerPlayer.AIDifficulty.Cheater: // add stuff here throw new ArgumentOutOfRangeException("Cheating AI not implement yet"); break; } myPlayers[i].name = "Computer Player " + (i + 1); } } else // load the player and then the AI's { myPlayers.Add(new HumanPlayer(this, "Human Player")); for (int i = 1; i < numberOfPlayers; ++i) { switch (difficulty) { case ComputerPlayer.AIDifficulty.Basic: myPlayers.Add(new BasicAI(this)); break; case ComputerPlayer.AIDifficulty.Advanced: // add stuff here throw new ArgumentOutOfRangeException("Advanced AI not implement yet"); break; case ComputerPlayer.AIDifficulty.Cheater: // add stuff here throw new ArgumentOutOfRangeException("Cheating AI not implement yet"); break; } } } // create a new deck myDeck = new Deck(theDeckSize); myDeck.shuffle(); // set the trump card trumpCard = myDeck[0]; // set game state and current attacking and defending players isAttacking = true; currentPlayer = 0; attackingPlayer = 0; defendingPlayer = 1; }