Package beans

Examples of beans.GameState


        return playerNode;
    }

    public static ObjectNode getGameStateJson(Integer gameId) {
        try {
            GameState gs = (new GameManager()).getGameState(gameId);
            if (gs == null) {
                return null;
            }
            GameStateJSONFormatter gsj = new GameStateJSONFormatter(gs);
            return gsj.getJSON();
View Full Code Here


     * @return
     * @throws java.lang.Exception
     */
    public GameState getGameState(Integer id) throws Exception {

        GameState gameState = new GameState();
        FixedTimeChallengeGame game = (FixedTimeChallengeGame) FixedTimeChallengeGame.find
                .where().eq("id", id).findUnique();

        //save new virtual current date if no gotten
        if (game.getVirtualStartDate() != null) {
            game.setVirtualCurrentDate(TimeKeeper.convert(game));
            game.save();
        }
        User player = UserManager.getCurrentLoggedInUser();

        // set the game state
        List<GamePlayer> gamePlayers = game.getPlayers();

        gameState.setPlayers(gamePlayers);
        gameState.setNumOfDays(game.getGameLength());
        gameState.setCurrentDay(game.getVirtualCurrentDate() == null ? 0 : GameUtil.getCurrentDay(game));
        if (gameState.getCurrentDay() > gameState.getNumOfDays()) {
            game.setGameStatus(enums.GameStatusEnum.END.toString());
            game.save();
        }
        gameState.setGame(game);
        GamePlayer currentGamePlayer = game.getPlayerInGame(player);
        gameState.setCurrentPlayer(currentGamePlayer);
        if (currentGamePlayer != null) {
            gameState.setMyPortfolio(currentGamePlayer.getPortfolios());
        }
        gameState.setGameOwner(game.getPlayerInGame(game.getOwner()));
        return gameState;
    }
View Full Code Here

TOP

Related Classes of beans.GameState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.