Пример #1
0
        /// <summary>
        /// Populates the Commodity Registry with data from the eddb json string
        /// </summary>
        /// <param name="json">Json string of EDDB commodities.json data</param>
        private void _ParseCommodities(string json)
        {
            AerDebug.Log("Loading Commodities...");
            Stopwatch timer = new Stopwatch();

            timer.Start();
            JArray ja = JArray.Parse(json);

            foreach (JObject jo in ja)
            {
                EliteCommodity ec = new EliteCommodity();
                ec.Name = jo["name"].ToString();
                try
                {
                    ec.AveragePrice = int.Parse(jo["average_price"].ToString());
                }
                catch (FormatException e)
                {
                    AerDebug.LogError(@"Error formatting Average Price for " + ec.Name + ", " + e.Message);
                    ec.AveragePrice = -1;
                }

                ec.id = int.Parse(jo["id"].ToString());
                _CommodityRegistry.Add(ec.id, ec);
                _CommodityNameRegistry.Add(ec.Name.ToLower(), ec.id);
            }

            timer.Stop();
        }
Пример #2
0
        public int GetPrice(int commodity_id)
        {
            EliteCommodity ec = GetCommodity(commodity_id);

            if (ec == null)
            {
                return(-1);
            }
            else
            {
                return(ec.AveragePrice);
            }
        }
Пример #3
0
 public void SayAveragePrice(EliteCommodity ec)
 {
     this.Say("The EDDB Average price for " + ec.Name + " is " + ec.AveragePrice);
 }
Пример #4
0
 public void SayCannotFindCommodity(EliteCommodity ec)
 {
     this.Say("I could not find " + ec.Name + " within 250 light years");
 }
Пример #5
0
 public void SayFoundCommodity(EliteCommodity ec, EliteStation est)
 {
     this.Say("You can find " + ec.Name + ", at " + est.Name + ", in " + est.System.Name + ", Spelled " + Spell(est.System.Name));
 }
Пример #6
0
        /// <summary>
        /// Populates the Commodity Registry with data from the eddb json string
        /// </summary>
        /// <param name="json">Json string of EDDB commodities.json data</param>
        private void _ParseCommodities(string json)
        {
            AerDebug.Log("Loading Commodities...");
            Stopwatch timer = new Stopwatch();
            timer.Start();
            JArray ja = JArray.Parse(json);

            foreach (JObject jo in ja)
            {
                EliteCommodity ec = new EliteCommodity();
                ec.Name = jo["name"].ToString();
                try
                {
                    ec.AveragePrice = int.Parse(jo["average_price"].ToString());
                }
                catch (FormatException e)
                {
                    AerDebug.LogError(@"Error formatting Average Price for "+ ec.Name +", " + e.Message);
                    ec.AveragePrice = -1;
                }

                ec.id = int.Parse(jo["id"].ToString());
                _CommodityRegistry.Add(ec.id, ec);
                _CommodityNameRegistry.Add(ec.Name.ToLower(), ec.id);

            }

            timer.Stop();
        }
Пример #7
0
 public void SayCannotFindCommodity(EliteCommodity ec)
 {
     this.Say("I could not find " + ec.Name + " within 250 light years");
 }
Пример #8
0
        public void SayFoundCommodity(EliteCommodity ec, EliteStation est)
        {
            string spellName = Regex.Replace(est.System.Name, @"(?<=.)(?!$)", ",");

            this.Say("You can find " + ec.Name + ", at " + est.Name + ", in " + est.System.Name + ", Spelled " + Spell(est.System.Name));
        }
Пример #9
0
 public void SayAveragePrice(EliteCommodity ec)
 {
     this.Say("The EDDB Average price for " + ec.Name + " is " + ec.AveragePrice);
 }
Пример #10
0
 public void SayFoundCommodity(EliteCommodity ec, EliteStation est)
 {
     this.Say("You can find " + ec.Name + ", at " + est.Name + ", in " + est.System.Name + ", Spelled " + Spell(est.System.Name));
 }