public static string InterpretScoreInputAndGetPlacementInfo(string args, ulong requesterID = 0) { args.ToLower(); string GAME_TYPE = ""; short FORTNIGHT = FORTNIGHT_NUMBER; try { if (args.Contains("overall")) { FORTNIGHT = -1; args = args.Replace("overall", ""); } else if (Regex.IsMatch(args, @"(fn|fortnight)\s?(\d{1,2})(\D|$)", RegexOptions.IgnoreCase)) { string fnNo = Regex.Match(args, @"(fn|fortnight)\s?(\d{1,2})(\D|$)").Groups[2].ToString(); FORTNIGHT = Int16.Parse(fnNo); if (FORTNIGHT >= 0 && FORTNIGHT < 13) { return("Individual tracking before Fortnight 13 is not available. Reference <#490300319729713172>."); } if (FORTNIGHT > FORTNIGHT_NUMBER) { return("The server is on Fortnight " + FORTNIGHT_NUMBER + ", and does not have tracking for future fortnights yet, silly goose."); } args = args.Replace("fn" + fnNo, ""); args = args.Replace("fn " + fnNo, ""); } string[] gameTypes = { "cah", "uno", "ms", "tetris", "bumps", "idlerpg", "pokeduel", "bingo", "chess", "tourney", "tournament", "casino", "minesweeper", "idle", "poke", "knight", "knights", "trivia" }; foreach (string gameType in gameTypes) { if (args.Contains(gameType)) { GAME_TYPE = gameType; args = args.Replace(gameType, ""); break; } } if (GAME_TYPE == "") { GAME_TYPE = "server"; } List <SocketGuildUser> x = new List <SocketGuildUser>(); bool local = false; if (args != "") { x = GuildCache.InterpretUserInput(args); } else if (requesterID != 0) { x = GuildCache.InterpretUserInput(requesterID.ToString()); local = true; } else { throw new Exception(); } if (x == null) { return("User not found."); } if (x.Count() == 0) { return("User not found."); } ulong userID = x[0].Id; string res; try { switch (GAME_TYPE) { case "server": res = GetUserScore("SERVER", userID, "POINTS", "Server", FORTNIGHT, local); break; case "uno": res = GetUserScore("UNO", userID, "FIRST", "First-place Uno!", FORTNIGHT, local); break; case "cah": res = GetUserScore("CAH", userID, "FIRST", "CAH", FORTNIGHT, local); break; case "bingo": res = GetUserScore("BINGO", userID, "HIGH", "Bingo", FORTNIGHT, local); break; case "ms": case "minesweeper": res = GetUserScore("MS", userID, "ITER", "Minesweeper", FORTNIGHT, local); break; case "tetris": res = GetUserScore("TETRIS", userID, "HIGH", "Tetris", FORTNIGHT, local); break; case "pokeduel": case "poke": res = GetUserScore("POKEDUEL", userID, "ITER", "Pokeduels", FORTNIGHT, local); break; case "idlerpg": case "idle": res = GetUserScore("IDLERPG", userID, "ITER", "IdleRPG duels", FORTNIGHT, local); break; case "chess": res = GetUserScore("CHESS", userID, "ITER", "Chess", FORTNIGHT, local); break; case "bumps": res = GetUserScore("BUMPS", userID, "ITER", "Bumps", FORTNIGHT, local); break; case "casino": res = GetUserScore("CASINO", userID, "POINTS", "Casino points", FORTNIGHT, local); break; case "tourney": case "tournament": res = GetUserScore("TOURNEY", userID, "POINTS", "Tourney points", FORTNIGHT, local); break; case "knight": case "knights": res = GetUserScore("KNIGHTS", userID, "ITER", "Knights", FORTNIGHT, local); break; case "trivia": res = GetUserScore("KNIGHTS", userID, "ITER", "Knights", FORTNIGHT, local); break; default: throw new Exception("Game not found"); } if (res == null) { throw new Exception("Leaderboard not found"); } } catch (Exception e) { return(e.Message + "\n" + e.StackTrace); } return(res); } catch (Exception e) { return(e.Message + "\n" + e.StackTrace); } }
public static Task ManualUnoLog(string message, bool force = false, bool manual = false, byte manualnoofplayers = 3) { string playerStrArr = message; byte noOfPlayers = manualnoofplayers; if (!manual) { playerStrArr = ""; noOfPlayers = 0; if (Byte.TryParse(message.Trim().Substring(0, message.IndexOf(" ")), out byte ignore)) { noOfPlayers = Byte.Parse(message.Trim().Substring(0, message.IndexOf(" "))); } else if (message.IndexOf("\n") != -1) { if (Byte.TryParse(message.Trim().Substring(0, message.IndexOf("\n")), out byte ignore2)) { noOfPlayers = Byte.Parse(message.Trim().Substring(0, message.IndexOf("\n"))); } } for (int i = 1; i <= 100; i++) { if (message.IndexOf(i + ". ") != -1 && message.IndexOf((i + 1) + ". ") != -1) { int start = message.IndexOf((i) + ". ") + ((i + 1) + ". ").Length; int end = message.IndexOf(i + 1 + ". "); var captureArea = message.Substring(start, end - start); playerStrArr += captureArea + ","; message = message.Substring(message.IndexOf(i + 1 + ". ")); } else if (message.IndexOf(i + ". ") != -1) { int start = message.IndexOf((i) + ". ") + ((i + 1) + ". ").Length; if (message.Contains("\n")) { if (start < message.IndexOf("\n")) { var captureArea = message.Substring(start, message.IndexOf("\n") - start); playerStrArr += captureArea; } break; } else if (message.Contains("This game lasted")) { var captureArea = message.Substring(start, message.IndexOf("This game lasted") - start); playerStrArr += captureArea; break; } else { var captureArea = message.Substring(start); playerStrArr += captureArea; break; } } } playerStrArr = playerStrArr.Replace("\n", ""); if (playerStrArr == "" || ((playerStrArr.Count(x => x == ',') < MIN_NO_OF_PLAYERS - 1) && noOfPlayers == 0)) { //throw new Exception("Minimum number of players was not met for logging."); } } var users = GuildCache.InterpretUserInput(playerStrArr); if (GuildCache.IsWellFormattedListOfUsers(users) != "") { string list = "`"; foreach (var user in users) { list += (user?.Username ?? "NULL") + ", "; } list += "`"; throw new Exception("Malformatted set of users: " + list); } List <Player> players = new List <Player>(); foreach (var user in users) { players.Add(new Player(user.Id.ToString(), user.Username, user.Discriminator, true, 1, 0, GuildCache.GetTeam(user) ?? "")); } if (noOfPlayers == 0) { noOfPlayers = (byte)players.Count(); } players = DeterminePointDistribution(players, noOfPlayers); if (!force) { if (!IsGameQualifable(players)) { throw new Exception("Each player was of the same team, rendering the game unqualifiable."); } } if (noOfPlayers == 2) { try { Games_1v1.Uno1v1Log(players.Select(x => UInt64.Parse(x.ID)).ToList()); return(Task.CompletedTask); }catch (Exception e) { throw e; } } List <Tuple <ulong, byte> > orderedPairs = new List <Tuple <ulong, byte> >(); foreach (Player p in players) { orderedPairs.Add(new Tuple <ulong, byte>(UInt64.Parse(p.ID), (byte)p.pointsEarned)); } Bridge.LogGame("uno", orderedPairs); int q = 0; foreach (var orderedPair in orderedPairs) { SaveFileUpdate(orderedPair, "uno"); if (q == 0) { string saveDir = USER_SAVE_DIRECTORY + "\\" + players[0].ID.ToString() + "\\" + UNO_SAVE_FILE_NAME; string FNsaveDir = USER_SAVE_DIRECTORY + "\\" + players[0].ID.ToString() + "\\" + "FN" + FORTNIGHT_NUMBER + "_" + UNO_SAVE_FILE_NAME; AddFieldValue("FIRST-UNO", saveDir, "1"); AddFieldValue("FIRST-UNO", FNsaveDir, "1"); if (Int32.Parse(SearchValue(saveDir, "HIGH-UNO")) < players[0].pointsEarned) { SetFieldValue("HIGH-UNO", saveDir, players[0].pointsEarned.ToString()); } if (Int32.Parse(SearchValue(FNsaveDir, "HIGH-UNO")) < players[0].pointsEarned) { SetFieldValue("HIGH-UNO", FNsaveDir, players[0].pointsEarned.ToString()); } } q++; } return(Task.CompletedTask); }