Пример #1
0
  @Override
  public boolean invoke(
      MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel) {
    if (commands.size() < 1) {
      mob.tell(
          L(
              "You must specify an item to fence, and possibly a ShopKeeper (unless it is implied)."));
      return false;
    }

    commands.add(0, "SELL"); // will be instantly deleted by parseshopkeeper
    final Environmental shopkeeper =
        CMLib.english().parseShopkeeper(mob, commands, L("Fence what to whom?"));
    if (shopkeeper == null) return false;
    if (commands.size() == 0) {
      mob.tell(L("Fence what?"));
      return false;
    }

    if (!super.invoke(mob, commands, givenTarget, auto, asLevel)) return false;

    final boolean success = proficiencyCheck(mob, 0, auto);
    if (success) {
      final CMMsg msg =
          CMClass.getMsg(
              mob,
              shopkeeper,
              this,
              CMMsg.MSG_SPEAK,
              auto ? "" : L("<S-NAME> fence(s) stolen loot to <T-NAMESELF>."));
      if (mob.location().okMessage(mob, msg)) {
        mob.location().send(mob, msg);
        invoker = mob;
        addBackMap.clear();
        mob.addEffect(this);
        mob.recoverCharStats();
        commands.add(0, CMStrings.capitalizeAndLower("SELL"));
        mob.doCommand(commands, MUDCmdProcessor.METAFLAG_FORCED);
        commands.add(shopkeeper.name());
        mob.delEffect(this);
        for (Item I : addBackMap.keySet()) {
          if (mob.isMine(I)) {
            I.addEffect(addBackMap.get(I));
          }
        }
        addBackMap.clear();
        mob.recoverCharStats();
      }
    } else
      beneficialWordsFizzle(
          mob,
          shopkeeper,
          L(
              "<S-NAME> attempt(s) to fence stolen loot to <T-NAMESELF>, but make(s) <T-HIM-HER> too nervous."));

    // return whether it worked
    return success;
  }