public bool GetAnnex(string value, GamePlayer player, ref string msg, ref bool result, ref eMessageType eMsg)
        {
            int itemID = int.Parse(value);

            using (PlayerBussiness playerBussiness = new PlayerBussiness())
            {
                ItemInfo userItemSingle = playerBussiness.GetUserItemSingle(itemID);
                if (userItemSingle != null)
                {
                    if (userItemSingle.TemplateID == 11408)
                    {
                        player.AddMedal(userItemSingle.Count);
                        bool result2 = true;
                        return(result2);
                    }
                    if (player.StackItemToAnother(userItemSingle) || player.AddItem(userItemSingle))
                    {
                        eMsg = eMessageType.Normal;
                        bool result2 = true;
                        return(result2);
                    }
                    eMsg   = eMessageType.ERROR;
                    result = false;
                    msg    = LanguageMgr.GetTranslation(userItemSingle.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("MailGetAttachHandler.NoPlace", new object[0]);
                }
            }
            return(false);
        }
示例#2
0
        public bool GetAnnex(string value, GamePlayer player, ref string msg, ref bool result, ref eMessageType eMsg)
        {
            int gid = int.Parse(value);

            using (PlayerBussiness db = new PlayerBussiness())
            {
                ItemInfo goods = db.GetUserItemSingle(gid);
                if (goods != null)
                {
                    if (goods.TemplateID == 11408)
                    {
                        player.AddMedal(goods.Count);
                        return(true);
                    }
                    else
                    {
                        if (player.AddItem(goods))
                        {
                            eMsg = eMessageType.Normal;
                            return(true);
                        }
                        else
                        {
                            eMsg   = eMessageType.ERROR;
                            result = false;
                            msg    = LanguageMgr.GetTranslation(goods.GetBagName()) + LanguageMgr.GetTranslation("MailGetAttachHandler.NoPlace");
                        }
                    }
                }
            }
            return(false);
        }
示例#3
0
 private void QuestDropItem(AbstractGame game, int copyId, int npcId, bool playResult)
 {
     if (m_player.GetItemCount(m_info.Para1) < m_info.Para2)
     {
         List <ItemInfo> infos = null;
         int             golds = 0, moneys = 0, gifttokens = 0, medal = 0;
         if (game is PVEGame)
         {
             DropInventory.PvEQuestsDrop(npcId, ref infos);
         }
         if (game is PVPGame)
         {
             DropInventory.PvPQuestsDrop(game.RoomType, playResult, ref infos);
         }
         if (infos != null)
         {
             foreach (ItemInfo info in infos)
             {
                 ItemInfo.FindSpecialItemInfo(info, ref golds, ref moneys, ref gifttokens, ref medal);
                 if (info != null)
                 {
                     m_player.TempBag.AddTemplate(info, info.Count);
                 }
             }
             m_player.AddGold(golds);
             m_player.AddGiftToken(gifttokens);
             m_player.AddMoney(moneys);
             m_player.AddMedal(medal);                                                                                                                                     //trminhpc
             LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Drop, m_player.PlayerCharacter.ID, moneys, m_player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", ""); //添加日志
         }
     }
 }
示例#4
0
        private void HandlePlayerAddMedal(GSPacketIn pkg)
        {
            GamePlayer playerById = WorldMgr.GetPlayerById(pkg.ClientID);

            if (playerById != null)
            {
                playerById.AddMedal(pkg.Parameter1);
            }
        }
示例#5
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.RewardItemCount1) + " ";
                                Int32 tempCount = award.RewardItemCount1;
                                if (award.IsCount == true)
                                {
                                    tempCount = tempCount * qdata.RandDobule;
                                }

                                for (int len = 0; len < tempCount; len += temp.MaxCount)
                                {
                                    int      count = len + temp.MaxCount > award.RewardItemCount1 ? award.RewardItemCount1 - 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)
                    {
                        if (item.TemplateID == 11408)//trminhpc
                        {
                            int rewardMedal = item.Count;
                            m_player.AddMedal(rewardMedal);
                            //msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Medal", rewardMedal + " ");
                        }
                        else
                        {
                            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, 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.RewardBindMoney != 0)
                    {
                        int rewardGiftToken = qinfo.RewardBindMoney * qdata.RandDobule;
                        m_player.AddGiftToken(rewardGiftToken);
                        msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.RewardGiftToken", rewardGiftToken + " ");
                    }
                    //if (qinfo.RewardMedal != 0)//trminhpc
                    //{
                    //    int rewardMedal = qinfo.RewardMedal * qdata.RandDobule;
                    //    m_player.AddMedal(rewardMedal);
                    //    msg = msg + LanguageMgr.GetTranslation("Game.Server.Quests.FinishQuest.Medal", rewardMedal + " ");
                    // }
                    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);
        }