/// <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(); }
public int GetPrice(int commodity_id) { EliteCommodity ec = GetCommodity(commodity_id); if (ec == null) { return(-1); } else { return(ec.AveragePrice); } }
public void SayAveragePrice(EliteCommodity ec) { this.Say("The EDDB Average price for " + ec.Name + " is " + ec.AveragePrice); }
public void SayCannotFindCommodity(EliteCommodity ec) { this.Say("I could not find " + ec.Name + " within 250 light years"); }
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)); }
/// <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(); }
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)); }