public Task OnGameUpdate(GameStateUpdate <object> update)
        {
            // OnGameUpdate fires when just about anything changes in the game. This might be coins added to a user because of a building,
            // cards being swapped, etc. Your bot doesn't need to pay attention to these updates if you don't wish, when your bot needs to make
            // an action OnGameActionRequested will be called with the current game state and a list of possible actions.

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
 public void Update(GameStateUpdate update)
 {
     Player1.PaddlePosition = update.Player1Position;
     Player2.PaddlePosition = update.Player2Position;
     Player1.Points         = update.Player1Points;
     Player2.Points         = update.Player2Points;
     Ball.Position          = update.BallPosition;
 }
Exemplo n.º 3
0
        public override async Task OnGameStateUpdate(GameStateUpdate <object> update)
        {
            // OnGameUpdate fires when just about anything changes in the game. This might be coins added to a user because of a building,
            // cards being swapped, etc. Your bot doesn't need to pay attention to these updates if you don't wish, when your bot needs to make
            // an action OnGameActionRequested will be called with the current game state and a list of possible actions.
            Logger.Log(Log.Info, $"Game Update - {update.Type} : {update.Reason}");

            await m_logicCore.OnGameUpdate(update);
        }
Exemplo n.º 4
0
        async Task SendGameState(GameState session)
        {
            ServerPlayer serverPlayer1 = GetPlayerById(session.Player1.Id);
            ServerPlayer serverPlayer2 = GetPlayerById(session.Player2.Id);

            GameStateUpdate update = session.GetUpdate();

            await Task.WhenAll(
                BaseServer.SendTo(serverPlayer1.NetPlayer, update, GameNet.ProtocolType.Udp),
                BaseServer.SendTo(serverPlayer2.NetPlayer, update, GameNet.ProtocolType.Udp)
                );
        }
Exemplo n.º 5
0
        private void GameLoop()
        {
            while (!CancellationToken.IsCancellationRequested)
            {
                Thread.Sleep(GameplayConstants.GameTicksPerSecond);
                _secretData++;
                _worldStateHandler.OnGameTick();

                if (_secretData >= GameplayConstants.InactiveTimeoutDuration * 60000 / GameplayConstants.GameTicksPerSecond)
                {
                    _entityManager.RemoveInactiveManagers();
                    _secretData = 0;
                }
            }
            GameStateUpdate?.Invoke(this, new GameStateUpdateEvent
            {
                GameState = $"Game Ending..."
            });
        }
Exemplo n.º 6
0
        public void TestDetectsXWin()
        {
            List <string> list = new List <string> {
                "X",
                "O",
                "?",
                "?",
                "X",
                "?",
                "?",
                "O",
                "X"
            };
            ServiceClientCredentials serviceClientCredentials = new TokenCredentials("FakeTokenValue");
            TicTacToeSDKClient       client = new TicTacToeSDKClient(new Uri("https://localhost:44305"), serviceClientCredentials);

            GameStateUpdate update = (GameStateUpdate)client.ExecuteMove(new Board(list));

            Assert.AreEqual <string> (update.Winner, "X");
            Assert.IsNotNull(update.WinPositions);
        }
Exemplo n.º 7
0
        public void TestPlaysXFirst()
        {
            List <string> list = new List <string> {
                "?",
                "?",
                "?",
                "?",
                "?",
                "?",
                "?",
                "?",
                "?"
            };
            ServiceClientCredentials serviceClientCredentials = new TokenCredentials("FakeTokenValue");
            TicTacToeSDKClient       client = new TicTacToeSDKClient(new Uri("https://localhost:44305"), serviceClientCredentials);

            GameStateUpdate update = (GameStateUpdate)client.ExecuteMove(new Board(list));

            Assert.AreEqual <string> (update.AzurePlayerSymbol, "X");
            Assert.AreEqual <string> (update.Winner, "inconclusive");
            Assert.IsNull(update.WinPositions);
        }
Exemplo n.º 8
0
 public Node(GameStateUpdate positions)
 {
     this.positions = positions;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Updates player's controls. Receieved from the frontend.
 /// </summary>
 /// <param name="update"></param>
 public Task UpdateGameState(GameStateUpdate update)
 {
     game.UpdateControls(update);
     return(Task.CompletedTask);
 }
Exemplo n.º 10
0
 // Fires when the game the bot has connected to has a state update.
 // This doesn't mean the bot must respond, but it can watch updates to know what's happening on other's turns.
 public abstract Task OnGameStateUpdate(GameStateUpdate <object> update);
Exemplo n.º 11
0
 void HandleGameStateUpdateMessage(GameStateUpdate message)
 {
     GameManager.Instance.Session?.Update(message);
 }