/// <summary> /// Converts four bytes from a byte array to a float. /// </summary> /// <param name="bytes">Bytes to be converted.</param> /// <param name="startIndex">Index of the starting byte.</param> static public float ToFloat(byte[] bytes, int startIndex) { byte[] subBytes = HHelper.SubArray(bytes, startIndex, 4); if (BitConverter.IsLittleEndian) { Array.Reverse(subBytes); } return(BitConverter.ToSingle(subBytes, 0)); }
/// <summary> /// Converts a byte array to a string, using BigEndianUnicode. /// </summary> /// <param name="bytes">Bytes to be converted.</param> /// <param name="startIndex">Index of the starting byte.</param> /// <param name="length">Number of bytes to convert.</param> static public string ToBigEndianUnicodeString(byte[] bytes, int startIndex, int length) { byte[] subBytes = HHelper.SubArray(bytes, startIndex, length); //subBytes = Helper.ConcatinateArray(new byte[] { 0xFE, 0xFF }, subBytes); //if (BitConverter.IsLittleEndian) // Array.Reverse(subBytes); string text = Encoding.BigEndianUnicode.GetString(subBytes); // UTF-16 BigEndian to string. return(text); }
/// <summary> /// Converts four bytes from a byte array to a int32. Using BigEndian. /// </summary> /// <param name="bytes">Bytes to be converted.</param> /// <param name="startIndex">Index of the starting byte.</param> static public int ToInt32(byte[] bytes, int startIndex) { if (BitConverter.IsLittleEndian) { bytes = HHelper.SubArray(bytes, startIndex, 4); Array.Reverse(bytes); startIndex = 0; } return(BitConverter.ToInt32(bytes, startIndex)); }
public override void Initialize() { // String working vars. int subStart, subEnd; string[] tempArray; if (_mail.MessageType == 0x0C) // MSG_OfficerReady { _homeSystem = _systemName; //subStart = _mail.Body.IndexOf("Assignment Request on ") + 22; // "Assignment Request on ".Length == 22 //subEnd = _mail.Body.IndexOf("<br><br>Commander,") - subStart; //_homePlanet = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); _homePlanet = _planetName; _ship = ""; } else if (_mail.MessageType == 0x14) // MSG_OfficerContact { _homeSystem = "<system name>"; subStart = _mail.Body.IndexOf("I was deployed from ") + 20; // "I was deployed from ".Length == 20 subEnd = _mail.Body.Substring(subStart).IndexOf(" in "); _homePlanet = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); _ship = "<ship name>"; } // Overview _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += Environment.NewLine; _overview += "Officer:" + Environment.NewLine; _overview += " " + _name + Environment.NewLine; _overview += Environment.NewLine; _overview += "Officer Home:" + Environment.NewLine; _overview += " " + _homeSystem; _overview += " " + _homePlanet; if (_mail.MessageType == 0x14) // MSG_OfficerContact { _overview += Environment.NewLine + Environment.NewLine; _overview += "Stationed ship:" + Environment.NewLine; _overview += " " + _ship; } // AttentionCodes if (_mail.MessageType == 0x14) // MSG_OfficerContact { _attentionCode = (byte)(_attentionCode | 0x01); // 0b00000001 } base.Initialize(); }
public HMail(string filePath) { _filePath = filePath; _mailBytes = HMail.Read(_filePath); _from_l = HHelper.ToInt32(_mailBytes, 15); _subj_l = HHelper.ToInt32(_mailBytes, 19 + _from_l + 10); _body_l = Math.Max(0, HHelper.ToInt32(_mailBytes, 19 + _from_l + 14 + _subj_l)); if (this.MessageFlags_Syst) { _syst_l = HHelper.ToInt32(_mailBytes, 19 + _from_l + 14 + _subj_l + 4 + _body_l + 1 + 4); _systSkipOffset += 8 + _syst_l; } if (this.MessageFlags_Plan) { _plan_l = HHelper.ToInt32(_mailBytes, 19 + _from_l + 14 + _subj_l + 4 + _body_l + 1 + _systSkipOffset + 4); _planSkipOffset += 8 + _plan_l; } }
public override void Initialize() { // String working vars. int subStart, subEnd; string[] tempArray; _messageId = _mail.MessageID; _subject = _mail.Subject; _messageType = _mail.MessageType; if (_messageType == 0x03) // MSG_CityOccupationReport { // ? } if (_messageType == 0x05) // MSG_CityIntelligenceReport { // ? } else if (_messageType == 0x12) // MSG_ShipLogFinal { subStart = _mail.Body.IndexOf("<p>") + 3; // "<p>".Length == 3 subEnd = _mail.Body.Substring(subStart).IndexOf("<div style"); string officerName = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); string officerHomeSystem = "<system name>"; subStart = _mail.Body.IndexOf("I was deployed from ") + 20; // "I was deployed from ".Length == 20 subEnd = _mail.Body.Substring(subStart).IndexOf(" in "); string officerHomePlanet = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); List <string> sectionsInReport = new List <string> { "<b>SPACECRAFT DESTROYED</b>" }; if (_mail.Body.Contains("<b>EVENT LOG</b>")) { sectionsInReport.Add("<b>EVENT LOG</b>"); } string shipDestruction = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, "<b>SPACECRAFT DESTROYED</b>")); shipDestruction = shipDestruction.Substring(("SPACECRAFT DESTROYED" + Environment.NewLine).Length); shipDestruction = shipDestruction.Replace(Environment.NewLine, Environment.NewLine + " "); shipDestruction = shipDestruction.Replace(". ", "." + Environment.NewLine + " "); shipDestruction = shipDestruction.Replace("! ", "!" + Environment.NewLine + " "); shipDestruction = shipDestruction.Replace("? ", "?" + Environment.NewLine + " "); string shipEvent = ""; if (sectionsInReport.Contains("<b>EVENT LOG</b>")) { shipEvent = HEvent.EventLogStyle(HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, "<b>EVENT LOG</b>"))); } _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += Environment.NewLine; _overview += "Ship:" + Environment.NewLine; _overview += " " + _name + Environment.NewLine; _overview += Environment.NewLine; _overview += "Officer:" + Environment.NewLine; _overview += " " + officerName + Environment.NewLine; _overview += Environment.NewLine; _overview += "Officer Home:" + Environment.NewLine; _overview += " " + officerHomeSystem + Environment.NewLine; _overview += " " + officerHomePlanet + Environment.NewLine; _overview += Environment.NewLine; _overview += "[color=red]Cause of destruction:" + Environment.NewLine; _overview += " " + shipDestruction + "[/color]" + Environment.NewLine; if (shipEvent != "") { _overview += Environment.NewLine; _overview += shipEvent; } } else if (_messageType == 0x13) // MSG_Government { if (_name == "State Department") { string tempSection = HHelper.CleanText(_mail.Body); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); string empireName = tempArray[tempArray.Length - 6].Substring(4); string empireEncounter = tempArray[tempArray.Length - 4]; string empireStance = tempArray[tempArray.Length - 3]; _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += Environment.NewLine; _overview += "Empire:" + Environment.NewLine; if (Hazeron.PirateEmpires.Contains(empireName)) { _overview += " [color=red]" + empireName + " (NPC pirate empire)[/color]" + Environment.NewLine; } else { _overview += " " + empireName + Environment.NewLine; } _overview += Environment.NewLine; _overview += "Encounter:" + Environment.NewLine; _overview += " " + empireEncounter + Environment.NewLine; _overview += Environment.NewLine; _overview += "Stance taken:" + Environment.NewLine; if (!empireStance.Contains("competitive")) { _overview += " " + empireStance + Environment.NewLine; } else { _overview += " [color=red]" + empireStance + "[/color]" + Environment.NewLine; } } else if (_name == "War Department") { // ? } else if (_name == "Treasury Department") { // Levy Tax? } } else if (_messageType == 0x16) // MSG_OfficerDeath { string officerHomeSystem = "<system name>"; string officerHomePlanet = "<planet name>"; string tempSection = HHelper.CleanText(_mail.Body); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); string officerDeath = tempArray[tempArray.Length - 3]; officerDeath = officerDeath.Replace(". ", "." + Environment.NewLine + " "); officerDeath = officerDeath.Replace("! ", "!" + Environment.NewLine + " "); officerDeath = officerDeath.Replace("? ", "?" + Environment.NewLine + " "); _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += Environment.NewLine; _overview += "Officer:" + Environment.NewLine; _overview += " " + _name + Environment.NewLine; _overview += Environment.NewLine; _overview += "Officer Home:" + Environment.NewLine; _overview += " " + officerHomeSystem + Environment.NewLine; _overview += " " + officerHomePlanet + Environment.NewLine; _overview += Environment.NewLine; _overview += "[color=red]Cause of death:" + Environment.NewLine; _overview += " " + officerDeath + "[/color]"; } else if (_messageType == 0x17) // MSG_CityFinalDecayReport { // ? } else if (_messageType == 0x18) // MSG_DiplomaticMessage { string tempSection = HHelper.CleanText(_mail.Body); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); string diplomat = tempArray[tempArray.Length - 2]; diplomat = diplomat.Remove(diplomat.IndexOf(" has asked")); string diplomaticMessage = tempArray[tempArray.Length - 1]; diplomaticMessage = diplomaticMessage.Replace(". ", "." + Environment.NewLine + " "); diplomaticMessage = diplomaticMessage.Replace("! ", "!" + Environment.NewLine + " "); diplomaticMessage = diplomaticMessage.Replace("? ", "?" + Environment.NewLine + " "); _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += Environment.NewLine; _overview += "Diplomat:" + Environment.NewLine; _overview += " " + diplomat + Environment.NewLine; _overview += Environment.NewLine; _overview += "Diplomatic Message:" + Environment.NewLine; _overview += " " + diplomaticMessage; } // AttentionCodes if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x01); // 0b00000001 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x03); // 0b00000010 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x04); // 0b00000100 } if (_messageType == 0x05) // MSG_CityIntelligenceReport { _attentionCode = (byte)(_attentionCode | 0x08); // 0b00001000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x10); // 0b00010000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x20); // 0b00100000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x40); // 0b01000000 } if (_messageType == 0x03 || _messageType == 0x12 || _messageType == 0x16 || _messageType == 0x17) // MSG_CityOccupationReport, MSG_ShipLogFinal, MSG_OfficerDeath or MSG_CityFinalDecayReport { _attentionCode = (byte)(_attentionCode | 0x80); // 0b10000000 } base.Initialize(); }
public override void Initialize() { // String working vars. int subStart, subEnd; string[] tempArray; List <string> sectionsInReport = new List <string>(); // This is the order of the sections in the mail body, keep them in same order! string[] sections = new string[] { "<b>EVENT LOG</b>" , "<b>DAMAGE REPORT</b>" , "<b>ACCOUNT</b>" , "<b>FUEL</b>" , "<b>CARGO</b>" , "<b>MISSION</b>" , "<b>ROSTER</b>" }; // Time for Ship spicific things. int abandonment = 0; // Check for sections. foreach (string section in sections) { if (_mail.Body.Contains(section)) { sectionsInReport.Add(section); } } // EVENT LOG const string headlineEVENT = "<b>EVENT LOG</b>"; if (sectionsInReport.Contains(headlineEVENT)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineEVENT)); //tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _eventOverview = HShip.EventLogStyle(tempSection); } // Decay if (!_mail.Body.Contains("I miss my home; ")) { subStart = _mail.Body.IndexOf("Commander,") + 10; // "Commander,".Length == 10 subEnd = _mail.Body.Substring(subStart).IndexOf("I was deployed from "); string crewMorale = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); abandonment = 7; switch (crewMorale) { case "The crew has high spirits. Every day seems filled with anticipation.": abandonment *= 4; break; case "More than a week has passed since we were last hailed by command. The crew is quiet, intent on their work as they attend to their duties.": abandonment *= 3; break; case "More than two weeks have passed since we last heard from command. There have been some tense confrontations between the crew members.": abandonment *= 2; break; case "More than three weeks have passed since we lost contact with command. Some of the crew have become surly and insubordinate. Fighting among them is a daily occurance.": abandonment *= 1; break; } _abandonmentColumn = (abandonment / 7) + " /4 weeks"; } else { subStart = _mail.Body.IndexOf("I miss my home; it's been ") + 26; // "I miss my home; it's been ".Length == 26 subEnd = _mail.Body.Substring(subStart).IndexOf(" days since I last heard from my family."); abandonment = 7 - Convert.ToInt32(_mail.Body.Substring(subStart, subEnd)); _abandonmentColumn = " " + abandonment + " /7 days"; } // DAMAGE REPORT const string headlineDAMAGE = "<b>DAMAGE REPORT</b>"; if (sectionsInReport.Contains(headlineDAMAGE)) { _damageOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineDAMAGE)); //tempArray = _damageOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //_damageColumn = tempArray[temp.Length - 1]; } // ACCOUNT const string headlineACCOUNT = "<b>ACCOUNT</b>"; if (sectionsInReport.Contains(headlineACCOUNT)) { _accountOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineACCOUNT)); tempArray = _accountOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _accountColumn = tempArray[1].Remove(tempArray[1].IndexOf('¢') + 1).Replace(',', '\'').Replace('.', '\''); _accountBalance = Convert.ToInt64(_accountColumn.Remove(_accountColumn.IndexOf('¢')).Replace("'", "")); _accountColumn = _accountBalance.ToString("C", Hazeron.NumberFormat); } // FUEL const string headlineFUEL = "<b>FUEL</b>"; if (sectionsInReport.Contains(headlineFUEL)) { _fuelOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineFUEL)); tempArray = _fuelOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _fuelColumn = tempArray[1]; } // CARGO const string headlineCARGO = "<b>CARGO</b>"; if (sectionsInReport.Contains(headlineCARGO)) { _cargoOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineCARGO)); //tempArray = _cargoOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //_cargoColumn = tempArray[tempArray.Length - 1]; } // MISSION const string headlineMISSION = "<b>MISSION</b>"; if (sectionsInReport.Contains(headlineMISSION)) { _missionOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineMISSION)); //tempArray = _missionOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //_missionColumn = tempArray[tempArray.Length - 1]; } // ROSTER const string headlineROSTER = "<b>ROSTER</b>"; if (sectionsInReport.Contains(headlineROSTER)) { _rosterOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineROSTER)); //tempArray = _rosterOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //_rosterColumn = tempArray[tempArray.Length - 1]; } // Officer Info //// Name subStart = _mail.Body.IndexOf("<p>") + 3; // "<p>".Length == 3 subEnd = _mail.Body.Substring(subStart).IndexOf("<div style"); _officerName = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); //// Home _officerHomeSystem = "<system name>"; subStart = _mail.Body.IndexOf("I was deployed from ") + 20; // "I was deployed from ".Length == 20 subEnd = _mail.Body.Substring(subStart).IndexOf(" in "); _officerHomePlanet = HHelper.CleanText(_mail.Body.Substring(subStart, subEnd)); // Officer Overview _officerOverview = "Location:" + Environment.NewLine; _officerOverview += " " + _systemName + Environment.NewLine; _officerOverview += " " + _planetName + Environment.NewLine; _officerOverview += Environment.NewLine; _officerOverview += "Officer:" + Environment.NewLine; _officerOverview += " " + _officerName + Environment.NewLine; _officerOverview += Environment.NewLine; _officerOverview += "Officer Home:" + Environment.NewLine; _officerOverview += " " + _officerHomeSystem; _officerOverview += " " + _officerHomePlanet; _officerOverview += Environment.NewLine + Environment.NewLine; _officerOverview += "Stationed ship:" + Environment.NewLine; _officerOverview += " " + _name; // Overview _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += Environment.NewLine; _overview += _eventOverview; // AttentionCodes if (abandonment <= 14) // 2 weeks until decay. { _attentionCode = (byte)(_attentionCode | 0x08); // 0b00000001 } if (abandonment <= 7) // 1 weeks until decay. { _attentionCode = (byte)(_attentionCode | 0x03); // 0b00000010 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x04); // 0b00000100 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x08); // 0b00001000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x10); // 0b00010000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x20); // 0b00100000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x40); // 0b01000000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x80); // 0b10000000 } base.Initialize(); }
public HCharacter(HMail mail) { _idNum = mail.SenderID; _id = HHelper.ToID(_idNum); _name = mail.From; }
public override void Initialize() { if (_mail.Body.Remove(4) == "UTC:") { _lastUpdated = HMail.DecodeUTC(_mail.Body.Remove(12)); } // String working vars. string[] tempArray; List <string> sectionsInReport = new List <string>(); // This is the order of the sections in the mail body, keep them in same order! string[] sections = new string[] { "<b style=\"color: rgb(255, 255, 0);\">DISTRESS</b>" , "<b>DECAY</b>" , "<b>EVENT LOG</b>" , "<b>MORALE</b>" , "<b>POPULATION</b>" , "<b>LIVING CONDITIONS</b>" , "<b>POWER RESERVE</b>" , "<b>BANK ACTIVITY</b>" , "<b>RESEARCH AND DEVELOPMENT</b>" , "<b>SPACECRAFT MANUFACTURING POTENTIAL</b>" , "<b>SPACECRAFT</b>" , "<b>FACILITIES</b>" , "<b>VEHICLES</b>" , "<b>INVENTORY</b>" }; Dictionary <string, int> moraleBuildingsPop = new Dictionary <string, int>(); moraleBuildingsPop.Add("Church", 45); moraleBuildingsPop.Add("Cantina", 50); moraleBuildingsPop.Add("Retail Store", 55); moraleBuildingsPop.Add("Police Station", 60); moraleBuildingsPop.Add("University", 70); moraleBuildingsPop.Add("Hospital", 80); moraleBuildingsPop.Add("Park", 90); moraleBuildingsPop.Add("Grocery", 100); moraleBuildingsPop.Add("Zoo", 150); moraleBuildingsPop.Add("Arena", 175); moraleBuildingsPop.Add("Casino", 200); // Time for City spicific things. string race = ""; int powerConsumption = 0, powerReserve = 0, powerReserveCapacity = 0; List <string> buildingList; bool decaying = false; int moraleChange = 0; int populationChange = 0; // Check for sections. foreach (string section in sections) { if (_mail.Body.Contains(section)) { sectionsInReport.Add(section); } } // City Resource Zone & Capital check { string tempSection = HHelper.CleanText(_mail.Body.Remove(_mail.Body.IndexOf(sectionsInReport[0]))); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in tempArray) { if (line.Contains("Resource Zone")) { _zone = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } else if (line == "Empire Capital City") { _empireCapital = true; } } } //DISTRESS const string headlineDISTRESS = "<b style=\"color: rgb(255, 255, 0);\">DISTRESS</b>"; if (sectionsInReport.Contains(headlineDISTRESS)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineDISTRESS)); //tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _distressOverview = "[color=red]" + "Distress:" + Environment.NewLine + " " + tempSection.Substring(("DISTRESS" + Environment.NewLine).Length).Replace(Environment.NewLine, Environment.NewLine + " ") + "[/color]"; decaying = tempSection.Contains("City is decaying."); } // DECAY const string headlineDECAY = "<b>DECAY</b>"; if (sectionsInReport.Contains(headlineDECAY)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineDECAY)); //tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _decayOverview = "[color=red]" + "Decay:" + Environment.NewLine + " " + tempSection.Substring(("DECAY" + Environment.NewLine).Length).Replace(Environment.NewLine, Environment.NewLine + " ") + "[/color]"; } // EVENT LOG const string headlineEVENT = "<b>EVENT LOG</b>"; if (sectionsInReport.Contains(headlineEVENT)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineEVENT)); //tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _eventOverview += HCity.EventLogStyle(tempSection); } // MORALE & Abandonment const string headlineMORALE = "<b>MORALE</b>"; if (sectionsInReport.Contains(headlineMORALE)) { _moraleOverview = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineMORALE)); tempArray = _moraleOverview.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); _moraleColumn = tempArray[tempArray.Length - 1].Remove(tempArray[tempArray.Length - 1].Length - 1); _morale = Convert.ToInt32(_moraleColumn.Substring(_moraleColumn.LastIndexOf(' ') + 1)); if (!_moraleColumn.Contains("remained steady")) { int posA, posB; posA = _moraleColumn.LastIndexOf(" by ") + 4; posB = _moraleColumn.LastIndexOf(" to "); moraleChange = Convert.ToInt32(_moraleColumn.Substring(posA, posB - posA)); if (_moraleColumn.Contains("decreased")) { moraleChange *= -1; _moraleColumn = _morale.ToString().PadLeft(3) + " (decreased " + Math.Abs(moraleChange) + ")"; } else { _moraleColumn = _morale.ToString().PadLeft(3) + " (increased " + moraleChange + ")"; } } else { _moraleColumn = _morale.ToString().PadLeft(3) + " (steady)"; } int abandonedDays = 0; int abandonedPenalty = 0; for (int i = 1; i < tempArray.Length - 1; i++) { _moraleModifiers.Add(tempArray[i].Substring(tempArray[i].IndexOf(' ') + 1), Convert.ToInt32(tempArray[i].Remove(tempArray[i].IndexOf(' ')))); if (tempArray[i].Contains("Abandonment Penalty")) { abandonedPenalty = Convert.ToInt32(tempArray[i].Remove(tempArray[i].IndexOf(' '))); int posA, posB; posA = tempArray[i].LastIndexOf(" in ") + 4; posB = tempArray[i].LastIndexOf(" days."); abandonedDays = Convert.ToInt32(tempArray[i].Substring(posA, posB - posA)); } if (tempArray[i].Contains("Harsh Environment Penalty")) { _hashEnv = true; } } _abandonment = ((_moraleModifiers.Values.Sum() + 1) * Hazeron.AbandonmentInterval) - (abandonedDays % Hazeron.AbandonmentInterval); _abandonmentMax = ((_moraleModifiers.Values.Sum() - abandonedPenalty + 1) * Hazeron.AbandonmentInterval); if (decaying) { _abandonmentColumn = " Decaying"; } else if (_abandonmentMax < Hazeron.AbandonmentInterval) { _abandonmentColumn = " Unstable"; } else if (_abandonment == _abandonmentMax) { _abandonmentColumn = _abandonment.ToString("00") + "~/" + _abandonmentMax.ToString("00") + " days"; } else if (_abandonment > 0) { _abandonmentColumn = _abandonment.ToString("00") + " /" + _abandonmentMax.ToString("00") + " days"; } else { _abandonmentColumn = " ERROR!?"; } } // POPULATION const string headlinePOPULATION = "<b>POPULATION</b>"; if (sectionsInReport.Contains(headlinePOPULATION)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlinePOPULATION)); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in tempArray) { if (line.Contains("Citizens are")) { race = line.Remove(line.Length - 1).Substring(13); } else if (line.Contains("Population") && !line.Contains("troops")) { _population = Convert.ToInt32(line.Remove(line.Length - 1).Substring(line.LastIndexOf(' ') + 1)); if (!line.Contains("remained steady")) { int posA, posB; posA = line.LastIndexOf(" by ") + 4; posB = line.LastIndexOf(" to "); populationChange = Convert.ToInt32(line.Substring(posA, posB - posA)); if (line.Contains("decreased")) { populationChange *= -1; _populationColumn = _population.ToString() + " (decreased " + Math.Abs(populationChange) + ")"; } else { _populationColumn = _population.ToString() + " (increased " + populationChange + ")"; } } else { _populationColumn = _population.ToString() + " (steady)"; } } else if (line.Contains("Garrison")) { // Nothing yet } else if (line.Contains("arsh environment")) { _hashEnv = true; } else if (line.Contains("loyal")) { _loyalty = Convert.ToInt32(line.Remove(line.IndexOf(' '))); if (line.Contains("disloyal")) { _loyalty = -_loyalty; } _loyaltyColumn = _loyalty + " (" + Math.Round(((double)_loyalty / _population) * 100, 2).ToString(Hazeron.NumberFormat) + "%)"; } } } // LIVING CONDITIONS const string headlineLIVING = "<b>LIVING CONDITIONS</b>"; if (sectionsInReport.Contains(headlineLIVING)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineLIVING)); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in tempArray) { if (line.Contains("Jobs")) { _livingConditionsColumn = line; _jobs = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } else if (line.Contains("Homes")) { _livingConditionsColumn += ", " + line; _homes = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } else if (line.Contains("Apartments")) { _apartments = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } else if (line.Contains("Food")) { _food = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } } } // POWER RESERVE const string headlinePOWER = "<b>POWER RESERVE</b>"; if (sectionsInReport.Contains(headlinePOWER)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlinePOWER)); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in tempArray) { if (line.Contains("Consumed")) { powerConsumption = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } else if (line.Contains("Reserve Power")) { powerReserve = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } else if (line.Contains("Reserve Capacity")) { powerReserveCapacity = Convert.ToInt32(line.Substring(line.LastIndexOf(' ') + 1)); } } } // BANK ACTIVITY const string headlineBANK = "<b>BANK ACTIVITY</b>"; if (sectionsInReport.Contains(headlineBANK)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineBANK)); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); bool GovAcc = true; for (int i = 1; i < tempArray.Length; i++) { string line = tempArray[i]; if (line == "Citizen Accounts") { GovAcc = false; } else if (line == "Previous Tribute") { i++; line = tempArray[i].Replace(",", "").Replace(".", ""); _bankTribute = Convert.ToInt64(line.Remove(line.Length - 1)); } else if (line == "Starting Balance") { i++; line = tempArray[i].Replace(",", "").Replace(".", ""); if (GovAcc) { _bankGovBalanceOld = Convert.ToInt64(line.Remove(line.Length - 1)); } else { _bankCitBalanceOld = Convert.ToInt64(line.Remove(line.Length - 1)); } } else if (line == "Current Balance") { i++; line = tempArray[i].Replace(",", "").Replace(".", ""); if (GovAcc) { _bankGovBalance = Convert.ToInt64(line.Remove(line.Length - 1)); } else { _bankCitBalance = Convert.ToInt64(line.Remove(line.Length - 1)); } } else if (line == "Income Tax") { i++; line = tempArray[i].Replace(",", "").Replace(".", ""); _bankTaxIncome = Convert.ToInt64(line.Remove(line.Length - 1)); } else if (line == "Sales Tax") { i++; line = tempArray[i].Replace(",", "").Replace(".", ""); _bankTaxSale = Convert.ToInt64(line.Remove(line.Length - 1)); } else if (line == "Bullion Production") { i++; line = tempArray[i].Replace(",", "").Replace(".", ""); _bankMinting = Convert.ToInt64(line.Remove(line.Length - 1)); } //else if (line == "Research and Development") //{ // i++; // line = tempArray[i].Replace(",", "").Replace(".", ""); // _bankExpenseResearch = Convert.ToInt64(line.Remove(line.Length - 1)); //} } } // RESEARCH AND DEVELOPMENT const string headlineRESEARCH = "<b>RESEARCH AND DEVELOPMENT</b>"; if (sectionsInReport.Contains(headlineRESEARCH)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineRESEARCH)); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); for (int i = 3; i < tempArray.Length; i += 2) { if (tempArray[i] != "Technology") { _reseatchProjects.Add(tempArray[i].Remove(tempArray[i].Length - 11), Convert.ToInt32(tempArray[i + 1])); } } foreach (int projectProcess in _reseatchProjects.Values) { _bankExpenseResearchEstReport += projectProcess; _bankExpenseResearchEstDay += projectProcess; } _bankExpenseResearchEstReport *= 780; _bankExpenseResearchEstDay *= 24 * 60 * 60; } //// SPACECRAFT MANUFACTURING POTENTIAL //const string headlinePOTENTIAL = "<b>SPACECRAFT MANUFACTURING POTENTIAL</b>"; //if (sectionsInReport.Contains(headlinePOTENTIAL)) //{ // string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlinePOTENTIAL)); // tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //} //// SPACECRAFT //const string headlineSPACECRAFT = "<b>SPACECRAFT</b>"; //if (sectionsInReport.Contains(headlineSPACECRAFT)) //{ // string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineSPACECRAFT)); // tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //} // FACILITIES const string headlineFACILITIES = "<b>FACILITIES</b>"; if (sectionsInReport.Contains(headlineFACILITIES)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineFACILITIES)); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); for (int i = 4; i < tempArray.Length; i += 3) { if (tempArray[i] != "Name") { int tl; if (!Int32.TryParse(tempArray[i + 1], out tl)) { tl = Convert.ToInt32(tempArray[i + 1].Split(new char[] { '-' })[1]) * -1; // Make negitive because it is not all buildings. } _factilitiesTL.Add(tempArray[i], tl); _factilitiesLV.Add(tempArray[i], Convert.ToInt32(tempArray[i + 2])); } } } //// VEHICLES //const string headlineVEHICLES = "<b>VEHICLES</b>"; //if (sectionsInReport.Contains(headlineVEHICLES)) //{ // string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineVEHICLES)); // tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); //} // INVENTORY const string headlineINVENTORY = "<b>INVENTORY</b>"; if (sectionsInReport.Contains(headlineINVENTORY)) { string tempSection = HHelper.CleanText(GetSectionText(_mail.Body, sectionsInReport, headlineINVENTORY)); if (tempSection.Contains("Computer")) { _bankExpenseResearchEstReport = (int)(_bankExpenseResearchEstReport * 2.25); _bankExpenseResearchEstDay = (int)(_bankExpenseResearchEstDay * 2.25); } if (_hashEnv && tempSection.Contains("Air")) { tempSection = tempSection.Substring(tempSection.IndexOf("Air")); tempArray = tempSection.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); for (int i = 1; i < tempArray.Length; i++) { if (tempArray[i].Contains(" Q")) { _air += Convert.ToInt32(tempArray[i].Remove(tempArray[i].IndexOf(' '))); } else { break; } } } } // Planet Size if (!_mail.Body.Contains("Ringworld Arc")) { int sub = _mail.Body.IndexOf("m dia, "); tempArray = _mail.Body.Remove(sub).Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); _populationLimit = Convert.ToInt32(tempArray[tempArray.Length - 1].Replace(",", "")); _populationLimit = Convert.ToInt32(100 * Math.Floor((float)_populationLimit / 1800)); } else { _populationLimit = 1000; } // Morale overview _moraleOverview = "City's morale:" + Environment.NewLine + " "; if (_morale >= 0) { _moraleOverview += "[color=green]"; } else { _moraleOverview += "[color=red]"; } _moraleOverview += "Morale " + _morale.ToString().PadLeft(3) + "[/color]" + Environment.NewLine + " "; if (moraleChange >= 0) { _moraleOverview += "[color=green]"; } else { _moraleOverview += "[color=red]"; } _moraleOverview += "Change "; _moraleOverview += moraleChange.ToString("+#0;-#0;±#0") + "[/color]" + Environment.NewLine; _moraleOverview += Environment.NewLine; _moraleOverview += "City's morale modifiers:" + Environment.NewLine; foreach (KeyValuePair <string, int> moraleModifier in _moraleModifiers) { if (moraleModifier.Value > 0) { _moraleOverview += " [color=green]"; } else { _moraleOverview += " [color=red]"; } _moraleOverview += moraleModifier.Value.ToString("+#0;-#0") + " " + moraleModifier.Key + "[/color]" + Environment.NewLine; } if (_moraleModifiers.Values.Sum() > 0) { _moraleOverview += "[color=green]"; } else if (_moraleModifiers.Values.Sum() < 0) { _moraleOverview += "[color=red]"; } _moraleOverview += "Total " + _moraleModifiers.Values.Sum().ToString("+#0;-#0;±#0"); if (_moraleModifiers.Values.Sum() > 0 || _moraleModifiers.Values.Sum() < 0) { _moraleOverview += "[/color]"; } _moraleModifiersColumn = _moraleModifiers.Values.Sum().ToString("+#0;-#0;±#0"); _moraleModifiersColumn += " (" + Math.Abs(_moraleModifiers.Values.Where(y => y < 0).Sum()).ToString("-#0") + ", " + _moraleModifiers.Values.Where(y => y > 0).Sum().ToString("+#0") + ")"; // Population overwiew const int populationPadding = 4; _populationOverview = "City's population:"; _populationOverview += Environment.NewLine + " " + _loyalty.ToString().PadLeft(populationPadding) + ", Loyal citizens"; if (_loyalty != _population) { int minutesToLoyal; bool disloyal = _loyalty < 0; if (!disloyal) { minutesToLoyal = ((_population - _loyalty) * 13); } else { minutesToLoyal = (Math.Abs(_loyalty) * 13); } _populationOverview += " [color=" + (disloyal ? "red" : "orange") + "]("; if (minutesToLoyal < 120) // Less than two hours. { _populationOverview += minutesToLoyal + " minutes"; } else if (minutesToLoyal < 2980) // Less than two days. { _populationOverview += (minutesToLoyal / 60) + " hours"; } else // More than two days. { _populationOverview += (minutesToLoyal / 1490) + " days"; } _populationOverview += " to " + (disloyal ? "loyal" : "fully") + ")[/color]"; } //else // _populationOverview += " [color=green](fully)[/color]"; _populationOverview += Environment.NewLine + " " + _population.ToString().PadLeft(populationPadding) + ", Citizens"; if (populationChange < 0) { _populationOverview += " [color=red](decreased " + Math.Abs(populationChange) + ")[/color]"; } else if (populationChange > 0) { _populationOverview += " [color=green](increased " + populationChange + ")[/color]"; } //else // _populationOverview += " (steady)"; _populationOverview += Environment.NewLine + " " + _homes.ToString().PadLeft(populationPadding) + ", Homes"; if (_jobs >= _homes) { int needed = (_jobs - _homes + 1); // Need at least one more home than jobs. _populationOverview += " [color=red](Overworked, " + needed + " more homes needed)[/color]"; } _populationOverview += Environment.NewLine + " " + _jobs.ToString().PadLeft(populationPadding) + ", Jobs"; if (((float)(_homes - _jobs) / _homes) > 0.2) { int needed = (int)((_homes * 0.8) - _jobs + 1); // Need at least one more job than 80% homes. _populationOverview += " [color=red](Unemployment, " + needed + " more jobs needed)[/color]"; } _populationOverview += Environment.NewLine + " " + _populationLimit.ToString().PadLeft(populationPadding) + ", Population limit"; if (_homes > _populationLimit) { int needed = (_homes - _populationLimit); _populationOverview += " [color=red](Overpopulated, " + needed + " homes too many)[/color]"; } _populationOverview += Environment.NewLine; _populationOverview += Environment.NewLine + "City's living conditions:"; _populationOverview += Environment.NewLine + " Citizens are " + race; { string powerUse = powerConsumption.ToString("N", Hazeron.NumberFormat); string powerSto = powerReserve.ToString("N", Hazeron.NumberFormat); int powerPadding = Math.Max(powerUse.Length, powerSto.Length); _populationOverview += Environment.NewLine + " " + powerUse.PadLeft(powerPadding) + " power comsumption"; _populationOverview += Environment.NewLine + " " + powerSto.PadLeft(powerPadding) + "/" + powerReserveCapacity.ToString("N", Hazeron.NumberFormat) + " power capacity (" + Math.Floor(((float)powerReserve / powerReserveCapacity) * 100) + "%)"; } { _populationOverview += Environment.NewLine + " "; int minutesToStarvation = (_food); if (minutesToStarvation < 120) // Less than two hours. { _populationOverview += minutesToStarvation + " minutes"; } else if (minutesToStarvation < 2980) // Less than two days. { _populationOverview += (minutesToStarvation / 60) + " hours"; } else // More than two days. { _populationOverview += (minutesToStarvation / 1490) + " days"; } _populationOverview += " worth of food"; } if (_hashEnv) { _populationOverview += Environment.NewLine + " "; int minutesToSuffocation = (_air); if (minutesToSuffocation < 120) // Less than two hours. { _populationOverview += minutesToSuffocation + " minutes"; } else if (minutesToSuffocation < 2980) // Less than two days. { _populationOverview += (minutesToSuffocation / 60) + " hours"; } else // More than two days. { _populationOverview += (minutesToSuffocation / 1490) + " days"; } _populationOverview += " worth of air"; } { _populationOverview += Environment.NewLine + " " + Math.Floor(((float)_apartments / _homes) * 100) + "% apartments"; int levelAjustment = ((_homes - _apartments) - _apartments); if ((levelAjustment / 4) > 0) { _populationOverview += " [color=green](" + (levelAjustment / 4) + " more levels possible)[/color]"; } else if (levelAjustment < 0) { _populationOverview += " [color=red](Cramped, " + Math.Abs(levelAjustment) + " more non-apartment homes needed)[/color]"; } } // Technology overview if (sectionsInReport.Contains(headlineRESEARCH)) { _technologyOverview = "City's technology projects:"; foreach (string building in _reseatchProjects.Keys) { if (_factilitiesTL.ContainsKey(building)) { _technologyOverview += Environment.NewLine + " " + _reseatchProjects[building].ToString().PadLeft(2) + " (TL" + Math.Abs(_factilitiesTL[building]).ToString().PadLeft(2) + ") running, " + building; } else { _technologyOverview += Environment.NewLine + " [color=red]" + _reseatchProjects[building].ToString().PadLeft(2) + " running, " + building + " (wasted, none in city)[/color]"; } } } if (_technologyOverview != "") { _technologyOverview += Environment.NewLine + Environment.NewLine; } _technologyOverview += "City's technology levels:"; buildingList = _factilitiesTL.Keys.ToList(); buildingList.Sort(); foreach (string building in buildingList) { _technologyOverview += Environment.NewLine + " TL" + Math.Abs(_factilitiesTL[building]).ToString().PadLeft(2) + ", " + building; if (_factilitiesTL[building] < 0) { _technologyOverview += " [color=red](not all buildings)[/color]"; } } // Buildings overview _buildingsOverview = "City's buildings:"; buildingList = _factilitiesLV.Keys.ToList(); foreach (string moraleBuilding in moraleBuildingsPop.Keys) { if (!_factilitiesLV.ContainsKey(moraleBuilding) && _homes > moraleBuildingsPop[moraleBuilding]) { buildingList.Add(moraleBuilding); } } if (!buildingList.Contains("Military Flag")) { buildingList.Add("Military Flag"); } if (!buildingList.Contains("Cantina")) { buildingList.Add("Cantina"); } if (!buildingList.Contains("Church")) { buildingList.Add("Church"); } buildingList.Sort(); foreach (string building in buildingList) { int levels = 0; if (_factilitiesLV.ContainsKey(building)) { levels = _factilitiesLV[building]; } _buildingsOverview += Environment.NewLine + " " + levels.ToString().PadLeft(3) + " levels, " + building; if (moraleBuildingsPop.ContainsKey(building)) { int levelsNeeded = _homes / moraleBuildingsPop[building]; if (building == "Cantina") { levelsNeeded += 1; } else if (building == "Church") { levelsNeeded += 2; } if (levels < levelsNeeded) { _buildingsOverview += " [color=red](" + (levelsNeeded - levels) + " levels more needed)[/color]"; } else if (levels > levelsNeeded && !(building == "Church" || building == "University" || building == "Park")) { _buildingsOverview += " [color=orange](" + (levels - levelsNeeded) + " levels too many)[/color]"; } } else if (building == "Military Flag") { int levelsPossible = (_homes / 150) + 1; if (levels > levelsPossible) { _buildingsOverview += " [color=red](" + (levels - levelsPossible) + " flags too many)[/color]"; } else if (levels < levelsPossible) { _buildingsOverview += " [color=green](" + (levelsPossible - levels) + " flags more possible)[/color]"; } } } // Bank overview _bankGovBalanceColumn = _bankGovBalance.ToString("C", Hazeron.NumberFormat) + " balance"; _bankOverview = "City's finances:"; if (_empireCapital && _bankTribute == 0) { _bankTributeColumn = "No tributing"; _bankOverview += Environment.NewLine + "".PadLeft(Hazeron.CurrencyPadding) + " Empire capital does not tribute"; } else { _bankTributeColumn = _bankTribute.ToString("C", Hazeron.NumberFormat) + " tributed"; _bankOverview += Environment.NewLine + " " + _bankTribute.ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " tributed to "; if (_empireCapital) { _bankOverview += "(overlord/ally)"; } else { _bankOverview += "(empire/sector) capital"; } } { _bankOverview += Environment.NewLine + "".PadLeft(Hazeron.CurrencyPadding) + " [color=green]("; int minutesToMidnight = (int)(DateTime.UtcNow.Subtract(DateTime.Now.TimeOfDay).AddDays(1) - _lastUpdated).TotalMinutes; if (minutesToMidnight < 120) // Less than two hours. { _bankOverview += minutesToMidnight + " minutes"; } else // More than two hours. { _bankOverview += (minutesToMidnight / 60) + " hours"; } _bankOverview += " to next tribute)[/color]"; } _bankOverview += Environment.NewLine; _bankOverview += Environment.NewLine + " " + _bankMinting.ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " bullion production"; _bankOverview += Environment.NewLine; _bankOverview += Environment.NewLine + " " + (_bankCitBalance - _bankCitBalanceOld).ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " citizen account net-change"; _bankOverview += Environment.NewLine + " " + _bankCitBalance.ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " citizen account balance"; _bankOverview += Environment.NewLine; _bankOverview += Environment.NewLine + " " + _bankTaxIncome.ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " income tax"; _bankOverview += Environment.NewLine + " " + _bankTaxSale.ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " Sales tax"; _bankOverview += Environment.NewLine; //_bankOverview += Environment.NewLine + " " + (-_vBankExpenseResearch).ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " research expense (unreliable)"; _bankOverview += Environment.NewLine + " " + (-_bankExpenseResearchEstReport).ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " research expense (estimate per report)"; _bankOverview += Environment.NewLine + " " + (-_bankExpenseResearchEstDay).ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " research expense (estimate per day)"; _bankOverview += Environment.NewLine; _bankOverview += Environment.NewLine + " " + (_bankGovBalance - _bankGovBalanceOld).ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " government account net-change"; _bankOverview += Environment.NewLine + " " + _bankGovBalance.ToString("C", Hazeron.NumberFormat).PadLeft(Hazeron.CurrencyPadding) + " government account balance"; // Overview _overview = "Location:" + Environment.NewLine; _overview += " " + _systemName + Environment.NewLine; _overview += " " + _planetName + Environment.NewLine; _overview += " Zone " + _zone; if (_distressOverview != "") { _overview += Environment.NewLine + Environment.NewLine + _distressOverview; } if (_decayOverview != "") { _overview += Environment.NewLine + Environment.NewLine + _decayOverview; } if (_eventOverview != "") { _overview += Environment.NewLine + Environment.NewLine + _eventOverview; } // AttentionCodes if ((_jobs >= _homes) || (((float)(_homes - _jobs) / _homes) > 0.2)) // Overworked, or too much unemployment. { _attentionCode = (byte)(_attentionCode | 0x01); // 0b00000001 } if (_population < _homes || _population > _homes) // Population not full, or more than full. { _attentionCode = (byte)(_attentionCode | 0x02); // 0b00000010 } if (Hazeron.AbandonmentInterval * 2 >= _abandonment) // Less than or equal to (Hazeron.AbandonmentInterval * 2) days to decay. { _attentionCode = (byte)(_attentionCode | 0x04); // 0b00000100 } if (Hazeron.AbandonmentInterval >= _abandonment) // Less than or equal to (Hazeron.AbandonmentInterval) days to decay. { _attentionCode = (byte)(_attentionCode | 0x08); // 0b00001000 } if (_population == 0 || _population > _populationLimit) // Population is 0, or zone over populated! { _attentionCode = (byte)(_attentionCode | 0x10); // 0b00010000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x20); // 0b00100000 } if (_morale < 20) // Morale not full. { _attentionCode = (byte)(_attentionCode | 0x40); // 0b01000000 } if (false) // Nothing yet! { _attentionCode = (byte)(_attentionCode | 0x80); // 0b10000000 } base.Initialize(); }
static public bool IsShipLog(byte[] mailBytes) // Same as above but mailBytes input. { return(IsShipLog(mailBytes[19 + HHelper.ToInt32(mailBytes, 15) + 9])); }
static public bool IsOfficerTenFour(byte[] mailBytes) // Same as above but mailBytes input. { return(IsOfficerTenFour(mailBytes[19 + HHelper.ToInt32(mailBytes, 15) + 9])); }