content: /**
   * This file is part of Aion-Lightning <aion-lightning.org>.
   *
   *  Aion-Lightning is free software: you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation, either version 3 of the License, or
   *  (at your option) any later version.
   *
   *  Aion-Lightning is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details. *
   *  You should have received a copy of the GNU General Public License
   *  along with Aion-Lightning.
   *  If not, see <http://www.gnu.org/licenses/>.
   */
  
  package quest.drakenspire_depths;
  
  import com.aionemu.gameserver.model.DialogAction;
  import com.aionemu.gameserver.model.gameobjects.Npc;
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.questEngine.handlers.QuestHandler;
  import com.aionemu.gameserver.questEngine.model.QuestEnv;
  import com.aionemu.gameserver.questEngine.model.QuestState;
  import com.aionemu.gameserver.questEngine.model.QuestStatus;
  
  public class _28952DrakenspireDomination extends QuestHandler {
  
  	private final static int questId = 28952;
  	private final static int[] boss = { 236227, 236228, 236229, 236232, 236238, 236247 };
  
  	public _28952DrakenspireDomination() {
  		super(questId);
  	}
  
  	@Override
  	public void register() {
  		qe.registerQuestNpc(209743).addOnQuestStart(questId);
  		qe.registerQuestNpc(209743).addOnTalkEvent(questId);
  		qe.registerQuestNpc(804738).addOnTalkEvent(questId);
  		for (int mob_id : boss) {
  			qe.registerQuestNpc(mob_id).addOnKillEvent(questId);
  		}
  	}
  
  	@Override
  	public boolean onDialogEvent(QuestEnv env) {
  		Player player = env.getPlayer();
  		int targetId = env.getTargetId();
  		QuestState qs = player.getQuestStateList().getQuestState(questId);
  		DialogAction dialog = env.getDialog();
  
  		if (qs == null || qs.getStatus() == QuestStatus.NONE || qs.canRepeat()) {
  			if (targetId == 209743) {
  				if (dialog == DialogAction.QUEST_SELECT) {
  					return sendQuestDialog(env, 4762);
  				}
  				else {
  					return sendQuestStartDialog(env);
  				}
  			}
  		}
  		else if (qs.getStatus() == QuestStatus.START) {
  			if (targetId == 804738) {
  				if (qs.getQuestVarById(0) == 5) {
  					switch (dialog) {
  						case QUEST_SELECT: {
  							return sendQuestDialog(env, 2375);
  						}
  						case SELECT_QUEST_REWARD: {
  							changeQuestStep(env, 5, 6, true);
  							return sendQuestEndDialog(env);
  						}
  						default:
  							break;
  					}
  				}
  			}
  		}
  		else if (qs.getStatus() == QuestStatus.REWARD) {
  			if (targetId == 804738) {
  				if (env.getDialogId() == 1352) {
  					return sendQuestDialog(env, 5);
  				}
  				else {
  					return sendQuestEndDialog(env);
  				}
  			}
  		}
  		return false;
  	}
  
  	@Override
  	public boolean onKillEvent(QuestEnv env) {
  		Player player = env.getPlayer();
  		QuestState qs = player.getQuestStateList().getQuestState(questId);
  		if (qs == null || qs.getStatus() != QuestStatus.START) {
  			return false;
  		}
  		int var = qs.getQuestVarById(0);
  		int targetId = 0;
  		Npc npc = null;
  		if (env.getVisibleObject() instanceof Npc) {
  			npc = (Npc) env.getVisibleObject();
  			targetId = npc.getNpcId();
  		}
  		switch (targetId) {
  			case 236227:
  			case 236228:
  				qs.setQuestVarById(0, var + 1);
  				updateQuestStatus(env);
  				return true;
  			case 236229:
  			case 236232:
  				qs.setQuestVarById(0, var + 1);
  				updateQuestStatus(env);
  				return true;
  			case 236238:
  				qs.setQuestVarById(0, var + 1);
  				updateQuestStatus(env);
  				return true;
  			case 236247:
  				qs.setStatus(QuestStatus.REWARD);
  				updateQuestStatus(env);
  				return true;
  		}
  		return false;
  	}
  }
  