Package org.scotlandyard.engine.json

Examples of org.scotlandyard.engine.json.GamePlayersJsonContainer


    Detective detective = new Detective(user);
    game.addDetective(detective);
   
    game.setPlayerPosition(detective.getEmail(), boardMap.getCoordinates().iterator().next().getLabel());
   
    GamePlayersJsonContainer container = new GamePlayersJsonContainer(game);
   
    assertNull(
        "mr x has not been initialized",
        container.mrx
        );
   
    assertNotNull(
      "check if the container has been initialized correctly",
      container.detectives
      );
   
    assertEquals(
        "testing if the container contains one detective",
        1,
        container.detectives.size()
      );
   
    //System.out.println(container.toJson());
   
    map.put("gameId", game.getIdentifier());
   
    final String json = (String)new GamePlayers().processRequest(map, engine);
    final GamePlayersJsonContainer gpjc = new GamePlayersJsonContainer().fromJson(json);
    assertEquals(gpjc.detectives.size(),1);
  }
View Full Code Here


  @Override
   public Object getOutput(
          final HttpServletRequest request,
        final GameEngine engine) throws GameException {

    final GamePlayersJsonContainer gpjc = new GamePlayersJsonContainer();

    if(game==null){
      throw new GameException("game is null");
    }

    if(game.getMrX()!=null){
      gpjc.mrx=getJsonPlayer(game.getMrX(), game);
    }
    gpjc.detectives=new ArrayList<JsonPlayer>();
    for(Detective d:game.getDetectives()){
      gpjc.detectives.add(getJsonPlayer(d, game));
    }

    return (gpjc.toJson());

  }
View Full Code Here

TOP

Related Classes of org.scotlandyard.engine.json.GamePlayersJsonContainer

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.