@Test public void testIsLegalAttackOtherVillager() { World world = new WorldImpl(1, 1, null, null); WorldObject villagersOrganization = createVillagersOrganization(world); WorldObject performer = TestUtils.createIntelligentWorldObject( 2, Constants.GROUP, new IdList().add(villagersOrganization)); WorldObject actionTarget = TestUtils.createIntelligentWorldObject( 3, Constants.GROUP, new IdList().add(villagersOrganization)); world.addWorldObject(performer); world.addWorldObject(actionTarget); assertEquals( false, DefaultGoalObstructedHandler.isLegal( performer, actionTarget, Actions.FIRE_BOLT_ATTACK_ACTION, Args.EMPTY, world)); }
@Test public void testIsLegalAttackTree() { World world = new WorldImpl(10, 10, null, null); WorldObject villagersOrganization = createVillagersOrganization(world); WorldObject performer = TestUtils.createIntelligentWorldObject( 2, Constants.GROUP, new IdList().add(villagersOrganization)); int targetId = PlantGenerator.generateTree(0, 0, world); WorldObject actionTarget = world.findWorldObjectById(targetId); world.addWorldObject(performer); world.addWorldObject(TestUtils.createIntelligentWorldObject(3, "observer")); villagersOrganization = createVillagersOrganization(world); assertEquals( true, DefaultGoalObstructedHandler.isLegal( performer, actionTarget, Actions.FIRE_BOLT_ATTACK_ACTION, Args.EMPTY, world)); }