@Override
  public String onEvent(String event, QuestState st, NpcInstance npc) {
    String htmltext = event;
    Castle castle = ResidenceHolder.getInstance().getResidence(ShuttgartCastle);
    if (castle.getOwner() == null) {
      return "Castle has no lord";
    }
    Player castleOwner = castle.getOwner().getLeader().getPlayer();

    if (event.equals("august_q714_03.htm")) {
      st.setState(STARTED);
      st.setCond(1);
      st.playSound(SOUND_ACCEPT);
    } else if (event.equals("august_q714_05.htm")) {
      st.setCond(2);
    } else if (event.equals("newyear_q714_03.htm")) {
      st.setCond(3);
    } else if (event.equals("yasheni_q714_02.htm")) {
      st.setCond(5);
    } else if (event.equals("august_q714_08.htm")) {
      Functions.npcSay(
          npc,
          NpcString.S1_HAS_BECOME_THE_LORD_OF_THE_TOWN_OF_SCHUTTGART,
          st.getPlayer().getName());
      castle.getDominion().changeOwner(castleOwner.getClan());
      st.playSound(SOUND_FINISH);
      st.exitCurrentQuest(true);
    }
    return htmltext;
  }
 private boolean validateCondition(Player player) {
   Residence residence = getCastle();
   if (residence != null && residence.getId() > 0)
     if (player.getClan() != null)
       if (residence.getOwnerId() == player.getClanId() && player.isClanLeader()) // Leader of clan
       return true; // Owner
   residence = getFortress();
   if (residence != null && residence.getId() > 0)
     if (player.getClan() != null)
       if (residence.getOwnerId() == player.getClanId() && player.isClanLeader()) // Leader of clan
       return true; // Owner
   residence = getClanHall();
   if (residence != null && residence.getId() > 0)
     if (player.getClan() != null)
       if (residence.getOwnerId() == player.getClanId() && player.isClanLeader()) // Leader of clan
       return true; // Owner
   return false;
 }
예제 #3
0
 @Override
 protected int getCond(Player player) {
   Residence residence = getResidence();
   Clan residenceOwner = residence.getOwner();
   if (residenceOwner != null && player.getClan() == residenceOwner) {
     return COND_OWNER;
   } else {
     return COND_FAIL;
   }
 }
  @Override
  public String onTalk(NpcInstance npc, QuestState st) {
    String htmltext = "noquest";
    int cond = st.getCond();
    Player player = st.getPlayer();
    Clan clan = player.getClan();
    ClanHall clanhall = ResidenceHolder.getInstance().getResidence(35);

    if (clanhall.getSiegeEvent().isRegistrationOver()) {
      htmltext = null;
      showHtmlFile(
          player,
          "azit_messenger_q0504_03.htm",
          false,
          "%siege_time%",
          TimeUtils.toSimpleFormat(clanhall.getSiegeDate()));
    } else if (clan == null || player.getObjectId() != clan.getLeaderId())
      htmltext = "azit_messenger_q0504_05.htm";
    else if (player.getObjectId() == clan.getLeaderId() && clan.getLevel() < 4)
      htmltext = "azit_messenger_q0504_04.htm";
    else if (clanhall.getSiegeEvent().getSiegeClan(SiegeEvent.ATTACKERS, player.getClan()) != null)
      htmltext = "azit_messenger_q0504_06.htm";
    else if (clan.getHasHideout() > 0) htmltext = "azit_messenger_q0504_10.htm";
    else if (cond == 0) htmltext = "azit_messenger_q0504_01.htm";
    else if (st.getQuestItemsCount(CONTEST_CERTIFICATE) == 1 && st.getQuestItemsCount(AMULET) < 30)
      htmltext = "azit_messenger_q0504_07.htm";
    else if (st.getQuestItemsCount(ALIANCE_TROPHEY) >= 1) htmltext = "azit_messenger_q0504_07a.htm";
    else if (st.getQuestItemsCount(CONTEST_CERTIFICATE) == 1
        && st.getQuestItemsCount(AMULET) == 30) {
      st.takeItems(AMULET, -1);
      st.takeItems(CONTEST_CERTIFICATE, -1);
      st.giveItems(ALIANCE_TROPHEY, 1);
      st.playSound(SOUND_FINISH);
      st.setCond(-1);
      htmltext = "azit_messenger_q0504_08.htm";
    }

    return htmltext;
  }