@Override public boolean isConversationAvailable(WorldObject performer, WorldObject target, World world) { WorldObject facade = performer.getProperty(Constants.FACADE); KnowledgeMap knowledgeMap = target.getProperty(Constants.KNOWLEDGE_MAP); boolean targetHasKnowledgeOverFacade = knowledgeMap != null ? knowledgeMap.hasProperty(performer, Constants.FACADE) : false; return ((facade != null) && (!FacadeUtils.performerIsSuccessFullyDisguised(performer)) && targetHasKnowledgeOverFacade); }
@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)); }