Ejemplo n.º 1
0
        public override void Start()
        {
            while (!IsFinished())
            {
                PathGameType.main.StateOfGame = $"{Players[0].Name} must throw the dices";
                Players[0].Input();
                Dm.Roll(Rnd);
                if ((Players[0].GetPlayerLocation() + Dm.GetTotal()) >= PBoard.SquareCount - 1)
                {
                    Players[0].UpdateLocation(new Square(PBoard.SquareCount), 1);
                    PathGameType.main.StateOfGame = $"{Players[0].Name} has throwed {Dm.GetTotal()} and he got on the final square";
                    PathGameType.main.StateOfGame = $"{Players[0].Name} is the winner. The game has ended.";
                    Thread.Sleep(2000);
                    break;
                }
                else
                {
                    Players[0].UpdateLocation(new Square(Players[0].GetPlayerLocation() + Dm.GetTotal()), 1);
                    PathGameType.main.StateOfGame = $"{Players[0].Name} has throwed {Dm.GetTotal()} and he got on the {Players[0].GetPlayerLocation()} square";
                    Thread.Sleep(2000);
                }

                PBoard.ApplySquareEffect(Players[0]);

                if (Dm.AllEqual())
                {
                    PathGameType.main.StateOfGame = $"{Players[0].Name} has thrown a double, he get the chance to throw again...";
                    Thread.Sleep(2000);
                }
                else
                {
                    var temp = Players[0];
                    for (int i = 0; i < Players.Count - 1; i++)
                    {
                        Players[i] = Players[i + 1];
                    }
                    Players[Players.Count - 1] = temp;
                }
            }
        }
Ejemplo n.º 2
0
        public override void Start()
        {
            int parameter = 0;

            while (!IsFinished())
            {
                CircularGameType.main.StateOfGame = $"{Players[0].Name} must throw the dices.";
                Players[0].Input();
                Dm.Roll(Rnd);
                int loc = Players[0].GetPlayerLocation();
                Players[0].UpdateLocation(new Square(Players[0].GetPlayerLocation() + Dm.GetTotal()), 2);
                CBoard.MakeItCircular(Players[0], CBoard.SquareCount);
                if (Players[0] is IScorable scPlayer)
                {
                    if (loc > Players[0].GetPlayerLocation())
                    {
                        scPlayer.UpdateScore(2000);
                        CircularGameType.main.StateOfGame = $"{Players[0].Name} went by start square and got 2000 bonus points. His points are {scPlayer.GetTotalScore()}";
                        #region UpdateScoreForTheUi
                        if (Players[0].Name.Equals("Player 1"))
                        {
                            CircularGameType.main.Player1 = $"Player1: {((ScorableHumanPlayer)Players[0]).GetTotalScore()} points";
                        }
                        else if (Players[0].Name.Equals("Player 2"))
                        {
                            CircularGameType.main.Player2 = $"Player2: {((ScorableHumanPlayer)Players[0]).GetTotalScore()} points";
                        }
                        else if (Players[0].Name.Equals("Computer"))
                        {
                            CircularGameType.main.Player3 = $"Computer: {((ScorableComputerPlayer)Players[0]).GetTotalScore()} points";
                        }
                        #endregion
                        Thread.Sleep(2000);
                    }
                    scPlayer.UpdateScore(Dm.GetTotal() * 10);
                    #region UpdateScoreForTheUi
                    if (Players[0].Name.Equals("Player 1"))
                    {
                        CircularGameType.main.Player1 = $"Player1: {((ScorableHumanPlayer)Players[0]).GetTotalScore()} points";
                    }
                    else if (Players[0].Name.Equals("Player 2"))
                    {
                        CircularGameType.main.Player2 = $"Player2: {((ScorableHumanPlayer)Players[0]).GetTotalScore()} points";
                    }
                    else if (Players[0].Name.Equals("Computer"))
                    {
                        CircularGameType.main.Player3 = $"Computer: {((ScorableComputerPlayer)Players[0]).GetTotalScore()} points";
                    }
                    #endregion
                    CircularGameType.main.StateOfGame = $"{Players[0].Name} has throwed {Dm.GetTotal()}. His score is {scPlayer.GetTotalScore()}\n";
                    Thread.Sleep(2000);
                    CBoard.ApplySquareEffect(Players[0]);

                    if (Dm.AllEqual())
                    {
                        CircularGameType.main.StateOfGame = $"\n{Players[0].Name} has thrown a double, he get the chance to throw again...\n";
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        var temp = Players[0];
                        for (int i = 0; i < Players.Count - 1; i++)
                        {
                            Players[i] = Players[i + 1];
                        }
                        Players[Players.Count - 1] = temp;

                        parameter++;
                        if (Tm.ATurnHasEnded(Players, ref parameter))
                        {
                            CircularGameType.main.StateOfGame = $"\nA turn has ended.\n";
                            CircularGameType.main.TurnsLeft   = $"Turns Left: {Tm.TurnCount}";
                            Thread.Sleep(1000);
                        }
                    }

                    if (Tm.AllTurnsAreMade())
                    {
                        int    max = scPlayer.GetTotalScore();
                        string name;

                        if (scPlayer is ScorableHumanPlayer)
                        {
                            name = ((ScorableHumanPlayer)scPlayer).Name;
                        }
                        else
                        {
                            name = ((ScorableComputerPlayer)scPlayer).Name;
                        }

                        foreach (IScorable sc in Players)
                        {
                            if (sc.GetTotalScore() > max)
                            {
                                max = sc.GetTotalScore();
                                if (sc is ScorableHumanPlayer)
                                {
                                    name = ((ScorableHumanPlayer)sc).Name;
                                }
                                else
                                {
                                    name = ((ScorableComputerPlayer)sc).Name;
                                }
                            }
                            else
                            {
                            }
                        }
                        CircularGameType.main.StateOfGame = $"\nThe winner is {name} with a total score of {max} points.";
                        Thread.Sleep(2000);
                    }
                }
            }
        }