Package game

Examples of game.Game$GameHolder


    /* (non-Javadoc)
     * @see org.directwebremoting.ScriptSessionFilter#match(org.directwebremoting.ScriptSession)
     */
    @Override
    public boolean match(final ScriptSession session) {
        final Game gameToMatch = (Game) session.getAttribute("game");
        final String emailToMatch = (String) session.getAttribute("email");
        return (gameToMatch != null && gameToMatch.equals(game) && !(emailToMatch).equals(email));
    }
View Full Code Here


     */
    @Override
    public void setScriptSessionGame() {
        final ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
        final HttpSession session = WebContextFactory.get().getSession();
        final Game game = (Game) session.getAttribute("game");
        final String email = (String) session.getAttribute("email");
        scriptSession.setAttribute("game", game);
        scriptSession.setAttribute("email", email);
    }
View Full Code Here

   
    @Before
    public void setUp() {
       
        player=new Player(4,4,4,false);
        game=new Game("username",001);
        action=new Action(player,"BAH","value",game,session);
    }
View Full Code Here

     */
    @Test
    public void testSetScriptSessionGame() {
        System.out.println("setScriptSessionGame");
  
        final Game game=new Game("user@gmail.com",1);
        context.checking(new Expectations(){
            {
                one(session).getAttribute("game");
                will(returnValue(game));
            }
        });
       
        Game resultgame=(Game) session.getAttribute("game");
        assertEquals(game,resultgame);
       
  
        context.checking(new Expectations(){
            {
View Full Code Here

     * @param action - The Action object to be performed.
     */
    public static void performAction(final Action action) {
        final String actionType = action.getActionType();
        final String value = action.getValue();
        Game game = action.getGame();
        final HttpSession session = action.getSession();
        if ("startgame".equals(actionType)) {
            game.setPlaying(true);
            game.startGame();
        }
        if ("setmap".equals(actionType)) {
            game = SessionListener.getSessionTracker().getGameTracker().createNewGame((String) session.getAttribute("email"));
            game.setMap(new Map(value));
            session.setAttribute("game", game);
        }
        if ("setmapname".equals(actionType)) {
            game.getMap().setMapName(value);
        }
        if ("setgamecreator".equals(actionType)) {
            game.setCreatorName(value);
            game.tellLobby();
        }
        if ("joingame".equals(actionType)) {
            game = SessionListener.getSessionTracker().getGameTracker().getGameMadeByCreator(value);
            game.addUserToGame((String) session.getAttribute("email"));
            session.setAttribute("game", game);
        }
        if("takeTurn".equals(actionType)) {
            try {
                game.playerTakesTurn(value);
            } catch (ParserConfigurationException ex) {
                System.err.print(ex);
            } catch (SAXException ex) {
                System.err.print(ex);
            } catch (IOException ex) {
                System.err.print(ex);
            }
        }
        if ("startDoubleMove".equals(actionType)) {
            game.startDoubleTurn();
        }
        if ("cancelDoubleMove".equals(actionType)) {
            game.cancelDoubleTurn();
        }
        if("cannotMove".equals(actionType)) {
            game.getPlayers().get(Integer.parseInt(value)).setCanMove(false);
        }
        if("checkGameEnd".equals(actionType)) {
            game.checkPlayersLose();
        }
        if("leaveGame".equals(actionType)) {
            if (game != null) {
                for (Player player : game.getPlayers()) {
                    if (player.getPlayerEmail().equals(value)) {
                        player.leaveGame();
                        if (game.getWhosTurn() == game.getPlayers().indexOf(player)) {
                            game.determineWhosTurnItIsNext();
                        }
                    }
                }
                session.setAttribute("game", null);
                if (!game.isFinished()) {
                    game.checkEnd();
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of game.Game$GameHolder

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.