public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result2;

            if (player.PlayerCharacter.ConsortiaID == 0)
            {
                result2 = 0;
            }
            else
            {
                int money = packet.ReadInt();
                if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                    result2 = 1;
                }
                else
                {
                    if (money < 1 || player.PlayerCharacter.Money < money)
                    {
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaRichesOfferHandler.NoMoney", new object[0]));
                        result2 = 1;
                    }
                    else
                    {
                        bool   result = false;
                        string msg    = "ConsortiaRichesOfferHandler.Failed";
                        using (ConsortiaBussiness db = new ConsortiaBussiness())
                        {
                            int riches = money * 100;
                            if (db.ConsortiaRichAdd(player.PlayerCharacter.ConsortiaID, ref riches, 5, player.PlayerCharacter.NickName))
                            {
                                result = true;
                                player.PlayerCharacter.RichesOffer += riches;
                                player.RemoveMoney(money, LogMoneyType.Consortia, LogMoneyType.Consortia_Rich);
                                player.OnPlayerAddItem("RichesOffer", riches);
                                msg = "ConsortiaRichesOfferHandler.Successed";
                                GameServer.Instance.LoginServer.SendConsortiaRichesOffer(player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.ID, player.PlayerCharacter.NickName, riches);
                            }
                        }
                        packet.WriteBoolean(result);
                        packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0]));
                        player.Out.SendTCP(packet);
                        result2 = 0;
                    }
                }
            }
            return(result2);
        }
Esempio n. 2
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.ConsortiaID == 0)
            {
                return(0);
            }

            int money = packet.ReadInt();

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return(1);
            }

            if (money < 1 || client.Player.PlayerCharacter.Money < money)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaRichesOfferHandler.NoMoney"));
                return(1);
            }

            bool   result = false;
            string msg    = "ConsortiaRichesOfferHandler.Failed";

            using (ConsortiaBussiness db = new ConsortiaBussiness())
            {
                int riches = money / 2;
                if (db.ConsortiaRichAdd(client.Player.PlayerCharacter.ConsortiaID, ref riches, 5, client.Player.PlayerCharacter.NickName))
                {
                    result = true;
                    client.Player.PlayerCharacter.RichesOffer += riches;
                    //client.Player.SetMoney(-money);

                    client.Player.RemoveMoney(money);
                    LogMgr.LogMoneyAdd(LogMoneyType.Consortia, LogMoneyType.Consortia_Rich, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, 0, 0, (int)eSubConsumerType.Consortia_Riches_Offer, 0, "", "", "");
                    msg = "ConsortiaRichesOfferHandler.Successed";
                    GameServer.Instance.LoginServer.SendConsortiaRichesOffer(client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, riches);
                }
            }
            packet.WriteBoolean(result);
            packet.WriteString(LanguageMgr.GetTranslation(msg));
            client.Out.SendTCP(packet);

            return(0);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }