예제 #1
0
 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 = "";
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }