Example #1
0
        private void SyncDamageDeckSeed(PlayerNo playerNo, int seed)
        {
            if (ReplaysManager.Mode == ReplaysMode.Write)
            {
                JSONObject parameters = new JSONObject();
                parameters.AddField("player", playerNo.ToString());
                parameters.AddField("seed", seed.ToString());

                GameController.SendCommand(
                    GameCommandTypes.DamageDecksSync,
                    null,
                    parameters.ToString()
                    );

                Console.Write("Command is executed: " + GameCommandTypes.DamageDecksSync, LogTypes.GameCommands, true, "aqua");
                GameController.GetCommand().Execute();
            }
            else if (ReplaysManager.Mode == ReplaysMode.Read)
            {
                GameCommand command = GameController.GetCommand();

                if (command.Type == GameCommandTypes.DamageDecksSync)
                {
                    Console.Write("Command is executed: " + command.Type, LogTypes.GameCommands, true, "aqua");
                    command.Execute();
                }
            }
        }
Example #2
0
        public override void GiveInitiativeToRandomPlayer()
        {
            if (ReplaysManager.Mode == ReplaysMode.Write)
            {
                int randomPlayer = UnityEngine.Random.Range(1, 3);

                JSONObject parameters = new JSONObject();
                parameters.AddField("player", Tools.IntToPlayer(randomPlayer).ToString());

                GameController.SendCommand(
                    GameCommandTypes.SyncPlayerWithInitiative,
                    null,
                    parameters.ToString()
                    );

                Console.Write("Command is executed: " + GameCommandTypes.SyncPlayerWithInitiative, LogTypes.GameCommands, true, "aqua");
                GameController.GetCommand().Execute();
            }
            else if (ReplaysManager.Mode == ReplaysMode.Read)
            {
                GameCommand command = GameController.GetCommand();

                if (command.Type == GameCommandTypes.SyncPlayerWithInitiative)
                {
                    Console.Write("Command is executed: " + command.Type, LogTypes.GameCommands, true, "aqua");
                    command.Execute();
                }
            }
        }
Example #3
0
 public void ProcessCommand(GameCommand command)
 {
     lock (commandLock)
     {
         var log = new JsonMessageLog();
         command.Execute(game, log);
         DispatchMessages(log);
     }
 }
Example #4
0
    bool RunCommands()
    {
        if (_currentCommand == null && _gameCommands.Count > 0)
        {
            _currentCommand = _gameCommands.Dequeue();
            _currentCommand.Execute();
        }

        return(_currentCommand != null);
    }
Example #5
0
    public static void TryExecute(GameCommand command)
    {
        if (command.GetType() == AcceptsCommandType)
        {
            GameController.ConfirmCommand();
            command.Execute();
            CommandsReceived++;

            if (command.GetType() == typeof(SyncPlayerWithInitiativeCommand))
            {
                AcceptsCommandType = null;
            }
        }
    }
Example #6
0
    public static void TryExecute(GameCommand command)
    {
        if (command.GetType() == AcceptsCommandType)
        {
            Console.Write("Command is executed: " + command.Type, LogTypes.GameCommands, true, "aqua");

            GameController.ConfirmCommand();
            command.Execute();
            CommandsReceived++;

            if (command.GetType() == typeof(SyncPlayerWithInitiativeCommand))
            {
                AcceptsCommandType = null;
            }
        }
        else
        {
            Console.Write("Command is not executed: wrong type of initialization command", LogTypes.GameCommands, true, "aqua");
        }
    }
Example #7
0
    // SQUADRONS

    private static void PrepareSquadrons()
    {
        if (ReplaysManager.Mode == ReplaysMode.Write)
        {
            foreach (var squad in SquadBuilder.SquadLists)
            {
                JSONObject parameters = new JSONObject();
                parameters.AddField("player", squad.PlayerNo.ToString());
                parameters.AddField("type", squad.PlayerType.ToString());

                squad.SavedConfiguration["description"].str = squad.SavedConfiguration["description"].str.Replace("\n", "");
                parameters.AddField("list", squad.SavedConfiguration);

                GameController.SendCommand(
                    GameCommandTypes.SquadsSync,
                    null,
                    parameters.ToString()
                    );

                Console.Write("Command is executed: " + GameCommandTypes.SquadsSync, LogTypes.GameCommands, true, "aqua");
                GameController.GetCommand().Execute();
            }
            ;
        }
        else if (ReplaysManager.Mode == ReplaysMode.Read)
        {
            for (int i = 0; i < 2; i++)
            {
                GameCommand command = GameController.GetCommand();
                if (command.Type == GameCommandTypes.SquadsSync)
                {
                    Console.Write("Command is executed: " + command.Type, LogTypes.GameCommands, true, "aqua");
                    command.Execute();
                }
            }
        }
    }