protected virtual void findGames() { NGame game = new NGame(); game.setName("My Game"); NGameCharacteristics gameCharacteristics = new NGameCharacteristics(); gameCharacteristics.setAutoStop(true); game.setGameCharacteristics(gameCharacteristics); sampleIO.log("Step 1 : Find games / Useful to build a games lobby."); NuggetaQuery nuggetaQuery = new NuggetaQuery(); gameApi.getGamesRequest(nuggetaQuery, (GetGamesResponse getgamesresponse)=> { List<NGame> games = getgamesresponse.getGames(); int gamesCount = games.Count; if (gamesCount > 0) { sampleIO.log("Step 1 : Found " + gamesCount + " games. Select one an join it with the 'JoinGameSample'"); for (int i = 0; i < gamesCount; i++) { NGame findGame = games[i]; sampleIO.log("Game name/id : " + findGame.getId()); } } else { sampleIO.log("Step 1 : No game Found. Create one and relaunch the sample to see what happens"); } }); }
protected virtual void step1CreateGame() { NGame game = new NGame(); game.setName("My Game"); NGameCharacteristics gameCharacteristics = new NGameCharacteristics(); gameCharacteristics.setMinPlayer(2); gameCharacteristics.setAutoStop(false); gameCharacteristics.setAutoStart(true); ; game.setGameCharacteristics(gameCharacteristics); sampleIO.log("Step 1 : Create Game "); gameApi.createGameRequest(game, (CreateGameResponse response)=> { if (response.getCreateGameStatus() == CreateGameStatus.SUCCESS) { gameId = response.getGameId(); sampleIO.log("Step 1 : Create Game successful / game Id : " + gameId); } else { sampleIO.log("Step 1 : Failed to create Game "); onExit(); } }); }