Example #1
0
        private void AddSpaGpByMin(GamePlayer player)
        {
            int priGrade = player.PlayerCharacter.Grade;
            int spaGpAddTemp;

            if (this.Spa_Room_Info.RoomType == 1)
            {
                spaGpAddTemp  = LevelMgr.GetSpaGoldGP(priGrade);
                spaGpAddTemp /= 60;
            }
            else
            {
                spaGpAddTemp  = LevelMgr.GetSpaMoneyGP(priGrade);
                spaGpAddTemp /= 60;
            }
            if (player.PlayerCharacter.Grade >= 40)
            {
                spaGpAddTemp = 0;
            }
            player.SpaRoomAddGPTotal += spaGpAddTemp;
            if (spaGpAddTemp >= 0)
            {
                player.AddGP(spaGpAddTemp);
            }
            else
            {
                player.AddGP(0);
            }
        }
Example #2
0
        private void HandlePlayerAddGP(GSPacketIn pkg)
        {
            GamePlayer playerById = WorldMgr.GetPlayerById(pkg.ClientID);

            if (playerById != null)
            {
                playerById.AddGP(pkg.Parameter1);
            }
        }
        private void HandlePlayerAddGP(GSPacketIn pkg)
        {
            GamePlayer player = WorldMgr.GetPlayerById(pkg.ClientID);
            int        check  = pkg.ReadInt();

            if (player != null && check == pkg.Parameter1)
            {
                player.AddGP(pkg.Parameter1);
            }
        }
Example #4
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result;

            if (string.IsNullOrEmpty(player.PlayerCharacter.CheckCode))
            {
                result = 1;
            }
            else
            {
                string check = packet.ReadString();
                if (player.PlayerCharacter.CheckCode.ToLower() == check.ToLower())
                {
                    int GP = LevelMgr.GetGP(player.PlayerCharacter.Grade);
                    if (player.PlayerCharacter.ChatCount != 5)
                    {
                        player.AddGP(LevelMgr.IncreaseGP(player.PlayerCharacter.Grade, player.PlayerCharacter.GP));
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("CheckCodeHandler.Msg1", new object[]
                        {
                            player.PlayerCharacter.Grade * 12
                        }));
                    }
                    player.PlayerCharacter.CheckCount = 0;
                    player.PlayerCharacter.ChatCount  = 0;
                    packet.ClearContext();
                    packet.WriteByte(1);
                    packet.WriteBoolean(false);
                    player.Out.SendTCP(packet);
                }
                else
                {
                    if (player.PlayerCharacter.CheckError < 9)
                    {
                        player.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("CheckCodeHandler.Msg3", new object[0]));
                        player.PlayerCharacter.CheckError++;
                        player.Out.SendCheckCode();
                    }
                    else
                    {
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("CheckCodeHandler.Msg3", new object[0]));
                        player.Disconnect();
                    }
                }
                result = 0;
            }
            return(result);
        }
Example #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.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);
        }
Example #6
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);
        }
Example #7
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);
        }