Exemplo n.º 1
0
 public TodayAwardInfo AddAward(TodayAwardInfo info, int count = 1)
 {
     this.Exp            += info.Exp * (double)count;
     this.GoldBind       += info.GoldBind * (double)count;
     this.MoJing         += info.MoJing * (double)count;
     this.ChengJiu       += info.ChengJiu * (double)count;
     this.ShengWang      += info.ShengWang * (double)count;
     this.ZhanGong       += info.ZhanGong * (double)count;
     this.DiamondBind    += info.DiamondBind * (double)count;
     this.XingHun        += info.XingHun * (double)count;
     this.YuanSuFenMo    += info.YuanSuFenMo * (double)count;
     this.ShouHuDianShu  += info.ShouHuDianShu * (double)count;
     this.ZaiZao         += info.ZaiZao * (double)count;
     this.LingJing       += info.LingJing * (double)count;
     this.RongYao        += info.RongYao * (double)count;
     this.ExtDiamondBind += info.ExtDiamondBind;
     return(this);
 }
Exemplo n.º 2
0
        public static void InitConfig()
        {
            string   fileName = Global.GameResPath("Config/JianFu.xml");
            XElement xml      = CheckHelper.LoadXml(fileName, true);

            if (null != xml)
            {
                try
                {
                    List <TodayInfo>       todayInfoList = new List <TodayInfo>();
                    IEnumerable <XElement> xmlItems      = xml.Elements();
                    foreach (XElement xmlItem in xmlItems)
                    {
                        if (xmlItem != null)
                        {
                            TodayInfo info = new TodayInfo();
                            info.ID        = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "ID", "0"));
                            info.Type      = info.ID / 100;
                            info.Name      = Global.GetDefAttributeStr(xmlItem, "Name", "0");
                            info.FuBenID   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "FuBenID", "0"));
                            info.HuoDongID = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "HuoDongID", "0"));
                            info.LevelMin  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MinZhuanSheng", "0")) * 100 + Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MinLevel", "0"));
                            info.LevelMax  = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MaxZhuanSheng", "0")) * 100 + Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MaxLevel", "0"));
                            info.TaskMin   = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "MinTasks", "0"));
                            info.NumMax    = Convert.ToInt32(Global.GetDefAttributeStr(xmlItem, "Num", "0"));
                            TodayAwardInfo awardInfo = new TodayAwardInfo();
                            awardInfo.Exp            = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "Exp", "0"));
                            awardInfo.GoldBind       = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "BandJinBi", "0"));
                            awardInfo.MoJing         = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "MoJing", "0"));
                            awardInfo.ChengJiu       = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "ChengJiu", "0"));
                            awardInfo.ShengWang      = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "ShengWang", "0"));
                            awardInfo.ZhanGong       = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "ZhanGong", "0"));
                            awardInfo.DiamondBind    = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "BandZuanShi", "0"));
                            awardInfo.XingHun        = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "XingHun", "0"));
                            awardInfo.YuanSuFenMo    = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "YuanSuFenMo", "0"));
                            awardInfo.ShouHuDianShu  = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "ShouHuDianShu", "0"));
                            awardInfo.ZaiZao         = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "ZaiZao", "0"));
                            awardInfo.LingJing       = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "LingJing", "0"));
                            awardInfo.RongYao        = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "RongYao", "0"));
                            awardInfo.ExtDiamondBind = (double)Convert.ToInt64(Global.GetDefAttributeStr(xmlItem, "ExtraBandZuanShi", "0"));
                            string goods = Global.GetDefAttributeStr(xmlItem, "Goods", "0");
                            if (!string.IsNullOrEmpty(goods) && !goods.Equals("0"))
                            {
                                string[] fields = goods.Split(new char[]
                                {
                                    '|'
                                });
                                awardInfo.GoodsList = GoodsHelper.ParseGoodsDataList(fields, fileName);
                            }
                            info.AwardInfo = awardInfo;
                            todayInfoList.Add(info);
                        }
                    }
                    TodayManager._todayInfoList = todayInfoList;
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载[{0}]时出错!!!", fileName), null, true);
                }
            }
        }
Exemplo n.º 3
0
        private string TodayAward(GameClient client, bool isAll, int todayID)
        {
            string result = "{0}:{1}";
            string result2;

            if (!this.IsGongNengOpened())
            {
                result2 = string.Format(result, -11, 0);
            }
            else
            {
                TodayInfo oneInfo = null;
                if (!isAll)
                {
                    oneInfo = this.GetTadayInfoByID(client, todayID);
                    if (oneInfo == null)
                    {
                        return(string.Format(result, -3, 0));
                    }
                    if (oneInfo.NumMax - oneInfo.NumEnd <= 0)
                    {
                        return(string.Format(result, -4, 0));
                    }
                }
                List <TodayInfo> listAll = new List <TodayInfo>();
                if (isAll)
                {
                    listAll = this.InitToday(client);
                }
                else
                {
                    listAll.Add(oneInfo);
                }
                if (listAll.IsNullOrEmpty <TodayInfo>())
                {
                    result2 = string.Format(result, -3, 0);
                }
                else
                {
                    IEnumerable <TodayInfo> fubenList = from info in listAll
                                                        where info.FuBenID > 0 && client.ClientData.FuBenID > 0 && client.ClientData.FuBenID == info.FuBenID && info.NumMax - info.NumEnd > 0 && info.NumEnd >= 0
                                                        select info;
                    if (fubenList.Any <TodayInfo>())
                    {
                        result2 = string.Format(result, -6, 0);
                    }
                    else
                    {
                        IEnumerable <TodayInfo> awardList = from info in listAll
                                                            where info.NumMax - info.NumEnd > 0
                                                            select info;
                        if (!awardList.Any <TodayInfo>())
                        {
                            result2 = string.Format(result, -5, 0);
                        }
                        else
                        {
                            int goodsCount = 0;
                            foreach (TodayInfo info2 in awardList)
                            {
                                goodsCount += info2.AwardInfo.GoodsList.Count;
                            }
                            if (!Global.CanAddGoodsNum(client, goodsCount))
                            {
                                result2 = string.Format(result, -2, 0);
                            }
                            else
                            {
                                foreach (TodayInfo info2 in awardList)
                                {
                                    SystemXmlItem fuBenInfo = null;
                                    if (info2.Type == 6)
                                    {
                                        TaskData taskData = TodayManager.GetTaoTask(client);
                                        if (taskData != null)
                                        {
                                            if (!Global.CancelTask(client, taskData.DbID, taskData.DoingTaskID))
                                            {
                                                return(string.Format(result, -8, 0));
                                            }
                                        }
                                    }
                                    else if (info2.Type == 9)
                                    {
                                        BufferData bufferData = Global.GetBufferDataByID(client, 34);
                                        if (bufferData != null)
                                        {
                                            bufferData.BufferVal  = 0L;
                                            bufferData.BufferSecs = 0;
                                            GameManager.ClientMgr.NotifyBufferData(client, bufferData);
                                        }
                                    }
                                    else if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(info2.FuBenID, out fuBenInfo))
                                    {
                                        return(string.Format(result, -7, 0));
                                    }
                                    if (!this.SetFinishNum(client, info2, fuBenInfo))
                                    {
                                        return(string.Format(result, -1, 0));
                                    }
                                }
                                TodayAwardInfo awardInfo = new TodayAwardInfo();
                                foreach (TodayInfo info2 in awardList)
                                {
                                    int num = info2.NumMax - info2.NumEnd;
                                    for (int i = 0; i < info2.AwardInfo.GoodsList.Count; i++)
                                    {
                                        GoodsData goods = info2.AwardInfo.GoodsList[i];
                                        Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client, goods.GoodsID, goods.GCount * num, goods.Quality, "", goods.Forge_level, goods.Binding, 0, "", true, 1, "每日专享", "1900-01-01 12:00:00", goods.AddPropIndex, goods.BornIndex, goods.Lucky, goods.Strong, goods.ExcellenceInfo, goods.AppendPropLev, 0, null, null, 0, true);
                                    }
                                    awardInfo.AddAward(info2.AwardInfo, num);
                                }
                                if (awardInfo.Exp > 0.0)
                                {
                                    GameManager.ClientMgr.ProcessRoleExperience(client, (long)awardInfo.Exp, true, true, false, "none");
                                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(30, new object[0]), new object[]
                                    {
                                        awardInfo.Exp
                                    }), GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlyErr, 0);
                                }
                                if (awardInfo.GoldBind > 0.0)
                                {
                                    GameManager.ClientMgr.AddMoney1(client, (int)awardInfo.GoldBind, "每日专享", true);
                                }
                                if (awardInfo.MoJing > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, (int)awardInfo.MoJing, "每日专享", true, true, false);
                                }
                                if (awardInfo.ChengJiu > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyChengJiuPointsValue(client, (int)awardInfo.ChengJiu, "每日专享", true, true);
                                }
                                if (awardInfo.ShengWang > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyShengWangValue(client, (int)awardInfo.ShengWang, "每日专享", true, true);
                                }
                                if (awardInfo.ZhanGong > 0.0)
                                {
                                    int zhanGong = (int)awardInfo.ZhanGong;
                                    GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref zhanGong, AddBangGongTypes.Today, 0);
                                }
                                if (awardInfo.DiamondBind > 0.0 || awardInfo.ExtDiamondBind > 0.0)
                                {
                                    GameManager.ClientMgr.AddUserGold(client, (int)(awardInfo.DiamondBind + awardInfo.ExtDiamondBind), "每日专享");
                                }
                                if (awardInfo.XingHun > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyStarSoulValue(client, (int)awardInfo.XingHun, "每日专享", true, true);
                                }
                                if (awardInfo.YuanSuFenMo > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyYuanSuFenMoValue(client, (int)awardInfo.YuanSuFenMo, "每日专享", true, false);
                                }
                                if (awardInfo.ShouHuDianShu > 0.0)
                                {
                                    SingletonTemplate <GuardStatueManager> .Instance().AddGuardPoint(client, (int)awardInfo.ShouHuDianShu, "每日专享");
                                }
                                if (awardInfo.ZaiZao > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyZaiZaoValue(client, (int)awardInfo.ZaiZao, "每日专享", true, true, false);
                                }
                                if (awardInfo.LingJing > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyMUMoHeValue(client, (int)awardInfo.LingJing, "每日专享", true, true, false);
                                }
                                if (awardInfo.RongYao > 0.0)
                                {
                                    GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, (int)awardInfo.RongYao, "每日专享", true);
                                }
                                result2 = this.GetTodayData(client);
                            }
                        }
                    }
                }
            }
            return(result2);
        }
Exemplo n.º 4
0
        private string TodayAward(GameClient client, bool isAll, int todayID)
        {
            #region 验证
            string result = "{0}:{1}";
            if (!IsGongNengOpened())
            {
                return(string.Format(result, (int)ETodayState.NotOpen, 0));
            }

            //单个领取
            TodayInfo oneInfo = null;
            if (!isAll)
            {
                oneInfo = GetTadayInfoByID(client, todayID);
                if (oneInfo == null)
                {
                    return(string.Format(result, (int)ETodayState.NoType, 0));
                }

                if ((oneInfo.NumMax - oneInfo.NumEnd) <= 0)
                {
                    return(string.Format(result, (int)ETodayState.IsAward, 0));
                }
            }

            //获取可领取数据
            List <TodayInfo> listAll = new List <TodayInfo>();;
            if (isAll)
            {
                listAll = InitToday(client);
            }
            else
            {
                listAll.Add(oneInfo);
            }

            if (listAll.IsNullOrEmpty())
            {
                return(string.Format(result, (int)ETodayState.NoType, 0));
            }

            //在副本中,不能领取client.ClientData.CopyMapID
            var fubenList = from info in listAll
                            where info.FuBenID > 0 && client.ClientData.FuBenID > 0 && client.ClientData.FuBenID == info.FuBenID &&
                            info.NumMax - info.NumEnd > 0
                            select info;

            if (fubenList.Any())
            {
                return(string.Format(result, (int)ETodayState.IsFuben, 0));
            }

            //可以领取
            var awardList = from info in listAll
                            where info.NumMax - info.NumEnd > 0
                            select info;

            if (!awardList.Any())
            {
                return(string.Format(result, (int)ETodayState.IsAllAward, 0));
            }

            //奖励物品数量
            int goodsCount = 0;
            foreach (var info in awardList)
            {
                goodsCount += info.AwardInfo.GoodsList.Count;
            }

            //背包
            if (!Global.CanAddGoodsNum(client, goodsCount))
            {
                return(string.Format(result, (int)ETodayState.NoBag, 0));
            }

            #endregion

            #region 设置次数
            bool b = false;
            foreach (var info in awardList)
            {
                SystemXmlItem fuBenInfo = null;
                if (info.Type == (int)(ETodayType.Tao))
                {
                    TaskData taskData = GetTaoTask(client);
                    if (taskData != null)
                    {
                        b = Global.CancelTask(client, taskData.DbID, taskData.DoingTaskID);
                        if (!b)
                        {
                            return(string.Format(result, (int)ETodayState.TaoCancel, 0));
                        }
                    }
                }
                else if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(info.FuBenID, out fuBenInfo))
                {
                    return(string.Format(result, (int)ETodayState.EFubenConfig, 0));
                }

                b = SetFinishNum(client, info, fuBenInfo);
                if (!b)
                {
                    return(string.Format(result, (int)ETodayState.Fail, 0));
                }
            }

            #endregion

            #region 发奖
            TodayAwardInfo awardInfo = new TodayAwardInfo();
            //(物品)
            foreach (var info in awardList)
            {
                int num = info.NumMax - info.NumEnd;
                for (int i = 0; i < info.AwardInfo.GoodsList.Count; i++)
                {
                    GoodsData goods = info.AwardInfo.GoodsList[i];
                    Global.AddGoodsDBCommand(Global._TCPManager.TcpOutPacketPool, client,
                                             goods.GoodsID, goods.GCount * num, goods.Quality, "", goods.Forge_level,
                                             goods.Binding, 0, "", true, 1,
                                             /**/ "每日专享", Global.ConstGoodsEndTime, goods.AddPropIndex, goods.BornIndex,
                                             goods.Lucky, goods.Strong, goods.ExcellenceInfo, goods.AppendPropLev);
                }

                awardInfo.AddAward(info.AwardInfo, num);
            }

            //(数值)
            //经验值
            if (awardInfo.Exp > 0)
            {
                GameManager.ClientMgr.ProcessRoleExperience(client, (long)awardInfo.Exp);
                GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                         StringUtil.substitute(Global.GetLang("恭喜获得经验 +{0}"), awardInfo.Exp),
                                                         GameInfoTypeIndexes.Hot, ShowGameInfoTypes.OnlyErr, (int)HintErrCodeTypes.None);
            }

            //绑金
            if (awardInfo.GoldBind > 0)
            {
                GameManager.ClientMgr.AddMoney1(client, (int)awardInfo.GoldBind, "每日专享", true);
            }
            //魔晶
            if (awardInfo.MoJing > 0)
            {
                GameManager.ClientMgr.ModifyTianDiJingYuanValue(client, (int)awardInfo.MoJing, "每日专享", true, true);
            }
            //成就
            if (awardInfo.ChengJiu > 0)
            {
                GameManager.ClientMgr.ModifyChengJiuPointsValue(client, (int)awardInfo.ChengJiu, "每日专享", true, true);
            }
            //声望
            if (awardInfo.ShengWang > 0)
            {
                GameManager.ClientMgr.ModifyShengWangValue(client, (int)awardInfo.ShengWang, "每日专享", true, true);
            }
            ;
            //战功
            if (awardInfo.ZhanGong > 0)
            {
                int zhanGong = (int)awardInfo.ZhanGong;
                GameManager.ClientMgr.AddBangGong(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, ref zhanGong, AddBangGongTypes.Today);
            }
            //绑钻
            if (awardInfo.DiamondBind > 0 || awardInfo.ExtDiamondBind > 0)
            {
                GameManager.ClientMgr.AddUserGold(client, (int)(awardInfo.DiamondBind + awardInfo.ExtDiamondBind), "每日专享");
            }
            ;
            //星魂
            if (awardInfo.XingHun > 0)
            {
                GameManager.ClientMgr.ModifyStarSoulValue(client, (int)awardInfo.XingHun, "每日专享", true, true);
            }
            ;
            //元素粉末
            if (awardInfo.YuanSuFenMo > 0)
            {
                GameManager.ClientMgr.ModifyYuanSuFenMoValue(client, (int)awardInfo.YuanSuFenMo, "每日专享", true);
            }
            ;
            //守护点数
            if (awardInfo.ShouHuDianShu > 0)
            {
                GuardStatueManager.Instance().AddGuardPoint(client, (int)awardInfo.ShouHuDianShu, "每日专享");
            }
            //再造点数
            if (awardInfo.ZaiZao > 0)
            {
                GameManager.ClientMgr.ModifyZaiZaoValue(client, (int)awardInfo.ZaiZao, "每日专享", true, true);
            }
            //灵晶
            if (awardInfo.LingJing > 0)
            {
                GameManager.ClientMgr.ModifyMUMoHeValue(client, (int)awardInfo.LingJing, "每日专享", true);
            }
            ;
            //荣耀
            if (awardInfo.RongYao > 0)
            {
                GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, (int)awardInfo.RongYao, "每日专享");
            }
            ;

            #endregion

            return(GetTodayData(client));
        }