private void PilotFinishedJourney(object sender, EventArgs e) { Pilot pilot = (Pilot)sender; if (pilot.IsPlayer) { return; } if (pilot.Ship.CurrentSystem.HasMarket) { Market market = pilot.Ship.CurrentSystem.Market; //Sell randomly held resources List <InventorySlot> inventory = pilot.Ship.Inventory.GetInventoryList(); int numSales = RNG.Next(0, inventory.Count); for (int i = 0; i < numSales && inventory.Count > 0; i++) { InventorySlot slot = inventory[RNG.Next(0, inventory.Count)]; int quantity = RNG.Next(1, slot.Quantity); //Check if the market can afford the purchase if (market.CalculateBuyPrice(slot.Item, quantity) <= market.MarketInventory.Credits) { market.MarketBuy(slot.Item, quantity); pilot.Ship.Inventory.RemoveItem(slot.Item, quantity); inventory = pilot.Ship.Inventory.GetInventoryList(); //List doesn't update automatically } } //Buy random resources List <InventorySlot> marketList = market.MarketInventory.GetInventoryList(); int numPurchases = RNG.Next(3, 6); for (int i = 0; i < numPurchases && marketList.Count > 0; i++) { InventorySlot slot = marketList[RNG.Next(0, marketList.Count)]; int quantity = RNG.Next(1, slot.Quantity); pilot.Ship.Inventory.AddItem(slot.Item, quantity); market.MarketSell(slot.Item, quantity); //Factions have infinite money for the moment marketList = market.MarketInventory.GetInventoryList(); //List doesn't update automatically } } }
public PilotFinishedTravelingEventArgs(Ship ship, Pilot pilot, StarSystem system) { Ship = ship; Pilot = pilot; Destination = system; }