Пример #1
0
  public void testFleeCommand() {
    Room room2 = new Room("a room with a monster", "room2");
    room2.spawnMonster(new Monster("monster", 0, 0, 1000, 1000));
    startingRoom.setExits(Exit.east, room2);

    game.playGame("go east");

    while (game.getPlayer().inBattle()) {
      game.playGame("flee");
    }

    assertTrue(
        "When player flees, it must go back to the previous room",
        game.getPlayer().getRoom() == startingRoom);
  }
Пример #2
0
  public void test() {

    Game game = getGame();
    Player dutch = game.getPlayer("model.nation.dutch");
    HighSeas highSeas = dutch.getHighSeas();
    UnitType caravel = spec().getUnitType("model.unit.caravel");
    Unit unit = new ServerUnit(game, highSeas, dutch, caravel);

    dutch.dumpObject();
  }
  public void testProductionSoldier() {

    Game game = getStandardGame();
    Map map = getTestMap();
    game.setMap(map);
    Player dutch = game.getPlayer("model.nation.dutch");

    Tile tile = map.getTile(5, 8);
    Resource grain = new Resource(game, tile, spec().getResourceType("model.resource.grain"));
    tile.addResource(grain);

    UnitType veteran = spec().getUnitType("model.unit.veteranSoldier");
    Unit soldier = new ServerUnit(game, map.getTile(6, 8), dutch, veteran);

    Colony colony = new ServerColony(game, dutch, "New Amsterdam", soldier.getTile());
    dutch.addSettlement(colony);
    GoodsType foodType = grainType;
    soldier.setWorkType(foodType);
    nonServerBuildColony(soldier, colony);

    // Test the colony
    assertEquals(map.getTile(6, 8), colony.getTile());

    assertEquals("New Amsterdam", colony.getName());

    assertEquals(colony, colony.getTile().getSettlement());

    assertEquals(dutch, colony.getTile().getOwner());

    // Disabled.  Removal of equipment has moved to the server, so
    // nonServerBuildColony is not going to work.
    //// Should have 50 Muskets and nothing else
    // GoodsType muskets = spec().getGoodsType("model.goods.muskets");
    // assertNotNull(muskets);
    //
    // for (GoodsType type : spec().getGoodsTypeList()){
    //    if (type == muskets)
    //        assertEquals(50, colony.getGoodsCount(type));
    //    else
    //        assertEquals(type.toString(), 0, colony.getGoodsCount(type));
    // }

    // Test the state of the soldier
    // Soldier should be working on the field with the bonus

    assertEquals(foodType, soldier.getWorkType());

    assertEquals(colony.getColonyTile(tile).getTile(), soldier.getLocation().getTile());

    assertEquals(0, soldier.getMovesLeft());

    // assertEquals(false, soldier.isArmed());
  }
Пример #4
0
	@SuppressWarnings("unchecked")
	public List<Meeple> extractTileMeeples(Element tileEl, Game game, Position pos) throws SnapshotCorruptedException {
		NodeList nl = tileEl.getElementsByTagName("meeple");
		List<Meeple> result = Lists.newArrayList();
		for(int i = 0; i < nl.getLength(); i++) {
			Element el = (Element) nl.item(i);
			Location loc = Location.valueOf(el.getAttribute("loc"));
			Class<? extends Meeple> mt = (Class<? extends Meeple>) XmlUtils.classForName(el.getAttribute("type"));
			int playerIndex = Integer.parseInt(el.getAttribute("player"));
			Meeple meeple = game.getPlayer(playerIndex).getUndeployedMeeple(mt);
			meeple.setLocation(loc);
			meeple.setPosition(pos);
			//don't set feature here. Feature must be set after meeple deployment to correct replace ref during merge
			result.add(meeple);
		}
		return result;
	}
Пример #5
0
 protected void setUp() {
   game = new Game();
   startingRoom = new Room("a room", "room");
   game.getPlayer().setRoom(startingRoom);
 }