/// <summary> /// 获取猎命水晶页面的列表 /// </summary> /// <param name="user"></param> /// <param name="allowSale">允许一键卖出</param> /// <param name="allowTake">允许一键拾取</param> /// <returns></returns> public static List <GrayCrystal> GetNotSaleCrystalNum(GameUser user, out bool allowSale, out bool allowTake) { allowSale = false; allowTake = false; var crystalsList = new List <GrayCrystal>(); var tempList = GetGrayCrystalList(user); if (tempList.Count > 0) { allowSale = true; crystalsList.AddRange(tempList); } var package = UserCrystalPackage.Get(user.UserID); UserCrystalInfo[] userCrystalsArray = package.CrystalPackage.FindAll(m => m.IsSale == 1).ToArray(); //UserCrystal[] userCrystalsArray = UserCrystal.FindAll(UserCrystal.Index_UserID, m => m.IsSale == 1, user.UserID); if (userCrystalsArray.Length > 0) { allowTake = true; } foreach (UserCrystalInfo userCrystal in userCrystalsArray) { crystalsList.Add(new GrayCrystal() { UserCrystalID = userCrystal.UserCrystalID, CrystalID = userCrystal.CrystalID, CreateDate = userCrystal.CreateDate }); } return(crystalsList); }
public override bool TakeAction() { int saleNum = 0; if (ops == 1) { var package = UserCrystalPackage.Get(Uid); UserCrystalInfo userCrystal = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(userCrystalID)); if (userCrystal != null) { totalPrice = (new ConfigCacheSet <CrystalInfo>().FindKey(userCrystal.CrystalID) ?? new CrystalInfo()).Price; ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, totalPrice, int.MaxValue); //ContextUser.Update(); UserLogHelper.AppenCtystalLog(ContextUser.UserID, 4, userCrystal.CrystalID, totalPrice, 0, null, userCrystal.CrystalLv, userCrystal.CurrExprience); package.RemoveCrystal(userCrystal); } else { CrystalHelper.SellGrayCrystal(ContextUser, userCrystalID, out saleNum); } } else if (ops == 2) { CrystalHelper.SellGrayCrystal(ContextUser, null, out saleNum); } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().ServerBusy; return(false); } return(true); }
/// <summary> /// 命运的属性值 /// </summary> public static Decimal GetFateNum(string userID, int generalID, AbilityType abilityType) { decimal abilityNum = 0; //命运水晶生命 var packageCrystal = UserCrystalPackage.Get(userID); UserCrystalInfo[] crystalList = packageCrystal.CrystalPackage.FindAll(m => m.GeneralID.Equals(generalID)).ToArray(); foreach (UserCrystalInfo item in crystalList) { decimal effectNum = 0; CrystalLvInfo lvInfo = new ShareCacheStruct <CrystalLvInfo>().FindKey(item.CrystalID, item.CrystalLv); if (lvInfo != null) { effectNum = lvInfo.AbilityNum; } if (abilityType == item.AbilityType) { if (abilityType != AbilityType.ShengMing) { abilityNum = effectNum; } } } return(abilityNum); }
public override bool TakeAction() { var package = UserCrystalPackage.Get(Uid); userCrystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)); userCrystalArray.QuickSort((x, y) => { int result = 0; if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } result = y.CrystalQuality.CompareTo(x.CrystalQuality); if (result == 0) { result = y.CurrExprience.CompareTo(x.CurrExprience); } return(result); }); return(true); }
/// <summary> /// 奖励命运水晶 /// </summary> public static string UserUserUniversalCrystal(GameUser user, CrystalQualityType qualityType, string systemContent) { string crystalContent = string.Empty; List <CrystalInfo> crystalArray2 = new ConfigCacheSet <CrystalInfo>().FindAll(m => m.CrystalQuality == qualityType); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); CrystalInfo crystal = new ConfigCacheSet <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); var packageCrystal = UserCrystalPackage.Get(user.UserID); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 2, CreateDate = DateTime.Now, }; packageCrystal.SaveCrystal(userCrystal); crystalContent = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_Crystal, qualityType, crystal.CrystalName)); } return(crystalContent); }
public override bool TakeAction() { string publicUserID = string.Empty; if (string.IsNullOrEmpty(toUserID)) { publicUserID = ContextUser.UserID; } else { publicUserID = toUserID; } short crystalLv = 0; var package = UserCrystalPackage.Get(publicUserID); _userCrystal = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(_userCrystalID)); //_userCrystal = UserCrystal.FindKey(_userCrystalID);) if (_userCrystal != null) { _crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(_userCrystal.CrystalID); crystalLv = _userCrystal.CrystalLv; } else { var grayCrystal = ContextUser.GrayCrystalList.Find(m => m.UserCrystalID == _userCrystalID); if (grayCrystal != null) { _crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(grayCrystal.CrystalID); } else { return(false); } } if (_crystalInfo == null) { return(false); } CrystalLvInfo currCrystal = new ShareCacheStruct <CrystalLvInfo>().FindKey(_crystalInfo.CrystalID, crystalLv); short upLv = MathUtils.Addition(crystalLv, (short)1, short.MaxValue); if (upLv >= 10) { upLv = 10; } _crystalLvInfo = new ShareCacheStruct <CrystalLvInfo>().FindKey(_crystalInfo.CrystalID, upLv);//下级经验 if (currCrystal != null && currCrystal.AbilityNum > 1) { _attrNum = currCrystal.AbilityNum.ToString().Replace(".0000", ""); } else if (currCrystal != null) { _attrNum = Math.Round((currCrystal.AbilityNum * 100), 1, MidpointRounding.AwayFromZero).ToString(); _attrNum = _attrNum.Replace(".0", "") + "%"; } return(true); }
/// <summary> /// 命格背包是否已满 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool IsCrystalNumFull(GameUser user) { var package = UserCrystalPackage.Get(user.UserID); UserCrystalInfo[] crystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID == 0).ToArray(); if (user.CrystalNum <= crystalArray.Length) { return(true); } return(false); }
/// <summary> /// 检查是否能猎命 /// </summary> /// <returns></returns> public static bool CheckAllowCrystall(GameUser user) { var package = UserCrystalPackage.Get(user.UserID); int currNum = 0; if (package != null) { currNum = package.CrystalPackage.FindAll(m => m.IsSale == 1).Count; currNum += user.GrayCrystalList == null ? 0 : user.GrayCrystalList.Count; } return(currNum < _crystalGridNum); }
/// <summary> /// 传承佣兵身上是否有水晶 /// </summary> /// <param name="general"></param> /// <returns></returns> public static bool IsGeneralCrystal(string userID, int generalID) { var package = UserCrystalPackage.Get(userID); if (package != null) { var usercrystalList = package.CrystalPackage.FindAll(s => s.GeneralID == generalID); if (usercrystalList.Count > 0) { return(true); } } return(false); }
/// <summary> /// 命运水晶 /// </summary> /// <param name="userID"></param> /// <param name="generalID"></param> /// <returns></returns> public static int GeneralCrystalPriority(string userID, int generalID) { int crystalPriority = 0; var package = UserCrystalPackage.Get(userID); if (package != null) { List <UserCrystalInfo> userCrystalArray = package.CrystalPackage.FindAll(m => m.GeneralID.Equals(generalID)); foreach (UserCrystalInfo crystal in userCrystalArray) { PriorityQuality quality = crystal.CrystalQuality.ToInt().ToEnum <PriorityQuality>(); int baseNum = PriorityBaseNum(PriorityType.Crystal, quality); int effectNum = crystal.CrystalLv >= 1 ? PriorityEffectNum(PriorityType.Crystal, quality) : 0; crystalPriority += (MathUtils.Addition(baseNum, crystal.CrystalLv * effectNum)); } } return(crystalPriority); }
/// <summary> /// 合成水晶 /// </summary> /// <param name="userCryStal1"></param> /// <param name="userCryStal2"></param> /// <param name="cryExprience2"></param> private void UpdateCrystal(string _userCrystalID1, string _userCrystalID2, int cryExprience2) { var package = UserCrystalPackage.Get(Uid); UserCrystalInfo userCryStalInfo1 = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(_userCrystalID1)); UserCrystalInfo userCryStalInfo2 = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(_userCrystalID2)); CacheList <SynthesisInfo> SynList = new CacheList <SynthesisInfo>(); SynList.Add(new SynthesisInfo() { DemandID = userCryStalInfo2.CrystalID, Num = userCryStalInfo2.CurrExprience }); userCryStalInfo1.CurrExprience = MathUtils.Addition(userCryStalInfo1.CurrExprience, cryExprience2); userCryStalInfo1.CurrExprience = MathUtils.Addition(userCryStalInfo1.CurrExprience, userCryStalInfo2.CurrExprience); package.SaveCrystal(userCryStalInfo1); //package.DelayChange(); UserHelper.CheckCrystalEscalate(ContextUser.UserID, userCryStalInfo1.UserCrystalID); UserLogHelper.AppenCtystalLog(ContextUser.UserID, 3, userCryStalInfo1.CrystalID, 0, 0, SynList, userCryStalInfo1.CrystalLv, userCryStalInfo1.CurrExprience); package.RemoveCrystal(userCryStalInfo2); }
public override bool TakeAction() { string publicUserID = string.Empty; if (string.IsNullOrEmpty(toUserID)) { publicUserID = ContextUser.UserID; } else { publicUserID = toUserID; } var package = UserCrystalPackage.Get(publicUserID); userCrystalArray = package.CrystalPackage.FindAll(m => m.GeneralID.Equals(_generalID)); userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, _generalID); var generalInfo = new ConfigCacheSet <GeneralInfo>().FindKey(userGeneral != null ? userGeneral.GeneralID : 0); _maxHeadID = generalInfo != null ? generalInfo.PicturesID : string.Empty; return(true); }
/// <summary> /// 获得一个水晶 /// </summary> /// <param name="userID"></param> /// <param name="crystalID"></param> /// <param name="crystalLv"></param> public static void AppendCrystal(string userID, int crystalID, short crystalLv) { CrystalInfo crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(crystalID); var crystalLvInfo = new ShareCacheStruct <CrystalLvInfo>().FindKey(crystalID, crystalLv); var package = UserCrystalPackage.Get(userID); if (package == null || crystalInfo == null || crystalLvInfo == null) { return; } UserCrystalInfo ucrystalInfo = new UserCrystalInfo(); ucrystalInfo.UserCrystalID = Guid.NewGuid().ToString(); ucrystalInfo.CrystalID = crystalID; ucrystalInfo.CrystalID = crystalInfo.CrystalID; ucrystalInfo.CrystalLv = crystalLv; ucrystalInfo.Position = 0; ucrystalInfo.CurrExprience = crystalLvInfo.UpExperience; ucrystalInfo.CreateDate = DateTime.Now; package.SaveCrystal(ucrystalInfo); }
/// <summary> /// 命运水晶ID=等级=数量 /// </summary> /// <param name="list"></param> /// <param name="userID"></param> private static void PutCrystal(string[] list, string userID) { var package = UserCrystalPackage.Get(userID); foreach (string crystal in list) { if (string.IsNullOrEmpty(crystal)) { continue; } string[] crystalList = crystal.Split(new char[] { '=' }); int crystalID = crystalList.Length > 0 ? Convert.ToInt32(crystalList[0]) : 0; short crystalLv = crystalList.Length > 1 ? Convert.ToInt16(crystalList[1]) : (short)0; int crystalNum = crystalList.Length > 2 ? Convert.ToInt32(crystalList[2]) : 0; CrystalInfo crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(crystalID); var crystalLvInfo = new ShareCacheStruct <CrystalLvInfo>().FindKey(crystalID, crystalLv); if (crystalNum > 0 && new ShareCacheStruct <CrystalInfo>().FindKey(crystalID) != null && crystalLvInfo != null) { for (int i = 0; i < crystalNum; i++) { UserCrystalInfo userCrystal = new UserCrystalInfo(); userCrystal.UserCrystalID = Guid.NewGuid().ToString(); userCrystal.CrystalID = crystalInfo.CrystalID; userCrystal.CrystalLv = crystalLv; userCrystal.GeneralID = 0; userCrystal.IsSale = 2; userCrystal.Position = 0; userCrystal.CurrExprience = crystalLvInfo.UpExperience; package.SaveCrystal(userCrystal); } } else { new Base.BaseLog().SaveLog("领取命运水晶异常", new Exception(string.Format("userID:{3},crystalID:{0},crystalNum:{1},crystalLv:{2}", crystalID, crystalNum, crystalLv, userID))); } } }
/// <summary> /// 命运水晶是否已满 已满false;未满true; /// </summary> public static bool CheckFull(string userID, int num) { GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID); var package = UserCrystalPackage.Get(userID); UserCrystalInfo[] crystalsArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)).ToArray(); //原因:当num大于0且crystalsArray.Length + num = userInfo.CrystalNum是提示背包已满 if (num > 0) { if (crystalsArray.Length + num > userInfo.CrystalNum) { return(false); } } else { if (crystalsArray.Length >= userInfo.CrystalNum) { return(false); } } return(true); }
public override bool TakeAction() { var package = UserCrystalPackage.Get(Uid); if (ops == 1) { UserCrystalInfo userCryStal1 = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(userCrystalID1)); UserCrystalInfo userCryStal2 = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(userCrystalID2)); // UserCrystal userCryStal1 = UserCrystal.FindKey(userCrystalID1); //UserCrystal userCryStal2 = UserCrystal.FindKey(userCrystalID2); if (userCryStal1 == null || userCryStal2 == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1308_CrystalNotEnough; return(false); } if (userCryStal1.CrystalLv > 9) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1308_CrystalLvFull; return(false); } CrystalInfo crystalInfo1 = new ShareCacheStruct <CrystalInfo>().FindKey(userCryStal1.CrystalID); CrystalInfo crystalInfo2 = new ShareCacheStruct <CrystalInfo>().FindKey(userCryStal2.CrystalID); int cryExprience1 = 0; int cryExprience2 = 0; if (crystalInfo1 != null && crystalInfo2 != null) { cryExprience1 = crystalInfo1.Experience; cryExprience2 = crystalInfo2.Experience; if (crystalInfo1.CrystalQuality == crystalInfo2.CrystalQuality) { if (userCryStal1.CurrExprience >= userCryStal2.CurrExprience) { UpdateCrystal(userCrystalID1, userCrystalID2, cryExprience2); } else { UpdateCrystal(userCrystalID2, userCrystalID1, cryExprience1); } } else if (crystalInfo1.CrystalQuality > crystalInfo2.CrystalQuality) { UpdateCrystal(userCrystalID1, userCrystalID2, cryExprience2); } else { UpdateCrystal(userCrystalID2, userCrystalID1, cryExprience1); } } } else if (ops == 2) { CacheList <SynthesisInfo> SynList = new CacheList <SynthesisInfo>(); int experience = 0; var userCrystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)); if (userCrystalArray.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1308_CrystalNotEnough; return(false); } userCrystalArray.QuickSort((x, y) => { int result = 0; if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } result = (int)new ShareCacheStruct <CrystalInfo>().FindKey(y.CrystalID).CrystalQuality.CompareTo( new ShareCacheStruct <CrystalInfo>().FindKey(x.CrystalID).CrystalQuality); if (result == 0) { result = y.CurrExprience.CompareTo(x.CurrExprience); } return(result); }); UserCrystalInfo userCrystal1 = package.CrystalPackage.Find(m => m.UserCrystalID == userCrystalArray[0].UserCrystalID); int maxExprience = 0; if (userCrystal1 == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1308_CrystalNotEnough; return(false); } short upLv = 10; CrystalLvInfo crystalLvInfo = new ShareCacheStruct <CrystalLvInfo>().FindKey(userCrystal1.CrystalID, upLv); maxExprience = crystalLvInfo == null ? 0 : crystalLvInfo.UpExperience; foreach (UserCrystalInfo crystal in userCrystalArray) { CrystalInfo crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(crystal.CrystalID); if (crystalInfo != null) { experience = crystalInfo.Experience; } if (userCrystal1.UserCrystalID != crystal.UserCrystalID) { SynList.Add(new SynthesisInfo() { DemandID = crystal.CrystalID, Num = crystal.CurrExprience }); if (userCrystal1.CurrExprience >= maxExprience) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1308_CrystalLvFull; break; } experience = MathUtils.Addition(experience, userCrystal1.CurrExprience); experience = MathUtils.Addition(experience, crystal.CurrExprience); userCrystal1.CurrExprience = experience; package.SaveCrystal(userCrystal1); //package.DelayChange(); package.RemoveCrystal(crystal); } } UserLogHelper.AppenCtystalLog(ContextUser.UserID, 3, userCrystal1.CrystalID, 0, 0, SynList, userCrystal1.CrystalLv, userCrystal1.CurrExprience); UserHelper.CheckCrystalEscalate(ContextUser.UserID, userCrystalArray[0].UserCrystalID); } return(true); }
/// <summary> /// 通用活动奖励 /// </summary> /// <param name="userID"></param> /// <param name="reward"></param> /// <param name="num"></param> public static string GameUserUniversalNocite(string userID, RewardType reward, int itemID, int num, string systemContent) { string content = string.Empty; GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID); if (userInfo != null) { if (reward == RewardType.GameGoin) { userInfo.GameCoin = MathUtils.Addition(userInfo.GameCoin, num, int.MaxValue); //userInfo.Update(); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_GameCoin, num)); } else if (reward == RewardType.Obtion) { userInfo.ObtainNum = MathUtils.Addition(userInfo.ObtainNum, num, int.MaxValue); //userInfo.Update(); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_ObtionNum, num)); } else if (reward == RewardType.EnergyNum) { userInfo.EnergyNum = MathUtils.Addition(userInfo.EnergyNum, (short)num, short.MaxValue); //userInfo.Update(); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_EnergyNum, num)); } else if (reward == RewardType.ExpNum) { userInfo.ExpNum = MathUtils.Addition(userInfo.ExpNum, num, int.MaxValue); //userInfo.Update(); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_ExpNum, num)); } else if (reward == RewardType.Gold) { userInfo.ItemGold = MathUtils.Addition(userInfo.ItemGold, num, int.MaxValue); //userInfo.Update(); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_GiftGoldNum, num)); } else if (reward == RewardType.Experience) { UserHelper.UserGeneralExp(userID, num); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_Experience, num)); } else if (reward == RewardType.Item) { UserItemHelper.AddUserItem(userID, itemID, num); ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(itemID); if (itemInfo != null) { string itemcontent = string.Format(LanguageManager.GetLang().St_Item, itemInfo.ItemName, 1, num); content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, itemcontent); } } else if (reward == RewardType.CrystalType) { CrystalQualityType qualityType = CrystalQualityType.PurPle; content = UserUserUniversalCrystal(userInfo, qualityType, systemContent); //GetUserCrystal(userInfo, qualityType); } else if (reward == RewardType.CrystalId) { var packageCrystal = UserCrystalPackage.Get(userID); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = itemID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 2, CreateDate = DateTime.Now }; packageCrystal.SaveCrystal(userCrystal); CrystalInfo info = new ConfigCacheSet <CrystalInfo>().FindKey(itemID); if (info != null) { content = string.Format(LanguageManager.GetLang().st_FestivalInfoReward, systemContent, string.Format(LanguageManager.GetLang().St_Crystal, info.CrystalQuality, info.CrystalName)); } } } return(content); }
public override bool TakeAction() { var package = UserCrystalPackage.Get(Uid); UserGeneral userGeneral = new PersonalCacheStruct <UserGeneral>().FindKey(ContextUser.UserID, generalID); UserCrystalInfo userCrystal = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(userCrystalID)); if (userCrystal == null || userGeneral == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } var userCrystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)); var crystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)); if (ops == 0) { if (userCrystal.IsSale == 2 && userCrystal.GeneralID != 0) { if (userCrystalArray.Count >= ContextUser.CrystalNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1307_FateBackpackFull; return(false); } if (userCrystalArray.Count < ContextUser.CrystalNum && userCrystal.GeneralID > 0 && userCrystal.Position > 0) { userCrystal.GeneralID = 0; userCrystal.Position = 0; package.SaveCrystal(userCrystal); //package.DelayChange(); } } } if (potion > IsGridOpen(userGeneral.GeneralLv)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1213_GridNumNotEnough; return(false); } else if (ops == 1) { if (userCrystal.IsSale == 2) { CrystalInfo crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(userCrystal.CrystalID); if (crystalInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (crystalArray.Count >= UserHelper.GetOpenNum(userGeneral.GeneralLv)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1309_OpenNumNotEnough; return(false); } foreach (UserCrystalInfo crystal in crystalArray) { CrystalInfo crystalInfo2 = new ShareCacheStruct <CrystalInfo>().FindKey(crystal.CrystalID); if (crystalInfo2 != null && crystalInfo.AbilityID == crystalInfo2.AbilityID) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1309_TheSameFate; return(false); } } UserCrystalInfo[] potionCrystalArray = package.CrystalPackage.FindAll(m => m.GeneralID == generalID && m.Position == potion).ToArray(); if (potionCrystalArray.Length > 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1309_TheGridFullSameFate; return(false); } if (userCrystal.IsSale == 2 && userCrystal.GeneralID == 0 && userCrystal.Position == 0) { userCrystal.GeneralID = generalID; userCrystal.Position = potion; package.SaveCrystal(userCrystal); } } } userGeneral.RefreshMaxLife(); return(true); }
public override bool TakeAction() { int currMaxLv = GameConfigSet.CurrMaxLv; string lifeUserID = string.Empty; UserCrystalInfo[] userCrystalsArrray = new UserCrystalInfo[0]; if (!string.IsNullOrEmpty(toUserID)) { var packageCrystal = UserCrystalPackage.Get(toUserID); userGeneral = new PersonalCacheStruct <UserGeneral>().FindKey(toUserID, generalID); userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray(); var package = UserItemPackage.Get(toUserID); userItemArray = package.ItemPackage.FindAll( u => !u.IsRemove && u.GeneralID.Equals(generalID) && u.ItemStatus == ItemStatus.YongBing); lifeUserID = toUserID; } else { var packageCrystal = UserCrystalPackage.Get(ContextUser.UserID); userGeneral = new PersonalCacheStruct <UserGeneral>().FindKey(ContextUser.UserID, generalID); userCrystalsArrray = packageCrystal.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(generalID)).ToArray(); var package = UserItemPackage.Get(ContextUser.UserID); userItemArray = package.ItemPackage.FindAll(u => !u.IsRemove && u.GeneralID.Equals(generalID) && u.ItemStatus == ItemStatus.YongBing); lifeUserID = ContextUser.UserID; } UserCacheGlobal.LoadOffline(lifeUserID); GeneralInfo generalInfo = new ShareCacheStruct <GeneralInfo>().FindKey(generalID); generalQuality = generalInfo == null ? (short)0 : generalInfo.GeneralQuality; if (generalInfo != null && userGeneral != null) { description = generalInfo.Description; if (userGeneral.GeneralLv >= currMaxLv) { genLv = (short)currMaxLv; userGeneral.CurrExperience = 0; } else { genLv = userGeneral.GeneralLv; } generalName = userGeneral.GeneralName; headID = userGeneral.HeadID; picturesID = userGeneral.PicturesID; _battleHeadId = generalInfo.BattleHeadID; _hitProbability = generalInfo.HitProbability; careerInfo = new ShareCacheStruct <CareerInfo>().FindKey(userGeneral.CareerID); GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(genLv); if (generalEscalate != null) { currExperience = userGeneral.CurrExperience; maxExperience = generalEscalate.UpExperience; } powerNum = MathUtils.Addition(userGeneral.PowerNum, userGeneral.TrainingPower, short.MaxValue); soulNum = MathUtils.Addition(userGeneral.SoulNum, userGeneral.TrainingSoul, short.MaxValue); intellectNum = MathUtils.Addition(userGeneral.IntellectNum, userGeneral.TrainingIntellect, short.MaxValue); if (!string.IsNullOrEmpty(ContextUser.MercenariesID) && generalID == LanguageManager.GetLang().GameUserGeneralID) { //公会技能加成 powerNum = MathUtils.RoundCustom(powerNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.PowerNum)).ToShort(); soulNum = MathUtils.RoundCustom(soulNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.SoulNum)).ToShort(); intellectNum = MathUtils.RoundCustom(intellectNum * CombatHelper.GetGuildAbilityNum(ContextUser.UserID, GuildAbilityType.IntellectNum)).ToShort(); } if (generalID == LanguageManager.GetLang().GameUserGeneralID) { //法宝基础属性加成 powerNum = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.PowerNum)); soulNum = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.SoulNum)); intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(ContextUser.UserID, generalID, AbilityType.IntelligenceNum)); //法宝--技能属性转换获得的值 //法宝--技能属性转换获得的值 decimal trumpPower = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.PowerNum); decimal trumpsoul = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.SoulNum); decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(ContextUser.UserID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum); powerNum = MathUtils.Addition(trumpPower.ToShort(), powerNum); soulNum = MathUtils.Addition(trumpsoul.ToShort(), soulNum); intellectNum = MathUtils.Addition(trumpintellect.ToShort(), intellectNum); } lifeNum = userGeneral.LifeNum; lifeMaxNum = UserHelper.GetMaxLife(lifeUserID, generalID); genLv = userGeneral.GeneralLv; generalStatus = (short)userGeneral.GeneralStatus; talentAbility = userGeneral.AbilityID; _potential = userGeneral.Potential; _battleHeadID = generalInfo.BattleHeadID; //玩家佣兵职业名称 userCareerName = careerInfo.CareerName; } else if (generalInfo != null) { genLv = 1; generalName = generalInfo.GeneralName; headID = generalInfo.HeadID; picturesID = generalInfo.PicturesID; _battleHeadId = generalInfo.BattleHeadID; careerInfo = new ShareCacheStruct <CareerInfo>().FindKey(generalInfo.CareerID); GeneralEscalateInfo generalEscalate = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(genLv); if (generalEscalate != null) { currExperience = 0; maxExperience = generalEscalate.UpExperience; } powerNum = generalInfo.PowerNum; soulNum = generalInfo.SoulNum; intellectNum = generalInfo.IntellectNum; lifeNum = generalInfo.LifeNum; lifeMaxNum = generalInfo.LifeNum; genLv = generalInfo.GeneralLv; generalStatus = (short)GeneralStatus.KeZhaoMu; talentAbility = generalInfo.AbilityID; } AbilityInfo ability = new ShareCacheStruct <AbilityInfo>().FindKey(talentAbility); talentName = ability == null ? string.Empty : ability.AbilityName; gPropertyList = CombatHelper.GetAbility(lifeUserID, generalID, userGeneral); int sumCrystal = 0; foreach (UserCrystalInfo crystal in userCrystalsArrray) { sumCrystal = MathUtils.Addition(sumCrystal, crystal.CurrExprience, int.MaxValue); } vitalityNum = (sumCrystal / 10); functionList = ViewHelper.GetFunctionList(lifeUserID); //佣兵魂技 UserAbility userAbility = new PersonalCacheStruct <UserAbility>().FindKey(ContextUser.UserID); if (userAbility != null) { abilityList = userAbility.AbilityList.FindAll(s => s.GeneralID == generalID); } soulGrid = UserPackHelper.GetPackTypePositionNum(BackpackType.HunJi, ContextUser.UserID); // 缘分系统 KarmaInfo karmaInfo = new ShareCacheStruct <KarmaInfo>().FindKey(generalID); if (karmaInfo != null && karmaInfo.KarmaList != null) { // 满足缘分条件显示激活状态 // 判断佣兵 UserMagic userMagic = new PersonalCacheStruct <UserMagic>().Find(ContextUser.UserID, s => s.IsEnabled); var cacheSetUserEmbattle = new PersonalCacheStruct <UserEmbattle>(); List <Karma> yongBingList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.YongBing); yongBingList.ForEach(yongBingInfo => { //yongBingInfo.IsActive = 1; // 若阵型中存在该记录,该缘分为激活状态 if (yongBingInfo.ValueID.Contains(",")) { string[] valueID = yongBingInfo.ValueID.Split(','); int i = 0; foreach (var id in valueID) { if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(id)) != null) { i++; } } yongBingInfo.IsActive = i == valueID.Length ? 1 : 0; } else { if (cacheSetUserEmbattle.Find(ContextUser.UserID, s => s.MagicID == userMagic.MagicID && s.GeneralID == MathUtils.ToInt(yongBingInfo.ValueID)) != null) { yongBingInfo.IsActive = 1; } else { yongBingInfo.IsActive = 0; } } }); // 判断装备 UserItemPackage itemPackage = new PersonalCacheStruct <UserItemPackage>().FindKey(UserId.ToString()); if (itemPackage != null) { List <Karma> itemList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ZhuangBei); itemList.ForEach(itemInfo => { if (itemPackage.ItemPackage.Find(s => s.ItemID == MathUtils.ToInt(itemInfo.ValueID) && s.GeneralID == generalID) != null) { itemInfo.IsActive = 1; } else { itemInfo.IsActive = 0; } }); } // 判断命运水晶 UserCrystalPackage crystalPackage = new PersonalCacheStruct <UserCrystalPackage>().FindKey(UserId.ToString()); if (itemPackage != null) { List <Karma> crystalList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.ShuiJing); crystalList.ForEach(crystalInfo => { if (crystalPackage.CrystalPackage.Find(s => s.CrystalID == MathUtils.ToInt(crystalInfo.ValueID) && s.GeneralID == generalID) != null) { crystalInfo.IsActive = 1; } else { crystalInfo.IsActive = 0; } }); } // 判断技能 UserAbility userAbilityInfo = new PersonalCacheStruct <UserAbility>().FindKey(UserId.ToString()); if (userAbilityInfo != null) { List <Karma> abilityList = karmaInfo.KarmaList.FindAll(s => s.KarmaType == KarmaType.JiNen); abilityList.ForEach(abilityInfo => { if (userAbilityInfo.AbilityList.Find(s => s.AbilityID == MathUtils.ToInt(abilityInfo.ValueID) && s.GeneralID == generalID) != null) { abilityInfo.IsActive = 1; } else { abilityInfo.IsActive = 0; } }); } karmaList = karmaInfo.KarmaList; if (userGeneral != null) { lifeNum = userGeneral.TLifeNum; lifeMaxNum = userGeneral.TLifeMaxNun; } } return(true); }
public override bool TakeAction() { var package = UserCrystalPackage.Get(Uid); var userCrystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 1 && m.GeneralID.Equals(0)); //命格背包 var crystalArray = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)); if (ops == 1) { UserCrystalInfo userCrystal = package.CrystalPackage.Find(m => m.UserCrystalID.Equals(userCrystalID)); if (crystalArray.Count >= ContextUser.CrystalNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1307_FateBackpackFull; return(false); } userCrystal.IsSale = 2; package.SaveCrystal(userCrystal); ErrorCode = 1; } else if (ops == 2) { userCrystalArray.QuickSort((x, y) => { int result = 0; if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } result = (int)new ShareCacheStruct <CrystalInfo>().FindKey(y.CrystalID).CrystalQuality.CompareTo( new ShareCacheStruct <CrystalInfo>().FindKey(x.CrystalID).CrystalQuality); if (result == 0) { result = y.CurrExprience.CompareTo(x.CurrExprience); } return(result); }); int subNum = ContextUser.CrystalNum; if (subNum <= crystalArray.Count) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1307_FateBackpackFull; return(false); } foreach (UserCrystalInfo crystal in userCrystalArray) { UserCrystalInfo[] crystalArray1 = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)).ToArray(); if (subNum <= crystalArray1.Length) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St1307_FateBackpackFull; return(false); } CrystalInfo crystalInfo = new ShareCacheStruct <CrystalInfo>().FindKey(crystal.CrystalID); if (crystalInfo != null && crystalInfo.IsTelegrams == 1 && crystal.IsSale == 1) { crystal.IsSale = 2; package.SaveCrystal(crystal); //package.DelayChange(); ErrorCode = 1; } } } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().ServerBusy; return(false); } return(true); }
public override bool TakeAction() { string publicUserID = string.Empty; if (string.IsNullOrEmpty(toUserID)) { publicUserID = ContextUser.UserID; } else { publicUserID = toUserID; UserCacheGlobal.LoadOffline(publicUserID); } GameUser user = new PersonalCacheStruct <GameUser>().FindKey(publicUserID); if (new PersonalCacheStruct <UserFunction>().FindKey(publicUserID, FunctionEnum.Mingyunshuijing) == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_NoFun; return(false); } UserHelper.GetUserLightOpen(publicUserID); var package = UserCrystalPackage.Get(publicUserID); crystalPackNum = user.CrystalNum; userGeneralArray = new PersonalCacheStruct <UserGeneral>().FindAll(publicUserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong && u.GeneralType != GeneralType.Soul); // 佣兵排序 GeneralSortHelper.GeneralSort(ContextUser.UserID, userGeneralArray); if (userGeneralArray.Count > 0) { genQuality = userGeneralArray[0].GeneralQuality.ToShort(); userCrystalArray1 = package.CrystalPackage.FindAll(m => m.GeneralID == userGeneralArray[0].GeneralID); if (string.IsNullOrEmpty(toUserID)) { userCrystalArray2 = package.CrystalPackage.FindAll(m => m.GeneralID == 0 && m.IsSale == 2); userCrystalArray2.QuickSort((x, y) => { int result; if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } result = y.CrystalQuality.CompareTo(x.CrystalQuality); if (result == 0) { result = y.CurrExprience.CompareTo(x.CurrExprience); } return(result); }); } } return(true); }
public static string HuntingLife(GameUser user, out string errStr) { #region errStr = string.Empty; int huntingID = UserLightLit(user.UserID); int huntingID2 = UserNextLight(user.UserID, huntingID); UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(user.UserID); var probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(errStr); } ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2); if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { if (probabilityInfo.Price > user.GameCoin) { errStr = LanguageManager.GetLang().St_GameCoinNotEnough; return(errStr); } } //暑期第三弹 if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(user)) { errStr = LanguageManager.GetLang().St1305_BeiBaoBackpackFull; return(errStr); } var lightCacheSet = new PersonalCacheStruct <UserLight>(); if (huntingID != 1001) { UserLight userLight1 = lightCacheSet.FindKey(user.UserID, huntingID); if (userLight1.IsLight == 2) { return(string.Empty); } if (userLight1.IsLight == 1) { userLight1.IsLight = 2; } } UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(user.UserID, huntingID2); if (RandomUtils.IsHit(probability1.Light)) { if (userLight != null) { userLight.IsLight = 1; if (userLight.HuntingID == 1005) { errStr = LanguageManager.GetLang().St1305_HuntingIDLight; } } else { userLight = new UserLight() { UserID = user.UserID, HuntingID = huntingID2, IsLight = 1 }; lightCacheSet.Add(userLight); } } if (userRestrain != null) { if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(user.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0); } else { userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue); } } else { user.GameCoin = MathUtils.Subtraction(user.GameCoin, probabilityInfo.Price, 0); } //每种品质的概率 double[] probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red }; int index2 = RandomUtils.GetHitIndex(probabilityArray2); CrystalQualityType qualityType = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString()); List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); var crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray) { //wuzf修改 8-15 灰色放在临时背包不存DB CrystalHelper.AppendGrayCrystal(user, crystal.CrystalID); } else if (crystal != null) { var package = UserCrystalPackage.Get(user.UserID); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 1, CreateDate = DateTime.Now }; package.SaveCrystal(userCrystal); UserLogHelper.AppenCtystalLog(user.UserID, 5, crystal.CrystalID, probabilityInfo.Price, 0, null, 1, 0); //高品质聊天通知); if (crystal.CrystalQuality >= CrystalQualityType.Yellow) { var cacheChat = new TjxChatService(); string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice, user.NickName, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName ); cacheChat.SystemSend(ChatType.World, content); } } } return(errStr); #endregion }
public override bool TakeAction() { UserHelper.GetUserLightOpen(ContextUser.UserID); short opType = 0; int huntingID2 = 0; if (huntingID < 1005) { huntingID2 = MathUtils.Addition(huntingID, 1, int.MaxValue); } else { huntingID2 = 1001; //huntingID; } UserHelper.ChechDailyRestrain(ContextUser.UserID); if (!CrystalHelper.CheckAllowCrystall(ContextUser)) { ErrorCode = 1000; ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull; return(false); } else { if (!CrystalHelper.CheckAllowCrystall(ContextUser)) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St1305_FateBackpackFull; return(false); } } ProbabilityInfo probabilityInfo = null; if (ops == 1) { #region opType = 1; UserDailyRestrain userRestrain = new PersonalCacheStruct <UserDailyRestrain>().FindKey(ContextUser.UserID); probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } ProbabilityInfo probability1 = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID2); if (userRestrain != null && userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { if (probabilityInfo.Price > ContextUser.GameCoin) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough; return(false); } } //暑期第三弹 if (huntingID2 == 1001 && !NoviceHelper.IsGianCrystalPack(ContextUser)) { ErrorCode = errorNum; ErrorInfo = LanguageManager.GetLang().St1305_BeiBaoBackpackFull; return(false); } var lightCacheSet = new PersonalCacheStruct <UserLight>(); if (huntingID != 1001) { UserLight userLight1 = lightCacheSet.FindKey(ContextUser.UserID, huntingID); if (userLight1.IsLight == 2) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (userLight1.IsLight == 1) { userLight1.IsLight = 2; //userLight1.Update(); } } UserLight userLight = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, huntingID2); if (RandomUtils.IsHit(probability1.Light)) { ErrorCode = ErrorCode; ErrorInfo = probability1.HuntingName; if (userLight != null) { userLight.IsLight = 1; //userLight.Update(); } else { userLight = new UserLight() { UserID = ContextUser.UserID, HuntingID = huntingID2, IsLight = 1 }; lightCacheSet.Add(userLight); } } if (userRestrain != null) { if (userRestrain.Funtion2 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0); //ContextUser.Update(); } else { userRestrain.Funtion2 = MathUtils.Addition(userRestrain.Funtion2, 1, int.MaxValue); //userRestrain.Update(); } } else { ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, probabilityInfo.Price, 0); //ContextUser.Update(); } lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID); #endregion } else if (ops == 2) { #region opType = 2; if (ContextUser.VipLv < 5) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_VipNotEnough; return(false); } probabilityInfo = new ShareCacheStruct <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } if (ContextUser.GoldNum < probabilityInfo.Price) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } UserLight uLightInfo = new PersonalCacheStruct <UserLight>().FindKey(ContextUser.UserID, probabilityInfo.GoldHunting); if (uLightInfo != null && uLightInfo.IsLight == 1) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1305_HuntingIDLight; return(false); } else if (uLightInfo != null && (uLightInfo.IsLight == 2 || uLightInfo.IsLight == 0)) { uLightInfo.IsLight = 1; } else { uLightInfo = new UserLight() { UserID = ContextUser.UserID, HuntingID = probabilityInfo.GoldHunting, IsLight = 1 }; new PersonalCacheStruct <UserLight>().Add(uLightInfo); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue); lightArray = new PersonalCacheStruct <UserLight>().FindAll(ContextUser.UserID); #endregion } //每种品质的概率 double[] probabilityArray2 = { (double)probabilityInfo.Gray, (double)probabilityInfo.Green, (double)probabilityInfo.Blue, (double)probabilityInfo.Purple, (double)probabilityInfo.Yellow, (double)probabilityInfo.Red }; int index2 = RandomUtils.GetHitIndex(probabilityArray2); CrystalQualityType qualityType = (CrystalQualityType)Enum.Parse(typeof(CrystalQualityType), (index2 + 1).ToString()); List <CrystalInfo> crystalArray2 = new ShareCacheStruct <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); crystal = new ShareCacheStruct <CrystalInfo>().FindKey(crystalArray2[randomNum].CrystalID); if (crystal != null && crystal.CrystalQuality == CrystalQualityType.Gray) { //wuzf修改 8-15 灰色放在临时背包不存DB CrystalHelper.AppendGrayCrystal(ContextUser, crystal.CrystalID); } else if (crystal != null) { var package = UserCrystalPackage.Get(Uid); UserCrystalInfo userCrystal = new UserCrystalInfo() { UserCrystalID = Guid.NewGuid().ToString(), CrystalID = crystal.CrystalID, CrystalLv = 1, CurrExprience = 0, GeneralID = 0, IsSale = 1, CreateDate = DateTime.Now }; package.SaveCrystal(userCrystal); UserLogHelper.AppenCtystalLog(ContextUser.UserID, opType, crystal.CrystalID, probabilityInfo.Price, probabilityInfo.Price, null, 1, 0); //高品质聊天通知); if (crystal.CrystalQuality >= CrystalQualityType.Yellow) { var cacheChat = new TjxChatService(); string content = string.Format(LanguageManager.GetLang().St1305_HighQualityNotice, ContextUser.NickName, CrystalHelper.GetQualityName(crystal.CrystalQuality), crystal.CrystalName ); cacheChat.SystemSend(ChatType.World, content); } } } //日常任务-猎命 TaskHelper.TriggerDailyTask(Uid, 4009); return(true); }
public override bool TakeAction() { List <UserTakePrize> userPrizeList = new ShareCacheStruct <UserTakePrize>().FindAll(m => !m.IsTasked && m.UserID == ObjectExtend.ToInt(Uid)); if (userPrizeList.Count > 0) { var userPrize = userPrizeList[0]; if (userPrize.ItemPackage.Length > 0) { if (UserItemHelper.CheckItemOut(ContextUser, ItemStatus.BeiBao, PutItemNum(userPrize))) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1107_GridNumFull; return(false); } } if (userPrize.SparePackage.Length > 0) { int currNum = ContextUser.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count; currNum = MathUtils.Addition(currNum, PutCrystalSpareNum(userPrize.SparePackage.Split(','), 1)); //原因:零件等于开启格子时提示背包已满 if (currNum > ContextUser.UserExtend.SparePartGridNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1213_GridNumFull; return(false); } } if (userPrize.CrystalPackage.Length > 0) { var package = UserCrystalPackage.Get(ContextUser.UserID); UserCrystalInfo[] crystalArrayErr = package.CrystalPackage.FindAll(m => m.IsSale == 2 && m.GeneralID.Equals(0)).ToArray(); int crystalNum = MathUtils.Addition(crystalArrayErr.Length, PutCrystalSpareNum(userPrize.CrystalPackage.Split(','), 2)); //原因:命运水晶等于开启格子时提示背包已满 if (crystalNum > ContextUser.CrystalNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1307_FateBackpackFull; return(false); } } if (!string.IsNullOrEmpty(userPrize.EnchantPackage) && userPrize.EnchantPackage.Length > 0) { var package = UserEnchant.Get(ContextUser.UserID); if (package != null) { var enchantList = package.EnchantPackage.FindAll(m => string.IsNullOrEmpty(m.UserItemID)); int enchantNum = MathUtils.Addition(enchantList.Count, PutCrystalSpareNum(userPrize.EnchantPackage.Split(','), 2)); if (ContextUser.UserExtend != null && enchantNum > ContextUser.UserExtend.EnchantGridNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1259_EnchantGridNumFull; return(false); } } } if (doProcessPrize(userPrize)) { ErrorInfo = userPrize.MailContent; } else { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } } return(true); }