private YesNoResponse getYesNoResponse(WorldObject target, World world) {
    StringBuilder responseBuilder = new StringBuilder(", ");
    int numberOfYesResponses = 0;
    if (target.getProperty(Constants.MATE_ID) != null) {
      int mateId = target.getProperty(Constants.MATE_ID);
      WorldObject mate = world.findWorldObjectById(mateId);
      responseBuilder.append("I have a mate named ").append(mate.getProperty(Constants.NAME));
      numberOfYesResponses++;
    } else {
      responseBuilder.append("I don't have a mate");
    }
    if (target.getProperty(Constants.CHILDREN).size() == 1) {
      responseBuilder.append(" and I have 1 child");
      numberOfYesResponses++;
    } else if (target.getProperty(Constants.CHILDREN).size() > 0) {
      responseBuilder
          .append(" and I have ")
          .append(target.getProperty(Constants.CHILDREN).size())
          .append(" children");
      numberOfYesResponses++;
    } else {
      responseBuilder.append(" and I don't have children");
    }

    if (numberOfYesResponses > 0) {
      return new YesNoResponse(responseBuilder.toString(), "");
    } else {
      return new YesNoResponse("", responseBuilder.toString());
    }
  }
Exemplo n.º 2
0
 public static WorldObject generateKey(int structureToLockId, World world) {
   WorldObject key = Item.KEY.generate(1f);
   WorldObject structureToLock = world.findWorldObjectById(structureToLockId);
   key.setProperty(Constants.NAME, getKeyName(structureToLock));
   key.setProperty(Constants.LOCK_ID, structureToLockId);
   return key;
 }
 private WorldObject createVotingBox(World world) {
   int id = BuildingGenerator.generateVotingBox(0, 0, world);
   WorldObject target = world.findWorldObjectById(id);
   return target;
 }
 private WorldObject createSmith(World world, WorldObject performer) {
   int smithId = BuildingGenerator.generateSmith(0, 0, world, performer);
   WorldObject target = world.findWorldObjectById(smithId);
   return target;
 }
Exemplo n.º 5
0
 private WorldObject createFish(World world, WorldObject organization) {
   int fishId = new CreatureGenerator(organization).generateFish(0, 0, world);
   WorldObject fish = world.findWorldObjectById(fishId);
   return fish;
 }