コード例 #1
0
        public JieriLianXuChargeErrorCode HandleGetAward(GameClient client, int awardId, int day)
        {
            JieriLianXuChargeErrorCode result;

            if (!this.InAwardTime() || client == null)
            {
                result = JieriLianXuChargeErrorCode.NotAwardTime;
            }
            else
            {
                JieriLianXuChargeActivity._ChargeLvl cl = this.chargeLvlList.Find((JieriLianXuChargeActivity._ChargeLvl _cl) => _cl.Id == awardId);
                if (cl == null)
                {
                    result = JieriLianXuChargeErrorCode.ConfigError;
                }
                else
                {
                    JieriLianXuChargeActivity._DayAward da = cl.AwardList.Find((JieriLianXuChargeActivity._DayAward _da) => _da.LianXuDay == day);
                    if (da == null)
                    {
                        result = JieriLianXuChargeErrorCode.ConfigError;
                    }
                    else
                    {
                        List <JieriLianXuChargeActivity._AwardInfo> myDataLst = this._GetMyActInfoFromDB(client);
                        if (myDataLst == null)
                        {
                            result = JieriLianXuChargeErrorCode.DBFailed;
                        }
                        else
                        {
                            JieriLianXuChargeActivity._AwardInfo info = myDataLst.Find((JieriLianXuChargeActivity._AwardInfo _info) => _info.AwardId == awardId);
                            if (info == null)
                            {
                                result = JieriLianXuChargeErrorCode.ConfigError;
                            }
                            else if (info.LianXuDay < day || Global.GetIntSomeBit(info.AwardFlag, day) == 1)
                            {
                                result = JieriLianXuChargeErrorCode.NotMeetAwardCond;
                            }
                            else
                            {
                                if (da.AwardGoods != null && da.AwardGoods.GoodsDataList != null && da.AwardGoods.GoodsDataList.Count > 0)
                                {
                                    int AwardGoodsCnt = da.AwardGoods.GoodsDataList.Count((GoodsData goods) => Global.IsRoleOccupationMatchGoods(client, goods.GoodsID));
                                    if (!Global.CanAddGoodsNum(client, AwardGoodsCnt))
                                    {
                                        return(JieriLianXuChargeErrorCode.NoBagSpace);
                                    }
                                }
                                int newAwardFlag = Global.SetIntSomeBit(day, info.AwardFlag, true);
                                if (!this._UpdateAwardFlag2DB(client, awardId, newAwardFlag))
                                {
                                    result = JieriLianXuChargeErrorCode.DBFailed;
                                }
                                else
                                {
                                    info.AwardFlag = newAwardFlag;
                                    base.GiveAward(client, da.AwardGoods);
                                    if (client._IconStateMgr.CheckJieriLianXuCharge(client))
                                    {
                                        client._IconStateMgr.AddFlushIconState(14000, client._IconStateMgr.IsAnyJieRiTipActived());
                                        client._IconStateMgr.SendIconStateToClient(client);
                                    }
                                    result = JieriLianXuChargeErrorCode.Success;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #2
0
 public bool Init()
 {
     try
     {
         GeneralCachingXmlMgr.RemoveCachingXml(Global.GameResPath(this.CfgFile));
         XElement xml = GeneralCachingXmlMgr.GetXElement(Global.GameResPath(this.CfgFile));
         if (null == xml)
         {
             return(false);
         }
         XElement args = xml.Element("Activities");
         if (null != args)
         {
             this.FromDate       = Global.GetSafeAttributeStr(args, "FromDate");
             this.ToDate         = Global.GetSafeAttributeStr(args, "ToDate");
             this.ActivityType   = (int)Global.GetSafeAttributeLong(args, "ActivityType");
             this.AwardStartDate = Global.GetSafeAttributeStr(args, "AwardStartDate");
             this.AwardEndDate   = Global.GetSafeAttributeStr(args, "AwardEndDate");
         }
         args = xml.Element("GiftList");
         Dictionary <int, JieriLianXuChargeActivity._ChargeLvl> awardId2ChargeLvl = new Dictionary <int, JieriLianXuChargeActivity._ChargeLvl>();
         if (null != args)
         {
             IEnumerable <XElement> xmlItems = args.Elements();
             foreach (XElement xmlItem in xmlItems)
             {
                 if (null != xmlItem)
                 {
                     int awardId    = (int)Global.GetSafeAttributeLong(xmlItem, "Group");
                     int needCharge = (int)Global.GetSafeAttributeLong(xmlItem, "NeedZuanShi");
                     JieriLianXuChargeActivity._ChargeLvl chargeLvl = null;
                     if (!awardId2ChargeLvl.TryGetValue(awardId, out chargeLvl))
                     {
                         chargeLvl                  = new JieriLianXuChargeActivity._ChargeLvl();
                         chargeLvl.Id               = awardId;
                         chargeLvl.NeedCharge       = needCharge;
                         awardId2ChargeLvl[awardId] = chargeLvl;
                     }
                     JieriLianXuChargeActivity._DayAward dayAward = new JieriLianXuChargeActivity._DayAward();
                     dayAward.LianXuDay = (int)Global.GetSafeAttributeLong(xmlItem, "Day");
                     string goodsIDs = Global.GetSafeAttributeStr(xmlItem, "GoodsOne");
                     if (string.IsNullOrEmpty(goodsIDs))
                     {
                         LogManager.WriteLog(LogTypes.Warning, string.Format("读取{0}配置文件中的物品配置项为空", this.CfgFile), null, true);
                     }
                     else
                     {
                         string[] fields = goodsIDs.Split(new char[]
                         {
                             '|'
                         });
                         if (fields.Length <= 0)
                         {
                             LogManager.WriteLog(LogTypes.Warning, string.Format("读取{0}配置文件中的物品配置项失败", this.CfgFile), null, true);
                         }
                         else
                         {
                             dayAward.AwardGoods.GoodsDataList.AddRange(HuodongCachingMgr.ParseGoodsDataList(fields, "连续充值活动goods1配置"));
                         }
                     }
                     goodsIDs = Global.GetSafeAttributeStr(xmlItem, "GoodsTwo");
                     if (!string.IsNullOrEmpty(goodsIDs))
                     {
                         string[] fields = goodsIDs.Split(new char[]
                         {
                             '|'
                         });
                         if (fields.Length <= 0)
                         {
                             LogManager.WriteLog(LogTypes.Warning, string.Format("读取{0}配置文件中的物品配置项失败", this.CfgFile), null, true);
                         }
                         else
                         {
                             dayAward.AwardGoods.GoodsDataList.AddRange(HuodongCachingMgr.ParseGoodsDataList(fields, "连续充值活动goods2配置"));
                         }
                     }
                     chargeLvl.AwardList.Add(dayAward);
                 }
             }
             this.chargeLvlList.AddRange(awardId2ChargeLvl.Values.ToList <JieriLianXuChargeActivity._ChargeLvl>());
             base.PredealDateTime();
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", this.CfgFile, ex.Message), null, true);
         return(false);
     }
     return(true);
 }