/// <summary> /// get the trade classifications /// </summary> /// <param name="filename">string - filename of trade class file to use</param> /// <remarks>loads the trade class</remarks> private void setTradeClasses(string prefix) { this.tradeclass = new ArrayList(); // create a valid array list StreamReader rd = new StreamReader("Assets/" + prefix + "TradeCodes.txt"); string line = ""; while ((line = rd.ReadLine()) != null) { if (line.StartsWith("#")) continue; // notes if (line.StartsWith(" ")) continue; // comment or white space if (line.Length < 12) continue; stTrade tc = new stTrade(); tc.code = line.Substring(0, 2); // code string[] ln = line.Split(new char[] { ',' }); tc.desc = ln[0].Substring(3); tc.size = ln[1]; tc.atm = ln[2]; tc.hyd = ln[3]; tc.pop = ln[4]; tc.gov = ln[5]; tc.law = ln[6]; tc.TL = ln[7]; try { tc.buymod = Convert.ToInt32(ln[8]); } catch { tc.buymod = 0; } // and see if the parameters match TravUtils util = new TravUtils(); if ((tc.size.Contains(util.convertToHex(this.size)) | tc.size == "-") & (tc.atm.Contains(util.convertToHex(this.atmo)) | tc.atm == "-") & (tc.hyd.Contains(util.convertToHex(this.hydro)) | tc.hyd == "-") & (tc.pop.Contains(util.convertToHex(this.pop)) | tc.pop == "-") & (tc.gov.Contains(util.convertToHex(this.gov)) | tc.gov == "-") & (tc.law.Contains(util.convertToHex(this.law)) | tc.law == "-") & (tc.TL.Contains(util.convertToHex(this.tech)) | tc.TL == "-")) { this.tradeclass.Add(tc); } } }
/// <summary> /// pass along an SEC line & version to create a world /// </summary> /// <param name="sec">sec - string, a line from an SEC file</param> /// <param name="tradetable">version - string, version (T5, CT, MT, CU)</param> public World(string sec, string version) { clearData(); this.secstring = sec; try { Match worldMatch = worldRegex.Match(sec); // establish UWP parameters string UWP = worldMatch.Groups["uwp"].Value; this.name = worldMatch.Groups["name"].Value; this.starport = UWP[0]; this.size = int.Parse(UWP[1].ToString(), System.Globalization.NumberStyles.HexNumber); this.atmo = int.Parse(UWP[2].ToString(), System.Globalization.NumberStyles.HexNumber); this.hydro = int.Parse(UWP[3].ToString(), System.Globalization.NumberStyles.HexNumber); this.pop = int.Parse(UWP[4].ToString(), System.Globalization.NumberStyles.HexNumber); this.gov = int.Parse(UWP[5].ToString(), System.Globalization.NumberStyles.HexNumber); this.law = int.Parse(UWP[6].ToString(), System.Globalization.NumberStyles.HexNumber); this.tech = int.Parse(UWP[8].ToString(), System.Globalization.NumberStyles.HexNumber); this.hex = worldMatch.Groups["hex"].Value; this.bases = worldMatch.Groups["base"].Value; this.travelclass = worldMatch.Groups["zone"].Value; switch (this.travelclass) { case "A": case "a": this.travelclass = "Amber"; break; case "R": case "r": this.travelclass = "Red"; break; default: this.travelclass = "Green"; break; } this.alliance = worldMatch.Groups["allegiance"].Value; string PBG = worldMatch.Groups["pbg"].Value; int.TryParse(PBG[0].ToString(), out this.popModifier); int.TryParse(PBG[1].ToString(), out this.belts); int.TryParse(PBG[2].ToString(), out this.gasGiant); this.stellar = worldMatch.Groups["stellar"].Value; this.bases = worldMatch.Groups["base"].Value; this.misc = new List<string>(); // empty set of misc data setTradeClasses(version); // set up the trade classifications loadSupport(); // load support data files loadNotes(version); // load any notes switch (version) { case "T5": T5Extensions(); // load up any T5 extensions break; default: break; } this.images = new List<string>(); // empty set of images loadImages(); // and load up any images calcWTN(); // get the GURPS World Trade Number this.berka = BerkaSystem(); // special trade class from SEC record string tCodes = worldMatch.Groups["codes"].Value; if (tCodes.Contains("Cp")) { stTrade tc = new stTrade(); tc.desc = "Subsector Capital"; tc.code = "Cp"; this.tradeclass.Add(tc); } if (tCodes.Contains("Cs")) { stTrade tc = new stTrade(); tc.desc = "Sector Capital"; tc.code = "Cs"; this.tradeclass.Add(tc); } if (tCodes.Contains("Ab")) { stTrade tc = new stTrade(); tc.desc = "Data Repository"; tc.code = "Ab"; this.tradeclass.Add(tc); } } catch (Exception ex) { this.errmsg = ex.Message; } }