private void ParseInvolvedParties() { // involved parties section var end = _killmail.IndexOf("Destroyed items:"); if (end == 0) { end = _killmail.IndexOf("Dropped items:"); if (end == 0) { //try to parse to the end of the mail in the event sections are missing end = _killmail.Length; } } var involvedPosition = _killmail.IndexOf("Involved parties:") + 17; var involvedSection = _killmail.Substring(involvedPosition, end - involvedPosition).TrimStart(); var involved = involvedSection.Split(new[] { "\n" }, StringSplitOptions.None); var groups = new List<List<string>>(); var startPos = 0; for (var j = 0; j < involved.Length; j++) { var current = involved[j]; var currentList = new List<string>(); var atEnd = j + 1 == involved.Length; if (current != "" || (!atEnd && involved[j + 1] == "")) continue; groups.Add(currentList); var k = startPos; while (k < j) { var invPart = involved[k]; if (!invPart.IsNullOrEmpty()) currentList.Add(involved[k]); k++; } startPos = j + 1; } for (var j = 0; j < groups.Count; j++) { var group = groups[j]; var party = new ParsedInvolvedParty(); foreach (var line in group) { string tmp; if (Match("Name: (.*)", line, out tmp)) { var slash = line.IndexOf("/"); if (slash >= 0) { var name = line.Substring(5, slash - 5).Trim(); var corporation = line.Substring(slash + 1, line.Length - slash + 1).Trim(); // now if the corp bit has final blow info, note it if (corporation.IndexOf("laid the final blow") > 0) { party.FinalBlow = true; party.WeaponName = name; end = corporation.IndexOf("(") - 1; corporation = corporation.Substring(0, end); } else { party.WeaponName = name; } // alliance lookup for warp disruptors - normal NPCs aren't to be bundled in // $crp = new Corporation(); // $crp->lookup($corporation); // if($crp->getID() > 0 && ( stristr($name, ' warp ') || stristr($name, ' control '))) // { // $al = $crp->getAlliance(); // $ianame = $al->getName(); // } // $ipname = $name; // $icname = $corporation; } else { party.PilotName = tmp; string tmpipname; if (Match(@"(.*) \(laid the final blow\)", tmp, out tmpipname)) { party.PilotName = tmpipname; party.FinalBlow = true; } } continue; } if (Match("Alliance: (.*)", line, out tmp)) { party.AllianceName = tmp; continue; } if (Match("Faction: (.*)", line, out tmp)) { party.FactionName = tmp; continue; } if (Match("Corp: (.*)", line, out tmp)) { party.CorporationName = tmp; continue; } if (Match("Ship: (.*)", line, out tmp)) { party.ShipName = tmp; continue; } if (Match("Weapon: (.*)", line, out tmp)) { party.WeaponName = tmp; continue; } if (Match("Security: (.*)", line, out tmp)) { party.SecurityStatus = tmp.ToInvariantDecimal(); continue; } if (Match("Damage Done: (.*)", line, out tmp)) { party.DamageDone = tmp.ToInvariantDecimal(); continue; } } if (party.AllianceName.InsensitiveCompare(Constants.None)) { party.AllianceName = party.FactionName; } if (party.CorporationName.InsensitiveCompare(Constants.None)) { AddError(string.Format("Involved party has no corp. (Party No. {0})", j)); } if (party.PilotName.InsensitiveCompare(Constants.Unkown)) { if (party.WeaponName.IndexOf("Mobile") >= 0 || party.WeaponName.IndexOf("Control Tower") >= 0) { //for involved parties parsed that lack a pilot, but are actually POS or mobile warp disruptors party.PilotName = party.WeaponName; } else { AddError(string.Format("Involved party has no name. (Party No. {0})", j)); } } if (party.WeaponName.InsensitiveCompare(Constants.Unkown)) { AddError(string.Format("No weapon found for pilot {0}.", party.PilotName)); } Result.AddInvolvedParty(party); } }
public void AddInvolvedParty(ParsedInvolvedParty party) { _involvedParties.Add(party); }