/* This is our callback hook that will be called when the player clicks
         * on any button in the quest offer dialog. We check if he accepts or
         * declines here...
         */

        private static void CheckPlayerAbortQuest(GamePlayer player, byte response)
        {
            TheDevilsintheDetails quest = player.IsDoingQuest(typeof(TheDevilsintheDetails)) as TheDevilsintheDetails;

            if (quest == null)
            {
                return;
            }

            if (response == 0x00)
            {
                SendSystemMessage(player, "Good, now go out there and finish your work!");
            }
            else
            {
                SendSystemMessage(player, "Aborting Quest " + questTitle + ". You can start over again if you want.");
                quest.AbortQuest();
            }
        }
        /* This is the method we declared as callback for the hooks we set to
         * Sir Quait. It will be called whenever a player right clicks on Sir Quait
         * or when he whispers something to him.
         */

        protected static void TalkTosentinelMoya(DOLEvent e, object sender, EventArgs args)
        {
            //We get the player from the event arguments and check if he qualifies
            GamePlayer player = ((SourceEventArgs)args).Source as GamePlayer;

            if (player == null)
            {
                return;
            }
            //We also check if the player is already doing the quest
            TheDevilsintheDetails quest = player.IsDoingQuest(typeof(TheDevilsintheDetails)) as TheDevilsintheDetails;

            sentinelMoya.TurnTo(player);
            //Did the player rightclick on Sir Quait?
            if (e == GameObjectEvent.Interact)
            {
                if (player.Inventory.GetFirstItemByID(boxTrain.Id_nb, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack) != null)
                {
                    sentinelMoya.SayTo(player, "Greetings, Guardian. What brings you to Ardee [today]?");
                }
                else
                {
                    sentinelMoya.SayTo(player, "Hello, how are you?");
                }
                return;
            }
            else if (e == GameLivingEvent.WhisperReceive)
            {
                WhisperReceiveEventArgs wArgs = (WhisperReceiveEventArgs)args;
                switch (wArgs.Text)
                {
                case "today":
                    RemoveItem(sentinelMoya, player, boxTrain);
                    sentinelMoya.SayTo(player, "Thank you so much! When you return to Mag Mell, please give Sentinel Maitias my thanks as well. I'm looking forward to training more of Hibernia's Sentinels. Take care!");
                    quest.Step = 2;
                    break;
                }
            }
        }
        /* This is the method we declared as callback for the hooks we set to
         * Sir Quait. It will be called whenever a player right clicks on Sir Quait
         * or when he whispers something to him.
         */

        protected static void TalkTosentinelMaitias(DOLEvent e, object sender, EventArgs args)
        {
            //We get the player from the event arguments and check if he qualifies
            GamePlayer player = ((SourceEventArgs)args).Source as GamePlayer;

            if (player == null)
            {
                return;
            }

            if (sentinelMaitias.CanGiveQuest(typeof(TheDevilsintheDetails), player) <= 0)
            {
                return;
            }

            //We also check if the player is already doing the quest
            TheDevilsintheDetails quest = player.IsDoingQuest(typeof(TheDevilsintheDetails)) as TheDevilsintheDetails;

            sentinelMaitias.TurnTo(player);
            //Did the player rightclick on Sir Quait?
            if (e == GameObjectEvent.Interact)
            {
                //We check if the player is already doing the quest
                if (quest != null)
                {
                    //If the player is already doing the quest, we ask if he found the fur!
                    if (player.Inventory.GetFirstItemByID(boxTrain.Id_nb, eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack) != null)
                    {
                        sentinelMaitias.SayTo(player, "Excellent. This crate of supplies must be delivered to my counterpart in Ardee, Sentinel Moya. The town is just a bit to the north, along the road. Without these new training swords, Moya would have difficulty drilling her recruits.");
                    }
                    else
                    {
                        sentinelMaitias.SayTo(player, "I see that you've returned. Did Sentinel Moya receive the supplies in [time]?");
                    }
                    return;
                }
                else
                {
                    sentinelMaitias.SayTo(player, "Good day to you, Guardian. Forgive me if I appear distracted, but my duties are many these days, and my staff keeps shrinking. In times past, Mag Mell formed the center of a vibrant elven community in Hibernia. Fagan dreams of [recreating] those days.");
                    return;
                }
            }
            // The player whispered to Sir Quait (clicked on the text inside the [])
            else if (e == GameLivingEvent.WhisperReceive)
            {
                WhisperReceiveEventArgs wArgs = (WhisperReceiveEventArgs)args;

                //We also check if the player is already doing the quest
                if (quest == null)
                {
                    switch (wArgs.Text)
                    {
                    case "recreating":
                        sentinelMaitias.SayTo(player, "I don't blame him for being ambitious. Fagan has lived through tumultuous times and wants the best for his people, but I think that sometimes he focuses too much on the big picture. As a result, it falls to me to keep Mag Mell running on a daily [basis].");
                        break;

                    case "basis":
                        sentinelMaitias.SayTo(player, "There should be some around the area of this village, take a look near the road to Camelot. Kill any wolf pups you can find, and bring me its fur.");
                        player.Out.SendQuestSubscribeCommand(sentinelMaitias, QuestMgr.GetIDForQuestType(typeof(TheDevilsintheDetails)), "Do you accept The Devil's in the Details quest?");
                        break;
                    }
                }
                else
                {
                    switch (wArgs.Text)
                    {
                    case "abort":
                        player.Out.SendCustomDialog("Do you really want to abort this quest, \nall items gained during quest will be lost?", new CustomDialogResponse(CheckPlayerAbortQuest));
                        break;

                    case "time":
                        sentinelMaitias.SayTo(player, "Thank you for taking care of that so quickly. Please take this coin as a reward for your efforts and perhaps we can work together again in the future. Be well.");
                        quest.FinishQuest();
                        break;
                    }
                }
            }
        }