public Parser(int id) { KeyID = id; conn = LoLKeep.GetConnection(); thread = new Thread(Run); thread.Start(); }
public static void Start() { conn = LoLKeep.GetConnection(); run = true; thread = new Thread(Run); thread.Start(); }
public void Run() { while (true) { if (LoLKeep.KeyStatus(KeyID, conn)) { LoLKeep.Queue(KeyID, conn); ParseGame(LoLKeep.GetQueue(KeyID, conn)); } else { if (!LoLKeep.CheckQueue(KeyID, conn)) { LoLKeep.DeleteQueue(KeyID, conn); } LoLKeep.DeleteKey(KeyID, conn); Console.WriteLine("Key: " + KeyID + " terminated"); break; } } }
public void ParseGame(UInt32 ID) { Console.Title = "Case: " + ID + " - Key: " + KeyID; if (LoLKeep.Check(ID, conn)) { Case caseData = new Case(ID); for (int game = 1; game <= 5; game++) { GameRecord gameData; Tribunal tribunalData = new Tribunal(); caseData.Games++; if ((gameData = GetGame(ID, game)) != null) { if (gameData.game_mode == "Classic" && gameData.game_mode_raw == "Classic" && gameData.players.Count == 10) { for (int n = 0; n < 10; n++) { Record recordData = new Record(); Player temp = gameData.players[n]; recordData.Champion = temp.champion_name; recordData.Team = temp.team != "Team1"; recordData.ReportedTeam = temp.association_to_offender != "enemy"; recordData.Offender = temp.association_to_offender == "offender"; switch (temp.outcome) { case "Win": recordData.Outcome = 0; break; case "Loss": recordData.Outcome = 1; break; case "Leave": recordData.Outcome = 2; break; } recordData.Time = temp.time_played; recordData.K = temp.scores.kills; recordData.D = temp.scores.deaths; recordData.A = temp.scores.assists; recordData.G = temp.gold_earned; LoLKeep.Insert(recordData, conn); if (recordData.Offender) { tribunalData.Record(recordData); } if (recordData.ReportedTeam) { tribunalData.AddKDA(recordData); } } tribunalData.Report = gameData.most_common_report_reason; LoLKeep.Insert(tribunalData, conn); } caseData.Ally += gameData.allied_report_count; caseData.Enemy += gameData.enemy_report_count; int count = gameData.reports.Count; for (int n = 0; n < count; n++) { switch (gameData.reports[n].offense) { case "OFFENSIVE_LANGUAGE": caseData.OFFENSIVE_LANGUAGE++; break; case "VERBAL_ABUSE": caseData.VERBAL_ABUSE++; break; case "INTENTIONAL_FEEDING": caseData.INTENTIONAL_FEEDING++; break; case "ASSISTING_ENEMY": caseData.ASSISTING_ENEMY++; break; case "UNSKILLED_PLAYER": caseData.UNSKILLED_PLAYER++; break; case "NO_COMMUNICATION_WITH_TEAM": caseData.NO_COMMUNICATION_WITH_TEAM++; break; case "LEAVING_AFK": caseData.LEAVING_AFK++; break; case "NEGATIVE_ATTITUDE": caseData.NEGATIVE_ATTITUDE++; break; case "INAPPROPRIATE_NAME": caseData.INAPPROPRIATE_NAME++; break; case "SPAMMING": caseData.SPAMMING++; break; } } } else if (game > 1) { break; } else { Console.WriteLine("Key: " + KeyID + " - Ended at " + ID); LoLKeep.TerminateKey(KeyID); return; } } if (GetDecision(ID, caseData)) { caseData.Decided = true; } caseData.Reports = (byte)(caseData.Ally + caseData.Enemy); LoLKeep.Insert(caseData, conn); } }
static void Main(string[] args) { Console.Title = "Tribunal Records"; LoLKeep.AlterIncrement(LoLKeep.NextCase()); //Worker.Start(); string[] s; while ((s = Console.ReadLine().ToLower().Split(' ')) != null) { if (s[0] == "help") { Console.WriteLine(" - generate"); Console.WriteLine(" - update"); Console.WriteLine(" - keys"); Console.WriteLine(" - terminate { }"); Console.WriteLine(" - start"); Console.WriteLine(" - stop"); Console.WriteLine(" - exit"); } else if (s[0] == "generate") { int count = 1; if (s.Length > 1) { int.TryParse(s[1], out count); } for (int i = 0; i < count; i++) { Parser p = new Parser(LoLKeep.GenerateKeyID()); Console.WriteLine(":: " + p.KeyID); } } else if (s[0] == "update") { if (LoLKeep.Keys == 0) { LoLKeep.AlterIncrement(LoLKeep.NextCase()); Console.WriteLine("Updated"); } else { Console.WriteLine("No keys may be active"); } } else if (s[0] == "keys") { LoLKeep.GetKeys(); } else if (s[0] == "terminate") { if (s.Length > 1) { int KeyID = 0; if (s[1] == "all") { LoLKeep.TerminateAllKeys(); } else if (int.TryParse(s[1], out KeyID)) { LoLKeep.TerminateKey(KeyID); } LoLKeep.GetKeys(); } else { Console.WriteLine(":: Key required"); } } else if (s[0] == "start") { if (!Worker.run) { Worker.Start(); } } else if (s[0] == "stop") { Worker.Stop(); } else if (s[0] == "exit") { Worker.Stop(); break; } else { Console.WriteLine(":: Command not recognized"); Console.WriteLine(" - help"); Console.WriteLine(" - generate"); Console.WriteLine(" - keys"); Console.WriteLine(" - terminate { }"); Console.WriteLine(" - exit"); } } }