Esempio n. 1
0
        public bool GameLoop()
        {
            GameEnded = false;
            List <int> currentPlace;
            List <int> nextPlace;

            if (!GameEnded)
            {
                if (Player2.CountOfPiecesForPlayer == 0)
                {
                    Player1.HasWonAndUpdateTheScore(Player2, Board);
                    WinnerID  = Player1.ID;
                    GameEnded = true;
                }
                else if (Player1.CountOfPiecesForPlayer == 0)
                {
                    Player2.HasWonAndUpdateTheScore(Player1, Board);
                    WinnerID  = Player2.ID;
                    GameEnded = true;
                }
                else if (Player1.HasQuitted)
                {
                    e_GameStatus = e_StatusOFGame.WIN;
                    Player2.HasWonAndUpdateTheScore(Player1, Board);
                    WinnerID  = Player2.ID;
                    GameEnded = true;
                }
                else if (Player2.HasQuitted)
                {
                    e_GameStatus = e_StatusOFGame.WIN;
                    Player1.HasWonAndUpdateTheScore(Player2, Board);
                    WinnerID  = Player1.ID;
                    GameEnded = true;
                }
                else if (Player2.HasAnyMovesLeft(out currentPlace, out nextPlace) && Player2.AnyMoveLeft(out currentPlace, out nextPlace) && !(Player1.HasAnyMovesLeft(out currentPlace, out nextPlace)) && !(Player1.AnyMoveLeft(out currentPlace, out nextPlace)))
                {
                    e_GameStatus = e_StatusOFGame.WIN;
                    Player1.HasWonAndUpdateTheScore(Player1, Board);
                    WinnerID  = Player1.ID;
                    GameEnded = true;
                }
                else if (Player2.HasAnyMovesLeft(out currentPlace, out nextPlace) && Player2.AnyMoveLeft(out currentPlace, out nextPlace) && !(Player1.HasAnyMovesLeft(out currentPlace, out nextPlace)) && !(Player1.AnyMoveLeft(out currentPlace, out nextPlace)))
                {
                    e_GameStatus = e_StatusOFGame.WIN;
                    Player2.HasWonAndUpdateTheScore(Player1, Board);
                    WinnerID  = Player2.ID;
                    GameEnded = true;
                }
                else
                {
                    e_GameStatus = e_StatusOFGame.TIE;
                }
            }

            return(GameEnded);
        }