/// <summary> /// 奖励物品 /// </summary> /// <param name="prize"></param> /// <returns></returns> public static void ChestGainTreasureInfo(GameUser user, DialInfo dialInfo, int count) { var treasure = new TreasureInfo(); treasure.UserID = user.UserID; treasure.Type = dialInfo.RewardType; treasure.ItemID = dialInfo.ItemID; treasure.Num = dialInfo.ItemNum; treasure.ItemLv = 1; UserDial userDial = new PersonalCacheStruct <UserDial>().FindKey(user.UserID); if (userDial == null) { userDial = new UserDial(); } userDial.GroupID = 0; userDial.RefreshDate = DateTime.Now; userDial.Treasure.Add(treasure); if (count == 0) { userDial.PrizeInfo = treasure; userDial.HeadID = dialInfo.HeadID; } if (GameConfigSet.Treasure > 0 && userDial.Treasure.Count > GameConfigSet.Treasure) { for (int i = 0; i < userDial.Treasure.Count - GameConfigSet.Treasure; i++) { userDial.Treasure.Remove(userDial.Treasure[i]); } } if (dialInfo.IsShow) { var cacheSet = new ShareCacheStruct <ServerEnvSet>(); var serverEnvSet = cacheSet.FindKey(ServerEnvKey.UserTreasure); if (serverEnvSet == null) { serverEnvSet = new ServerEnvSet(); serverEnvSet.EnvKey = ServerEnvKey.UserTreasure; cacheSet.Add(serverEnvSet); } var treasureInfoList = ServerEnvSetTreasure(treasure); serverEnvSet.EnvValue = JsonUtils.Serialize(treasureInfoList); } if (dialInfo.IsBroadcast && !string.IsNullOrEmpty(dialInfo.BroadContent)) { TjxChatService chatService = new TjxChatService(); chatService.SystemSend(ChatType.World, string.Format(dialInfo.BroadContent, user.NickName)); } if (dialInfo.RewardType == RewardType.Again || dialInfo.RewardType == RewardType.Mood || dialInfo.RewardType == RewardType.Recharge) { if (dialInfo.RewardType == RewardType.Recharge) { userDial.ReturnRatio = treasure.Num; } return; } ChestGetUserTake(treasure, user); }
/// <summary> /// 处理击杀奖励 /// </summary> private void DoKillPrize(GameUser user) { BossActivePrize bossPrize = GameActive.BossPrize; if (bossPrize == null) { return; } TjxChatService chatService = new TjxChatService(); var rankingList = RefreshRanking(); ServerEnvSet.Set(ServerEnvKey.FirstHalfBoss, rankingList.ToJson()); int length = rankingList.Count > bossPrize.TopObtain ? bossPrize.TopObtain : rankingList.Count; //处理排名奖励 for (int i = 0; i < length; i++) { string prizeItemMsg = string.Empty; GameUser tempUser = new GameDataCacheSet <GameUser>().FindKey(rankingList[i].UserId); tempUser.GameCoin = MathUtils.Addition(tempUser.GameCoin, bossPrize.TopObtainNum, int.MaxValue); //前3名奖励 if (i == 0) { DoTopThreePrize(i + 1, tempUser, bossPrize.Rank1, bossPrize.Items, out prizeItemMsg); } else if (i == 1) { DoTopThreePrize(i + 1, tempUser, bossPrize.Rank2, bossPrize.Items, out prizeItemMsg); } else if (i == 2) { DoTopThreePrize(i + 1, tempUser, bossPrize.Rank3, bossPrize.Items, out prizeItemMsg); } //tempUser.Update(); if (!string.IsNullOrEmpty(prizeItemMsg)) { prizeItemMsg = "," + prizeItemMsg; } chatService.SystemSend(ChatType.World, string.Format(LanguageManager.GetLang().St5405_CombatRankmReward, tempUser.NickName, (i + 1), bossPrize.TopObtainNum, prizeItemMsg)); TraceLog.ReleaseWriteDebug(string.Format(LanguageManager.GetLang().St5405_CombatRankmReward, tempUser.NickName, (i + 1), bossPrize.TopObtainNum, prizeItemMsg)); // CountryCombat.Contribution(tempUser.UserID, bossPrize.TopObtainNum); //公会贡献 } }
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); }