@Test
  public void testCalculateTargetMaskedIllusion() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");
    WorldObject target =
        TestUtils.createIntelligentWorldObject(3, Constants.ILLUSION_CREATOR_ID, 7);
    target.setProperty(Constants.X, 1);
    target.setProperty(Constants.Y, 1);

    WorldObject realTarget = TestUtils.createIntelligentWorldObject(3, "realTarget");
    realTarget.setProperty(Constants.X, 1);
    realTarget.setProperty(Constants.Y, 1);

    assertEquals(
        realTarget, DefaultGoalObstructedHandler.calculateTarget(performer, target, world));
  }
  @Test
  public void testCheckLegalityAfterBrawlVictory() {
    World world = new WorldImpl(10, 10, null, null);
    world.addListener(new BrawlListener());
    WorldObject villagersOrganization = createVillagersOrganization(world);
    WorldObject performer =
        TestUtils.createSkilledWorldObject(
            2, Constants.GROUP, new IdList().add(villagersOrganization));
    MockMetaInformation.setMetaInformation(performer, Goals.BRAWL_GOAL);
    WorldObject actionTarget =
        TestUtils.createSkilledWorldObject(
            3, Constants.GROUP, new IdList().add(villagersOrganization));
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);
    world.addWorldObject(TestUtils.createIntelligentWorldObject(4, "observer"));

    villagersOrganization = createVillagersOrganization(world);

    BrawlPropertyUtils.startBrawl(performer, actionTarget, 20);
    actionTarget.setProperty(Constants.HIT_POINTS, 1);

    new OperationInfo(performer, actionTarget, Args.EMPTY, Actions.NON_LETHAL_MELEE_ATTACK_ACTION)
        .perform(world);

    assertEquals(1, performer.getProperty(Constants.GROUP).size());
    assertEquals(true, BrawlPropertyUtils.isBrawling(performer));
    assertEquals(true, BrawlPropertyUtils.isBrawling(actionTarget));

    BrawlPropertyUtils.completelyEndBrawling(performer);
    BrawlPropertyUtils.completelyEndBrawling(actionTarget);
    assertEquals(false, BrawlPropertyUtils.isBrawling(performer));
    assertEquals(false, BrawlPropertyUtils.isBrawling(actionTarget));
  }
  @Test
  public void testAlterRelationships() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(1, Constants.GENDER, "male");
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList());
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);
    WorldObject villagersOrganization = createVillagersOrganization(world);

    performer.setProperty(Constants.GROUP, new IdList().add(villagersOrganization));

    DefaultGoalObstructedHandler.alterRelationships(
        performer,
        actionTarget,
        actionTarget,
        null,
        Actions.MELEE_ATTACK_ACTION,
        world,
        -10,
        performer,
        actionTarget);

    assertEquals(-10, performer.getProperty(Constants.RELATIONSHIPS).getValue(actionTarget));
    assertEquals(-10, actionTarget.getProperty(Constants.RELATIONSHIPS).getValue(performer));
    assertEquals(true, actionTarget.getProperty(Constants.GROUP).getIds().isEmpty());
  }
  @Test
  public void testHasAnyoneSeenAction() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.GROUP, new IdList().add(1));
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList().add(1));
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);

    performer.setProperty(Constants.X, 1);
    performer.setProperty(Constants.Y, 1);

    actionTarget.setProperty(Constants.X, 2);
    actionTarget.setProperty(Constants.Y, 2);

    assertEquals(
        true,
        DefaultGoalObstructedHandler.hasAnyoneSeenAction(
            performer, actionTarget, Actions.TALK_ACTION, Args.EMPTY, world));
  }
  @Test
  public void testCalculateTargetDisguised() {
    World world = new WorldImpl(10, 10, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(2, "performer");
    WorldObject target = TestUtils.createIntelligentWorldObject(3, "target");
    WorldObject disguise = TestUtils.createIntelligentWorldObject(4, "disguise");
    world.addWorldObject(disguise);

    FacadeUtils.disguise(target, disguise.getProperty(Constants.ID), world);
    performer.setProperty(Constants.KNOWLEDGE_MAP, new KnowledgeMap());

    assertEquals(disguise, DefaultGoalObstructedHandler.calculateTarget(performer, target, world));
  }
  @Test
  public void testAreBrawlingItemEquiped() {
    WorldObject performer =
        TestUtils.createIntelligentWorldObject(1, Constants.BRAWL_OPPONENT_ID, 2);
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.BRAWL_OPPONENT_ID, 1);

    performer.setProperty(Constants.LEFT_HAND_EQUIPMENT, Item.IRON_CLAYMORE.generate(1f));

    assertEquals(
        false,
        DefaultGoalObstructedHandler.areBrawling(
            performer, actionTarget, Actions.NON_LETHAL_MELEE_ATTACK_ACTION));
  }
  @Test
  public void testLogToBackground() {
    World world = new WorldImpl(1, 1, null, null);
    WorldObject performer = TestUtils.createIntelligentWorldObject(1, Constants.GENDER, "male");
    WorldObject actionTarget =
        TestUtils.createIntelligentWorldObject(2, Constants.GROUP, new IdList());
    world.addWorldObject(performer);
    world.addWorldObject(actionTarget);

    actionTarget.setProperty(Constants.BACKGROUND, new BackgroundImpl());

    DefaultGoalObstructedHandler.logToBackground(
        Goals.PROTECT_ONE_SELF_GOAL,
        actionTarget,
        actionTarget,
        Actions.MELEE_ATTACK_ACTION,
        Args.EMPTY,
        performer,
        world);
    List<String> angryReasons =
        actionTarget.getProperty(Constants.BACKGROUND).getAngryReasons(true, 2, performer, world);
    assertEquals(1, angryReasons.size());
  }
 private WorldObject createVillagersOrganization(World world) {
   WorldObject organization = GroupPropertyUtils.createVillagersOrganization(world);
   organization.setProperty(Constants.ID, 1);
   world.addWorldObject(organization);
   return organization;
 }