Beispiel #1
0
        public BaseQuest(QuestInfo info, QuestDataInfo data)
        {
            this.m_info         = info;
            this.m_data         = data;
            this.m_data.QuestID = this.m_info.ID;
            this.m_list         = new List <BaseCondition>();
            List <QuestConditionInfo> questCondiction = QuestMgr.GetQuestCondiction(info);
            int num = 0;

            foreach (QuestConditionInfo current in questCondiction)
            {
                BaseCondition baseCondition = BaseCondition.CreateCondition(this, current, data.GetConditionValue(num++));
                if (baseCondition != null)
                {
                    this.m_list.Add(baseCondition);
                }
            }
        }
Beispiel #2
0
        public BaseQuest(QuestInfo info, QuestDataInfo data)
        {
            this.m_info         = info;
            this.m_data         = data;
            this.m_data.QuestID = this.m_info.ID;
            this.m_list         = new List <BaseCondition>();
            List <QuestConditionInfo> list = QuestMgr.GetQuestCondiction(info);
            int index = 0;

            foreach (QuestConditionInfo ci in list)
            {
                BaseCondition cd = BaseCondition.CreateCondition(this, ci, data.GetConditionValue(index++));
                if (cd != null)
                {
                    this.m_list.Add(cd);
                }
            }
        }
Beispiel #3
0
        public bool AddQuest(QuestInfo info, out string msg)
        {
            msg = "";
            try
            {
                if (info == null)
                {
                    msg = "Game.Server.Quests.NoQuest";
                    bool result = false;
                    return(result);
                }
                if (info.TimeMode && DateTime.Now.CompareTo(info.StartDate) < 0)
                {
                    msg = "Game.Server.Quests.NoTime";
                }
                if (info.TimeMode && DateTime.Now.CompareTo(info.EndDate) > 0)
                {
                    msg = "Game.Server.Quests.TimeOver";
                }
                if (this.m_player.PlayerCharacter.Grade < info.NeedMinLevel)
                {
                    msg = "Game.Server.Quests.LevelLow";
                }
                if (this.m_player.PlayerCharacter.Grade > info.NeedMaxLevel)
                {
                    msg = "Game.Server.Quests.LevelTop";
                }
                if (info.PreQuestID != "0,")
                {
                    string[] array = info.PreQuestID.Split(new char[]
                    {
                        ','
                    });
                    for (int i = 0; i < array.Length - 1; i++)
                    {
                        if (!this.IsQuestFinish(Convert.ToInt32(array[i])))
                        {
                            msg = "Game.Server.Quests.NoFinish";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QuestInventory.log.Info(ex.InnerException);
            }
            if (info.IsOther == 1 && !this.m_player.PlayerCharacter.IsConsortia)
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            if (info.IsOther == 2 && !this.m_player.PlayerCharacter.IsMarried)
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            BaseQuest baseQuest = this.FindQuest(info.ID);

            if (baseQuest != null && baseQuest.Data.IsComplete)
            {
                msg = "Game.Server.Quests.Have";
            }
            if (baseQuest != null && !baseQuest.Info.CanRepeat)
            {
                msg = "Game.Server.Quests.NoRepeat";
            }
            if (baseQuest != null && DateTime.Now.CompareTo(baseQuest.Data.CompletedDate.Date.AddDays((double)baseQuest.Info.RepeatInterval)) < 0 && baseQuest.Data.RepeatFinish < 1)
            {
                msg = "Game.Server.Quests.Rest";
            }
            BaseQuest baseQuest2 = this.m_player.QuestInventory.FindQuest(info.ID);

            if (baseQuest2 != null)
            {
                msg = "Game.Server.Quests.Have";
            }
            if (msg == "")
            {
                QuestMgr.GetQuestCondiction(info);
                int rand = 1;
                if (ThreadSafeRandom.NextStatic(1000000) <= info.Rands)
                {
                    rand = info.RandDouble;
                }
                this.BeginChanges();
                if (baseQuest == null)
                {
                    baseQuest = new BaseQuest(info, new QuestDataInfo());
                    this.AddQuest(baseQuest);
                    baseQuest.Reset(this.m_player, rand);
                }
                else
                {
                    baseQuest.Reset(this.m_player, rand);
                    baseQuest.AddToPlayer(this.m_player);
                    this.OnQuestsChanged(baseQuest);
                }
                this.CommitChanges();
                this.SaveToDatabase();
                return(true);
            }
            msg = LanguageMgr.GetTranslation(msg, new object[0]);
            return(false);
        }
Beispiel #4
0
        public bool AddQuest(QuestInfo info, out string msg)
        {
            msg = "";
            if (info == null)
            {
                msg = "Game.Server.Quests.NoQuest";
            }
            if (info.TimeMode && DateTime.Now.CompareTo(info.StartDate) < 0)
            {
                msg = "Game.Server.Quests.NoTime";
            }
            if (info.TimeMode && DateTime.Now.CompareTo(info.EndDate) > 0)
            {
                msg = "Game.Server.Quests.TimeOver";
            }
            if (this.m_player.PlayerCharacter.Grade < info.NeedMinLevel)
            {
                msg = "Game.Server.Quests.LevelLow";
            }
            if (this.m_player.PlayerCharacter.Grade > info.NeedMaxLevel)
            {
                msg = "Game.Server.Quests.LevelTop";
            }
            if (info.PreQuestID != "0,")
            {
                string[] tempArry = info.PreQuestID.Split(new char[]
                {
                    ','
                });
                for (int i = 0; i < tempArry.Length - 1; i++)
                {
                    if (!this.IsQuestFinish(Convert.ToInt32(tempArry[i])))
                    {
                        msg = "Game.Server.Quests.NoFinish";
                    }
                }
            }
            if (info.IsOther == 1 && this.m_player.PlayerCharacter.ConsortiaID == 0)
            {
                msg = "Game.Server.Quests.NoConsortia";
            }
            if (info.IsOther == 2 && !this.m_player.PlayerCharacter.IsMarried)
            {
                msg = "Game.Server.Quest.QuestInventory.HaveMarry";
            }
            BaseQuest oldData = this.FindQuest(info.ID);

            if (oldData != null && !oldData.Data.IsComplete)
            {
                msg = "Game.Server.Quests.Have";
            }
            if (this.IsQuestFinish(info.ID) && !info.CanRepeat)
            {
                msg = "Game.Server.Quests.NoRepeat";
            }
            if (oldData != null && TimeHelper.GetDaysBetween(oldData.Data.CompletedDate, DateTime.Now) < info.RepeatInterval && oldData.Data.RepeatFinish < 1)
            {
                msg = "Game.Server.Quests.Reset";
            }
            bool result;

            if (msg == "")
            {
                List <QuestConditionInfo> info_condition = QuestMgr.GetQuestCondiction(info);
                int rand = 1;
                if (QuestInventory.random.Next(1000000) <= info.Rands)
                {
                    rand = info.RandDouble;
                }
                this.BeginChanges();
                if (oldData == null)
                {
                    oldData = new BaseQuest(info, new QuestDataInfo());
                }
                oldData.Reset(this.m_player, rand);
                this.AddQuest(oldData);
                this.CommitChanges();
                result = true;
            }
            else
            {
                msg    = LanguageMgr.GetTranslation(msg, new object[0]);
                result = false;
            }
            return(result);
        }