コード例 #1
0
ファイル: Program.cs プロジェクト: bschreder/WarCardGame
        /// <summary>
        /// Primary loop that runs the War card game
        /// </summary>
        /// <param name="battleOutput">User interface output class</param>
        /// <returns>GamesResults object with winning and losing player</returns>
        public static GameResults RunGame(IBattleOutput battleOutput)
        {
            Game     game = new Game(battleOutput);
            CardPile deck = new CardPile();

            game.CreateDeck(deck);
            game.Shuffle(deck, _numberOfShuffles);

            Player player1 = new Player();
            Player player2 = new Player();

            game.DealCards(deck, player1, player2);

            if (player1.NumberOfCards == 0 || player2.NumberOfCards == 0)
            {
                Console.WriteLine("Error:  Something happend during the creation / shuffling / dealing of the game");
                return(null);
            }

            return(game.PlayGame(player1, player2));
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: bschreder/WarCardGame
 /// <summary>
 /// Constructor used to instantiated the game play object
 /// </summary>
 /// <param name="battleOutput">Interface to the game's UI class</param>
 public Game(IBattleOutput battleOutput)
 {
     _battleOutput = battleOutput;
 }