// Instantiates a marketplace with the given planet's tech level. public Marketplace() { this.planetTech = Game.Instance.Universe.CurrentPlanet.Techlevel; this.player = Game.Instance.Player; productionPrices = new Dictionary <Good, Int32>(); purchasePrices = new Dictionary <Good, Int32>(); //TODO: implement crew skills TradeSkillModifier = new Random().Next((2 * player.TradeSkill) + 1); // Initialize goods the planet can produce foreach (Good item in Goods.Values) { // Check if planetTech is higher than minTech for the good if (planetTech.CompareTo(item.MinTechToProduce) >= 0) { productionPrices.Add(item, AdjustPriceOnSkills(item)); } } // Initialize goods the planet can buy. Copy over production goods and // add any other goods it can sell. foreach (KeyValuePair <Good, int> pair in productionPrices) { purchasePrices.Add(pair.Key, pair.Value); } foreach (Good item in Goods.Values) { if (!productionPrices.ContainsKey(item) && planetTech.CompareTo(item.MinTechToUse) >= 0) { purchasePrices.Add(item, AdjustPriceOnSkills(item)); } } Random rand = new Random(); int quantity = rand.Next(9) + 10; Supply = new List <Good>(quantity); Good[] usableGoods = productionPrices.Keys.ToArray(); while (Supply.Count < quantity) { Supply.Add(usableGoods[rand.Next(productionPrices.Count)]); } }