public List <Tuple <ulong, byte> > Players = new List <Tuple <ulong, byte> >(); //(player ID, point value) public SavedGame(List <string> allSequences) { status = Status.Uninitialized; for (int i = 0; i < allSequences.Count(); i++) { string currentSequence = allSequences[i]; if (!SaveFiles_Sequences.IsValidSequence(currentSequence)) { throw new InvalidSaveSequenceException("Passed in: " + currentSequence, ""); } if (i == 0) { TranslateSaveSequence(currentSequence); } else { //discard if not same ID if (GetGameID(currentSequence) != this.gameID) { throw new Exception("Sequences with different IDs were passed in. Ensure one SavedGame Object is created per Game ID."); } TranslateUserIDAndScore(currentSequence); } } this.allSequences = allSequences; status = Status.Initialized; return; }
public static DateTime GetFortnightStartDateTime(byte FNno) { if (FNno < 13 || FNno > FORTNIGHT_NUMBER) { throw new Exception("Fortnight does not exist yet."); } string stringRep = SearchValue(SAVEFILE_FORTNIGHTDATES, FNno.ToString("X2")); try { int dateHex = Int32.Parse(stringRep, NumberStyles.HexNumber); return(SaveFiles_Sequences.TranslateDateHex(dateHex)); } catch { throw new Exception(stringRep + " is not a number, Fortnight startdate could not be determined"); } }
public static void LogCMD() { string date = ""; if (DateTime.Now.TimeOfDay.TotalMinutes > 180) { date = SaveFiles_Sequences.GenerateDateHex().Substring(0, 3); } else { date = (Int32.Parse(SaveFiles_Sequences.GenerateDateHex().Substring(0, 3), NumberStyles.HexNumber) - 0x1).ToString(); } SaveFiles_Mapped.AddLine(COMMANDS_BY_DATE_DIRECTORY, date, cmdEx.ToString()); cmdEx = 0; GuildCache.IncrementCMD(0); }
/// <summary> /// Expects game to already be in save file /// </summary>= public static Embed ReportLoggedGame(string GameID, bool revert = false) { int x = -1; try { x = Int32.Parse(GameID, NumberStyles.HexNumber); if (x < 0x0 || x > 0xFFFFFFF) { throw new Exception("Incorrectly formatted Game ID."); } List <string> matchingSequences = SaveFiles_Sequences.SearchSaveFileForID(x); SavedGame gameObject = new SavedGame(matchingSequences); Dictionary <string, string> embedContents = gameObject.MakeHumanReadable(true); if (revert) { return(GenerateLogEmbed("Game Statistics:", embedContents, revert)); } return(GenerateLogEmbed("Game Statistics:", embedContents)); } catch (Exception e) { throw e; } }
/// <summary> /// Assumes IDpointcorr is well-formatted. Ensure this is complete to avoid ID nullification. /// </summary> public static Task LogGame(string GameName, List <Tuple <ulong, byte> > IDpointcorr, SocketCommandContext context = null) { ISocketMessageChannel reportingChannel = (ISocketMessageChannel)GuildCache.Uno_Cache.GetChannel(REPORT_CHANNEL_ID); byte GameType; string GameID = ""; int attemptedGameType = Array.IndexOf(GameIden, GameName); if (attemptedGameType == -1 || attemptedGameType > Byte.MaxValue) { throw new Exception("Game Identification not found."); } else { GameType = (byte)attemptedGameType; } try { GameID = SaveFiles_Sequences.GenerateID(GameType); } catch (Exception e) { throw e; } List <string> SaveSequences = new List <string>(); //for creating an object to return in human readable form foreach (var player in IDpointcorr) { try { SaveFiles_Sequences.LogGame(Int32.Parse(GameID, NumberStyles.HexNumber), player.Item1, player.Item2); } catch (Exception e) { //revert SaveFiles_Sequences.RevertbyID(Int32.Parse(GameID, NumberStyles.HexNumber)); throw e; } } Embed em = ReportLoggedGame(GameID); reportingChannel.SendMessageAsync("", false, em); return(Task.CompletedTask); }