Package scotlandyard.engine.impl

Examples of scotlandyard.engine.impl.Game


    Engine.instance().logout(detectiveHash);
  }

  @Test
  public void testGetMoves(){
    Game game = Engine.instance().games.get(gameId);
    IPlayer player = game.getPlayer(mrxHash);
    player.setPosition(1);
    Integer[] moves = game.getLegalMoves(player.getEmail());
    Assert.assertTrue(contains(moves,16));
  }
View Full Code Here


    Assert.assertTrue(contains(moves,16));
  }
 
  @Test
  public void testGetMovesWithMissingTicket(){
    Game game = Engine.instance().games.get(gameId);
    IPlayer player = game.getPlayer(mrxHash);
    player.setTickets(4, 0);
    player.setPosition(1);
    Integer[] moves = game.getLegalMoves(player.getEmail());
    Assert.assertTrue(!contains(moves,16));
    player.setTickets(0, 0);
    moves = game.getLegalMoves(player.getEmail());
    Assert.assertTrue(!contains(moves,1));
  }
View Full Code Here

  }
 
  @Test
  public void testincreaseMrxTokens()
  {
    Game game = Engine.instance().games.get(gameId);
    IPlayer mrXplayer = game.getPlayer(mrxHash);
    IPlayer detectivePlayer = game.getPlayer(detectiveHash);
                mrXplayer.setPosition(4);
                try
                {
                    game.movePlayer(mrXplayer.getEmail(), 5, 2);
                }
                catch (Exception e)
                {
                    Assert.assertTrue(false);
                }

    detectivePlayer.setPosition(2);
    try {
      int before = detectivePlayer.getTickets(1);
      game.movePlayer(detectiveEmail, 3, 1);
      int after = detectivePlayer.getTickets(1);
      if(after != (before - 1))
      {
        Assert.assertEquals("detective tickets havent ben decreased properly", 2, 3);
      }
View Full Code Here

      int counter=0;
      for(final IGame game:Engine.instance().games.values()){
        counter+=(game.getMapPath().equals(map_path)?1:0);
      }
      counter++;
      final Game game = new Game(game_id+" ("+counter+")",mp);
     
      Engine.instance().games.put(game.getId(),game);
        game.setMapPath(map_path);
       
        return "{\"msg\":\"OK\"}";
       
    }catch(Exception e){
      return ("{\"msg\" : \"EXCEPTION : "+(e.getMessage()+"").replace("\"", "'")+"\", \"className\" : \""+getClass().getName()+"\"}");
View Full Code Here

          if(xhash==null || "".equals(xhash)){throw new Exception("Unknown HASH");}

          final String gameId  = request.getParameter("selected_game");
          if(gameId==null || "".equals(gameId)){throw new Exception("Game Id is unknown");}

          final Game game = Engine.instance().games.get(gameId);
          if(game==null){throw new Exception("Game is unknown");}

          final IPlayer player = game.getPlayer(xhash);
          if(player==null){throw new Exception("player is unknown");}

          game.start(player);

          out.print("{\"msg\" : \""+Game.getStatusDefinition(game.getStatus())+"\"}");

      }catch(Exception e){
        out.print("{\"msg\" : \"EXCEPTION : "+(e.getMessage()+"").replace("\"", "'")+"\", \"className\" : \""+getClass().getName()+"\"}");
      }
  }
View Full Code Here

TOP

Related Classes of scotlandyard.engine.impl.Game

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.