Exemplo n.º 1
0
        public IActionResult GetState(int gameId)
        {
            GameStateDescription stateDescription = GamePlayManager.GetGameState(gameId);

            return(Ok(new GameState
            {
                State = stateDescription
            }
                      ));
        }
Exemplo n.º 2
0
        public IActionResult UpdateState(int gameId, GameState gameState)
        {
            GameStateDescription state = GamePlayManager.GetGameState(gameId);

            switch (state)
            {
            case GameStateDescription.Undefined when gameState.State == GameStateDescription.OpenForRegistration:
                GamePlayManager.OpenGameForRegistration(gameId);
                return(NoContent());

            case GameStateDescription.OpenForRegistration when gameState.State == GameStateDescription.Start:
                GamePlayManager.Start(gameId);
                return(NoContent());

            default: return(UnprocessableEntity("Dieser Statuswechsel ist momentan nicht erlaubt"));
            }
        }