public void onNewChatLine(string line) { string name = ""; string ability = ""; string otherTarget = ""; string regexLogLine = ""; bool hasTarget = false; bool uses = false; Match m = usesRegex.Match(line); if (m.Success) { uses = m.Groups["uses"].Value == "uses"; name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; if (uses) { regexLogLine = Regex.Escape(" uses " + ability + "."); } else { regexLogLine = Regex.Escape(" casts " + ability + "."); } } else { m = readiesRegex.Match(line); if (m.Success) { name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; regexLogLine = Regex.Escape(" readies " + ability + "."); } else { m = startsUsingRegex.Match(line); if (m.Success) { hasTarget = true; name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; otherTarget = m.Groups["target"].Value; regexLogLine = Regex.Escape(" starts using " + ability + " on ") + "(.+)" + Regex.Escape("."); } else { m = castingRegex.Match(line); if (m.Success) { name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; regexLogLine = Regex.Escape(" begins casting " + ability + "."); } else { m = suffersRegex.Match(line); if (m.Success) { name = bossName; ability = m.Groups["ability"].Value; otherTarget = m.Groups["target"].Value; regexLogLine = Regex.Escape(" suffers the effect of " + ability + "."); bool foundPerson = false; foreach (var KVP in EncounterController.pcEntities) { ActorEntity pe = KVP.Value; if (pe.Name == otherTarget) { foundPerson = true; } } if (!foundPerson || ability == "Pacification" || ability == "Weakness" || ability == "Brink of Death" || ability == "Holmgang") { return; } } else { return; } } } } } if (!m.Success) { return; } // ignore pets if (name.Contains("-Egi") || name == "Eos" || name == "Selene" || name == "Topaz Carbuncle" || name == "Emerald Carbuncle") { return; } // ignore players foreach (var KVP in EncounterController.pcEntities) { ActorEntity pe = KVP.Value; if (pe.Name == name) { return; } } if (!abilityList.ContainsKey(name) || abilityList[name] == null) { abilityList[name] = new Dictionary<string, learningAbilities>(); } if (!abilityList[name].ContainsKey(ability) || abilityList[name][ability] == null) { abilityList[name][ability] = new learningAbilities(); abilityList[name][ability].logAbilityName = ability; abilityList[name][ability].mobName = name; abilityList[name][ability].abilityName = nameStripperRegex.Replace(ability, ""); abilityList[name][ability].count = 0; abilityList[name][ability].hasTarget = hasTarget; abilityList[name][ability].regexLogLine = regexLogLine; } if (!abilityTimedOrder.ContainsKey(name) || abilityTimedOrder[name] == null) { abilityTimedOrder[name] = new List<lineDetails>(); } if (DateTime.Now - abilityList[name][ability].lastUsed < TimeSpan.FromSeconds(10)) { //return; } abilityList[name][ability].count++; abilityList[name][ability].lastUsed = DateTime.Now; lineDetails tmpLine = new lineDetails(); tmpLine.ability = abilityList[name][ability]; try { tmpLine.bossHPPct = ((double)bossEntity.HPPercent) * 100.0d; } catch { debug("LearningHelper bossEntity is null"); } tmpLine.logLine = line; tmpLine.logTime = DateTime.Now; tmpLine.mobName = name; tmpLine.session = -1; tmpLine.sessionStart = EncounterController.started; abilityTimedOrder[name].Add(tmpLine); abilityTimedOrderAll.Add(tmpLine); }
public void onNewChatLine(string line) { string name = ""; string ability = ""; string otherTarget = ""; string regexLogLine = ""; bool hasTarget = false; bool uses = false; Match m = usesRegex.Match(line); if (m.Success) { uses = m.Groups["uses"].Value == "uses"; name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; if (uses) { regexLogLine = Regex.Escape(" uses " + ability + "."); } else { regexLogLine = Regex.Escape(" casts " + ability + "."); } } else { m = readiesRegex.Match(line); if (m.Success) { name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; regexLogLine = Regex.Escape(" readies " + ability + "."); } else { m = startsUsingRegex.Match(line); if (m.Success) { hasTarget = true; name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; otherTarget = m.Groups["target"].Value; regexLogLine = Regex.Escape(" starts using " + ability + " on ") + "(.+)" + Regex.Escape("."); } else { m = castingRegex.Match(line); if (m.Success) { name = m.Groups["name"].Value; ability = m.Groups["ability"].Value; regexLogLine = Regex.Escape(" begins casting " + ability + "."); } else { m = suffersRegex.Match(line); if (m.Success) { name = bossName; ability = m.Groups["ability"].Value; otherTarget = m.Groups["target"].Value; regexLogLine = Regex.Escape(" suffers the effect of " + ability + "."); bool foundPerson = false; foreach (var KVP in EncounterController.pcEntities) { ActorEntity pe = KVP.Value; if (pe.Name == otherTarget) { foundPerson = true; } } if (!foundPerson || ability == "Pacification" || ability == "Weakness" || ability == "Brink of Death" || ability == "Holmgang") { return; } } else { return; } } } } } if (!m.Success) { return; } // ignore pets if (name.Contains("-Egi") || name == "Eos" || name == "Selene" || name == "Topaz Carbuncle" || name == "Emerald Carbuncle") { return; } // ignore players foreach (var KVP in EncounterController.pcEntities) { ActorEntity pe = KVP.Value; if (pe.Name == name) { return; } } if (!abilityList.ContainsKey(name) || abilityList[name] == null) { abilityList[name] = new Dictionary <string, learningAbilities>(); } if (!abilityList[name].ContainsKey(ability) || abilityList[name][ability] == null) { abilityList[name][ability] = new learningAbilities(); abilityList[name][ability].logAbilityName = ability; abilityList[name][ability].mobName = name; abilityList[name][ability].abilityName = nameStripperRegex.Replace(ability, ""); abilityList[name][ability].count = 0; abilityList[name][ability].hasTarget = hasTarget; abilityList[name][ability].regexLogLine = regexLogLine; } if (!abilityTimedOrder.ContainsKey(name) || abilityTimedOrder[name] == null) { abilityTimedOrder[name] = new List <lineDetails>(); } if (DateTime.Now - abilityList[name][ability].lastUsed < TimeSpan.FromSeconds(10)) { //return; } abilityList[name][ability].count++; abilityList[name][ability].lastUsed = DateTime.Now; lineDetails tmpLine = new lineDetails(); tmpLine.ability = abilityList[name][ability]; try { tmpLine.bossHPPct = ((double)bossEntity.HPPercent) * 100.0d; } catch { debug("LearningHelper bossEntity is null"); } tmpLine.logLine = line; tmpLine.logTime = DateTime.Now; tmpLine.mobName = name; tmpLine.session = -1; tmpLine.sessionStart = EncounterController.started; abilityTimedOrder[name].Add(tmpLine); abilityTimedOrderAll.Add(tmpLine); }
public void readInAllData() { abilityList.Clear(); abilityTimedOrder.Clear(); abilityTimedOrderAll.Clear(); OleDbCommand command = new OleDbCommand("select * from abilities order by mobName, abilityName", database); DataRowCollection abilitiesResult = query(command); foreach (DataRow row in abilitiesResult) { learningAbilities abil = new learningAbilities(); abil.abilityName = (string)row["abilityName"]; abil.mobName = (string)row["mobName"]; abil.logAbilityName = (string)row["logAbilityName"]; abil.regexLogLine = (string)row["logLineRegex"]; abil.hasTarget = (bool)row["hasTarget"]; if (!abilityList.ContainsKey(abil.mobName)) { abilityList[abil.mobName] = new Dictionary<string,learningAbilities>(); } abilityList[abil.mobName][abil.abilityName] = abil; } command = new OleDbCommand("select * from abilityUses order by sessionId, logTime, id", database); DataRowCollection logLinesResult = query(command); foreach (DataRow row in logLinesResult) { lineDetails line = new lineDetails(); line.mobName = (string)row["mobName"]; line.ability = abilityList[line.mobName][(string)row["abilityName"]]; line.session = (int)row["sessionId"]; line.sessionStart = new DateTime(((long)((double)row["sessionStart"]))); line.logLine = (string)row["logLine"]; line.logTime = new DateTime(((long)((double)row["logTime"]))); line.bossHPPct = (double)row["bossHPPct"]; if (!abilitySessionMobLines.ContainsKey(line.session)) { abilitySessionMobLines[line.session] = new Dictionary<string, List<lineDetails>>(); } if (!abilitySessionMobLines[line.session].ContainsKey(line.mobName)) { abilitySessionMobLines[line.session][line.mobName] = new List<lineDetails>(); } if (!abilitySessionMobLinesAll.ContainsKey(line.session)) { abilitySessionMobLinesAll[line.session] = new List<lineDetails>(); } abilitySessionMobLines[line.session][line.mobName].Add(line); abilitySessionMobLinesAll[line.session].Add(line); } }
public void readInAllData() { abilityList.Clear(); abilityTimedOrder.Clear(); abilityTimedOrderAll.Clear(); OleDbCommand command = new OleDbCommand("select * from abilities order by mobName, abilityName", database); DataRowCollection abilitiesResult = query(command); foreach (DataRow row in abilitiesResult) { learningAbilities abil = new learningAbilities(); abil.abilityName = (string)row["abilityName"]; abil.mobName = (string)row["mobName"]; abil.logAbilityName = (string)row["logAbilityName"]; abil.regexLogLine = (string)row["logLineRegex"]; abil.hasTarget = (bool)row["hasTarget"]; if (!abilityList.ContainsKey(abil.mobName)) { abilityList[abil.mobName] = new Dictionary <string, learningAbilities>(); } abilityList[abil.mobName][abil.abilityName] = abil; } command = new OleDbCommand("select * from abilityUses order by sessionId, logTime, id", database); DataRowCollection logLinesResult = query(command); foreach (DataRow row in logLinesResult) { lineDetails line = new lineDetails(); line.mobName = (string)row["mobName"]; line.ability = abilityList[line.mobName][(string)row["abilityName"]]; line.session = (int)row["sessionId"]; line.sessionStart = new DateTime(((long)((double)row["sessionStart"]))); line.logLine = (string)row["logLine"]; line.logTime = new DateTime(((long)((double)row["logTime"]))); line.bossHPPct = (double)row["bossHPPct"]; if (!abilitySessionMobLines.ContainsKey(line.session)) { abilitySessionMobLines[line.session] = new Dictionary <string, List <lineDetails> >(); } if (!abilitySessionMobLines[line.session].ContainsKey(line.mobName)) { abilitySessionMobLines[line.session][line.mobName] = new List <lineDetails>(); } if (!abilitySessionMobLinesAll.ContainsKey(line.session)) { abilitySessionMobLinesAll[line.session] = new List <lineDetails>(); } abilitySessionMobLines[line.session][line.mobName].Add(line); abilitySessionMobLinesAll[line.session].Add(line); } }