Beispiel #1
0
        public static bool Delayed(PlayerMobile player, BaseQuest quest, object quester, bool message)
        {
            QuestRestartInfo restartInfo = GetRestartInfo(player, quest.GetType());

            if (restartInfo != null)
            {
                if (quest.DoneOnce)
                {
                    if (message && quester is Mobile)
                    {
                        ((Mobile)quester).Say(1075454); // I can not offer you the quest again.
                    }

                    return(false);
                }

                DateTime endTime = restartInfo.RestartTime;

                if (DateTime.UtcNow < endTime)
                {
                    if (message && quester is Mobile)
                    {
                        TimeSpan ts = endTime - DateTime.UtcNow;
                        string   str;

                        if (ts.TotalDays > 1)
                        {
                            str = String.Format("I cannot offer this quest again for about {0} more days.", ts.TotalDays);
                        }
                        else if (ts.TotalHours > 1)
                        {
                            str = String.Format("I cannot offer this quest again for about {0} more hours.", ts.TotalHours);
                        }
                        else if (ts.TotalMinutes > 1)
                        {
                            str = String.Format("I cannot offer this quest again for about {0} more minutes.", ts.TotalMinutes);
                        }
                        else
                        {
                            str = "I can offer this quest again very soon.";
                        }

                        ((Mobile)quester).SayTo(player, false, str);
                    }

                    return(false);
                }

                if (quest.RestartDelay > TimeSpan.Zero)
                {
                    player.DoneQuests.Remove(restartInfo);
                }

                return(true);
            }

            return(true);
        }
Beispiel #2
0
        public static BaseQuest GetQuest(PlayerMobile from, Type type)
        {
            if (type == null)
                return null;
				
            for (int i = from.Quests.Count - 1; i >= 0; i --)
            {
                BaseQuest quest = from.Quests[i];

                if (quest.GetType() == type)
                    return quest;
            }
			
            return null;
        }
Beispiel #3
0
        public static void Quests(GenericWriter writer, List <BaseQuest> quests)
        {
            if (quests == null)
            {
                writer.Write((int)0);
                return;
            }

            writer.Write((int)quests.Count);

            for (int i = 0; i < quests.Count; i++)
            {
                BaseQuest quest = quests[i];

                Type(writer, quest.GetType());

                quest.Serialize(writer);
            }
        }
Beispiel #4
0
        public static Type FindFirstChainQuest(BaseQuest quest)
        {
            if (quest == null)
            {
                return(null);
            }

            Type[] quests = null;

            if (quest.Quester is MondainQuester)
            {
                MondainQuester mQuester = (MondainQuester)quest.Quester;

                quests = mQuester.Quests;
            }
            else if (quest.Quester is BaseQuestItem)
            {
                BaseQuestItem iQuester = (BaseQuestItem)quest.Quester;

                quests = iQuester.Quests;
            }

            if (quests != null)
            {
                for (int i = 0; i < quests.Length; i++)
                {
                    BaseQuest fQuest = Construct(quests[i]) as BaseQuest;

                    if (fQuest != null && fQuest.ChainID == quest.ChainID)
                    {
                        return(fQuest.GetType());
                    }
                }
            }

            return(null);
        }
Beispiel #5
0
        public static bool Delayed(PlayerMobile player, BaseQuest quest, bool message)
        {
            List <QuestRestartInfo> doneQuests = player.DoneQuests;

            for (int i = doneQuests.Count - 1; i >= 0; i--)
            {
                QuestRestartInfo restartInfo = doneQuests[i];

                if (restartInfo.QuestType == quest.GetType())
                {
                    if (quest.DoneOnce)
                    {
                        if (message && quest.StartingMobile != null)
                        {
                            quest.StartingMobile.Say(1075454);                               // I can not offer you the quest again.
                        }
                        return(false);
                    }

                    DateTime endTime = restartInfo.RestartTime;

                    if (DateTime.Now < endTime)
                    {
                        return(false);
                    }

                    if (quest.RestartDelay > TimeSpan.Zero)
                    {
                        doneQuests.RemoveAt(i);
                    }

                    return(true);
                }
            }

            return(true);
        }
Beispiel #6
0
 public static bool InChainProgress(PlayerMobile pm, BaseQuest quest)
 {
     return(pm.Quests.Any(q => q.ChainID != QuestChain.None && q.ChainID == quest.ChainID && q.GetType() != quest.GetType()));
 }
Beispiel #7
0
 public static bool FirstChainQuest(BaseQuest quest, object quester)
 {
     return(quest != null && BaseChain.Chains[(int)quest.ChainID] != null && BaseChain.Chains[(int)quest.ChainID].Length > 0 && BaseChain.Chains[(int)quest.ChainID][0] == quest.GetType());
 }
Beispiel #8
0
 public static bool CheckDoneOnce(PlayerMobile player, BaseQuest quest, Mobile quester, bool message)
 {
     return(quest.DoneOnce && CheckDoneOnce(player, quest.GetType(), quester, message));
 }
Beispiel #9
0
        public static bool Delayed(PlayerMobile player, BaseQuest quest, bool message)
        {
            List<QuestRestartInfo> doneQuests = player.DoneQuests;
																					
            for (int i = doneQuests.Count - 1; i >= 0; i --)
            { 
                QuestRestartInfo restartInfo = doneQuests[i];

                if (restartInfo.QuestType == quest.GetType())
                {
                    if (quest.DoneOnce)
                    {
                        if (message && quest.StartingMobile != null)
                            quest.StartingMobile.Say(1075454); // I can not offer you the quest again.
					
                        return false;
                    }
						
                    DateTime endTime = restartInfo.RestartTime;
					
                    if (DateTime.UtcNow < endTime)
                        return false;
					
                    if (quest.RestartDelay > TimeSpan.Zero)
                        doneQuests.RemoveAt(i);
													
                    return true;
                }
            }
			
            return true;
        }
Beispiel #10
0
        public static bool FirstChainQuest(BaseQuest quest, object quester)
        {
            Type[] quests = null;
		
            if (quester is MondainQuester)
            {
                MondainQuester mQuester = (MondainQuester)quester;
				
                quests = mQuester.Quests;
            }
            else if (quester is BaseQuestItem)
            {
                BaseQuestItem iQuester = (BaseQuestItem)quester;
				
                quests = iQuester.Quests;
            }
			
            if (quests != null)
            {
                for (int i = 0; i < quests.Length; i ++)
                {
                    if (quests[i] == quest.GetType())
                        return true;
                }
            }
			
            return false;
        }
Beispiel #11
0
        public static bool InChainProgress(PlayerMobile pm, BaseQuest quest)
        {
            for (var index = 0; index < pm.Quests.Count; index++)
            {
                var q = pm.Quests[index];

                if (q.ChainID != QuestChain.None && q.ChainID == quest.ChainID && q.GetType() != quest.GetType())
                {
                    return(true);
                }
            }

            return(false);
        }