public override void Entry(IModHelper helper)
        {
            monitor = Monitor;
            config  = helper.ReadConfig <Config>();
            ChessGame.LoadTextures(helper);
            helper.ConsoleCommands.Add("chess", "[chess {id} (open)] starts or laods a chess session", (s, p) =>
            {
                if (Context.IsWorldReady)
                {
                    Game1.currentMinigame = new ChessGame(p.Length == 0 ? "ConsoleGame" : p[0], p.Length == 0 || (p.Length > 1 && p[1] == "open"), helper);
                }
                else
                {
                    Monitor.Log("You need to load a save first.", LogLevel.Error);
                }
            });

            TileAction Lock = new TileAction("StartChess", (a, l, v, s) =>
            {
                var p = a.Split(' ');
                Game1.currentMinigame = new ChessGame(p.Length < 1 ? "ConsoleGame" : p[1], p.Length == 0 || (p.Length > 2 && p[2] == "open"), helper);
                return(true);
            }).register();

            FullReceiver = new PyReceiver <SaveData>(fullReceiverName, (s) =>
            {
                monitor.Log("Receiving Data");

                ChessGame.SavedGameData = s;
            }, 30, SerializationType.JSON);

            SessionReceiver = new PyReceiver <Session>(sessionReceiverName, (s) =>
            {
                monitor.Log("Receiving Session: " + s.Id);

                ChessGame.SavedGameData.Sessions.AddOrReplace(s.Id, s);

                if (Game1.currentMinigame is ChessGame cg && cg.Id == s.Id)
                {
                    cg.updateSession();
                }
            }, 30, SerializationType.JSON);
Exemplo n.º 2
0
 public void Pick(ChessGame game)
 {
     Action.Invoke(Id);
     game.GameQuestion = null;
 }