Пример #1
0
  @Override
  public void execute(Mob mob, String input) {

    String bagString = getLastWord(input);

    Item bag = mob.getInventory().get(bagString);

    if (bag == null) {
      bag = mob.getRoom().getInventory().get(bagString);
    }

    if (bag == null) {
      mob.out("There is no bag to put stuff into");
      return;
    }

    if (!bag.isContainer()) {
      mob.out("You can not put things into " + bag.getName());
      return;
    }

    String target = getFirstWord(input);

    Item anItem = mob.getInventory().get(target);

    if (anItem == null) {
      mob.out("Can not put " + target + " it is not here!");
      return;
    }

    if (anItem == bag) {
      mob.out("You can not put something into itself");
      return;
    }

    Bag aBag = (Bag) bag;

    if (bag instanceof Chest) {
      if (((Chest) bag).getState() != DoorState.OPEN) {
        mob.out("That item is not open");
        return;
      }
    }

    aBag.getInventory().add(anItem);
    mob.getInventory().remove(anItem);

    mob.out("You put an " + anItem.getName() + " into a " + bag.getName());
  }
Пример #2
0
 public static void inveDagger(Mob player1Mob) {
   player1Mob.getInventory().add(makeDagger());
 }