Package scotlandyard.engine.impl

Examples of scotlandyard.engine.impl.Game


    // TODO Auto-generated constructor stub
  }

  @Test
  public void testEXPOSE(){
    final Game game = new Game();
    Assert.assertTrue(game.isRoundExposingMrX(3));
    Assert.assertTrue(game.isRoundExposingMrX(8));
    Assert.assertTrue(game.isRoundExposingMrX(13));
    Assert.assertTrue(game.isRoundExposingMrX(18));
    Assert.assertFalse(game.isRoundExposingMrX(23));
  }
View Full Code Here


  @Before
  public void setup() throws Exception
  {
    String mp = "web/maps/palmerstonNorth.xml";
    gameId=(gameId==null||"optional".equals(gameId)?System.currentTimeMillis()+"":gameId);
    Game game = new Game(gameId,mp);
    Engine myEngine = Engine.instance();
    myEngine.games.put(game.getId(),game);
    game.setMapPath("/maps/palmerstonNorth.xml");

    myEngine.icons.put("x1.gif",false);
    myEngine.icons.put("d1.gif",false);
   
   
    IUser mrx = myEngine.login(mrxEmail,mrxName,"0");
    IUser detective = myEngine.login(detectiveEmail,detectiveName,"1");

    game.addPlayer(mrx,true);

    game.addPlayer(detective,false);
    IPlayer player = game.getPlayer(mrxHash);

    Assert.assertNotNull(player);

    game.start(player);
  }
View Full Code Here

  @Test
  public void testStartPositions()
  {
    boolean detectiveEmailFound = false;
    boolean mrxEmailFound = false;
    Game game = Engine.instance().games.get(gameId);
    IBMap map = game.getMap();
    String[] positions = map.getPositions();
    for(int i = 0; i < positions.length;i++)
    {
      if(positions[i] == detectiveEmail)
      {
View Full Code Here

    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

  @Before
  public void setup() throws Exception {
    new WebUserBean();   
    String mp = "web/maps/palmerstonNorth.xml";
    gameId=(gameId==null||"optional".equals(gameId)?System.currentTimeMillis()+"":gameId);
    Game game = new Game(gameId,mp);
    Engine.instance().games.put(game.getId(),game);
    game.setMapPath("/maps/palmerstonNorth.xml");

    IUser mrx = Engine.instance().login(mrxEmail,mrxName,"0");
    IUser detective = Engine.instance().login(detectiveEmail,detectiveName,"1");
   
    game.addPlayer(mrx,true);
    game.addPlayer(detective,false);
    game.start(game.getPlayer(mrxHash));
  }
View Full Code Here

    // TODO Auto-generated constructor stub
  }

  @Test
  public void testEXPOSE(){
    final Game game = new Game();
    Assert.assertTrue(game.isRoundExposingMrX(3));
    Assert.assertTrue(game.isRoundExposingMrX(8));
    Assert.assertTrue(game.isRoundExposingMrX(13));
    Assert.assertTrue(game.isRoundExposingMrX(18));
    Assert.assertFalse(game.isRoundExposingMrX(23));
  }
View Full Code Here

  @Before
  public void setup() throws Exception
  {
    String mp = "web/maps/palmerstonNorth.xml";
    gameId=(gameId==null||"optional".equals(gameId)?System.currentTimeMillis()+"":gameId);
    Game game = new Game(gameId,mp);
    Engine myEngine = Engine.instance();
    myEngine.games.put(game.getId(),game);
    game.setMapPath("/maps/palmerstonNorth.xml");

    myEngine.icons.put("x1.gif",false);
    myEngine.icons.put("d1.gif",false);
   
   
    IUser mrx = myEngine.login(mrxEmail,mrxName,"0");
    IUser detective = myEngine.login(detectiveEmail,detectiveName,"1");

    game.addPlayer(mrx,true);

    game.addPlayer(detective,false);
    IPlayer player = game.getPlayer(mrxHash);

    Assert.assertNotNull(player);

    game.start(player);
  }
View Full Code Here

  @Test
  public void testStartPositions()
  {
    boolean detectiveEmailFound = false;
    boolean mrxEmailFound = false;
    Game game = Engine.instance().games.get(gameId);
    IBMap map = game.getMap();
    String[] positions = map.getPositions();
    for(int i = 0; i < positions.length;i++)
    {
      if(positions[i] == detectiveEmail)
      {
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.