public static bool TryReceiveQuestItem(PlayerMobile player, Type type, TimeSpan delay) { if (type.IsSubclassOf(typeof(Item))) { QuestRestartInfo info = null; for (var index = 0; index < player.DoneQuests.Count; index++) { var x = player.DoneQuests[index]; if (x.QuestType == type) { info = x; break; } } if (info != null) { DateTime endTime = info.RestartTime; if (DateTime.UtcNow < endTime) { TimeSpan ts = endTime - DateTime.UtcNow; if (ts.Days > 0) { player.SendLocalizedMessage(1158377, string.Format("{0}\t{1}", ts.Days.ToString(), "day[s]")); } else if (ts.Hours > 0) { player.SendLocalizedMessage(1158377, string.Format("{0}\t{1}", ts.Hours.ToString(), "hour[s]")); } else { player.SendLocalizedMessage(1158377, string.Format("{0}\t{1}", ts.Minutes.ToString(), "minute[s]")); } return(false); } info.Reset(delay); } else { player.DoneQuests.Add(new QuestRestartInfo(type, delay)); } return(true); } return(false); }
public static void Delay(PlayerMobile player, Type type, TimeSpan delay) { QuestRestartInfo restartInfo = GetRestartInfo(player, type); if (restartInfo != null) { restartInfo.Reset(delay); return; } player.DoneQuests.Add(new QuestRestartInfo(type, delay)); }
public static void Delay(PlayerMobile player, Type type, TimeSpan delay) { for (int i = 0; i < player.DoneQuests.Count; i++) { QuestRestartInfo restartInfo = player.DoneQuests[i]; if (restartInfo.QuestType == type) { restartInfo.Reset(delay); return; } } player.DoneQuests.Add(new QuestRestartInfo(type, delay)); }
public virtual void ClearQuest(bool completed) { StopTimer(); if (m_From.Quest == this) { m_From.Quest = null; TimeSpan restartDelay = this.RestartDelay; if ((completed && restartDelay > TimeSpan.Zero) || (!completed && restartDelay == TimeSpan.MaxValue)) { List <QuestRestartInfo> doneQuests = m_From.DoneQuests; if (doneQuests == null) { m_From.DoneQuests = doneQuests = new List <QuestRestartInfo>(); } bool found = false; Type ourQuestType = this.GetType(); for (int i = 0; i < doneQuests.Count; ++i) { QuestRestartInfo restartInfo = doneQuests[i]; if (restartInfo.QuestType == ourQuestType) { restartInfo.Reset(restartDelay); found = true; break; } } if (!found) { doneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay)); } } } }
public virtual void ClearQuest(bool completed) { StopTimer(); if (From.Quest == this) { From.Quest = null; TimeSpan restartDelay = RestartDelay; if (completed && restartDelay > TimeSpan.Zero || !completed && restartDelay == TimeSpan.MaxValue) { From.DoneQuests ??= new List <QuestRestartInfo>(); bool found = false; Type ourQuestType = GetType(); for (int i = 0; i < From.DoneQuests.Count; ++i) { QuestRestartInfo restartInfo = From.DoneQuests[i]; if (restartInfo.QuestType == ourQuestType) { restartInfo.Reset(restartDelay); found = true; break; } } if (!found) { From.DoneQuests.Add(new QuestRestartInfo(ourQuestType, restartDelay)); } } } }