예제 #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello! Stick Game has started!");
            Console.WriteLine("\nThe 1rst step is create the players");
            var cont       = 1;
            var playerName = "";
            var stickGame  = new StickGame();

            CreatePlayersStep(cont, stickGame);
            Console.Clear();
            Console.WriteLine("\n\nLet's go to the game!");

            while (stickGame.GetStatus() != GameStatus.Finished)
            {
                foreach (var player in stickGame.Players)
                {
                    Console.WriteLine($"\n[Player {player.Name}] - How many sticks?");
                    int.TryParse(Console.ReadLine(), out int quantity);
                    stickGame.RemoveSticks(player.Name, quantity);
                    GiveFeedBack(quantity);
                    Console.WriteLine($"{stickGame.QtdSticks} sticks remaining!");

                    if (stickGame.GetStatus() == GameStatus.Finished)
                    {
                        break;
                    }
                }
            }
            Console.WriteLine($"And the winner was {stickGame.GetWinner().Name} with {stickGame.GetWinner().Score} points!");
            Console.WriteLine($"Really nice! Bye!");
        }
예제 #2
0
        public void GameMustInformTheWinnerCorrectly()
        {
            var stickGame = new StickGame();

            AddDefaultPlayers(stickGame);
            stickGame.RemoveSticks("mario", 14);
            stickGame.RemoveSticks("pc", 16);
            Assert.IsTrue(stickGame.GetWinner().Name == "pc");

            stickGame = new StickGame();
            AddDefaultPlayers(stickGame);
            stickGame.RemoveSticks("mario", 5);
            stickGame.RemoveSticks("pc", 5);
            stickGame.RemoveSticks("mario", 5);
            stickGame.RemoveSticks("pc", 5);
            stickGame.RemoveSticks("mario", 5);
            stickGame.RemoveSticks("pc", 2);
            stickGame.RemoveSticks("mario", 1);
            Assert.IsTrue(stickGame.GetWinner().Name == "mario");
        }