Esempio n. 1
0
 public void stopQuestTimers() {
   for (QuestTimer timer : getTimers().values()) {
     timer.setQuestState(null);
     timer.stop();
   }
   _timers.clear();
 }
Esempio n. 2
0
 /**
  * Remove the variable of quest from the list of variables for the quest.<br>
  * <br>
  * <U><I>Concept : </I></U> Remove the variable of quest represented by "var" from the class
  * variable FastMap "vars" and from the database.
  *
  * @param var : String designating the variable for the quest to be deleted
  * @return String pointing out the previous value associated with the variable "var"
  */
 public String unset(String var) {
   if (var == null) {
     return null;
   }
   String old = _vars.remove(var);
   if (old != null) {
     Quest.deleteQuestVarInDb(this, var);
   }
   return old;
 }
Esempio n. 3
0
  /**
   * Destroy element used by quest when quest is exited
   *
   * @param repeatable
   * @return QuestState
   */
  public QuestState exitCurrentQuest(boolean repeatable) {
    Player player = getPlayer();
    if (player == null) {
      return this;
    }

    removePlayerOnKillListener();
    // Clean drops
    for (int itemId : _quest.getItems()) {
      // Get [item from] / [presence of the item in] the inventory of the player
      ItemInstance item = player.getInventory().getItemByItemId(itemId);
      if ((item == null) || (itemId == 57)) {
        continue;
      }
      long count = item.getCount();
      // If player has the item in inventory, destroy it (if not gold)
      player.getInventory().destroyItemByItemId(itemId, count);
      player.getWarehouse().destroyItemByItemId(itemId, count); // TODO [G1ta0] analyze this
    }

    // If quest is repeatable, delete quest from list of quest of the player and from database
    // (quest CAN be created again => repeatable)
    if (repeatable) {
      player.removeQuestState(_quest.getName());
      Quest.deleteQuestInDb(this);
      _vars.clear();
    } else { // Otherwise, delete variables for quest and update database (quest CANNOT be created
             // again => not repeatable)
      for (String var : _vars.keySet()) {
        if (var != null) {
          unset(var);
        }
      }
      setState(Quest.COMPLETED);
      Quest.updateQuestInDb(this); // FIXME: оно вроде не нужно?
    }
    if (isCompleted()) {
      // WorldStatisticsManager.getInstance().updateStat(player, CategoryType.QUESTS_COMPLETED,0,
      // 1);
    }
    player.sendPacket(new QuestList(player));
    return this;
  }
Esempio n. 4
0
  /**
   * <font color=red>Использовать осторожно! Служебная функция!</font><br>
   * <br>
   *
   * <p>Устанавливает переменную и сохраняет в базу, если установлен флаг. Если получен cond
   * обновляет список квестов игрока (только с флагом).
   *
   * @param var : String pointing out the name of the variable for quest
   * @param val : String pointing out the value of the variable for quest
   * @param store : Сохраняет в базу и если var это cond обновляет список квестов игрока.
   * @return String (equal to parameter "val")
   */
  public String set(String var, String val, boolean store) {
    if (val == null) {
      val = StringUtils.EMPTY;
    }

    _vars.put(var, val);

    if (store) {
      Quest.updateQuestVarInDb(this, var, val);
    }

    return val;
  }
Esempio n. 5
0
 /**
  * <font color=red>Не использовать для получения кондов!</font><br>
  * <br>
  *
  * <p>Return the value of the variable of quest represented by "var"
  *
  * @param var : name of the variable of quest
  * @return Object
  */
 public String get(String var) {
   return _vars.get(var);
 }
Esempio n. 6
0
 public boolean getBool(String var) {
   String val = _vars.get(var);
   return (val != null) || var.equals("1");
 }