コード例 #1
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;
         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);
                 if (info != null)
                 {
                     m_player.TempBag.AddTemplate(info, info.Count);
                 }
             }
             m_player.AddGold(golds);
             m_player.AddGiftToken(gifttokens);
             m_player.AddMoney(moneys);
             LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Drop, m_player.PlayerCharacter.ID, moneys, m_player.PlayerCharacter.Money, 0, 0, 0, "", "", "");//添加日志
         }
     }
 }
コード例 #2
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int count = packet.ReadInt();
            int money = 200;
            int result;

            if (count < 0)
            {
                result = 0;
            }
            else
            {
                money *= count;
                int gold = 10000 * count;
                if (player.PlayerCharacter.Money >= money)
                {
                    if (player.RemoveMoney(money, LogMoneyType.Shop, LogMoneyType.MoneyToGold) == money)
                    {
                        player.AddGold(gold);
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ExchangeMoneyToGoldHandler.success", new object[]
                        {
                            gold
                        }));
                    }
                }
                else
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ExchangeMoneyToGoldHandler.nomoney", new object[0]));
                }
                result = 0;
            }
            return(result);
        }
コード例 #3
0
        private void HandlePlayerAddGold(GSPacketIn pkg)
        {
            GamePlayer playerById = WorldMgr.GetPlayerById(pkg.ClientID);

            if (playerById != null)
            {
                playerById.AddGold(pkg.Parameter1);
            }
        }
コード例 #4
0
        private void HandlePlayerAddGold(GSPacketIn pkg)
        {
            GamePlayer player = WorldMgr.GetPlayerById(pkg.ClientID);
            int        check  = pkg.ReadInt();

            if (player != null && check == pkg.Parameter1)
            {
                player.AddGold(pkg.Parameter1);
            }
        }
コード例 #5
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int        gold          = 0;
            int        money         = 0;
            int        offer         = 0;
            int        gifttoken     = 0;
            int        type          = 1;
            List <int> needitemsinfo = new List <int>();
            int        index         = packet.ReadInt();
            int        GoodsID       = packet.ReadInt();
            ItemInfo   item          = player.FightBag.GetItemAt(index);

            if (item != null)
            {
                player.FightBag.RemoveItem(item, eItemRemoveType.Sell);
                ShopItemInfo shopitem = ShopMgr.GetShopItemInfoById(GoodsID);
                needitemsinfo = ShopMgr.GetShopItemBuyConditions(shopitem, type, ref gold, ref money, ref offer, ref gifttoken);
                player.AddGold(gold);
            }
            return(0);
        }
コード例 #6
0
    public override void OnSelect( )
    {
        AudioClip clip = LoadManager.Instance.GetSFXData(SFXType.Coin).clip;

        Audio.play(clip, 1F, 0F, 1F);

        BuildingClickRequest request = new BuildingClickRequest( );

        request.index       = (int)info.index;
        request.clickAction = ClickAction.MainBuildingTakeGold;
        request.value       = 1;
        request.SendPacket(false);

        var sheet  = TableManager.Instance.BuildingTable.MainBuildingInfoSheet;
        var record = BaseTable.Get(sheet, "index", (int)info.index);
        int value  = info.LV * (int)record["nextLV"];

        GamePlayer gamePlayer = GameManager.Instance.LocalPlayer;

        gamePlayer.AddGold(ResourceType.Gold, new BigInteger(value));
        GameManager.Instance.GameMode.CurrentPage.OnUpdate( );
    }
コード例 #7
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);
        }
コード例 #8
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int             bagType = (int)packet.ReadByte();
            int             place   = packet.ReadInt();
            PlayerInventory arkBag  = player.GetInventory((eBageType)bagType);
            ItemInfo        goods   = arkBag.GetItemAt(place);
            string          full    = "";
            List <ItemInfo> infos   = new List <ItemInfo>();
            int             result;

            if (goods != null && goods.IsValidItem() && goods.Template.CategoryID == 11 && goods.Template.Property1 == 6 && player.PlayerCharacter.Grade >= goods.Template.NeedLevel)
            {
                int   money     = 0;
                int   gold      = 0;
                int   giftToken = 0;
                int[] bags      = new int[3];
                int   gp        = 0;
                this.OpenUpItem(goods.Template.Data, bags, infos, ref gold, ref money, ref giftToken, ref gp);
                if (infos.Count == 0 && gold == 0 && money == 0 && giftToken == 0 && gp == 0)
                {
                    result = 0;
                    return(result);
                }
                bags[goods.GetBagType()]--;
                if (player.RemoveItem(goods, eItemRemoveType.Use))
                {
                    player.OnUsingItem(goods.Template.TemplateID);
                    StringBuilder notice = new StringBuilder();
                    StringBuilder msg    = new StringBuilder();
                    msg.Append(LanguageMgr.GetTranslation("OpenUpArkHandler.Start", new object[0]));
                    if (money != 0)
                    {
                        msg.Append(money + LanguageMgr.GetTranslation("OpenUpArkHandler.Money", new object[0]));
                        player.AddMoney(money, LogMoneyType.Box, LogMoneyType.Box_Open);
                    }
                    if (gold != 0)
                    {
                        msg.Append(gold + LanguageMgr.GetTranslation("OpenUpArkHandler.Gold", new object[0]));
                        player.AddGold(gold);
                    }
                    if (giftToken != 0)
                    {
                        msg.Append(giftToken + LanguageMgr.GetTranslation("OpenUpArkHandler.GiftToken", new object[0]));
                        player.AddGiftToken(giftToken);
                    }
                    if (gp != 0)
                    {
                        msg.Append(gp + LanguageMgr.GetTranslation("OpenUpArkHandler.Gp", new object[0]));
                        player.AddGpDirect(gp);
                    }
                    StringBuilder msga = new StringBuilder();
                    foreach (ItemInfo info in infos)
                    {
                        msg.Append(info.Template.Name + "x" + info.Count.ToString() + ",");
                        List <ItemInfo> list = ItemMgr.SpiltGoodsMaxCount(info);
                        List <ItemInfo> last = new List <ItemInfo>();
                        foreach (ItemInfo it in list)
                        {
                            if (!player.AddItem(it))
                            {
                                last.Add(it);
                            }
                        }
                        if (last.Count > 0)
                        {
                            player.SendItemsToMail(last, LanguageMgr.GetTranslation("OpenUpArkHandler.Content1", new object[0]) + info.Template.Name + LanguageMgr.GetTranslation("OpenUpArkHandler.Content2", new object[0]), LanguageMgr.GetTranslation("OpenUpArkHandler.Title", new object[0]) + info.Template.Name + "]", eMailType.Common);
                            full = LanguageMgr.GetTranslation("OpenUpArkHandler.Mail", new object[0]);
                        }
                    }
                    foreach (ItemInfo info in infos)
                    {
                        player.SendItemNotice(info, goods.Template.Name, 3);
                    }
                    msg.Remove(msg.Length - 1, 1);
                    msg.Append(".");
                    player.Out.SendMessage(eMessageType.Normal, full + msg.ToString());
                    if (!string.IsNullOrEmpty(full))
                    {
                        player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                    }
                }
            }
            result = 1;
            return(result);
        }
コード例 #9
0
        //0表示男女,1男2女
        //type 1表示物品,2表示金币,3表示点券,4表示经验,5表示功勋,6表示BUFF
        public static bool AddDailyAward(GamePlayer player)
        {
            if (DateTime.Now.Date == player.PlayerCharacter.LastAward.Date)
            {
                return(false);
            }

            //if (player.PlayerCharacter.DayLoginCount > 0)
            //    return false;

            player.PlayerCharacter.DayLoginCount++;
            player.PlayerCharacter.LastAward = DateTime.Now;
            DailyAwardInfo[] infos = GetAllAwardInfo();
            StringBuilder    msg   = new StringBuilder();
            string           full  = string.Empty;
            bool             has   = false;

            foreach (DailyAwardInfo info in infos)
            {
                if (info.Sex != 0 && (player.PlayerCharacter.Sex ? 1 : 2) != info.Sex)
                {
                    continue;
                }

                has = true;
                switch (info.Type)
                {
                case 1:
                    ItemTemplateInfo itemTemplateInfo = Bussiness.Managers.ItemMgr.FindItemTemplate(info.TemplateID);
                    if (itemTemplateInfo != null)
                    {
                        int itemCount = info.Count;
                        for (int len = 0; len < itemCount; len += itemTemplateInfo.MaxCount)
                        {
                            int      count = len + itemTemplateInfo.MaxCount > itemCount ? itemCount - len : itemTemplateInfo.MaxCount;
                            ItemInfo item  = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, (int)ItemAddType.DailyAward);
                            item.ValidDate = info.ValidDate;
                            item.IsBinds   = info.IsBinds;

                            //if (player.AddItem(item, Game.Server.Statics.ItemAddType.DailyAward, item.GetBagType()) == -1)
                            if (!player.AddTemplate(item, item.Template.BagType, item.Count))
                            {
                                using (PlayerBussiness db = new PlayerBussiness())
                                {
                                    item.UserID = 0;
                                    db.AddGoods(item);

                                    MailInfo message = new MailInfo();
                                    message.Annex1     = item.ItemID.ToString();
                                    message.Content    = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Content", item.Template.Name);
                                    message.Gold       = 0;
                                    message.Money      = 0;
                                    message.Receiver   = player.PlayerCharacter.NickName;
                                    message.ReceiverID = player.PlayerCharacter.ID;
                                    message.Sender     = message.Receiver;
                                    message.SenderID   = message.ReceiverID;
                                    message.Title      = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Title", item.Template.Name);
                                    message.Type       = (int)eMailType.DailyAward;
                                    db.SendMail(message);

                                    full = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Mail");
                                }
                            }
                        }
                    }
                    break;

                case 2:
                    player.AddGold(info.Count);
                    break;

                case 3:
                    player.AddMoney(info.Count);
                    LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Daily, player.PlayerCharacter.ID, info.Count, player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                    break;

                case 4:
                    player.AddGP(info.Count);
                    break;

                case 5:
                    player.AddOffer(info.Count, false);
                    break;

                case 6:
                    ItemTemplateInfo template = Bussiness.Managers.ItemMgr.FindItemTemplate(info.TemplateID);
                    if (template != null)
                    {
                        AbstractBuffer buffer = BufferList.CreateBufferHour(template, info.ValidDate);
                        buffer.Start(player);
                    }
                    break;
                }
            }


            if (has)
            {
                //player.Out.SendMessage(eMessageType.DailyAward, full + msg.ToString());

                if (!string.IsNullOrEmpty(full))
                {
                    player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                }
            }

            return(true);
        }
コード例 #10
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int          id    = packet.ReadInt();
            byte         type  = packet.ReadByte();
            List <int>   types = new List <int>();
            string       msg   = "";// LanguageMgr.GetTranslation("MailGetAttachHandler.Falied");
            eMessageType eMsg  = eMessageType.Normal;

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

            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();

            using (PlayerBussiness db = new PlayerBussiness())
            {
                MailInfo mes = db.GetMailSingle(client.Player.PlayerCharacter.ID, id);
                if (mes != null)
                {
                    bool       result   = true;
                    int        oldMoney = mes.Money;
                    GamePlayer player   = Managers.WorldMgr.GetPlayerById(mes.ReceiverID);

                    if (mes.Type > 100 && mes.Money > client.Player.PlayerCharacter.Money)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MailGetAttachHandler.NoMoney"));
                        return(0);
                    }

                    if (!mes.IsRead)
                    {
                        mes.IsRead    = true;
                        mes.ValidDate = 3 * 24;
                        mes.SendTime  = DateTime.Now;
                    }
                    if (result && (type == 0 || type == 1) && !string.IsNullOrEmpty(mes.Annex1))
                    {
                        if (GetAnnex(mes.Annex1, client.Player, ref msg, ref result, ref eMsg))
                        {
                            types.Add(1);
                            mes.Annex1 = null;
                        }
                    }

                    if (result && (type == 0 || type == 2) && !string.IsNullOrEmpty(mes.Annex2))
                    {
                        if (GetAnnex(mes.Annex2, client.Player, ref msg, ref result, ref eMsg))
                        {
                            types.Add(2);
                            mes.Annex2 = null;
                        }
                    }

                    if (result && (type == 0 || type == 3) && !string.IsNullOrEmpty(mes.Annex3))
                    {
                        if (GetAnnex(mes.Annex3, client.Player, ref msg, ref result, ref eMsg))
                        {
                            types.Add(3);
                            mes.Annex3 = null;
                        }
                    }

                    if (result && (type == 0 || type == 4) && !string.IsNullOrEmpty(mes.Annex4))
                    {
                        if (GetAnnex(mes.Annex4, client.Player, ref msg, ref result, ref eMsg))
                        {
                            types.Add(4);
                            mes.Annex4 = null;
                        }
                    }

                    if (result && (type == 0 || type == 5) && !string.IsNullOrEmpty(mes.Annex5))
                    {
                        if (GetAnnex(mes.Annex5, client.Player, ref msg, ref result, ref eMsg))
                        {
                            types.Add(5);
                            mes.Annex5 = null;
                        }
                    }

                    if ((type == 0 || type == 6) && mes.Gold > 0)
                    {
                        types.Add(6);
                        player.AddGold(mes.Gold);
                        mes.Gold = 0;
                    }

                    if ((type == 0 || type == 7) && mes.Type < 100 && mes.Money > 0)
                    {
                        types.Add(7);
                        player.AddMoney(mes.Money);
                        LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Money, player.PlayerCharacter.ID, mes.Money, player.PlayerCharacter.Money, 0, 0, 0, "", "", "");//添加日志
                        mes.Money = 0;
                    }

                    if (mes.Type > 100 && mes.Money > 0)
                    {
                        mes.Money = 0;
                        msg       = LanguageMgr.GetTranslation("MailGetAttachHandler.Deduct") + (string.IsNullOrEmpty(msg) ? LanguageMgr.GetTranslation("MailGetAttachHandler.Success") : msg);
                    }

                    if (db.UpdateMail(mes, oldMoney))
                    {
                        if (mes.Type > 100 && oldMoney > 0)
                        {
                            player.RemoveMoney(oldMoney);
                            LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Pay, client.Player.PlayerCharacter.ID, oldMoney, client.Player.PlayerCharacter.Money, 0, 0, 0, "", "", "");
                            client.Out.SendMailResponse(mes.SenderID, eMailRespose.Receiver);
                            client.Out.SendMailResponse(mes.ReceiverID, eMailRespose.Send);
                        }
                    }

                    //pkg.WriteBoolean(result);
                    pkg.WriteInt(id);
                    pkg.WriteInt(types.Count);
                    foreach (int i in types)
                    {
                        pkg.WriteInt(i);
                    }

                    client.Out.SendTCP(pkg);

                    client.Out.SendMessage(eMsg, string.IsNullOrEmpty(msg) ? LanguageMgr.GetTranslation("MailGetAttachHandler.Success") : msg);
                }
                else
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MailGetAttachHandler.Falied"));
                }
            }

            return(0);
        }
コード例 #11
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int     operate = packet.ReadInt();
            BoxInfo box     = null;
            int     result2;

            if (operate == 0)
            {
                int time       = packet.ReadInt();
                int onlineTime = (int)DateTime.Now.Subtract(player.BoxBeginTime).TotalMinutes;
                box = BoxMgr.FindTemplateByCondition(0, player.PlayerCharacter.Grade, player.PlayerCharacter.BoxProgression);
                if (box != null && onlineTime >= time && box.Condition == time)
                {
                    using (ProduceBussiness db = new ProduceBussiness())
                    {
                        db.UpdateBoxProgression(player.PlayerCharacter.ID, player.PlayerCharacter.BoxProgression, player.PlayerCharacter.GetBoxLevel, player.PlayerCharacter.AddGPLastDate, DateTime.Now, time);
                        player.PlayerCharacter.AlreadyGetBox = time;
                        player.PlayerCharacter.BoxGetDate    = DateTime.Now;
                    }
                }
                result2 = 0;
            }
            else
            {
                int        type = packet.ReadInt();
                GSPacketIn pkg  = packet.Clone();
                pkg.ClearContext();
                bool updatedb = false;
                bool result   = true;
                if (type == 0)
                {
                    int onlineTime = (int)DateTime.Now.Subtract(player.BoxBeginTime).TotalMinutes;
                    box = BoxMgr.FindTemplateByCondition(0, player.PlayerCharacter.Grade, player.PlayerCharacter.BoxProgression);
                    if (box != null && (onlineTime >= box.Condition || player.PlayerCharacter.AlreadyGetBox == box.Condition))
                    {
                        using (ProduceBussiness db = new ProduceBussiness())
                        {
                            if (db.UpdateBoxProgression(player.PlayerCharacter.ID, box.Condition, player.PlayerCharacter.GetBoxLevel, player.PlayerCharacter.AddGPLastDate, DateTime.Now.Date, 0))
                            {
                                player.PlayerCharacter.BoxProgression = box.Condition;
                                player.PlayerCharacter.BoxGetDate     = DateTime.Now.Date;
                                player.PlayerCharacter.AlreadyGetBox  = 0;
                                updatedb = true;
                            }
                        }
                    }
                }
                else
                {
                    box = BoxMgr.FindTemplateByCondition(1, player.PlayerCharacter.GetBoxLevel, Convert.ToInt32(player.PlayerCharacter.Sex));
                    if (box != null && player.PlayerCharacter.Grade >= box.Level)
                    {
                        using (ProduceBussiness db = new ProduceBussiness())
                        {
                            if (db.UpdateBoxProgression(player.PlayerCharacter.ID, player.PlayerCharacter.BoxProgression, box.Level, player.PlayerCharacter.AddGPLastDate, player.PlayerCharacter.BoxGetDate, 0))
                            {
                                player.PlayerCharacter.GetBoxLevel = box.Level;
                                updatedb = true;
                            }
                        }
                    }
                }
                if (updatedb)
                {
                    if (box != null)
                    {
                        List <ItemInfo> mailList  = new List <ItemInfo>();
                        List <ItemInfo> items     = new List <ItemInfo>();
                        int             gold      = 0;
                        int             money     = 0;
                        int             giftToken = 0;
                        int             gp        = 0;
                        ItemBoxMgr.CreateItemBox(Convert.ToInt32(box.Template), items, ref gold, ref money, ref giftToken, ref gp);
                        if (gold > 0)
                        {
                            player.AddGold(gold);
                        }
                        if (money > 0)
                        {
                            player.AddMoney(money, LogMoneyType.Award, LogMoneyType.Award);
                        }
                        if (giftToken > 0)
                        {
                            player.AddGiftToken(giftToken);
                        }
                        if (gp > 0)
                        {
                            player.AddGP(gp);
                        }
                        foreach (ItemInfo item in items)
                        {
                            item.RemoveType = 120;
                            if (!player.AddItem(item))
                            {
                                mailList.Add(item);
                            }
                        }
                        if (type == 0)
                        {
                            player.BoxBeginTime = DateTime.Now;
                            box = BoxMgr.FindTemplateByCondition(0, player.PlayerCharacter.Grade, player.PlayerCharacter.BoxProgression);
                            if (box != null)
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.success", new object[]
                                {
                                    box.Condition
                                }));
                            }
                            else
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.todayOver", new object[0]));
                            }
                        }
                        else
                        {
                            box = BoxMgr.FindTemplateByCondition(1, player.PlayerCharacter.GetBoxLevel, Convert.ToInt32(player.PlayerCharacter.Sex));
                            if (box != null)
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.level", new object[]
                                {
                                    box.Level
                                }));
                            }
                            else
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.over", new object[0]));
                            }
                        }
                        if (mailList.Count > 0)
                        {
                            if (player.SendItemsToMail(mailList, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.mail", new object[0]), LanguageMgr.GetTranslation("UserGetTimeBoxHandler.title", new object[0]), eMailType.OpenUpArk))
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBixHandler..full", new object[0]));
                                result = true;
                                player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                            }
                        }
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserGetTimeBoxHandler.fail", new object[0]));
                }
                if (type == 0)
                {
                    pkg.WriteBoolean(result);
                    pkg.WriteInt(player.PlayerCharacter.BoxProgression);
                    player.SendTCP(pkg);
                }
                result2 = 0;
            }
            return(result2);
        }
コード例 #12
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result2;

            if (player.PlayerState != ePlayerState.Playing)
            {
                result2 = 0;
            }
            else
            {
                if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                    result2 = 0;
                }
                else
                {
                    int        mailId      = packet.ReadInt();
                    byte       attachIndex = packet.ReadByte();
                    GSPacketIn pkg         = packet.Clone();
                    pkg.ClearContext();
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        MailInfo mes = db.GetMailSingle(player.PlayerCharacter.ID, mailId);
                        if (mes != null && mes.ReceiverID == player.PlayerId)
                        {
                            List <int>   getIndexes = new List <int>();
                            string       msg        = "";
                            eMessageType eMsg       = eMessageType.Normal;
                            bool         result     = true;
                            int          oldMoney   = mes.Money;
                            if (mes.Type > 100 && mes.Money > player.PlayerCharacter.Money)
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MailGetAttachHandler.NoMoney", new object[0]));
                                result2 = 0;
                                return(result2);
                            }
                            if (!mes.IsRead)
                            {
                                mes.IsRead    = true;
                                mes.ValidDate = 72;
                                mes.SendTime  = DateTime.Now;
                            }
                            if (result && (attachIndex == 0 || attachIndex == 1) && !string.IsNullOrEmpty(mes.Annex1))
                            {
                                result = this.GetAnnex(db, mes.Annex1, player, ref msg, ref eMsg);
                                if (result)
                                {
                                    getIndexes.Add(1);
                                    mes.Annex1 = null;
                                }
                            }
                            if (result && (attachIndex == 0 || attachIndex == 2) && !string.IsNullOrEmpty(mes.Annex2))
                            {
                                result = this.GetAnnex(db, mes.Annex2, player, ref msg, ref eMsg);
                                if (result)
                                {
                                    getIndexes.Add(2);
                                    mes.Annex2 = null;
                                }
                            }
                            if (result && (attachIndex == 0 || attachIndex == 3) && !string.IsNullOrEmpty(mes.Annex3))
                            {
                                result = this.GetAnnex(db, mes.Annex3, player, ref msg, ref eMsg);
                                if (result)
                                {
                                    getIndexes.Add(3);
                                    mes.Annex3 = null;
                                }
                            }
                            if (result && (attachIndex == 0 || attachIndex == 4) && !string.IsNullOrEmpty(mes.Annex4))
                            {
                                result = this.GetAnnex(db, mes.Annex4, player, ref msg, ref eMsg);
                                if (result)
                                {
                                    getIndexes.Add(4);
                                    mes.Annex4 = null;
                                }
                            }
                            if (result && (attachIndex == 0 || attachIndex == 5) && !string.IsNullOrEmpty(mes.Annex5))
                            {
                                result = this.GetAnnex(db, mes.Annex5, player, ref msg, ref eMsg);
                                if (result)
                                {
                                    getIndexes.Add(5);
                                    mes.Annex5 = null;
                                }
                            }
                            if ((attachIndex == 0 || attachIndex == 6) && mes.Gold > 0)
                            {
                                getIndexes.Add(6);
                                player.AddGold(mes.Gold);
                                mes.Gold = 0;
                            }
                            if ((attachIndex == 0 || attachIndex == 7) && mes.Type < 100 && mes.Money > 0)
                            {
                                int money = player.PlayerCharacter.Money;
                                getIndexes.Add(7);
                                player.AddMoney(mes.Money, LogMoneyType.Mail, LogMoneyType.Mail_Money);
                                if (player.PlayerCharacter.Money - money == mes.Money)
                                {
                                    player.SaveIntoDatabase();
                                    mes.Money = 0;
                                }
                            }
                            if ((attachIndex == 0 || attachIndex == 8) && mes.GiftToken > 0)
                            {
                                getIndexes.Add(8);
                                player.AddGiftToken(mes.GiftToken);
                                mes.GiftToken = 0;
                            }
                            if (mes.Type > 100 && mes.Money > 0)
                            {
                                mes.Money = 0;
                                msg       = LanguageMgr.GetTranslation("MailGetAttachHandler.Deduct", new object[0]) + (string.IsNullOrEmpty(msg) ? LanguageMgr.GetTranslation("MailGetAttachHandler.Success", new object[0]) : msg);
                            }
                            if (db.UpdateMail(mes, oldMoney))
                            {
                                if (mes.Type > 100 && oldMoney > 0)
                                {
                                    player.RemoveMoney(oldMoney, LogMoneyType.Mail, LogMoneyType.Mail_Pay);
                                    player.Out.SendMailResponse(mes.SenderID, eMailRespose.Receiver);
                                    player.Out.SendMailResponse(mes.ReceiverID, eMailRespose.Send);
                                }
                            }
                            pkg.WriteInt(mailId);
                            pkg.WriteInt(getIndexes.Count);
                            foreach (int i in getIndexes)
                            {
                                pkg.WriteInt(i);
                            }
                            player.Out.SendTCP(pkg);
                            player.Out.SendMessage(eMsg, string.IsNullOrEmpty(msg) ? LanguageMgr.GetTranslation("MailGetAttachHandler.Success", new object[0]) : msg);
                        }
                        else
                        {
                            player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MailGetAttachHandler.error", new object[0]));
                            MailGetAttachHandler.log.ErrorFormat("User want to get attachment failed: userid :{0}  mailId:{1} attachIndex:{2}", player.PlayerId, mailId, attachIndex);
                        }
                    }
                    result2 = 0;
                }
            }
            return(result2);
        }
コード例 #13
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int          num  = packet.ReadInt();
            byte         b    = packet.ReadByte();
            List <int>   list = new List <int>();
            string       text = "";
            eMessageType type = eMessageType.Normal;

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(0);
            }
            GSPacketIn gSPacketIn = new GSPacketIn(113, client.Player.PlayerCharacter.ID);

            using (PlayerBussiness playerBussiness = new PlayerBussiness())
            {
                MailInfo mailSingle = playerBussiness.GetMailSingle(client.Player.PlayerCharacter.ID, num);
                if (mailSingle != null)
                {
                    bool       flag       = true;
                    int        money      = mailSingle.Money;
                    GamePlayer playerById = WorldMgr.GetPlayerById(mailSingle.ReceiverID);
                    if (mailSingle.Type > 100 && mailSingle.Money > client.Player.PlayerCharacter.Money)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MailGetAttachHandler.NoMoney", new object[0]));
                        return(0);
                    }
                    if (!mailSingle.IsRead)
                    {
                        mailSingle.IsRead    = true;
                        mailSingle.ValidDate = 72;
                        mailSingle.SendTime  = DateTime.Now;
                    }
                    if (flag && (b == 0 || b == 1) && !string.IsNullOrEmpty(mailSingle.Annex1) && this.GetAnnex(mailSingle.Annex1, client.Player, ref text, ref flag, ref type))
                    {
                        list.Add(1);
                        mailSingle.Annex1 = null;
                    }
                    if (flag && (b == 0 || b == 2) && !string.IsNullOrEmpty(mailSingle.Annex2) && this.GetAnnex(mailSingle.Annex2, client.Player, ref text, ref flag, ref type))
                    {
                        list.Add(2);
                        mailSingle.Annex2 = null;
                    }
                    if (flag && (b == 0 || b == 3) && !string.IsNullOrEmpty(mailSingle.Annex3) && this.GetAnnex(mailSingle.Annex3, client.Player, ref text, ref flag, ref type))
                    {
                        list.Add(3);
                        mailSingle.Annex3 = null;
                    }
                    if (flag && (b == 0 || b == 4) && !string.IsNullOrEmpty(mailSingle.Annex4) && this.GetAnnex(mailSingle.Annex4, client.Player, ref text, ref flag, ref type))
                    {
                        list.Add(4);
                        mailSingle.Annex4 = null;
                    }
                    if (flag && (b == 0 || b == 5) && !string.IsNullOrEmpty(mailSingle.Annex5) && this.GetAnnex(mailSingle.Annex5, client.Player, ref text, ref flag, ref type))
                    {
                        list.Add(5);
                        mailSingle.Annex5 = null;
                    }
                    if ((b == 0 || b == 6) && mailSingle.Gold > 0)
                    {
                        list.Add(6);
                        playerById.AddGold(mailSingle.Gold);
                        mailSingle.Gold = 0;
                    }
                    if ((b == 0 || b == 7) && mailSingle.Type < 100 && mailSingle.Money > 0)
                    {
                        list.Add(7);
                        playerById.AddMoney(mailSingle.Money);
                        LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Money, playerById.PlayerCharacter.ID, mailSingle.Money, playerById.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                        mailSingle.Money = 0;
                    }
                    if (mailSingle.Type > 100 && mailSingle.GiftToken > 0)
                    {
                        list.Add(8);
                        playerById.AddGiftToken(mailSingle.GiftToken);
                        mailSingle.GiftToken = 0;
                    }
                    if (mailSingle.Type > 100 && mailSingle.Money > 0)
                    {
                        mailSingle.Money = 0;
                        text             = LanguageMgr.GetTranslation("MailGetAttachHandler.Deduct", new object[0]) + (string.IsNullOrEmpty(text) ? LanguageMgr.GetTranslation("MailGetAttachHandler.Success", new object[0]) : text);
                    }
                    if (playerBussiness.UpdateMail(mailSingle, money) && mailSingle.Type > 100 && money > 0)
                    {
                        playerById.RemoveMoney(money);
                        LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Pay, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                        client.Out.SendMailResponse(mailSingle.SenderID, eMailRespose.Receiver);
                        client.Out.SendMailResponse(mailSingle.ReceiverID, eMailRespose.Send);
                    }
                    gSPacketIn.WriteInt(num);
                    gSPacketIn.WriteInt(list.Count);
                    foreach (int current in list)
                    {
                        gSPacketIn.WriteInt(current);
                    }
                    client.Out.SendTCP(gSPacketIn);
                    client.Out.SendMessage(type, string.IsNullOrEmpty(text) ? LanguageMgr.GetTranslation("MailGetAttachHandler.Success", new object[0]) : text);
                }
                else
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("MailGetAttachHandler.Falied", new object[0]));
                }
            }
            return(0);
        }