public MarketState MarketChanged() { bool randomProbability = MyRandom.SomethingHappened(Settings.PROBABILITY_COLLAPSED_MARKET_STATE); int targetGum = MyRandom.Random(0, this.Gums.Count - 1); MarketGum g = this.Gums[targetGum]; if (randomProbability) { double discountFactor = MyRandom.Random(35, 65) / (double)100; g.CurrentPrice = (int)Math.Ceiling(g.CurrentPrice * discountFactor); this.CityMessage = "Prices of " + g.Name + " have tanked!"; ///Other gums are slightly depressed as well foreach (MarketGum mGum in this.Gums) { if (mGum.Name == g.Name) { continue; } double discountFactor2 = MyRandom.Random(80, 90) / (double)100; mGum.CurrentPrice = (int)Math.Ceiling(mGum.CurrentPrice * discountFactor2); } return(MarketState.Collapsed); } randomProbability = MyRandom.SomethingHappened(Settings.PROBABILITY_SPIKED_MARKET_STATE); if (randomProbability) { double spikeFactor = MyRandom.Random(125, 165) / (double)100; g.CurrentPrice = (int)Math.Floor(g.CurrentPrice * spikeFactor); this.CityMessage = "Prices of " + g.Name + " have spiked!"; ///Other gums are slightly more expensive too foreach (MarketGum mGum in this.Gums) { if (mGum.Name == g.Name) { continue; } double spikeFactor2 = MyRandom.Random(110, 120) / (double)100; mGum.CurrentPrice = (int)Math.Ceiling(mGum.CurrentPrice * spikeFactor2); } return(MarketState.Spiked); } return(MarketState.Normal); }
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); }