public CCommodities(CCommodities other)             // main fields copied, not the extra data ones
 {
     id            = other.id; name = other.name; buyPrice = other.buyPrice; sellPrice = other.sellPrice; meanPrice = other.meanPrice;
     demandBracket = other.demandBracket; stockBracket = other.stockBracket; stock = other.stock; demand = other.demand;
     type          = other.type;
     StatusFlags   = new List <string>(other.StatusFlags);
     ComparisionLR = ComparisionRL = "";
 }
        public static List <CCommodities> Merge(List <CCommodities> left, List <CCommodities> right, string otherstation)
        {
            List <CCommodities> merged = new List <CCommodities>();

            foreach (CCommodities l in left)
            {
                CCommodities m = new CCommodities(l);
                CCommodities r = right.Find(x => x.name == l.name);
                if (r != null)
                {
                    if (l.buyPrice > 0)     // if we can buy it..
                    {
                        m.ComparisionLR  = (r.sellPrice - l.buyPrice).ToString();
                        m.ComparisionBuy = true;
                    }

                    if (r.buyPrice > 0)
                    {
                        m.ComparisionRL  = (l.sellPrice - r.buyPrice).ToString();
                        m.ComparisionBuy = true;
                    }
                }
                else
                {                                   // not found in right..
                    if (l.buyPrice > 0)             // if we can buy it here, note you can't price it in right
                    {
                        m.ComparisionLR = "No Price";
                    }
                }

                merged.Add(m);
            }

            foreach (CCommodities r in right)
            {
                CCommodities m = merged.Find(x => x.name == r.name);        // see if any in right we have not merged
                if (m == null)
                {
                    m      = new CCommodities(r);
                    m.name = m.name + " at " + otherstation;
                    m.ComparisionRightOnly = true;

                    if (r.buyPrice > 0)                             // if we can buy it here, note you can't price it in left
                    {
                        m.ComparisionBuy = true;
                        m.ComparisionRL  = "No price";
                    }
                    merged.Add(m);
                }
            }

            Sort(merged);
            return(merged);
        }
Ejemplo n.º 3
0
        public void Rescan(JArray jcommodities)
        {
            Commodities = new List <CCommodities>();

            if (jcommodities != null)
            {
                foreach (JObject commodity in jcommodities)
                {
                    CCommodities com = new CCommodities(commodity, false);
                    Commodities.Add(com);
                }

                Commodities.Sort((l, r) => l.locName.CompareTo(r.locName));
            }
        }
Ejemplo n.º 4
0
        public void Rescan(JObject evt)
        {
            Station     = evt["StationName"].Str();
            StarSystem  = evt["StarSystem"].Str();
            MarketID    = evt["MarketID"].LongNull();
            Commodities = new List <CCommodities>(); // always made..

            JArray jcommodities = (JArray)evt["Items"];

            if (jcommodities != null)
            {
                foreach (JObject commodity in jcommodities)
                {
                    CCommodities com = new CCommodities(commodity, true);
                    Commodities.Add(com);
                }
            }
        }
Ejemplo n.º 5
0
        public JournalEDDCommodityPrices(JObject evt) : base(evt, JournalTypeEnum.EDDCommodityPrices)
        {
            Station     = evt["station"].Str();
            Faction     = evt["faction"].Str();
            Commodities = new List <CCommodities>();

            JArray jcommodities = evt["commodities"].Array();

            if (jcommodities != null)
            {
                foreach (JObject commodity in jcommodities)
                {
                    CCommodities com = new CCommodities(commodity);
                    Commodities.Add(com);
                }

                Commodities.Sort((l, r) => l.locName.CompareTo(r.locName));
            }
        }
        public JournalEDDCommodityPrices(JObject evt) : base(evt, JournalTypeEnum.EDDCommodityPrices)
        {
            Station     = evt["station"].Str();
            Faction     = evt["faction"].Str();
            Commodities = new List <CCommodities>();

            JArray jcommodities = null;

            if (!evt["commodities"].Empty())
            {
                jcommodities = (JArray)evt["commodities"];
            }

            if (jcommodities != null)
            {
                foreach (JObject commodity in jcommodities)
                {
                    CCommodities com = new CCommodities(commodity);
                    Commodities.Add(com);
                }

                CCommodities.Sort(Commodities);
            }
        }