Esempio n. 1
0
 public static boolean hasEnoughResources(
     WorldObject performer, IntProperty property, int quantity) {
   WorldObjectContainer inventory = performer.getProperty(Constants.INVENTORY);
   int inventoryQuantity = inventory.getQuantityFor(property);
   if (inventoryQuantity < quantity) {
     return false;
   } else {
     return true;
   }
 }
Esempio n. 2
0
 public static boolean hasEnoughResources(
     WorldObject performer, int woodQuantity, int oreQuantity) {
   WorldObjectContainer inventory = performer.getProperty(Constants.INVENTORY);
   int wood = inventory.getQuantityFor(Constants.WOOD);
   int ore = inventory.getQuantityFor(Constants.ORE);
   if ((wood < woodQuantity) || (ore < oreQuantity)) {
     return false;
   } else {
     return true;
   }
 }
Esempio n. 3
0
 public void addToInventory(
     WorldObject performer,
     WorldObject target,
     SkillProperty skillProperty,
     IntProperty qualityProperty,
     World world) {
   double skillBonus =
       SkillUtils.useSkill(performer, skillProperty, world.getWorldStateChangedListeners());
   int quantity = target.getProperty(qualityProperty);
   WorldObjectContainer inventory = performer.getProperty(Constants.INVENTORY);
   inventory.addQuantity(generate(skillBonus), quantity);
 }
  @Override
  public void execute(WorldObject performer, WorldObject target, int[] args, World world) {
    WorldObjectContainer inventory = performer.getProperty(Constants.INVENTORY);

    double skillBonus =
        SkillUtils.useSkill(
            performer, Constants.ALCHEMY_SKILL, world.getWorldStateChangedListeners());
    int quantity = target.getProperty(Constants.APOTHECARY_QUALITY);
    inventory.addQuantity(Item.POISON.generate(skillBonus), quantity);

    inventory.removeQuantity(Constants.NIGHT_SHADE, NIGHT_SHADE_REQUIRED);
  }
  @Override
  public void execute(WorldObject performer, WorldObject target, int[] args, World world) {
    WorldObjectContainer inventory = performer.getProperty(Constants.INVENTORY);

    double skillBonus =
        SkillUtils.useSkill(
            performer, Constants.SMITHING_SKILL, world.getWorldStateChangedListeners());
    int quantity = SmithPropertyUtils.calculateSmithingQuantity(performer, target);
    inventory.addQuantity(Item.IRON_HELMET.generate(skillBonus), quantity);

    inventory.removeQuantity(Constants.WOOD, WOOD_REQUIRED);
    inventory.removeQuantity(Constants.ORE, ORE_REQUIRED);
  }