Пример #1
0
    public void StartGame()
    {
        int turnIndex = 0;

        while (turnIndex % this.Players.Length != 0 || !CheckEndGameState(this.Players))
        {
            bool   validPlay = false;
            string message   = "";

            int playerIndex = turnIndex % this.Players.Length;

            ProgramOutput.PrintBoardState(Board);

            Player player = Players[playerIndex];

            ProgramOutput.PrintPlayerState(player);

            (validPlay, message) = UserInput.GetCommands(Board, player);

            ProgramOutput.CommandFeedback(message);

            if (validPlay == true)
            {
                ProgramOutput.ValidInputMessage(message);
                turnIndex++;
            }
            else
            {
                ProgramOutput.InvalidInputWarning(message);
            }
        }

        ProgramOutput.EndGameScoring(Players);
        ProgramOutput.PreExitPrompt();
    }
Пример #2
0
        public void EndGameScoring_ThreePlayerScore_DisplayWinner()
        {
            Player[] players = new Player[3];

            players[0] = new Player("Will", false, new Caravan(1, 3, 0, 1));

            players[0].AcquiredOrder.Add(new Order(20, new Caravan(0, 0, 0, 5)));
            players[0].AcquiredOrder.Add(new Order(19, new Caravan(0, 0, 1, 4)));
            players[0].AcquiredOrder.Add(new Order(16, new Caravan(0, 0, 4, 1)));
            players[0].AcquiredOrder.Add(new Order(15, new Caravan(2, 2, 0, 2)));
            players[0].AcquiredOrder.Add(new Order(14, new Caravan(0, 1, 1, 2)));

            players[0].ExtraPoints.Add(0);
            players[0].ExtraPoints.Add(1);
            players[0].ExtraPoints.Add(3);
            players[0].ExtraPoints.Add(0);
            players[0].ExtraPoints.Add(1);

            players[1] = new Player("Ben", false, new Caravan(0, 2, 2, 2));

            players[1].AcquiredOrder.Add(new Order(20, new Caravan(1, 0, 2, 3)));
            players[1].AcquiredOrder.Add(new Order(18, new Caravan(1, 1, 3, 1)));
            players[1].AcquiredOrder.Add(new Order(17, new Caravan(2, 0, 2, 2)));
            players[1].AcquiredOrder.Add(new Order(16, new Caravan(1, 3, 1, 1)));

            players[1].ExtraPoints.Add(1);
            players[1].ExtraPoints.Add(1);
            players[1].ExtraPoints.Add(1);
            players[1].ExtraPoints.Add(0);

            players[2] = new Player("Ben", false, new Caravan(5, 0, 0, 0));

            players[2].AcquiredOrder.Add(new Order(15, new Caravan(2, 2, 0, 2)));
            players[2].AcquiredOrder.Add(new Order(12, new Caravan(1, 1, 1, 1)));
            players[2].AcquiredOrder.Add(new Order(13, new Caravan(2, 2, 2, 0)));

            players[2].ExtraPoints.Add(3);
            players[2].ExtraPoints.Add(1);
            players[2].ExtraPoints.Add(0);

            Assert.Equal(93, ProgramOutput.EndGameScoring(players));
        }