예제 #1
0
        public void LoadFromDatabase(int playerId)
        {
            object @lock;

            Monitor.Enter(@lock = this.m_lock);
            try
            {
                this.m_states = ((this.m_player.PlayerCharacter.QuestSite.Count <byte>() == 0) ? this.InitQuest() : this.m_player.PlayerCharacter.QuestSite);
                using (PlayerBussiness playerBussiness = new PlayerBussiness())
                {
                    QuestDataInfo[] userQuest = playerBussiness.GetUserQuest(playerId);
                    this.BeginChanges();
                    QuestDataInfo[] array = userQuest;
                    for (int i = 0; i < array.Length; i++)
                    {
                        QuestDataInfo questDataInfo = array[i];
                        QuestInfo     singleQuest   = QuestMgr.GetSingleQuest(questDataInfo.QuestID);
                        if (singleQuest != null)
                        {
                            this.AddQuest(new BaseQuest(singleQuest, questDataInfo));
                        }
                        this.AddQuestData(questDataInfo);
                    }
                    this.CommitChanges();
                }
                List <BaseQuest> arg_B0_0 = this.m_list;
            }
            finally
            {
                Monitor.Exit(@lock);
            }
        }
예제 #2
0
        public void LoadFromDatabase(int playerId)
        {
            object @lock;

            Monitor.Enter(@lock = this.m_lock);
            try
            {
                this.m_states = ((this.m_player.PlayerCharacter.QuestSite.Count <byte>() == 0) ? this.InitQuest() : this.m_player.PlayerCharacter.QuestSite);
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    QuestDataInfo[] datas = db.GetUserQuest(playerId);
                    this.BeginChanges();
                    QuestDataInfo[] array = datas;
                    for (int i = 0; i < array.Length; i++)
                    {
                        QuestDataInfo dt   = array[i];
                        QuestInfo     info = QuestMgr.GetSingleQuest(dt.QuestID);
                        if (info != null && this.CheckQuest(info))
                        {
                            this.AddQuest(new BaseQuest(info, dt));
                        }
                    }
                    this.CommitChanges();
                }
            }
            finally
            {
                Monitor.Exit(@lock);
            }
        }
예제 #3
0
        /// <summary>
        /// 删除任务
        /// </summary>
        /// <returns></returns>
        public bool RemoveQuest(int questID)
        {
            QuestDataInfo quest = GetCurrentQuest(questID, true);

            if (quest != null && !quest.IsComplete)
            {
                quest.IsExist = false;
                // _player.Out.SendQuestUpdate(quest);
                return(true);
            }
            return(false);
        }
예제 #4
0
 public static XElement CreateQuestDataInfo(QuestDataInfo info)
 {
     return(new XElement("Item", new XAttribute("CompletedDate", info.CompletedDate),
                         new XAttribute("IsComplete", info.IsComplete),
                         new XAttribute("Condition1", info.Condition1),
                         new XAttribute("Condition2", info.Condition2),
                         new XAttribute("Condition3", info.Condition3),
                         new XAttribute("Condition4", info.Condition4),
                         new XAttribute("QuestID", info.QuestID),
                         new XAttribute("UserID", info.UserID),
                         new XAttribute("RepeatFinish", info.RepeatFinish)));
 }
예제 #5
0
        private bool AddQuestData(QuestDataInfo data)
        {
            List <BaseQuest> list;

            Monitor.Enter(list = this.m_list);
            try
            {
                this.m_datas.Add(data);
            }
            finally
            {
                Monitor.Exit(list);
            }
            return(true);
        }
예제 #6
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);
                }
            }
        }
예제 #7
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);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 用户领奖
        /// </summary>
        /// <param name="quest"></param>
        /// <param name="rewardItemID"></param>
        /// <returns></returns>
        public bool Finish(BaseQuest baseQuest, int selectedItem)
        {
            //if (baseQuest.CanCompleted(m_player) == false)
            //    return false;

            #region 定义变量
            //提示用户
            string msg = "";
            //奖励Buff
            string        RewardBuffName = string.Empty;
            int           RewardBuffTime = 0;
            QuestInfo     qinfo          = baseQuest.Info;
            QuestDataInfo qdata          = baseQuest.Data;
            #endregion

            #region 从游戏中领取奖品
            m_player.BeginAllChanges();
            try
            {
                if (baseQuest.Finish(m_player))
                {
                    RemoveQuest(baseQuest);

                    //固定奖励&选择奖励
                    List <QuestAwardInfo> awards = QuestMgr.GetQuestGoods(qinfo);
                    List <ItemInfo>       mainBg = new List <ItemInfo>();
                    List <ItemInfo>       propBg = new List <ItemInfo>();
                    foreach (QuestAwardInfo award in awards)
                    {
                        //获取固定奖励 或者 已经选取的可选奖励
                        if (award.IsSelect == false || award.RewardItemID == selectedItem)
                        {
                            ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(award.RewardItemID);
                            if (temp != null)
                            {
                                msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", temp.Name, award.RewardItemCount) + " ";
                                Int32 tempCount = award.RewardItemCount;
                                if (award.IsCount == true)
                                {
                                    tempCount = tempCount * qdata.RandDobule;
                                }

                                for (int len = 0; len < tempCount; len += temp.MaxCount)
                                {
                                    int      count = len + temp.MaxCount > award.RewardItemCount ? award.RewardItemCount - len : temp.MaxCount;
                                    ItemInfo item  = ItemInfo.CreateFromTemplate(temp, count, (int)ItemAddType.Quest);
                                    if (item == null)
                                    {
                                        continue;
                                    }
                                    item.ValidDate       = award.RewardItemValid;
                                    item.IsBinds         = true;
                                    item.StrengthenLevel = award.StrengthenLevel; //等级
                                    item.AttackCompose   = award.AttackCompose;   //攻击加成
                                    item.DefendCompose   = award.DefendCompose;   //防御加成
                                    item.AgilityCompose  = award.AgilityCompose;  //敏捷加成
                                    item.LuckCompose     = award.LuckCompose;     //幸运加成
                                    if (temp.BagType == eBageType.PropBag)
                                    {
                                        propBg.Add(item);
                                    }
                                    else
                                    {
                                        mainBg.Add(item);
                                    }
                                }
                            }
                        }
                    }

                    //判断背包的空位是否足够
                    if (mainBg.Count > 0 && m_player.MainBag.GetEmptyCount() < mainBg.Count)
                    {
                        baseQuest.CancelFinish(m_player);
                        m_player.Out.SendMessage(eMessageType.ERROR, m_player.GetInventoryName(eBageType.MainBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull") + " ");
                        return(false);
                    }
                    if (propBg.Count > 0 && m_player.PropBag.GetEmptyCount() < propBg.Count)
                    {
                        baseQuest.CancelFinish(m_player);
                        m_player.Out.SendMessage(eMessageType.ERROR, m_player.GetInventoryName(eBageType.PropBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull") + " ");
                        return(false);
                    }

                    //把物品放入背包
                    foreach (ItemInfo item in mainBg)
                    {
                        m_player.AddTemplate(item, eBageType.MainBag, 1);
                    }
                    foreach (ItemInfo item in propBg)
                    {
                        m_player.AddTemplate(item, eBageType.PropBag, 1);
                    }

                    msg = LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Reward") + msg;

                    //发放Buff
                    if ((qinfo.RewardBuffID > 0) && (qinfo.RewardBuffDate > 0))
                    {
                        ItemTemplateInfo temp = Bussiness.Managers.ItemMgr.FindItemTemplate(qinfo.RewardBuffID);
                        if (temp != null)
                        {
                            RewardBuffTime = qinfo.RewardBuffDate * qdata.RandDobule;
                            AbstractBuffer buffer = BufferList.CreateBufferHour(temp, RewardBuffTime);
                            buffer.Start(m_player);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardBuff", temp.Name, RewardBuffTime) + " ";
                        }
                    }

                    //奖励金币
                    if (qinfo.RewardGold != 0)
                    {
                        int rewardGold = qinfo.RewardGold * qdata.RandDobule;
                        m_player.AddGold(rewardGold);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGold", rewardGold) + " ";
                    }
                    //奖励点卷
                    if (qinfo.RewardMoney != 0)
                    {
                        int rewardMoney = qinfo.RewardMoney * qdata.RandDobule;
                        m_player.AddMoney(qinfo.RewardMoney * qdata.RandDobule);
                        LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Quest, m_player.PlayerCharacter.ID, rewardMoney, m_player.PlayerCharacter.Money, 0, 0, 0, "", "", "");//添加日志
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardMoney", rewardMoney) + " ";
                    }
                    //奖励GP
                    if (qinfo.RewardGP != 0)
                    {
                        int rewardGp = qinfo.RewardGP * qdata.RandDobule;
                        m_player.AddGP(rewardGp);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGB1", rewardGp) + " ";
                    }
                    //有公会则奖励财富
                    if ((qinfo.RewardRiches != 0) && (m_player.PlayerCharacter.ConsortiaID != 0))
                    {
                        int riches = qinfo.RewardRiches * qdata.RandDobule;
                        m_player.AddRichesOffer(riches);
                        using (ConsortiaBussiness db = new ConsortiaBussiness())
                        {
                            db.ConsortiaRichAdd(m_player.PlayerCharacter.ConsortiaID, ref riches);
                        }
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardRiches", riches) + " ";
                    }
                    //奖励功勋
                    if (qinfo.RewardOffer != 0)
                    {
                        int rewardOffer = qinfo.RewardOffer * qdata.RandDobule;
                        m_player.AddOffer(rewardOffer, false);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardOffer", rewardOffer) + " ";
                    }
                    //奖励礼劵
                    if (qinfo.RewardGiftToken != 0)
                    {
                        int rewardGiftToken = qinfo.RewardGiftToken * qdata.RandDobule;
                        m_player.AddGiftToken(rewardGiftToken);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", rewardGiftToken + " ");
                    }
                    m_player.Out.SendMessage(eMessageType.Normal, msg);
                    SetQuestFinish(baseQuest.Info.ID);
                    m_player.PlayerCharacter.QuestSite = m_states;
                }
                OnQuestsChanged(baseQuest);
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Quest Finish:" + ex);
                }
                return(false);
            }
            finally
            {
                m_player.CommitAllChanges();
            }
            #endregion
            return(true);
        }
예제 #9
0
        public bool Finish(BaseQuest baseQuest, int selectedItem)
        {
            string        text     = "";
            string        arg_0B_0 = string.Empty;
            QuestInfo     info     = baseQuest.Info;
            QuestDataInfo data     = baseQuest.Data;

            this.m_player.BeginAllChanges();
            try
            {
                if (baseQuest.Finish(this.m_player))
                {
                    this.RemoveQuest(baseQuest);
                    List <QuestAwardInfo> questGoods = QuestMgr.GetQuestGoods(info);
                    List <ItemInfo>       list       = new List <ItemInfo>();
                    List <ItemInfo>       list2      = new List <ItemInfo>();
                    List <ItemInfo>       list3      = new List <ItemInfo>();
                    List <ItemInfo>       list4      = new List <ItemInfo>();
                    foreach (QuestAwardInfo current in questGoods)
                    {
                        if (!current.IsSelect || current.RewardItemID == selectedItem)
                        {
                            ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(current.RewardItemID);
                            if (itemTemplateInfo != null)
                            {
                                text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", new object[]
                                {
                                    itemTemplateInfo.Name,
                                    current.RewardItemCount1
                                }) + " ";
                                int num = current.RewardItemCount1;
                                if (current.IsCount)
                                {
                                    num *= data.RandDobule;
                                }
                                for (int i = 0; i < num; i += itemTemplateInfo.MaxCount)
                                {
                                    int      count    = (i + itemTemplateInfo.MaxCount > current.RewardItemCount1) ? (current.RewardItemCount1 - i) : itemTemplateInfo.MaxCount;
                                    ItemInfo itemInfo = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, 106);
                                    if (itemInfo != null)
                                    {
                                        itemInfo.ValidDate       = current.RewardItemValid;
                                        itemInfo.IsBinds         = true;
                                        itemInfo.StrengthenLevel = current.StrengthenLevel;
                                        itemInfo.AttackCompose   = current.AttackCompose;
                                        itemInfo.DefendCompose   = current.DefendCompose;
                                        itemInfo.AgilityCompose  = current.AgilityCompose;
                                        itemInfo.LuckCompose     = current.LuckCompose;
                                        if (itemTemplateInfo.BagType == eBageType.PropBag)
                                        {
                                            list2.Add(itemInfo);
                                        }
                                        else
                                        {
                                            if (itemTemplateInfo.BagType == eBageType.Farm)
                                            {
                                                list3.Add(itemInfo);
                                            }
                                            else
                                            {
                                                list.Add(itemInfo);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (list.Count > 0 && this.m_player.MainBag.GetEmptyCount() < list.Count)
                    {
                        baseQuest.CancelFinish(this.m_player);
                        this.m_player.Out.SendMessage(eMessageType.ERROR, this.m_player.GetInventoryName(eBageType.MainBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull", new object[0]) + " ");
                        bool result = false;
                        return(result);
                    }
                    if (list2.Count > 0 && this.m_player.PropBag.GetEmptyCount() < list2.Count)
                    {
                        baseQuest.CancelFinish(this.m_player);
                        this.m_player.Out.SendMessage(eMessageType.ERROR, this.m_player.GetInventoryName(eBageType.PropBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull", new object[0]) + " ");
                        bool result = false;
                        return(result);
                    }
                    foreach (ItemInfo current2 in list)
                    {
                        if (!this.m_player.MainBag.StackItemToAnother(current2) && !this.m_player.MainBag.AddItem(current2))
                        {
                            list4.Add(current2);
                        }
                    }
                    foreach (ItemInfo current3 in list2)
                    {
                        if (current3.Template.CategoryID != 10)
                        {
                            if (!this.m_player.PropBag.StackItemToAnother(current3) && !this.m_player.PropBag.AddItem(current3))
                            {
                                list4.Add(current3);
                            }
                        }
                        else
                        {
                            int templateID = current3.TemplateID;
                            switch (templateID)
                            {
                            case 10001:
                                this.m_player.PlayerCharacter.openFunction(Step.PICK_TWO_TWENTY);
                                break;

                            case 10002:
                                break;

                            case 10003:
                                this.m_player.PlayerCharacter.openFunction(Step.POP_WIN);
                                break;

                            case 10004:
                                this.m_player.PlayerCharacter.openFunction(Step.FIFTY_OPEN);
                                this.m_player.AddGift(eGiftType.NEWBIE);
                                break;

                            case 10005:
                                this.m_player.PlayerCharacter.openFunction(Step.FORTY_OPEN);
                                break;

                            case 10006:
                                this.m_player.PlayerCharacter.openFunction(Step.THIRTY_OPEN);
                                break;

                            case 10007:
                                this.m_player.PlayerCharacter.openFunction(Step.POP_TWO_TWENTY);
                                break;

                            case 10008:
                                this.m_player.PlayerCharacter.openFunction(Step.POP_TIP_ONE);
                                break;

                            default:
                                switch (templateID)
                                {
                                case 10024:
                                    this.m_player.PlayerCharacter.openFunction(Step.PICK_ONE);
                                    break;

                                case 10025:
                                    this.m_player.PlayerCharacter.openFunction(Step.POP_EXPLAIN_ONE);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    foreach (ItemInfo current4 in list3)
                    {
                        if (!this.m_player.FarmBag.StackItemToAnother(current4) && !this.m_player.FarmBag.AddItem(current4))
                        {
                            list4.Add(current4);
                        }
                    }
                    if (list4.Count > 0)
                    {
                        this.m_player.SendItemsToMail(list4, "Bagfull trả về thư!", "Phần thưởng nhiệm vụ!", eMailType.ItemOverdue);
                        this.m_player.Out.SendMailResponse(this.m_player.PlayerCharacter.ID, eMailRespose.Receiver);
                    }
                    text = LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Reward", new object[0]) + text;
                    if (info.RewardBuffID > 0 && info.RewardBuffDate > 0)
                    {
                        ItemTemplateInfo itemTemplateInfo2 = ItemMgr.FindItemTemplate(info.RewardBuffID);
                        if (itemTemplateInfo2 != null)
                        {
                            int            num2           = info.RewardBuffDate * data.RandDobule;
                            AbstractBuffer abstractBuffer = BufferList.CreateBufferHour(itemTemplateInfo2, num2);
                            abstractBuffer.Start(this.m_player);
                            text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardBuff", new object[]
                            {
                                itemTemplateInfo2.Name,
                                num2
                            }) + " ";
                        }
                    }
                    if (info.RewardGold != 0)
                    {
                        int num3 = info.RewardGold * data.RandDobule;
                        this.m_player.AddGold(num3);
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGold", new object[]
                        {
                            num3
                        }) + " ";
                    }
                    if (info.RewardMoney != 0)
                    {
                        int num4 = info.RewardMoney * data.RandDobule;
                        this.m_player.AddMoney(info.RewardMoney * data.RandDobule);
                        LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Quest, this.m_player.PlayerCharacter.ID, num4, this.m_player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardMoney", new object[]
                        {
                            num4
                        }) + " ";
                    }
                    if (info.RewardGP != 0)
                    {
                        int num5 = info.RewardGP * data.RandDobule;
                        this.m_player.AddGP(num5);
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGB1", new object[]
                        {
                            num5
                        }) + " ";
                    }
                    if (info.RewardRiches != 0 && this.m_player.PlayerCharacter.ConsortiaID != 0)
                    {
                        int num6 = info.RewardRiches * data.RandDobule;
                        this.m_player.AddRichesOffer(num6);
                        using (ConsortiaBussiness consortiaBussiness = new ConsortiaBussiness())
                        {
                            consortiaBussiness.ConsortiaRichAdd(this.m_player.PlayerCharacter.ConsortiaID, ref num6);
                        }
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardRiches", new object[]
                        {
                            num6
                        }) + " ";
                    }
                    if (info.RewardOffer != 0)
                    {
                        int num7 = info.RewardOffer * data.RandDobule;
                        this.m_player.AddOffer(num7, false);
                        text = text + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardOffer", new object[]
                        {
                            num7
                        }) + " ";
                    }
                    if (info.RewardBindMoney != 0)
                    {
                        int num8 = info.RewardBindMoney * data.RandDobule;
                        this.m_player.AddGiftToken(num8);
                        text += LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", new object[]
                        {
                            num8 + " "
                        });
                    }
                    this.m_player.Out.SendMessage(eMessageType.Normal, text);
                    this.SetQuestFinish(baseQuest.Info.ID);
                    this.m_player.PlayerCharacter.QuestSite = this.m_states;
                }
                this.OnQuestsChanged(baseQuest);
            }
            catch (Exception arg)
            {
                if (QuestInventory.log.IsErrorEnabled)
                {
                    QuestInventory.log.Error("Quest Finish:" + arg);
                }
                bool result = false;
                return(result);
            }
            finally
            {
                this.m_player.CommitAllChanges();
            }
            return(true);
        }
예제 #10
0
        public bool Finish(BaseQuest baseQuest, int selectedItem)
        {
            bool result;

            if (!baseQuest.CanCompleted(this.m_player))
            {
                result = false;
            }
            else
            {
                string        msg            = "";
                string        RewardBuffName = string.Empty;
                QuestInfo     qinfo          = baseQuest.Info;
                QuestDataInfo qdata          = baseQuest.Data;
                this.m_player.BeginAllChanges();
                try
                {
                    if (baseQuest.Finish(this.m_player))
                    {
                        List <QuestAwardInfo> awards = QuestMgr.GetQuestGoods(qinfo);
                        List <ItemInfo>       mainBg = new List <ItemInfo>();
                        List <ItemInfo>       propBg = new List <ItemInfo>();
                        foreach (QuestAwardInfo award in awards)
                        {
                            if (!award.IsSelect || award.RewardItemID == selectedItem)
                            {
                                ItemTemplateInfo temp = ItemMgr.FindItemTemplate(award.RewardItemID);
                                if (temp != null)
                                {
                                    int NeedSex = this.m_player.PlayerCharacter.Sex ? 1 : 2;
                                    if (temp.NeedSex == 0 || temp.NeedSex == NeedSex)
                                    {
                                        int tempCount = award.RewardItemCount;
                                        if (award.IsCount)
                                        {
                                            tempCount *= qdata.RandDobule;
                                            msg        = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", new object[]
                                            {
                                                temp.Name,
                                                tempCount
                                            }) + " ";
                                        }
                                        else
                                        {
                                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardProp", new object[]
                                            {
                                                temp.Name,
                                                award.RewardItemCount
                                            }) + " ";
                                        }
                                        for (int len = 0; len < tempCount; len += temp.MaxCount)
                                        {
                                            int      count = (len + temp.MaxCount > tempCount) ? (tempCount - len) : temp.MaxCount;
                                            ItemInfo item  = ItemInfo.CreateFromTemplate(temp, count, 106);
                                            if (item != null)
                                            {
                                                item.ValidDate       = award.RewardItemValid;
                                                item.IsBinds         = true;
                                                item.StrengthenLevel = award.StrengthenLevel;
                                                item.AttackCompose   = award.AttackCompose;
                                                item.DefendCompose   = award.DefendCompose;
                                                item.AgilityCompose  = award.AgilityCompose;
                                                item.LuckCompose     = award.LuckCompose;
                                                if (temp.BagType == eBageType.PropBag)
                                                {
                                                    propBg.Add(item);
                                                }
                                                else
                                                {
                                                    mainBg.Add(item);
                                                }
                                                if (temp.TemplateID == 11408)
                                                {
                                                    this.m_player.OnPlayerAddItem("Medal", count);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (mainBg.Count > 0 && this.m_player.MainBag.GetEmptyCount() < mainBg.Count)
                        {
                            baseQuest.CancelFinish(this.m_player);
                            this.m_player.Out.SendMessage(eMessageType.ERROR, this.m_player.GetInventoryName(eBageType.MainBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull", new object[0]) + " ");
                            result = false;
                            return(result);
                        }
                        if (propBg.Count > 0 && this.m_player.PropBag.GetEmptyCount() < propBg.Count)
                        {
                            baseQuest.CancelFinish(this.m_player);
                            this.m_player.Out.SendMessage(eMessageType.ERROR, this.m_player.GetInventoryName(eBageType.PropBag) + LanguageMgr.GetTranslation("Game.Server.Quests.BagFull", new object[0]) + " ");
                            result = false;
                            return(result);
                        }
                        foreach (ItemInfo item in mainBg)
                        {
                            //ItemInfo item;
                            if (!this.m_player.MainBag.StackItemToAnother(item))
                            {
                                this.m_player.MainBag.AddItem(item);
                            }
                        }
                        foreach (ItemInfo item in propBg)
                        {
                            //ItemInfo item;
                            if (!this.m_player.PropBag.StackItemToAnother(item))
                            {
                                this.m_player.PropBag.AddItem(item);
                            }
                        }
                        msg = LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Reward", new object[0]) + msg;
                        if (qinfo.RewardBuffID > 0 && qinfo.RewardBuffDate > 0)
                        {
                            ItemTemplateInfo temp = ItemMgr.FindItemTemplate(qinfo.RewardBuffID);
                            if (temp != null)
                            {
                                int            RewardBuffTime = qinfo.RewardBuffDate * qdata.RandDobule;
                                AbstractBuffer buffer         = BufferList.CreateBufferHour(temp, RewardBuffTime);
                                buffer.Start(this.m_player);
                                msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardBuff", new object[]
                                {
                                    temp.Name,
                                    RewardBuffTime
                                }) + " ";
                            }
                        }
                        if (qinfo.RewardGold != 0)
                        {
                            int rewardGold = qinfo.RewardGold * qdata.RandDobule;
                            this.m_player.AddGold(rewardGold);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGold", new object[]
                            {
                                rewardGold
                            }) + " ";
                        }
                        if (qinfo.RewardMoney != 0)
                        {
                            int rewardMoney = qinfo.RewardMoney * qdata.RandDobule;
                            this.m_player.AddMoney(qinfo.RewardMoney * qdata.RandDobule, LogMoneyType.Award, LogMoneyType.Award_Quest);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardMoney", new object[]
                            {
                                rewardMoney
                            }) + " ";
                        }
                        if (qinfo.RewardGP != 0)
                        {
                            int rewardGp = qinfo.RewardGP * qdata.RandDobule;
                            this.m_player.AddGpDirect(rewardGp);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGB1", new object[]
                            {
                                rewardGp
                            }) + " ";
                        }
                        if (qinfo.RewardRiches != 0 && this.m_player.PlayerCharacter.ConsortiaID != 0)
                        {
                            int riches = qinfo.RewardRiches * qdata.RandDobule;
                            this.m_player.AddRichesOffer(riches);
                            using (ConsortiaBussiness db = new ConsortiaBussiness())
                            {
                                db.ConsortiaRichAdd(this.m_player.PlayerCharacter.ConsortiaID, ref riches);
                            }
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardRiches", new object[]
                            {
                                riches
                            }) + " ";
                        }
                        if (qinfo.RewardOffer != 0)
                        {
                            int rewardOffer = qinfo.RewardOffer * qdata.RandDobule;
                            this.m_player.AddOffer(rewardOffer, false);
                            msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardOffer", new object[]
                            {
                                rewardOffer
                            }) + " ";
                        }
                        if (qinfo.RewardGiftToken != 0)
                        {
                            int rewardGiftToken = qinfo.RewardGiftToken * qdata.RandDobule;
                            this.m_player.AddGiftToken(rewardGiftToken);
                            msg += LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", new object[]
                            {
                                rewardGiftToken + " "
                            });
                        }
                        this.m_player.Out.SendMessage(eMessageType.Normal, msg);
                        this.RemoveQuest(baseQuest);
                        this.SetQuestFinish(baseQuest.Info.ID);
                        this.m_player.PlayerCharacter.QuestSite = this.m_states;
                    }
                    this.OnQuestsChanged(baseQuest);
                }
                catch (Exception ex)
                {
                    //if (QuestInventory.log.IsErrorEnabled)
                    {
                        QuestInventory.log.Error("Quest Finish:" + ex);
                    }
                    result = false;
                    return(result);
                }
                finally
                {
                    this.m_player.CommitAllChanges();
                }
                this.m_player.OnPlayerQuestFinish(baseQuest);
                result = true;
            }
            return(result);
        }