示例#1
0
 private void UpdatePlantQuailty(UserPlantQuality plantQuality, PlantQualityType pQualityType, int totalNum)
 {
     plantQuality.GeneralID    = generalID;
     plantQuality.PlantQuality = pQualityType;
     plantQuality.RefreshDate  = DateTime.Now;
     plantQuality.RefreshNum   = MathUtils.Addition(totalNum, 1, int.MaxValue);
 }
示例#2
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "UserID": return(UserID);

                case "GeneralID": return(GeneralID);

                case "PlantType": return(PlantType);

                case "PlantQuality": return(PlantQuality);

                case "RefreshNum": return(RefreshNum);

                case "RefreshDate": return(RefreshDate);

                default: throw new ArgumentException(string.Format("UserPlantQuality index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "UserID":
                    _UserID = value.ToNotNullString();
                    break;

                case "GeneralID":
                    _GeneralID = value.ToInt();
                    break;

                case "PlantType":
                    _PlantType = value.ToEnum <PlantType>();
                    break;

                case "PlantQuality":
                    _PlantQuality = value.ToEnum <PlantQualityType>();
                    break;

                case "RefreshNum":
                    _RefreshNum = value.ToInt();
                    break;

                case "RefreshDate":
                    _RefreshDate = value.ToDateTime();
                    break;

                default: throw new ArgumentException(string.Format("UserPlantQuality index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
示例#3
0
        public override bool TakeAction()
        {
            PlantType        pType            = (PlantType)Enum.Parse(typeof(PlantType), plantType.ToString());
            UserPlantQuality userPlantQuality = new GameDataCacheSet <UserPlantQuality>().FindKey(ContextUser.UserID, generalID, pType);

            if (userPlantQuality != null)
            {
                plantQualityType = (short)userPlantQuality.PlantQuality;
            }
            else
            {
                UserPlantQuality plant = new UserPlantQuality()
                {
                    UserID       = ContextUser.UserID,
                    GeneralID    = generalID,
                    PlantQuality = PlantQualityType.PuTong,
                    PlantType    = pType,
                    RefreshNum   = 0,
                    RefreshDate  = DateTime.Now,
                };
                new GameDataCacheSet <UserPlantQuality>().Add(plant);
                plantQualityType = 1;
            }
            PlantQualityType qualityType = (PlantQualityType)Enum.Parse(typeof(PlantQualityType), plantQualityType.ToString());
            short            generalLv   = 0;

            userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID);
            if (userGeneral == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (pType == PlantType.Experience)
            {
                generalLv = ContextUser.UserLv;
            }
            else if (pType == PlantType.GameGoin)
            {
                generalLv = userGeneral.GeneralLv;
            }
            plantInfo = new ConfigCacheSet <PlantInfo>().FindKey(generalLv, plantType, qualityType);
            double addNum = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.ManorAddition);//活动加成

            rewardNum = plantInfo.GainNum;
            UserLand land = new GameDataCacheSet <UserLand>().FindKey(ContextUser.UserID, landPostion);

            if (land != null && land.IsRedLand == 1)
            {
                rewardNum = MathUtils.Addition(rewardNum, (int)(rewardNum * 0.2), int.MaxValue);
            }
            if (land != null && land.IsBlackLand == 1)
            {
                rewardNum = MathUtils.Addition(rewardNum, (int)(rewardNum * 0.4), int.MaxValue);
            }
            rewardNum = (rewardNum * addNum).ToInt();
            return(true);
        }
示例#4
0
        private void AppendPlantQuality(PlantType pType, PlantQualityType plantQualityType)
        {
            UserPlantQuality plant = new UserPlantQuality()
            {
                UserID       = ContextUser.UserID,
                GeneralID    = generalID,
                PlantType    = pType,
                PlantQuality = plantQualityType,
                RefreshNum   = 1,
                RefreshDate  = DateTime.Now
            };

            new GameDataCacheSet <UserPlantQuality>().Add(plant, GameEnvironment.CacheUserPeriod);
        }
示例#5
0
        private void AppendPlantQuality(PlantType pType, PlantQualityType plantQualityType)
        {
            UserPlantQuality plant = new UserPlantQuality()
            {
                UserID       = ContextUser.UserID,
                GeneralID    = generalID,
                PlantType    = pType,
                PlantQuality = plantQualityType,
                RefreshNum   = 1,
                RefreshDate  = DateTime.Now
            };

            new PersonalCacheStruct <UserPlantQuality>().Add(plant);
        }
示例#6
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "GeneralLv": return(GeneralLv);

                case "PlantType": return(PlantType);

                case "PlantQualityType": return(PlantQualityType);

                case "GainNum": return(GainNum);

                default: throw new ArgumentException(string.Format("PlantInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "GeneralLv":
                    _GeneralLv = value.ToShort();
                    break;

                case "PlantType":
                    _PlantType = value.ToShort();
                    break;

                case "PlantQualityType":
                    _PlantQualityType = value.ToEnum <PlantQualityType>();
                    break;

                case "GainNum":
                    _GainNum = value.ToInt();
                    break;

                default: throw new ArgumentException(string.Format("PlantInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
示例#7
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "QualityID": return(QualityID);

                case "QualityName": return(QualityName);

                case "Light": return(Light);

                default: throw new ArgumentException(string.Format("QualityProbabilityInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "QualityID":
                    _QualityID = value.ToEnum <PlantQualityType>();
                    break;

                case "QualityName":
                    _QualityName = value.ToNotNullString();
                    break;

                case "Light":
                    _Light = value.ToDecimal();
                    break;

                default: throw new ArgumentException(string.Format("QualityProbabilityInfo index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
        protected override object this[string index]
		{
			get
			{
                #region
				switch (index)
				{
                    case "QualityID": return QualityID;
                    case "QualityName": return QualityName;
                    case "Light": return Light;
					default: throw new ArgumentException(string.Format("QualityProbabilityInfo index[{0}] isn't exist.", index));
				}
                #endregion
			}
			set
			{
                #region
				switch (index)
				{
                    case "QualityID":
				        _QualityID = value.ToEnum<PlantQualityType>();
                        break; 
                    case "QualityName": 
                        _QualityName = value.ToNotNullString(); 
                        break; 
                    case "Light": 
                        _Light = value.ToDecimal(); 
                        break; 
					default: throw new ArgumentException(string.Format("QualityProbabilityInfo index[{0}] isn't exist.", index));
				}
                #endregion
			}
		}
示例#9
0
 private void UpdatePlantQuailty(UserPlantQuality plantQuality, PlantQualityType pQualityType, int totalNum)
 {
     plantQuality.GeneralID = generalID;
     plantQuality.PlantQuality = pQualityType;
     plantQuality.RefreshDate = DateTime.Now;
     plantQuality.RefreshNum = MathUtils.Addition(totalNum, 1, int.MaxValue);
 }
示例#10
0
 private void AppendPlantQuality(PlantType pType, PlantQualityType plantQualityType)
 {
     UserPlantQuality plant = new UserPlantQuality()
                                  {
                                      UserID = ContextUser.UserID,
                                      GeneralID = generalID,
                                      PlantType = pType,
                                      PlantQuality = plantQualityType,
                                      RefreshNum = 1,
                                      RefreshDate = DateTime.Now
                                  };
     new GameDataCacheSet<UserPlantQuality>().Add(plant, GameEnvironment.CacheUserPeriod);
 }
示例#11
0
        public override bool TakeAction()
        {
            short optype             = 0;
            int   qualityID          = 0;
            int   totalNum           = 0;
            var   plantQualitieArray = new GameDataCacheSet <UserPlantQuality>().FindAll(ContextUser.UserID, u => u.RefreshDate.Date == DateTime.Now.Date);

            if (plantQualitieArray.Count > 0)
            {
                totalNum = plantQualitieArray[0].RefreshNum;
            }
            foreach (UserPlantQuality userPlantQuality in plantQualitieArray)
            {
                if (totalNum < userPlantQuality.RefreshNum)
                {
                    totalNum = userPlantQuality.RefreshNum;
                }
            }

            PlantType pType = (PlantType)Enum.Parse(typeof(PlantType), plantType.ToString());

            if (pType == PlantType.Experience)
            {
                optype = 4;
            }
            else
            {
                optype = 5;
            }
            int refreshNum = ConfigEnvSet.GetInt("UserPlant.QualityRefreshNum");
            UserPlantQuality plantQuality = new GameDataCacheSet <UserPlantQuality>().FindKey(ContextUser.UserID, generalID, pType);

            if (plantQuality == null)
            {
                return(false);
            }
            if (plantQuality.PlantQuality == PlantQualityType.Shenhua)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St10005_MaxQualityType;
                return(false);
            }

            if (refershID == 1 && ops == 1)
            {
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St10005_Refresh, GetRefreshNum(ContextUser.UserID, totalNum));
                return(false);
            }
            else if (refershID == 1 && ops == 2)
            {
                if (ContextUser.GoldNum < GetRefreshNum(ContextUser.UserID, totalNum))
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GetRefreshNum(ContextUser.UserID, totalNum), int.MaxValue);

                QualityProbabilityInfo probabilityInfo = new ConfigCacheSet <QualityProbabilityInfo>().FindKey(plantQuality.PlantQuality);
                if (RandomUtils.IsHit(probabilityInfo.Light))
                {
                    if (!string.IsNullOrEmpty(plantQuality.UserID) && DateTime.Now.Date == plantQuality.RefreshDate.Date && plantQuality.PlantQuality != PlantQualityType.Shenhua)
                    {
                        qualityID = MathUtils.Addition(Convert.ToInt32(plantQuality.PlantQuality), 1, int.MaxValue);
                    }
                    else
                    {
                        qualityID = 2;
                    }
                    PlantQualityType pQualityType = (PlantQualityType)Enum.Parse(typeof(PlantQualityType), qualityID.ToString());
                    ErrorCode = ErrorCode;
                    ErrorInfo = probabilityInfo.QualityName;
                    if (!string.IsNullOrEmpty(plantQuality.UserID))
                    {
                        UpdatePlantQuailty(plantQuality, pQualityType, totalNum);
                    }
                    else
                    {
                        AppendPlantQuality(pType, pQualityType);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(plantQuality.UserID) && DateTime.Now.Date == plantQuality.RefreshDate.Date && plantQuality.PlantQuality != PlantQualityType.PuTong)
                    {
                        qualityID = MathUtils.Subtraction(Convert.ToInt32(plantQuality.PlantQuality), 1, 0);
                    }
                    else
                    {
                        qualityID = 1;
                    }
                    PlantQualityType pQualityType = (PlantQualityType)Enum.Parse(typeof(PlantQualityType), qualityID.ToString());
                    UpdatePlantQuailty(plantQuality, pQualityType, totalNum);
                }
                UserLogHelper.AppenLandLog(ContextUser.UserID, optype, generalID, 0, GetRefreshNum(ContextUser.UserID, totalNum),
                                           (short)plantQuality.PlantQuality, 0, 0);
            }
            else if (refershID == 2 && ops == 1)
            {
                if (ContextUser.VipLv < 5)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_VipNotEnough;
                    return(false);
                }
                ErrorCode = 1;
                ErrorInfo = string.Format(LanguageManager.GetLang().St10005_Refresh, refreshNum);
                return(false);
            }
            else if (refershID == 2 && ops == 2)
            {
                if (ContextUser.GoldNum < refreshNum)
                {
                    ErrorCode = 2;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                PlantQualityType pQualityType = PlantQualityType.Shenhua;
                if (!string.IsNullOrEmpty(plantQuality.UserID))
                {
                    UpdatePlantQuailty(plantQuality, pQualityType, totalNum);
                }
                else
                {
                    AppendPlantQuality(pType, pQualityType);
                }

                ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, refreshNum, int.MaxValue);

                UserLogHelper.AppenLandLog(ContextUser.UserID, optype, generalID, 0, refreshNum, (short)plantQuality.PlantQuality, 0, 0);
            }

            return(true);
        }
示例#12
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "GeneralLv": return GeneralLv;
             case "PlantType": return PlantType;
             case "PlantQualityType": return PlantQualityType;
             case "GainNum": return GainNum;
             default: throw new ArgumentException(string.Format("PlantInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "GeneralLv":
                 _GeneralLv = value.ToShort();
                 break;
             case "PlantType":
                 _PlantType = value.ToShort();
                 break;
             case "PlantQualityType":
                 _PlantQualityType = value.ToEnum<PlantQualityType>();
                 break;
             case "GainNum":
                 _GainNum = value.ToInt();
                 break;
             default: throw new ArgumentException(string.Format("PlantInfo index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
示例#13
0
        protected override object this[string index]
        {
            get
            {
                #region
                switch (index)
                {
                case "UserID": return(UserID);

                case "LandPositon": return(LandPositon);

                case "GeneralID": return(GeneralID);

                case "PlantType": return(PlantType);

                case "IsGain": return(IsGain);

                case "IsRedLand": return(IsRedLand);

                case "IsBlackLand": return(IsBlackLand);

                case "GainDate": return(GainDate);

                case "PlantQuality": return(PlantQuality);

                default: throw new ArgumentException(string.Format("UserLand index[{0}] isn't exist.", index));
                }
                #endregion
            }
            set
            {
                #region
                switch (index)
                {
                case "UserID":
                    _UserID = value.ToNotNullString();
                    break;

                case "LandPositon":
                    _LandPositon = value.ToInt();
                    break;

                case "GeneralID":
                    _GeneralID = value.ToInt();
                    break;

                case "PlantType":
                    _PlantType = value.ToEnum <PlantType>();
                    break;

                case "IsGain":
                    _IsGain = value.ToShort();
                    break;

                case "IsRedLand":
                    _IsRedLand = value.ToShort();
                    break;

                case "IsBlackLand":
                    _IsBlackLand = value.ToShort();
                    break;

                case "GainDate":
                    _GainDate = value.ToDateTime();
                    break;

                case "PlantQuality":
                    _PlantQuality = value.ToEnum <PlantQualityType>();
                    break;

                default: throw new ArgumentException(string.Format("UserLand index[{0}] isn't exist.", index));
                }
                #endregion
            }
        }
示例#14
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "UserID": return UserID;
             case "GeneralID": return GeneralID;
             case "PlantType": return PlantType;
             case "PlantQuality": return PlantQuality;
             case "RefreshNum": return RefreshNum;
             case "RefreshDate": return RefreshDate;
             default: throw new ArgumentException(string.Format("UserPlantQuality index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "GeneralID":
                 _GeneralID = value.ToInt();
                 break;
             case "PlantType":
                 _PlantType = value.ToEnum<PlantType>();
                 break;
             case "PlantQuality":
                 _PlantQuality = value.ToEnum<PlantQualityType>();
                 break;
             case "RefreshNum":
                 _RefreshNum = value.ToInt();
                 break;
             case "RefreshDate":
                 _RefreshDate = value.ToDateTime();
                 break;
             default: throw new ArgumentException(string.Format("UserPlantQuality index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
示例#15
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "UserID": return UserID;
             case "LandPositon": return LandPositon;
             case "GeneralID": return GeneralID;
             case "PlantType": return PlantType;
             case "IsGain": return IsGain;
             case "IsRedLand": return IsRedLand;
             case "IsBlackLand": return IsBlackLand;
             case "GainDate": return GainDate;
             case "PlantQuality": return PlantQuality;
             default: throw new ArgumentException(string.Format("UserLand index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "LandPositon":
                 _LandPositon = value.ToInt();
                 break;
             case "GeneralID":
                 _GeneralID = value.ToInt();
                 break;
             case "PlantType":
                 _PlantType = value.ToEnum<PlantType>();
                 break;
             case "IsGain":
                 _IsGain = value.ToShort();
                 break;
             case "IsRedLand":
                 _IsRedLand = value.ToShort();
                 break;
             case "IsBlackLand":
                 _IsBlackLand = value.ToShort();
                 break;
             case "GainDate":
                 _GainDate = value.ToDateTime();
                 break;
             case "PlantQuality":
                 _PlantQuality = value.ToEnum<PlantQualityType>();
                 break;
             default: throw new ArgumentException(string.Format("UserLand index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
示例#16
0
 private void AppendPlantQuality(PlantType pType, PlantQualityType plantQualityType)
 {
     UserPlantQuality plant = new UserPlantQuality()
                                  {
                                      UserID = ContextUser.UserID,
                                      GeneralID = generalID,
                                      PlantType = pType,
                                      PlantQuality = plantQualityType,
                                      RefreshNum = 1,
                                      RefreshDate = DateTime.Now
                                  };
     new PersonalCacheStruct<UserPlantQuality>().Add(plant);
 }