Пример #1
0
        public override bool Equals(object obj)
        {
            // Just to be sure, we will have the Equals method here.

            StationData other = obj as StationData;

            if (obj == null)
            {
                return(false);
            }
            if (this.system != other.system)
            {
                return(false);
            }
            if (this.name != other.name)
            {
                return(false);
            }
            // Disregards prices & other data as the *should* not change.
            return(true);
        }
Пример #2
0
        private void btnAddTransaction_Click(object sender, EventArgs e)
        {
            Destination nextDestination = mainScreen.getNextDestination(index);
            StationData stationData     = mainScreen.data.GetStation(destination.system, destination.station);
            StationData nextStationData = null;

            if (nextDestination != null)
            {
                nextStationData = mainScreen.data.GetStation(nextDestination.system, nextDestination.station);
            }
            mainScreen.commoditySelection.stationData     = stationData;
            mainScreen.commoditySelection.nextStationData = nextStationData;
            mainScreen.commoditySelection.UpdateDisplay();

            if (mainScreen.commoditySelection.ShowDialog(mainScreen) == DialogResult.OK)
            {
                Transaction ta = new Transaction();
                ta.amount    = mainScreen.commoditySelection.selectedAmount;
                ta.commodity = mainScreen.commoditySelection.selectedCommodity;
                destination.transactions.Add(ta);
                mainScreen.updateDisplay();
            }
        }
Пример #3
0
        public void reloadStations(Data data)
        {
            //TODO: Respect saveVersion!

            data.systems.Clear();

            /*
             * Systems
             */
            foreach (string system in readerSystemData.rootSection.subsections.Keys)
            {
                CmdrsLogDataReader.Section systemSection = readerSystemData.rootSection.subsections[system];

                SystemData sysData = new SystemData(system);
                data.systems[system] = sysData;

                /*
                 * Stations
                 */
                foreach (string station in systemSection.subsections.Keys)
                {
                    CmdrsLogDataReader.Section stationSection = systemSection.subsections[station];

                    StationData stationData = new StationData(station);
                    sysData.stations[station] = stationData;
                    stationSection.dictionary.TryGetValue("economy", out stationData.economy);
                    stationSection.dictionary.TryGetValue("government", out stationData.government);
                    stationSection.dictionary.TryGetValue("faction", out stationData.faction);
                    //TODO: Respect hidden
                    //TODO: Respect blackmarket?

                    //TODO: DAU-Safe code (make wrapper inside Section class!)
                    CmdrsLogDataReader.Section commoditiesSection = stationSection.subsections["Commodities"];

                    //TODO: Load Notes?

                    /*
                     * Commodities
                     */
                    foreach (string commodity in commoditiesSection.subsections.Keys)
                    {
                        CmdrsLogDataReader.Section commoditySection = commoditiesSection.subsections[commodity];

                        CommodityPrice cp = new CommodityPrice(commodity);
                        stationData.commodityData[commodity] = cp;
                        string status   = null;
                        string modTime  = null;
                        string price    = null;
                        string quantity = null;
                        commoditySection.dictionary.TryGetValue("status", out status);
                        commoditySection.dictionary.TryGetValue("modTime", out modTime);
                        commoditySection.dictionary.TryGetValue("price", out price);
                        commoditySection.dictionary.TryGetValue("quantity", out quantity);

                        int statusAsInt = 8;
                        int priceAsInt  = 0;

                        //TODO: respect modTime?
                        int.TryParse(price, out priceAsInt);
                        int.TryParse(quantity, out cp.quantity);
                        int.TryParse(status, out statusAsInt);

                        cp.demandType = parseStatusCmdrsLogV1(statusAsInt);

                        switch (cp.demandType)
                        {
                        case DemandType.HighDemand:
                        case DemandType.MediumDemand:
                        case DemandType.LowDemand:
                            cp.priceBuy = priceAsInt;
                            break;

                        case DemandType.HighSupply:
                        case DemandType.MediumSupply:
                        case DemandType.LowSupply:
                            cp.priceSell = priceAsInt;
                            break;
                        }
                    }
                }
            }
        }
Пример #4
0
        public void reloadStations(Data data)
        {
            autoSaveCsvReader.Open();
            autoSaveCsvReader.ReadHeaders();

            data.systems.Clear();

            string[] line = null;

            while ((line = autoSaveCsvReader.ReadLine()) != null)
            {
                string system           = line[0];
                string station          = line[1];
                string commodity        = line[2];
                string sellPrice        = line[3];
                string buyPrice         = line[4];
                string demandAmount     = line[5];
                string demandLevel      = line[6];
                string supplyAmount     = line[7];
                string supplyLevel      = line[8];
                string date             = line[9];
                string sourceScreenshot = line[10];

                SystemData systemData = data.GetSystem(system);
                if (systemData == null)
                {
                    systemData           = new SystemData(system);
                    data.systems[system] = systemData;
                }

                StationData stationData = systemData.GetStation(station);
                if (stationData == null)
                {
                    stationData = new StationData(system, station);
                    systemData.stations[station] = stationData;
                }

                CommodityPrice cp = stationData.GetPrice(commodity);
                if (cp == null)
                {
                    cp = new CommodityPrice(commodity);
                    stationData.commodityData[commodity] = cp;
                }
                int.TryParse(buyPrice, out cp.priceBuy);
                int.TryParse(sellPrice, out cp.priceSell);

                if (demandLevel == "Low")
                {
                    cp.demandType = DemandType.LowDemand;
                    int.TryParse(demandAmount, out cp.quantity);
                }
                else if (demandLevel == "Med")
                {
                    cp.demandType = DemandType.MediumDemand;
                    int.TryParse(demandAmount, out cp.quantity);
                }
                else if (demandLevel == "High")
                {
                    cp.demandType = DemandType.HighDemand;
                    int.TryParse(demandAmount, out cp.quantity);
                }
                else if (supplyLevel == "Low")
                {
                    cp.demandType = DemandType.LowSupply;
                    int.TryParse(supplyAmount, out cp.quantity);
                }
                else if (supplyLevel == "Med")
                {
                    cp.demandType = DemandType.MediumSupply;
                    int.TryParse(supplyAmount, out cp.quantity);
                }
                else if (supplyLevel == "High")
                {
                    cp.demandType = DemandType.HighSupply;
                    int.TryParse(supplyAmount, out cp.quantity);
                }
                else
                {
                    cp.demandType = DemandType.NotSet;
                }
            }

            autoSaveCsvReader.Close();
        }
Пример #5
0
        public void UpdateDisplay()
        {
            evaluations.Clear();
            Destination     currentData    = mainScreen.currentRoute.destinations[index];
            StationData     currentStation = mainScreen.data.GetStation(currentData.system, currentData.station);
            CommoditySorter sorter         = new CommoditySorter();

            sorter.criteria  = CommoditySorterCriteria.Profit;
            sorter.sortOrder = SortOrder.Descending;
            foreach (StationData station in mainScreen.data.Stations)
            {
                if (station == currentStation)
                {
                    continue;
                }
                List <ComparedCommodity> compared = new List <ComparedCommodity>();
                int amount = mainScreen.pilotData.maxCargo;
                foreach (string commodity in mainScreen.data.allCommodities)
                {
                    compared.Add(new ComparedCommodity(commodity, amount, currentStation.GetPrice(commodity), station.GetPrice(commodity)));
                }
                compared.Sort(sorter);
                Destination destination = new Destination(currentData);
                int         profit      = 0;
                if (respectBalance)
                {
                    if (sliceTransactions)
                    {
                        //TODO: go from most to least profitable and add transactions with as much as we can afford
                    }
                    else
                    {
                        //TODO: go from most to least profitable and add a single transaction once we can afford a full load.
                    }
                    //TODO: What to do if we cannot afford anything? Fallback?
                }
                else
                {
                    ComparedCommodity comm = compared.First();
                    profit += comm.profitPer * amount;
                    destination.transactions.Add(new Transaction(comm.commodity, 0));
                }
                evaluations.Add(new Evaluation(destination, new Destination(station), profit));
            }
            evaluations.Sort(new EvaluationSorter());

            if (evaluations.Count > showResults)
            {
                evaluations.RemoveRange(evaluations.Count, evaluations.Count - showResults);
            }

            // Cut off controls we don't need anymore
            if (destinationControls.Count > evaluations.Count)
            {
                for (int i = destinationControls.Count - 1; i >= evaluations.Count; i--)
                {
                    destinationControls[i].Dispose();
                    destinationControls.RemoveAt(i);
                }
                destinationControls.TrimExcess();
            }
            // Add missing controls & update existing ones
            destinationControls.Capacity = evaluations.Count;
            for (int i = 0; i < evaluations.Count; i++)
            {
                EvaluateDestinationControl ctrl;
                if (i >= destinationControls.Count)
                {
                    ctrl = new EvaluateDestinationControl(this);
                    destinationControls.Add(ctrl);
                    ctrl.Parent = flowLayoutPanel1;
                }
                else
                {
                    ctrl = destinationControls[i];
                }
                ctrl.index           = i;
                ctrl.destination     = evaluations[i].destination;
                ctrl.nextDestination = evaluations[i].nextDestination;
                ctrl.updateDisplay();
            }
        }
Пример #6
0
 public Destination(StationData station)
     : this()
 {
     this.system  = station.system;
     this.station = station.name;
 }