Beispiel #1
0
        public override Task <Game> Reset(GameId request, ServerCallContext context)
        {
            // ManagedObjects.Games[request.Value] =  ManagedObjects.InitialGames[request.Value].Clone();

            // return Task.FromResult(ManagedObjects.InitialGameAPIs[request.Value]);

            var game = ManagedObjects.InitialGames[request.Value].Clone();

            ManagedObjects.Games[request.Value] = game;
            game.StartGame();
            return(Task.FromResult(new Game(game, request.Value)));
        }
Beispiel #2
0
        public Game(SabberStoneCore.Model.Game game, int id = -1)
        {
            currentPlayer_   = new Controller(game.CurrentPlayer);
            currentOpponent_ = new Controller(game.CurrentOpponent);
            state_           = (Types.State)game.State;
            turn_            = game.Turn;

            if (id < 0)
            {
                id = _id_gen++;;

                ManagedObjects.Games.Add(id, game);
                ManagedObjects.InitialGames.Add(id, game.Clone());
                //ManagedObjects.InitialGameAPIs.Add(id, this);
                ManagedObjects.OptionBuffers.Add(id, new List <Option>(50));
            }

            id_ = new GameId(id);
        }
Beispiel #3
0
        public override Task <Options> GetOptions(GameId request, ServerCallContext context)
        {
            var           game = ManagedObjects.Games[request.Value];
            List <Option> options;

            try
            {
                options = game.CurrentPlayer.PythonOptions(request.Value);
            }
            catch
            {
                throw;
            }

            //var options = game.CurrentPlayer.Options();
            //return Task.FromResult(new Options(options, request.Value));

            return(Task.FromResult(new Options(options)));
        }