public Trade(Trade copy) { commodity = new Commodity(copy.Commodity); startSystem = new StarSystem(copy.StartSystem); endSystem = new StarSystem(copy.EndSystem); startStation = new Station(copy.StartStation); endStation = new Station(copy.EndStation); unitsBought = copy.UnitsBought; score = copy.Score; }
private static void CalculateAllTrades(GameData gameData) { gameData.Trades.Clear(); for (int x = 0; x < gameData.StarSystems.Count - 1; x++) for (int y = x + 1; y < gameData.StarSystems.Count; y++) { StarSystem system1 = gameData.StarSystems[x]; StarSystem system2 = gameData.StarSystems[y]; foreach (Station station1 in system1.Stations) foreach (Station station2 in system2.Stations) foreach (Commodity commodity1 in station1.Commodities) foreach (Commodity commodity2 in station2.Commodities) if (commodity1.Name == commodity2.Name) { if (commodity1.BuyPrice > 0 && commodity1.Supply > 0 && commodity1.BuyPrice < commodity2.SellPrice) { Trade newTrade = new Trade(); newTrade.Commodity.Name = commodity1.Name; newTrade.Commodity.BuyPrice = commodity1.BuyPrice; newTrade.Commodity.Supply = commodity1.Supply; newTrade.Commodity.SellPrice = commodity2.SellPrice; newTrade.Commodity.LastUpdated = commodity1.LastUpdated <= commodity2.LastUpdated ? commodity1.LastUpdated : commodity2.LastUpdated; newTrade.StartSystem = system1; newTrade.EndSystem = system2; newTrade.StartStation = station1; newTrade.EndStation = station2; gameData.Trades.Add(newTrade); } if (commodity2.BuyPrice > 0 && commodity2.Supply > 0 && commodity2.BuyPrice < commodity1.SellPrice) { Trade newTrade = new Trade(); newTrade.Commodity.Name = commodity1.Name; newTrade.Commodity.BuyPrice = commodity2.BuyPrice; newTrade.Commodity.Supply = commodity2.Supply; newTrade.Commodity.SellPrice = commodity1.SellPrice; newTrade.Commodity.LastUpdated = commodity1.LastUpdated <= commodity2.LastUpdated ? commodity1.LastUpdated : commodity2.LastUpdated; newTrade.StartSystem = system2; newTrade.EndSystem = system1; newTrade.StartStation = station2; newTrade.EndStation = station1; gameData.Trades.Add(newTrade); } } } }
private static bool TradePartOfExistingManifest(GameData gameData, Trade trade) { foreach (Manifest manifest in gameData.OptimalManifests) if (manifest.Trades[0].StartSystem.Name == trade.StartSystem.Name && manifest.Trades[0].EndSystem.Name == trade.EndSystem.Name && manifest.Trades[0].StartStation.Name == trade.StartStation.Name && manifest.Trades[0].EndStation.Name == trade.EndStation.Name) { manifest.AddTrade(trade); return true; } return false; }
public bool Equals(Trade compareTo) { if (commodity.Equals(compareTo.Commodity) == false) return false; if (startSystem.Name != compareTo.StartSystem.Name || endSystem.Name != compareTo.EndSystem.Name || startStation.Name != compareTo.StartStation.Name || endStation.Name != compareTo.EndStation.Name || unitsBought != compareTo.UnitsBought || score != compareTo.Score) return false; return true; }