Exemple #1
0
        private TurnResult TakeTurn(TurnResult result, IPlayer player, IBoard board, RollResult rollResult)
        {
            result.PreTurnMortgageActivity.Add(mortgageService.ProcessMortgageTransactions(player));

            result = MovePlayerToLocation(result, player, board, rollResult);

            result.PostTurnMortgageActivity.Add(mortgageService.ProcessMortgageTransactions(player));

            return result;
        }
Exemple #2
0
        private TurnResult TakeInJailTurn(TurnResult result, IPlayer player, IBoard board, RollResult rollResult)
        {
            if (bailAdvisor.PlayerShouldPayBail(player))
            {
                player.WithdrawMoney(MonopolyConstants.BailMoney);
                player.GetOutOfJail();
                result.PlayerPaidBail = true;
                result = TakeTurn(result, player, board, rollResult);
            }
            else if (rollResult.IsDoubles)
            {
                player.GetOutOfJail();
                result = TakeTurn(result, player, board, rollResult);
            }
            else
            {
                player.AddEscapeAttempt();
            }

            if (player.HasReachedMaxEscapeAttempts())
            {
                player.WithdrawMoney(MonopolyConstants.BailMoney);
                player.GetOutOfJail();
                result.PlayerPaidBail = true;
                result = TakeTurn(result, player, board, rollResult);
            }

            return result;
        }
Exemple #3
0
        private TurnResult MovePlayerToLocation(TurnResult result, IPlayer player, IBoard board, RollResult rollResult)
        {
            var moveResult = moveService.MoveToLocation(player.Location, rollResult.Total);

            player.MoveToLocation(moveResult.CurrentLocation.LocationIndex);
            result.Locations.Add(moveResult.CurrentLocation.LocationIndex);
            result.EndingLocation = player.Location;

            foreach (var location in moveResult.LocationHistory)
            {
                location.ProcessPassingAction(player);
            }

            moveResult.CurrentLocation.ProcessLandingAction(player);

            return result;
        }