public MarketGum(string name, int minPrice, int maxPrice, Player player) { this.Name = name; _player = player; _price = MyRandom.Random(minPrice, maxPrice); }
public RandomFortunes RandomFortuneHappened() { bool gainedGum = MyRandom.SomethingHappened(Settings.RANDOM_FORTUNE_GAIN_GUM_PROBABILITY); if (gainedGum) { if (this.Player.RemainingCapacity < 100) { return(RandomFortunes.None); } int randomGum = MyRandom.Random(0, this.CurrentCity.Gums.Count - 1); int randomCapacity = MyRandom.Random(50, this.Player.RemainingCapacity - 10); this.Player.BuyGum(this.CurrentCity.Gums[randomGum], randomCapacity, 0); this.CurrentMessage += "You found " + randomCapacity + " boxes of " + this.CurrentCity.Gums[randomGum].Name + "!"; return(RandomFortunes.GainGum); } bool gainedCapacity = MyRandom.SomethingHappened(Settings.RANDOM_FORTUNE_GAIN_CAPACITY_PROBABILITY); if (gainedCapacity && this.Player.CarryingCapacity < Settings.MAX_CAPACITY) { int newCapacity = MyRandom.Random(this.Player.CarryingCapacity + 250, this.Player.CarryingCapacity + 1000); this.CurrentMessage += "You now have " + newCapacity + " carrying capacity!"; this.Player.CarryingCapacity = newCapacity; return(RandomFortunes.GainCapacity); } bool gainedMoney = MyRandom.SomethingHappened(Settings.RANDOM_FORTUNE_GAIN_MONEY_PROBABILITY); if (gainedMoney) { int money = MyRandom.Random(1000, this.Player.Money + 500); this.CurrentMessage += "You found $" + money + "!"; this.Player.Money += money; return(RandomFortunes.GainMoney); } bool lostMoney = MyRandom.SomethingHappened(Settings.RANDOM_FORTUNE_LOSE_MONEY_PROBABILITY); if (lostMoney) { if (this.Player.Money <= 100) { return(RandomFortunes.None); } double maxMoney = this.Player.Money * .75; int money = MyRandom.Random(100, (int)maxMoney); this.CurrentMessage += "You lost $" + money + " in a Ponzi scheme."; this.Player.Money -= money; return(RandomFortunes.LostMoney); } bool lostGum = MyRandom.SomethingHappened(Settings.RANDOM_FORTUNE_LOSE_GUM_PROBABILITY); if (lostGum) { if (this.Player.OwnedGums.Count == 0) { return(RandomFortunes.None); } OwnedGum gum = this.Player.OwnedGums[0]; if (gum.Quantity < 5) { return(RandomFortunes.None); } double maxGumLost = gum.Quantity / 2.0; int amountLost = MyRandom.Random(1, (int)maxGumLost); gum.Quantity -= amountLost; this.CurrentMessage += "Someone has stolen " + amountLost + " boxes of " + gum.Name; return(RandomFortunes.LostGum); } return(RandomFortunes.None); }