public void GetEffectNameAndID(EventLine el, string firstLine) { string preEffectSplit = firstLine.Split(']')[4].Remove(0, 2); string preEffect = preEffectSplit.Split(':')[1]; int efEffctIndex = preEffect.IndexOf('{'); el.Effect.Name = preEffect.Remove(efEffctIndex).Trim(); bool hasID = preEffect.Contains('{'); if (hasID) { Int64 efID; int efIDindex = preEffect.IndexOf('}'); bool idParse = Int64.TryParse(preEffect.Remove(efIDindex) .Split('{')[1], out efID); el.Effect.ID = efID; } }
public void GetTarget(EventLine el, String firstLine) { string preTargetName = firstLine.Split(']')[2].Remove(0, 2); if (preTargetName.Contains('@')) { el.Source.IsPlayer = true; el.Target.Name = preTargetName.Replace("@", ""); } else { el.Source.IsPlayer = false; //This part will have to change after we see non-players el.Target.Name = preTargetName; } }
public void GetMitigation(EventLine el, string firstLine) { bool isMit = firstLine.Contains("))"); int mitVal; if (isMit) { string preMit = firstLine.Split(']')[5]; string preMit2 = preMit.Split('(')[2]; int indexMit = preMit2.IndexOf(' '); bool isNumber = int.TryParse(preMit2.Remove(indexMit), out mitVal); el.Mitigation.Value = mitVal; int mitIDindex = preMit2.IndexOf('}'); Int64 mitID; bool mitIDparse = Int64.TryParse(preMit2.Remove(mitIDindex) .Split('{')[1], out mitID); el.Mitigation.ID = mitID; el.Mitigation.Name = preMit2.Split(' ')[1]; } }
public void GetAbilityName(EventLine el, string firstLine) { string preAbilityName = firstLine.Split(']')[3].Remove(0, 2); int abNameIndex = preAbilityName.IndexOf('{'); if (abNameIndex != -1) { el.AbilityName.Name = preAbilityName.Remove(abNameIndex).Trim(); } else { el.AbilityName.Name = preAbilityName; } bool hasID = preAbilityName.Contains('{'); if (hasID) { Int64 abNameID; bool idParse = Int64.TryParse(preAbilityName.Split('{')[1] .Replace("}", ""), out abNameID); el.AbilityName.ID = abNameID; } }
public void GetValue(EventLine el, string firstLine) { int valAmount; string preVal = firstLine.Split(']')[5].Remove(0, 2); bool hasID = preVal.Contains('{'); if (hasID) { Int64 valID; string preValAmount = preVal.Split(' ')[0]; if (preValAmount.Contains('*')) { el.Value.IsCrit = true; } bool valAmountParse = int.TryParse(preValAmount .Replace("*", ""), out valAmount); el.Value.Amount = valAmount; el.Value.Name = preVal.Split(' ')[1]; string preValID = preVal.Split(' ')[2] .Remove(0, 1).Replace("}", ""); bool valIDparse = Int64.TryParse(preValID, out valID); el.Value.ID = valID; } }
public void GetEvent(EventLine el, string firstLine) { string preEvent = firstLine.Split(']')[4].Remove(0, 2); int evNameIndex = preEvent.IndexOf('{'); if (evNameIndex != -1) { el.Event.Name = preEvent.Remove(evNameIndex).Trim(); } else { el.Event.Name = preEvent.Split(':')[0]; } bool hasID = preEvent.Contains('{'); if (hasID) { Int64 evID; int evIDindex = preEvent.IndexOf('}'); bool idParse = Int64.TryParse(preEvent.Remove(evIDindex) .Split('{')[1], out evID); el.Event.ID = evID; } }
static void Main(string[] args) { var list = new List<EventLine>(); //TextWriter tw = new TextWriter() using (TextReader tr = new StreamReader("..\\..\\ComLog1.txt")) { //int counter = 0; bool isEOF = false; do { //counter++; EventLine el = new EventLine(); string firstLine = tr.ReadLine(); if (firstLine != null) { el.TimeStamp = Convert.ToDateTime(firstLine.Split(']')[0].Remove(0, 1)); Console.WriteLine(el.TimeStamp); el.Source.GetSource(el, firstLine); Console.WriteLine(el.Source.Name); el.Target.GetTarget(el, firstLine); Console.WriteLine(el.Target.Name); el.AbilityName.GetAbilityName(el, firstLine); Console.WriteLine(el.AbilityName.Name + " " + el.AbilityName.ID); el.Event.GetEvent(el, firstLine); Console.WriteLine(el.Event.Name + " " + el.Event.ID); el.Effect.GetEffectNameAndID(el, firstLine); Console.WriteLine(el.Effect.Name + " " + el.Effect.ID); el.Value.GetValue(el, firstLine); Console.WriteLine(String.Format("{0} {1} {2}" , el.Value.Amount, el.Value.Name, el.Value.ID)); el.Mitigation.GetMitigation(el, firstLine); Console.WriteLine(el.Mitigation.Value + " " + el.Mitigation.Name + " " + el.Mitigation.ID); bool isThreat = firstLine.Contains('<'); if (isThreat) { string preThreat = firstLine.Split('<')[1].Replace(">", ""); int eThreat; bool isNumber2 = int.TryParse(preThreat, out eThreat); el.Threat = eThreat; Console.WriteLine(el.Threat); } } else { isEOF = true; } list.Add(el); } while (isEOF == false); //Console.WriteLine(list.Count); Console.ReadLine(); //3191 } }