コード例 #1
0
        private static void TestConsumer(GameApi api, PlayersApi players, Configuration config)
        {
            GameRules rules = new GameRules(true, 2, "Test", 1, password: null);

            PrintHeader("Create Game");
            int game = api.CreateGame(rules);

            Print("Game ID: " + game);
            Print("Stats : " + api.GetGameState(game));
            PrintHeader("Join Game");
            players.Join(game);
            ConsumerApi  consumerApi = new ConsumerApi(config);
            JoinResponse response    = consumerApi.RegisterConsumer(game, new ConsumerRegistration("Test", "Ein consumer"));

            Print($"id : {response.Id}");
            Print($"pat : {response.Pat}");
            players.Configuration.ApiKey["pat"] = response.Pat;
            api.Configuration.ApiKey["pat"]     = response.Pat;
            config.ApiKey["pat"] = response.Pat;
            JoinResponse somePlayer = players.Join(game);

            Print(players.GetPlayer(game, somePlayer.Id).ToJson());
            PrintHeader("Start Game");
            api.CommitAction(game, ActionType.STARTGAME);
            PrintHeader("Fetch Events");
            EventHandlingApi eventApi = new EventHandlingApi(config);

            for (int i = 0; i < 8; i++)
            {
                Print(eventApi.FetchNextEvent(game).Type.ToString());
            }
        }
コード例 #2
0
 public ConsumerApiTests()
 {
     instance = new ConsumerApi();
 }