Esempio n. 1
0
        private List <Token> MoveToken(Token token)
        {
            List <Token> tokens      = new List <Token>();
            var          player      = Game.WhoseTurnIsIt();
            var          newPosition = GetNewPosition(token, player.DieRoll);

            // Token har just left the starting zone if Position == null
            if (token.Position == null)
            {
                token.MovedSteps = 1;
                AddMessageToHistoryList($"P{player.PlayerNumber + 1} moved 1 steps. ({player.DieRoll})");
            }
            else
            {
                token.MovedSteps += player.DieRoll;
                AddMessageToHistoryList($"P{player.PlayerNumber + 1} moved {player.DieRoll} steps.");
            }

            // Update the token pos and that the player has moved
            token.Position  = newPosition;
            player.HasMoved = true;

            // Add the token to list to move it in the GUI later
            tokens.Add(token);

            // Do some checks to see where the token is
            token.CheckIfTokenHasFinished();
            token.CheckIfTokenIsOnFinishLine();

            // Check if the token will bump another player back to start
            var tokenToPushBack = Game.GetOccupyingToken(token);

            if (tokenToPushBack != null)
            {
                tokens.Add(tokenToPushBack);
            }

            return(tokens);
        }