/// <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; }
/// <summary> /// Handle situations where a player passes a location but does not land there. /// </summary> /// <returns>A printable string documenting what happened.</returns> /// <param name="p">THe player.</param> public string PassBy(Player p) { string result = string.Empty; if (p == null) { return result; } if (this.PropertyType == Zoning.MotherEarth && this.SalaryOver > 0) { p.Deposit(this.SalaryOver); result = "Earned $" + this.SalaryOver.ToString() + " salary!" + Environment.NewLine; } return result; }