Examples of GameEngine


Examples of org.scotlandyard.impl.engine.GameEngine

        response.setHeader("Pragma","no-cache");
        response.setDateHeader ("Expires", -1);


        //try{
      final GameEngine engine = GameEngine.instance();//(GameEngine)this.getServletContext().getAttribute("GameEngine");
      if (engine == null) {
        throw new ServletException("Game Engine has not been initialized, you may refresh the page to get it done. Or come backe later");
      }
      this.sessionId=request.getSession().getId();
        try {
View Full Code Here

Examples of org.scotlandyard.impl.engine.GameEngine

    fail(OUTPUT); // TODO testGetTurn
  }

  @Test  //TODO add description of what the test should do
  public final void testRemove() throws GameException{
    final GameEngine engine = GameEngine.instance();
    User user1,user2;
    user1 = new UserImpl("user1","user1");
    user2 = new UserImpl("user2","user2");
    Assert.assertEquals(engine.getUsers().size(), 0);
    engine.loginUser(user1);
    engine.loginUser(user2);


    Assert.assertEquals(engine.getLobby().getAvailableGames().size(), 0);

    final Game game = GameImpl.getNewInstance("game1", user1, boardMap);
    Assert.assertEquals(engine.getLobby().getAvailableGames().size(), 1);

    final Player player1 = new Detective(user1);
    final Player player2 = new MrX(user2);

    Assert.assertEquals(engine.getUsers().size(), 2);
    Assert.assertEquals(game.getDetectives().size(), 0);
    game.setMrX(player2);


    try{
      engine.startGame(game);
      Assert.assertFalse(true);
    }catch(Exception ex){
      Assert.assertTrue(true);
    }

    try{
      game.addDetective((Detective)player2);
      Assert.assertFalse(true);
    }catch(Exception ex){
      Assert.assertTrue(true);
    }

    game.addDetective((Detective)player1);

    Assert.assertNotNull(game.getPlayer(user1.getEmail()));
    Assert.assertNotNull(game.getPlayer(user2.getEmail()));

    Assert.assertEquals(game.getDetectives().size(), 1);
    Assert.assertEquals(game.getPlayers().size(),2);

    Assert.assertTrue(engine.logoutUser(user1.getEmail()));
    Assert.assertFalse(engine.logoutUser(user1.getEmail()));

    Assert.assertEquals(game.getPlayers().size(),1);

    try{
      engine.startGame(game);
      Assert.assertFalse(true);
    }catch(Exception ex){
      Assert.assertTrue(true);
    }

    engine.getUsers().put(user1.getEmail(), user1);

    try{
      game.setMrX(player1); // should not allow to override existing mrX
      Assert.assertFalse(true);
    }catch(Exception ex){
      Assert.assertTrue(true);
    }

    Assert.assertEquals(game.getDetectives().size(), 0);
    game.addDetective((Detective)player1);
    Assert.assertEquals(game.getDetectives().size(), 1);

    Assert.assertEquals(game.getPlayers().size(), 2);

    Assert.assertSame(game.getMrX(),player2);
    Assert.assertTrue(game.getDetectives().contains(player1));

    Assert.assertFalse(game.getDetectives().contains(player2));

    try{
      game.addDetective((Detective)player2); //should not allow player to be both mrx and detective in the same game
      Assert.assertFalse(true);
    }catch(Exception ex){
      Assert.assertTrue(true);
    }

    try{
      game.addDetective((Detective)player1); //should not allow player to be added as detective twice
      Assert.assertFalse(true);
    }catch(Exception ex){
      Assert.assertTrue(true);
    }

    Assert.assertEquals(game.getDetectives().size(),1);
    Assert.assertEquals(game.getPlayers().size(),2);


    engine.startGame(game);

    Assert.assertEquals(engine.startGame(game), "done");
    Assert.assertEquals(game.getGameStatus().toString(),GameStatus.STARTED.toString());

    Assert.assertTrue(game.removePlayer(user1.getEmail()));
    Assert.assertTrue(game.removePlayer(user2.getEmail()));
    try{
View Full Code Here

Examples of org.terasology.engine.GameEngine

        popup.setMessage("Join Game", "Connecting to '" + address + ":" + port + "' - please wait ...");
        popup.onSuccess(new Function<JoinStatus, Void>() {

            @Override
            public Void apply(JoinStatus result) {
                GameEngine engine = CoreRegistry.get(GameEngine.class);
                if (result.getStatus() != JoinStatus.Status.FAILED) {
                    engine.changeState(new StateLoading(result));
                } else {
                    MessagePopup screen = manager.pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
                    screen.setMessage("Failed to Join", "Could not connect to server - " + result.getErrorMessage());
                }
View Full Code Here

Examples of org.terasology.engine.GameEngine

    public void handleInput(float delta) {
    }

    @Override
    public void update(float delta) {
        GameEngine gameEngine = CoreRegistry.get(GameEngine.class);
        EngineTime time = (EngineTime) CoreRegistry.get(Time.class);
        long startTime = time.getRawTimeInMs();
        while (current != null && time.getRawTimeInMs() - startTime < 20 && !gameEngine.hasPendingState()) {
            if (current.step()) {
                popStep();
            }
        }
        if (current == null) {
View Full Code Here

Examples of org.terasology.engine.GameEngine

        this.networkSystem = networkSystem;
    }

    @Override
    public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
        GameEngine gameEngine = CoreRegistry.get(GameEngine.class);
        if (gameEngine != null) {
            gameEngine.changeState(new StateMainMenu("Disconnected From Server"));
        }
    }
View Full Code Here

Examples of org.terasology.engine.GameEngine

    }

    @Override
    public void preUpdate(GameState currentState, float delta) {
        NUIManager nuiManager = CoreRegistry.get(NUIManager.class);
        GameEngine engine = CoreRegistry.get(GameEngine.class);

        // TODO: this originally occurred before GameThread.processWaitingProcesses();
        boolean newGrabbed = engine.hasMouseFocus() && !(nuiManager.isReleasingMouse());
        if (newGrabbed != mouseGrabbed) {
            Mouse.setGrabbed(newGrabbed);
            mouseGrabbed = newGrabbed;
        }
    }
View Full Code Here

Examples of org.terasology.engine.GameEngine

*/
public class HeadlessStateChangeListener implements StateChangeSubscriber {

    @Override
    public void onStateChange() {
        GameEngine engine = CoreRegistry.get(GameEngine.class);
        GameState state = engine.getState();
        if (state instanceof StateMainMenu) {
            engine.shutdown();
        }
    }
View Full Code Here

Examples of pdp.scrabble.game.GameEngine

    gameEnv = new GameGEnvImpl(null, 0, lang, null);
    //choose your play mode
   
    mf = new MainFrame(lang, gameEnv);
   
    GameEngine eng = ChooseModeDialog.mode(gameEnv, mf);
    gameEnv.setEngine(eng);
    gameEnv.setMainFrame(mf);
    mf.initialize();
    SearchPlacementImpl.initAnagrams();
   
View Full Code Here

Examples of pdp.scrabble.game.GameEngine

    ChooseModeDialog c= new ChooseModeDialog();
    c.start();
    String mode = c.playMode.getSelection().getActionCommand();
    if(mode.compareTo("load")==0)
      mainFrame.getMenubar().getItem("Load").doClick();
    GameEngine eng = Factory.FACTORY.createEngine(mode, gameEnv);
    return eng;
  }
View Full Code Here

Examples of worldManager.gameEngine.GameEngine

        }

        World world = client.getWorld();

        if (world != null) {
            GameEngine gameEngine = world.getGameEngine();
            if (gameEngine != null) {
                gameEngine.run();
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.