Esempio n. 1
0
  public void execute(Char aChar, CommandTokenizer toker, String cmd) {
    if (!toker.hasMoreTokens()) {
      aChar.send(SYNTAX);
      return;
    }
    String topic = toker.nextToken();

    String help = theManager.findHelpTopic(topic);
    if (help == null) {
      aChar.send("Tópico não encontrado.");
      return;
    }

    aChar.send(help);
  }
Esempio n. 2
0
  public void execute(Char aChar, CommandTokenizer toker, String cmd) {
    if (!toker.hasMoreTokens()) {
      aChar.send(SYNTAX);
      return;
    }

    IndexedToken itok = toker.nextIndexedToken();

    if (!toker.hasMoreTokens()) {
      if (Keywords.ROOM.equals(itok.getTarget())) {
        Room rm = (Room) aChar.getPlace();
        aChar.send(rm.getSheet(aChar));
        return;
      }
      Item it = aChar.searchItem(itok, aChar);
      if (it != null) {
        aChar.send(it.getSheet());
        return;
      }
      Char ch = aChar.getPlace().findCharByName(itok, aChar);
      if (ch != null) ch.sendSheet(aChar);
      else aChar.send("Não há isso aqui.");
      return;
    }

    int id = 0;
    String opt = itok.getTarget();
    try {
      id = Integer.parseInt(toker.nextToken());
    } catch (NumberFormatException e) {
      aChar.send("O argumento deve ser um número.");
      return;
    }

    if (Keywords.ROOM.startsWith(opt)) {
      Room ro = theWorld.findRoomById(id);
      if (ro == null) {
        aChar.send("Sala não encontrada.");
        return;
      }
      aChar.send(ro.getSheet(aChar));
      return;
    }

    if (Keywords.ITEM.startsWith(opt)) {
      Item it = theWorld.findItemById(id, aChar);
      if (it != null) {
        aChar.send(it.getSheet());
        return;
      }
    }
    if (Keywords.CHAR.startsWith(opt)) {
      Char ch = theWorld.findCharById(id, aChar);
      if (ch != null) ch.sendSheet(aChar);
      else aChar.send("No momento não existe tal coisa no mundo.");
      return;
    } else {
      aChar.send(SYNTAX);
      return;
    }
  }