예제 #1
0
        public CommodityPrice GetPrice(string commodity)
        {
            CommodityPrice price = null;

            commodityData.TryGetValue(commodity, out price);
            return(price);
        }
예제 #2
0
        public void updateDisplay()
        {
            lblStationName.Text = destination.station;
            lblSystemName.Text  = destination.system;

            listView1.Items.Clear();
            overallProfit = 0;

            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);
            }

            foreach (Transaction transaction in destination.transactions)
            {
                int profitPer = 0;

                if (stationData != null && nextStationData != null)
                {
                    CommodityPrice ourPrice   = stationData.GetPrice(transaction.commodity);
                    CommodityPrice theirPrice = nextStationData.GetPrice(transaction.commodity);
                    if (ourPrice != null && theirPrice != null && theirPrice.priceSell > 0 && ourPrice.priceBuy > 0)
                    {
                        profitPer = theirPrice.priceSell - ourPrice.priceBuy;
                    }
                }

                int profit = profitPer * transaction.amount;
                overallProfit += profit;
                ListViewItem li = new ListViewItem(new string[] {
                    transaction.commodity,
                    transaction.amount.ToString("N0"),
                    profitPer.ToString("N0"),
                    profit.ToString("N0")
                });

                if (profit == 0)
                {
                    li.BackColor = Color.Yellow;
                    li.ForeColor = Color.OrangeRed;
                }
                else if (profit < 0)
                {
                    li.BackColor = Color.Red;
                    li.ForeColor = Color.Yellow;
                }
                else
                {
                    li.BackColor = Color.Green;
                    li.ForeColor = Color.LightGreen;
                }
                listView1.Items.Add(li);
            }
        }
예제 #3
0
        public void updateDisplay()
        {
            lblStationName.Text = destination.station;
            lblSystemName.Text  = destination.system;

            listView1.Items.Clear();
            overallProfit = 0;

            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);
            }

            foreach (Transaction transaction in destination.transactions)
            {
                CommodityPrice ourPrice   = null;
                CommodityPrice theirPrice = null;
                if (stationData != null)
                {
                    ourPrice = stationData.GetPrice(transaction.commodity);
                    if (nextStationData != null)
                    {
                        theirPrice = nextStationData.GetPrice(transaction.commodity);
                    }
                }
                ComparedCommodity compared = new ComparedCommodity(transaction.commodity, transaction.GetAmount(mainScreen.pilotData.maxCargo), ourPrice, theirPrice);

                overallProfit += compared.profit;
                ListViewItem li = new ListViewItem(new string[] {
                    transaction.commodity,
                    transaction.amount == 0 ? String.Format("MAX ({0:0})", mainScreen.pilotData.maxCargo) : transaction.amount.ToString("N0"),
                    compared.ProfitPer,
                    compared.Profit
                });

                if (compared.profitPer == 0)
                {
                    li.BackColor = Color.Yellow;
                    li.ForeColor = Color.OrangeRed;
                }
                else if (compared.profitPer < 0)
                {
                    li.BackColor = Color.Red;
                    li.ForeColor = Color.Yellow;
                }
                else
                {
                    li.BackColor = Color.Green;
                    li.ForeColor = Color.LightGreen;
                }
                listView1.Items.Add(li);
            }
        }
예제 #4
0
		public void UpdateDisplay()
		{
			listView1.Items.Clear();
			listView1.Groups.Clear();
			foreach (KeyValuePair<string, string[]> commodityGroup in mainScreen.data.commodities)
			{
				ListViewGroup group = listView1.Groups.Add(commodityGroup.Key, commodityGroup.Key);

				foreach (string commodity in commodityGroup.Value)
				{
					CommodityPrice ourPrice = null;
					CommodityPrice theirPrice = null;
					if (stationData != null)
					{
						ourPrice = stationData.GetPrice(commodity);
						if (nextStationData != null)
						{
							theirPrice = nextStationData.GetPrice(commodity);
						}
					}
					int amount = selectedAmount == 0 ? mainScreen.pilotData.maxCargo : selectedAmount;
					ComparedCommodity compared = new ComparedCommodity(commodity, amount, ourPrice, theirPrice);

					ListViewItem li = new ListViewItem(new string[] {
						compared.Commodity,
						compared.Demand,
						compared.PriceSell,
						compared.PriceBuy,
						compared.ProfitPer,
						compared.Profit
					}, group);
					li.Tag = compared;
					if (compared.profitPer == 0)
					{
						//li.BackColor = Color.Yellow;
						//li.ForeColor = Color.OrangeRed;
					}
					else if (compared.profitPer < 0)
					{
						li.BackColor = Color.Red;
						li.ForeColor = Color.Yellow;
					}
					else
					{
						li.BackColor = Color.Green;
						li.ForeColor = Color.LightGreen;
					}

					listView1.Items.Add(li);
				}
			}
		}
예제 #5
0
 public ComparedCommodity(string commodity, int amount, CommodityPrice ourPrice, CommodityPrice theirPrice)
 {
     this.commodity = commodity;
     if (ourPrice != null)
     {
         priceBuy  = ourPrice.priceBuy;
         priceSell = ourPrice.priceSell;
         demand    = ourPrice.demandType;
         if (theirPrice != null && theirPrice.priceSell > 0 && ourPrice.priceBuy > 0)
         {
             profitPer = theirPrice.priceSell - ourPrice.priceBuy;
         }
     }
     profit = profitPer * amount;
 }
예제 #6
0
        public void UpdateDisplay()
        {
            listView1.Items.Clear();
            listView1.Groups.Clear();
            foreach (KeyValuePair <string, string[]> commodityGroup in mainScreen.data.commodities)
            {
                ListViewGroup group = listView1.Groups.Add(commodityGroup.Key, commodityGroup.Key);

                foreach (string commodity in commodityGroup.Value)
                {
                    int    profitPer    = 0;
                    string priceBuy     = "";
                    string priceSell    = "";
                    string demand       = "";
                    string profitPerStr = "";
                    string profitStr    = "";

                    if (stationData != null)
                    {
                        CommodityPrice ourPrice = stationData.GetPrice(commodity);
                        if (ourPrice != null)
                        {
                            if (ourPrice.priceBuy > 0)
                            {
                                priceBuy = ourPrice.priceBuy.ToString("N0");
                            }
                            if (ourPrice.priceSell > 0)
                            {
                                priceSell = ourPrice.priceSell.ToString("N0");
                            }
                            demand = ourPrice.demandType.ToString();
                        }
                        if (nextStationData != null)
                        {
                            CommodityPrice theirPrice = nextStationData.GetPrice(commodity);
                            if (ourPrice != null && theirPrice != null && theirPrice.priceSell > 0 && ourPrice.priceBuy > 0)
                            {
                                profitPer = theirPrice.priceSell - ourPrice.priceBuy;
                            }
                        }
                    }
                    int profit = profitPer * (selectedAmount == 0 ? maxCargo : selectedAmount);

                    if (profitPer != 0)
                    {
                        profitPerStr = profitPer.ToString("N0");
                        profitStr    = profit.ToString("N0");
                    }

                    ListViewItem li = new ListViewItem(new string[] {
                        commodity,
                        demand,
                        priceSell,
                        priceBuy,
                        profitPerStr,
                        profitStr
                    }, group);
                    if (profit == 0)
                    {
                        //li.BackColor = Color.Yellow;
                        //li.ForeColor = Color.OrangeRed;
                    }
                    else if (profit < 0)
                    {
                        li.BackColor = Color.Red;
                        li.ForeColor = Color.Yellow;
                    }
                    else
                    {
                        li.BackColor = Color.Green;
                        li.ForeColor = Color.LightGreen;
                    }

                    listView1.Items.Add(li);
                }
            }
        }
예제 #7
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;
                        }
                    }
                }
            }
        }
예제 #8
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();
        }