/// <summary> /// Deals with the player's decision of whether to buy the location. /// </summary> /// <returns>A message documenting what happened.</returns> /// <param name="p">The player.</param> /// <param name="answer">The player's answer.</param> private string BuyLocation(Player p, string answer) { if (string.IsNullOrWhiteSpace(answer)) { return string.Empty; } if (answer.ToLower(System.Globalization.CultureInfo.CurrentCulture).StartsWith("y", StringComparison.CurrentCulture)) { p.Withdraw(this.PriceSale); this.Owner = p; return p.Name + " now owns " + this.Name + "."; } return string.Empty; }
/// <summary> /// Handles the player's response of what to do when landing on another player's property. /// </summary> /// <returns>A message documenting what happened.</returns> /// <param name="p">The player.</param> /// <param name="answer">The player's answer.</param> private string RentLocation(Player p, string answer) { if (answer.ToLower(System.Globalization.CultureInfo.CurrentCulture).StartsWith("p", StringComparison.CurrentCulture)) { p.Withdraw(this.PriceRent); this.Owner.Deposit(this.PriceRent); return "Owned by " + this.Owner.Name + ", rent is $" + this.PriceRent.ToString(); } return string.Empty; }
/// <summary> /// Message to print when the player lands on the location. /// </summary> /// <returns>The on-landing message documenting what happened.</returns> /// <param name="p">The player.</param> /// <param name="answerer"> /// Routine that can handle the question's answer if the message is a question. /// </param> public string PrintOnLanding(Player p, ref Func<Player, string, string> answerer) { bool canBuy = this.CanBuy; bool ownable = this.Ownable; if (p == null) { return string.Empty; } switch (this.PropertyType) { case Zoning.Residential: case Zoning.Railroad: case Zoning.Franchise: if (canBuy && p.Balance > this.PriceSale) { answerer = this.BuyLocation; return "Want to buy " + this.Name + " for " + this.PriceSale.ToString() + "?"; } else if (canBuy) { return "Can't buy " + Name + ". Not enough money."; } else if (ownable && Owner != p) { int rent = PriceRent; if (this.PropertyType == Zoning.Franchise || this.PropertyType == Zoning.Railroad) { var rrs = board.Where(x => x.PropertyType == PropertyType && x.Owner == Owner); int nrrs = rrs.Count(); for (int i = 0; i < nrrs; i++) { rent *= Multiplier; } } answerer = RentLocation; return "Owned by " + Owner.Name + ", rent is $" + PriceRent.ToString() + ". [P]ay?"; } else if (ownable) { return p.Name + " already owns " + Name + "."; } break; case Zoning.Luxury: case Zoning.Necessity: p.Withdraw(this.PriceRent); return "Tax of $" + this.PriceRent.ToString() + " levied on " + p.Name + "."; case Zoning.Legacy: int due = this.PriceRent > p.Balance / 10 ? p.Balance / 10 : this.PriceRent; p.Withdraw(due); return "Tax of $" + due.ToString() + " levied on " + p.Name + "."; case Zoning.Trespassing: p.InJail = true; return p.Name + " was caught trespassing by Lord Blueblood and is sent to jail!"; case Zoning.MotherEarth: p.Deposit(this.Salary); return "Labor upon Mother Earth produces wages: $" + this.Salary.ToString() + "."; case Zoning.Park: return "Spending a day at the park."; } return string.Empty; }