예제 #1
0
        public override string Action(Player player, List <Player> players, Dictionary <int, int> realEstateOwnerMap, Dictionary <int, Location> locations, int rollOfDice)
        {
            if (IsEmptyProperty(player.BoardPosition, realEstateOwnerMap))
            {
                if (!DoesPlayerHaveBalanceToBuyProperty(player))
                {
                    return(String.Format("{0} does not have sufficient balance to buy {1}, which costs {2}",
                                         player.Name, this.Name, this.Cost));
                }

                BuyProperty(player, realEstateOwnerMap);
                return(String.Format("{0} has bought {1}", player.Name, this.Name));
            }
            if (realEstateOwnerMap[player.BoardPosition] == player.Id)
            {
                return(String.Format("{0} owns {1}, so no rent needs to be paid", player.Name, this.Name));
            }
            if (IsMortgaged)
            {
                return(String.Format("{0} is mortgaged, so no rent needs to be paid", this.Name));
            }

            var rent = GetRent(realEstateOwnerMap, locations, player, rollOfDice);

            player.DecreaseBalance(rent);
            var realEstateOwnerPlayer = players.First(p => p.Id == realEstateOwnerMap[player.BoardPosition]);

            realEstateOwnerPlayer.IncreaseBalance(rent);
            return(String.Format("{0} paid ${1} in rent to {2}", player.Name, rent, realEstateOwnerPlayer.Name));
        }
예제 #2
0
 public override string Action(Player player, List <Player> estateOwnerMap, Dictionary <int, int> realEstateOwnerMap, Dictionary <int, Location> locations, int rollOfDice)
 {
     player.DecreaseBalance(TaxAmountByLocation[Id]);
     return(String.Format("{0} have been charged with income tax $100", player.Name));
 }
예제 #3
0
 public void BuyProperty(Player player, Dictionary <int, int> propertyOwnerMap)
 {
     player.RealEstates.Add(this);
     propertyOwnerMap.Add(player.BoardPosition, player.Id);
     player.DecreaseBalance(Cost);
 }