コード例 #1
0
 public static void SaveGame(GameSettings settings, bool autoSave, int slot = 0, bool web = false)
 {
     if (autoSave)
     {
         var name = "Autosave" + "(" + settings.FirstPlayerName + "-" + settings.SecondPlayerName + ")";
         settings.SaveName = name;
         settings.SaveTime = DateTime.Now.ToString("MM/dd/yyyy H:mm:ss");
         if (settings.NumTurns != (settings.BoardHeight * settings.BoardWidth))
         {
             AvailableSaves.Saves[slot] = settings.SaveName + " " + settings.SaveTime;
             GameConfigHandler.SaveConfig(settings);
         }
     }
     else
     {
         if (!web)
         {
             slot = SlotSelector();
             if (slot == BackCommand)
             {
                 return;
             }
         }
         var name = settings.FirstPlayerName + "-" + settings.SecondPlayerName;
         settings.SaveName          = name;
         settings.SaveTime          = DateTime.Now.ToString("MM/dd/yyyy H:mm:ss");
         AvailableSaves.Saves[slot] = settings.SaveName + " " + settings.SaveTime;
         GameConfigHandler.SaveConfig(settings, slot);
     }
 }
コード例 #2
0
        public static void PreLoadSaves()
        {
            var dbOption = new DbContextOptionsBuilder <AppDbContext>()
                           .UseSqlite(@"Data Source=D:\Databases\connect4.db").Options;
            var ctx = new AppDbContext(dbOption);

            ctx.Database.EnsureCreated();

            var save = new List <GameSettings>(4);

            for (var i = 0; i < MAXSAVES; i++)
            {
                save.Add(GameConfigHandler.LoadConfig(i));
                Saves[i] = save[i].ToString();
            }
        }