Package models.data

Examples of models.data.FixedTimeChallengeGame


     *
     * @param gameForm
     * @return
     */
    public Game createFixedTimeChallengeGame(GameForm gameForm) {
        FixedTimeChallengeGame game = new FixedTimeChallengeGame();
        User user = UserManager.getCurrentLoggedInUser();
        // if user is not in the session, then cannot create game
        if (user == null) {
            return null;
        }

        // creating game
        game.setGameLength(gameForm.gameLength);
        game.setGameStatus(GameStatusEnum.CREATED.getValue());
        game.setGameTitle(gameForm.gameTitle);
        game.setAddedOn(GameUtil.getCurrentTimeStamp());
        game.setMaxPlayers(gameForm.maxPlayers);
        game.setOwner((Player) user);
        game.setOpenBalance(gameForm.openBalance);
        //adding game player to list
        game.save();
        game.joinGame(user);
        return game;
    }
View Full Code Here


     * @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 models.data.FixedTimeChallengeGame

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.