protected override void ProcessCmd(string[] args) { int magicID = args.Length > 0 ? args[0].Trim().ToInt() : 0; short magicLv = args.Length > 1 ? args[1].Trim().ToShort() : (short)1; var cacheSet = new GameDataCacheSet<UserMagic>(); var userMagic = cacheSet.FindKey(UserID, magicID); MagicInfo magic = new ConfigCacheSet<MagicInfo>().FindKey(magicID); if (magic == null) { return; } if (userMagic == null) { userMagic = new UserMagic() { UserID = UserID, MagicID = magicID, MagicLv = magicLv, IsEnabled = false, MagicType = magic.MagicType, }; cacheSet.Add(userMagic); } else { userMagic.MagicLv = magicLv; } }
public override bool TakeAction() { var cacheSet = new GameDataCacheSet<GameUser>(); GameUser user = cacheSet.FindKey(_useridreq); if (null != user) { if ((user.UserName != _username) || (user.UserType != _usertype)) { return false; } /*更新客户端上报的存档信息*/ user.ClientArchive = _clientarchive; cacheSet.Add(user); cacheSet.Update(); return true; } else { return false; } }
public static short _currMaxLv = GameConfigSet.CurrMaxLv.ToShort(); //玩家最大等级 #endregion Fields #region Methods /// <summary> /// 创建佣兵或佣兵灵魂 /// </summary> /// <param name="userID"></param> /// <param name="general"></param> /// <param name="type"></param> /// <param name="num"></param> public static void CreateUserGeneral(string userID, GeneralInfo general, GeneralType type, int num) { var cacheSet = new GameDataCacheSet<UserGeneral>(); int generalID = 0; CareerInfo careerInfo = null; if (type == GeneralType.YongBing) { generalID = general.GeneralID; careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(general.CareerID); } else if (type == GeneralType.Soul) { generalID = general.SoulID; } if (generalID > 0) { UserGeneral userGeneral = new UserGeneral(); userGeneral.UserID = userID; userGeneral.GeneralID = generalID; userGeneral.GeneralName = general.GeneralName; userGeneral.HeadID = general.HeadID; userGeneral.PicturesID = general.PicturesID; userGeneral.GeneralLv = 1; userGeneral.GeneralType = type; userGeneral.CareerID = general.CareerID; userGeneral.PowerNum = general.PowerNum; userGeneral.SoulNum = general.SoulNum; userGeneral.IntellectNum = general.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.AbilityID = general.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = string.Empty; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong; userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; if (careerInfo != null) { userGeneral.LifeNum = MathUtils.Addition(general.LifeNum, careerInfo.LifeIncreaseNum * (MathUtils.Subtraction(careerInfo.Lv, (short)1, (short)0)), int.MaxValue); } if (type == GeneralType.Soul) { userGeneral.AtmanNum = num; } userGeneral.HeritageType = HeritageType.Normal; userGeneral.AbilityNum = 3; cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod); } }
/// <summary> /// 下发任务 /// </summary> /// <param name="user"></param> /// <param name="taskID"></param> public static List<UserTask> SendAllowTask(GameUser user, int taskID) { List<UserTask> userTaskList = new List<UserTask>(); var cacheSet = new GameDataCacheSet<UserTask>(); UserTask preTask = cacheSet.FindKey(user.UserID, taskID); if (taskID > 0 && preTask != null && (preTask.TaskState != TaskState.Close || preTask.TaskType == TaskType.Offset)) { return userTaskList; } if (taskID == 0 && cacheSet.FindAll(user.UserID, m => m.TaskType < TaskType.Daily).Count > 0) { return userTaskList; } IList<StoryTaskInfo> taskList = StoryTaskInfo.GetNextTask(taskID); bool isSend = true; foreach (StoryTaskInfo taskInfo in taskList) { if (taskInfo.CountryID != CountryType.None && user.CountryID != taskInfo.CountryID) { continue; } UserTask userTask = cacheSet.FindKey(user.UserID, taskInfo.TaskID); if (userTask == null) { userTask = new UserTask { TaskID = taskInfo.TaskID, UserID = user.UserID, TaskType = taskInfo.TaskType, TaskState = taskInfo.TaskLv <= user.UserLv ? TaskState.AllowTake : TaskState.NoTake, CompleteNum = 0, CreateDate = DateTime.Now }; cacheSet.Add(userTask); userTask = cacheSet.FindKey(user.UserID, taskInfo.TaskID); userTaskList.Add(userTask); } else { //判断是否已下发过 isSend = false; break; } } if (isSend) { return userTaskList; } return new List<UserTask>(); }
/// <summary> /// 创建用户 /// </summary> public GameUser CreateGameuser() { GameUser newuser = new GameUser(_buserinfo.UserId); newuser.UserName = _userinfo.UserName; newuser.UserType = _userinfo.UserType; newuser.ClientOS = _userinfo.ClientOS; newuser.ClientVersion = _userinfo.ClientVersion; newuser.UserMagic = _userinfo.UserMagic; newuser.UserBirthday = _userinfo.UserBirthday; var cacheSet = new GameDataCacheSet<GameUser>(); cacheSet.Add(newuser); cacheSet.Update(); return _userinfo; }
private void Process(string userID, int fun) { FunctionEnum funEnum = fun.ToEnum<FunctionEnum>(); var cacheSet = new GameDataCacheSet<UserFunction>(); UserFunction userFunction = cacheSet.FindKey(UserID, funEnum); if (userFunction == null) { userFunction = new UserFunction() { UserID = userID, FunEnum = funEnum, CreateDate = DateTime.Now }; cacheSet.Add(userFunction, GameEnvironment.CacheUserPeriod); } }
private void CreateGeneral(CareerInfo careerInfo) { GeneralInfo general = new ConfigCacheSet <GeneralInfo>().FindKey(generalID); List <UserGeneral> userGeneralArray = new GameDataCacheSet <UserGeneral>().FindAll(Uid); if (userGeneralArray.Count > 0 || general == null) { return; } UserGeneral userGeneral = new UserGeneral(); userGeneral.UserID = Uid; userGeneral.GeneralID = general.GeneralID; userGeneral.GeneralName = general.GeneralName; userGeneral.HeadID = general.HeadID; userGeneral.PicturesID = general.PicturesID; userGeneral.GeneralLv = (short)careerInfo.Lv; userGeneral.GeneralType = GeneralType.YongHu; userGeneral.CareerID = _careerID; userGeneral.PowerNum = general.PowerNum; userGeneral.SoulNum = general.SoulNum; userGeneral.IntellectNum = general.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.AbilityID = general.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = string.Empty; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong; userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; //userGeneral.LifeNum = MathUtils.Addition(general.LifeNum, careerInfo.LifeIncreaseNum * (MathUtils.Subtraction(careerInfo.Lv, (short)1, (short)0)), int.MaxValue); userGeneral.RefreshMaxLife(); userGeneral.HeritageType = HeritageType.Normal; userGeneral.AbilityNum = 3; var cacheSet = new GameDataCacheSet <UserGeneral>(); cacheSet.Add(userGeneral); cacheSet.Update(); UserAbilityHelper.AddUserAbility(general.AbilityID, Uid.ToInt(), generalID, 1); }
/// <summary> /// 添加玩家魂技 /// </summary> /// <param name="abilityId"></param> /// <param name="userId"></param> public static void AddUserAbility(int abilityId, int userId, int generalID, int position) { var userAbility = _cacheSetAbility.FindKey(userId.ToString()); var ability = userAbility != null && userAbility.AbilityList != null ? userAbility.AbilityList.Find(s => s.AbilityID == abilityId) : null; var abilityLv = new ConfigCacheSet <AbilityLvInfo>().FindKey(abilityId, 1); int experienceNum = abilityLv != null ? abilityLv.Experience : 0; if (userAbility == null) { userAbility = new UserAbility(userId); ability = new Ability(); userAbility.CreateDate = DateTime.Now; ability.UserItemID = Guid.NewGuid().ToString(); ability.AbilityID = abilityId; ability.AbilityLv = 1; ability.GeneralID = generalID; ability.ExperienceNum = experienceNum; ability.Position = position; userAbility.AbilityList.Add(ability); _cacheSetAbility.Add(userAbility); // 添加到玩家集邮册 UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.Ability, abilityId); } else { ability = new Ability(); ability.UserItemID = Guid.NewGuid().ToString(); userAbility.CreateDate = DateTime.Now; ability.AbilityID = abilityId; ability.AbilityLv = 1; ability.GeneralID = generalID; ability.Position = position; ability.ExperienceNum = experienceNum; userAbility.AbilityList.Add(ability); // 添加到玩家集邮册 UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.Ability, abilityId); } UserAlbumHelper.AddUserAlbum(userId.ToString(), AlbumType.General, generalID); }
/// <summary> /// 检查每日抽奖次数 /// </summary> /// <param name="userID"></param> public static void CheckDialNum(string userID) { UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID); if (userDial != null && userDial.RefreshDate.Date != DateTime.Now.Date) { userDial.DialNum = 0; userDial.RefreshDate = DateTime.Now; } if (userDial == null) { var cacheSet = new GameDataCacheSet<UserDial>(); userDial = new UserDial(); userDial.UserID = userID; userDial.HeadID = string.Empty; userDial.ReturnRatio = 0; userDial.DialNum = 0; cacheSet.Add(userDial); } }
/// <summary> /// 累计消费活动奖励(晶石,金币,精力) /// </summary> private static void FestivalConsumeCount(FestivalInfo info, string userID) { UserConsume consume = new GameDataCacheSet <UserConsume>().FindKey(userID); if (consume == null) { return; } var cacheSet = new GameDataCacheSet <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest != null && fRest.RestrainNum >= 1 && fRest.RefreashDate == info.StartDate) { return; } if ((info.FestivalType == FestivalType.SparConsumption && consume.GoldDate >= info.StartDate && consume.GoldNum >= info.RestrainNum) || (info.FestivalType == FestivalType.GameCoin && consume.CoinDate >= info.StartDate && consume.GameCoin >= info.RestrainNum) || (info.FestivalType == FestivalType.Energy && consume.EnergyDate >= info.StartDate && consume.EnergyNum >= info.RestrainNum)) { CacheList <PrizeInfo> prizeList = PrizeHelper.GetPrizeInfo(info.Reward); foreach (PrizeInfo prize in prizeList) { UserTakePrize userTask = PrizeHelper.GetUserTake(prize, userID, info); new ShareCacheStruct <UserTakePrize>().Add(userTask); } if (fRest == null) { fRest = new FestivalRestrain(); fRest.FestivalID = info.FestivalID; fRest.RefreashDate = info.StartDate; fRest.RestrainNum = 1; fRest.UserID = userID; cacheSet.Add(fRest); } else { fRest.RefreashDate = info.StartDate; fRest.RestrainNum = 1; //fRest.Update(); } } }
/// <summary> /// 默认玩家注册获得背包格子数 /// </summary> /// <param name="userId"></param> public static void AddUserPack(string userId) { var userPack = _cacheSetUserPack.FindKey(userId); var backpackList = _cacheSetBackpack.FindAll(); backpackList.ForEach(backpack => { if (userPack == null) { userPack = new UserPack(userId.ToInt()); userPack.CreateDate = DateTime.Now; var packType = new PackType(); packType.BackpackType = backpack.BackpackType; packType.OpenNum = 0; packType.Position = backpack.DefaultNum; userPack.PackTypeList.Add(packType); _cacheSetUserPack.Add(userPack, userId.ToInt()); } else { var packType = userPack.PackTypeList != null ? userPack.PackTypeList.Find( s => s.BackpackType == backpack.BackpackType) : null; if (packType == null) { packType = new PackType(); packType.BackpackType = backpack.BackpackType; packType.OpenNum = 0; packType.Position = backpack.DefaultNum; userPack.PackTypeList.Add(packType); } else { packType.BackpackType = backpack.BackpackType; packType.OpenNum = 0; packType.Position = backpack.DefaultNum; } } }); }
/// <summary> /// 检查每日抽奖次数 /// </summary> /// <param name="userID"></param> public static void CheckDialNum(string userID) { UserDial userDial = new GameDataCacheSet <UserDial>().FindKey(userID); if (userDial != null && userDial.RefreshDate.Date != DateTime.Now.Date) { userDial.DialNum = 0; userDial.RefreshDate = DateTime.Now; } if (userDial == null) { var cacheSet = new GameDataCacheSet <UserDial>(); userDial = new UserDial(); userDial.UserID = userID; userDial.HeadID = string.Empty; userDial.ReturnRatio = 0; userDial.DialNum = 0; cacheSet.Add(userDial); } }
/// <summary> /// 注册默认添加祈祷 /// </summary> /// <param name="userId"></param> public static void AddUserPray(int userId, PrayType prayType) { var userPray = _cacheSetUserPray.FindKey(userId.ToString()); if (userPray != null) { userPray.PrayDate = DateTime.Now.AddDays(-1); userPray.PrayNum = 0; userPray.IsPray = false; userPray.PrayType = prayType; } else { userPray = new UserPray(userId); userPray.PrayDate = DateTime.Now.AddDays(-1); userPray.PrayNum = 0; userPray.IsPray = false; userPray.PrayType = prayType; _cacheSetUserPray.Add(userPray, userId); } }
/// <summary> /// 累计充值活动 /// </summary> public static void FestivalPayCount(FestivalInfo info, GameUser user) { UserRecharge recharge = new GameDataCacheSet <UserRecharge>().FindKey(user.UserID); if (recharge == null) { return; } var cacheSet = new GameDataCacheSet <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(user.UserID, info.FestivalID); if (fRest != null && fRest.RestrainNum >= 1 && fRest.RefreashDate == info.StartDate) { return; } if (recharge.FestivalDate >= info.StartDate && recharge.FestivalCount >= info.RestrainNum) { CacheList <PrizeInfo> prizeList = PrizeHelper.GetPrizeInfo(info.Reward); foreach (PrizeInfo prize in prizeList) { UserTakePrize userTask = PrizeHelper.GetUserTake(prize, user.UserID, info); new ShareCacheStruct <UserTakePrize>().Add(userTask); } if (fRest == null) { fRest = new FestivalRestrain(); fRest.FestivalID = info.FestivalID; fRest.RefreashDate = info.StartDate; fRest.RestrainNum = 1; fRest.UserID = user.UserID; cacheSet.Add(fRest); } else { fRest.RefreashDate = info.StartDate; fRest.RestrainNum = 1; } } }
private void Process(string userID, int generalID) { GeneralInfo generalInfo = new ConfigCacheSet <GeneralInfo>().FindKey(generalID); if (generalInfo != null) { var cacheSet = new GameDataCacheSet <UserGeneral>(); var usergeneral = cacheSet.FindKey(userID, generalID); if (usergeneral == null) { usergeneral = new UserGeneral() { UserID = userID, GeneralID = generalID, GeneralName = generalInfo.GeneralName, HeadID = generalInfo.HeadID, PicturesID = generalInfo.PicturesID, GeneralLv = generalInfo.GeneralLv, LifeNum = generalInfo.LifeNum, GeneralType = GeneralType.YongBing, CareerID = generalInfo.CareerID, PowerNum = generalInfo.PowerNum, SoulNum = generalInfo.SoulNum, IntellectNum = generalInfo.IntellectNum, TrainingPower = 0, TrainingSoul = 0, TrainingIntellect = 0, AbilityID = generalInfo.AbilityID, Momentum = 25, HitProbability = 85, GeneralStatus = GeneralStatus.DuiWuZhong, Experience1 = 0, Experience2 = 0, CurrExperience = 0, Description = string.Empty, }; cacheSet.Add(usergeneral); } } }
private void Process(string userID, int generalID) { GeneralInfo generalInfo = new ConfigCacheSet<GeneralInfo>().FindKey(generalID); if (generalInfo != null) { var cacheSet = new GameDataCacheSet<UserGeneral>(); var usergeneral = cacheSet.FindKey(userID, generalID); if (usergeneral == null) { usergeneral = new UserGeneral() { UserID = userID, GeneralID = generalID, GeneralName = generalInfo.GeneralName, HeadID = generalInfo.HeadID, PicturesID = generalInfo.PicturesID, GeneralLv = generalInfo.GeneralLv, LifeNum = generalInfo.LifeNum, GeneralType = GeneralType.YongBing, CareerID = generalInfo.CareerID, PowerNum = generalInfo.PowerNum, SoulNum = generalInfo.SoulNum, IntellectNum = generalInfo.IntellectNum, TrainingPower = 0, TrainingSoul = 0, TrainingIntellect = 0, AbilityID = generalInfo.AbilityID, Momentum = 25, HitProbability = 85, GeneralStatus = GeneralStatus.DuiWuZhong, Experience1 = 0, Experience2 = 0, CurrExperience = 0, Description = string.Empty, }; cacheSet.Add(usergeneral); } } }
private void CreateDailyRestrain() { if (new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid) == null) { UserDailyRestrain dailyRestrain = new UserDailyRestrain(); dailyRestrain.UserID = Uid; dailyRestrain.RefreshDate = DateTime.Now; dailyRestrain.Funtion1 = 0; dailyRestrain.Funtion2 = 0; dailyRestrain.Funtion3 = 0; dailyRestrain.Funtion4 = 0; dailyRestrain.Funtion5 = 0; dailyRestrain.Funtion6 = 0; dailyRestrain.Funtion7 = 0; dailyRestrain.Funtion8 = 0; dailyRestrain.Funtion9 = 0; var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); cacheSet.Add(dailyRestrain); cacheSet.Update(); } }
public static void TriggerWeekPack(string userID, int gameCoin) { int packType = 3; List <RechargePacks> rechargePackseArray = new ConfigCacheSet <RechargePacks>().FindAll(m => m.PacksType == packType); foreach (RechargePacks rechargePackse in rechargePackseArray) { if (rechargePackse.RechargeNum <= gameCoin) { var packCacheSet = new GameDataCacheSet <PackageReceive>(); List <PackageReceive> packageReceivess = packCacheSet.FindAll(userID, m => m.PacksID == rechargePackse.PacksID); if (packageReceivess.Count == 0) { PackageReceive receive = new PackageReceive(); receive.ReceiveID = Guid.NewGuid().ToString(); receive.PacksID = rechargePackse.PacksID; receive.UserID = userID; receive.IsReceive = false; receive.ReceiveDate = DateTime.Now; packCacheSet.Add(receive, GameEnvironment.CacheUserPeriod); } else if (!IsHaveWeek(packageReceivess)) { PackageReceive receive = packageReceivess[0]; if (receive.IsReceive) { receive.IsReceive = false; receive.ReceiveDate = DateTime.Now; //receive.Update(); } for (int i = 1; i <= packageReceivess.Count - 1; i++) { packCacheSet.Delete(packageReceivess[i]); } } } } }
/// <summary> /// 添加玩家魂技 /// </summary> /// <param name="abilityId"></param> /// <param name="userId"></param> private void AddUserAbility(int abilityId, int userId, int generalID, int position) { GameDataCacheSet <UserAbility> _cacheSetAbility = new GameDataCacheSet <UserAbility>(); var userAbility = _cacheSetAbility.FindKey(userId.ToString()); var ability = userAbility != null && userAbility.AbilityList != null ? userAbility.AbilityList.Find(s => s.AbilityID == abilityId) : null; var abilityLv = new ConfigCacheSet <AbilityLvInfo>().FindKey(abilityId, 1); int experienceNum = abilityLv != null ? abilityLv.Experience : 0; if (userAbility == null) { userAbility = new UserAbility(userId); ability = new Ability(); userAbility.CreateDate = DateTime.Now; ability.UserItemID = Guid.NewGuid().ToString(); ability.AbilityID = abilityId; ability.AbilityLv = 1; ability.GeneralID = generalID; ability.ExperienceNum = experienceNum; ability.Position = position; userAbility.AbilityList.Add(ability); _cacheSetAbility.Add(userAbility, GameEnvironment.CacheUserPeriod); } else { ability = new Ability(); ability.UserItemID = Guid.NewGuid().ToString(); userAbility.CreateDate = DateTime.Now; ability.AbilityID = abilityId; ability.AbilityLv = 1; ability.GeneralID = generalID; ability.Position = position; ability.ExperienceNum = experienceNum; userAbility.AbilityList.Add(ability); } }
protected override void ProcessCmd(string[] args) { int taskID = args.Length > 0 ? args[0].Trim().ToInt() : 0; GameUser user = new GameDataCacheSet <GameUser>().FindKey(UserID); if (user == null) { UserCacheGlobal.Load(UserID); user = new GameDataCacheSet <GameUser>().FindKey(UserID); } var taskList = StoryTaskInfo.GetNextTask(taskID); foreach (StoryTaskInfo taskInfo in taskList) { if (taskInfo.CountryID != CountryType.None && user.CountryID != taskInfo.CountryID) { continue; } var cacheSet = new GameDataCacheSet <UserTask>(); UserTask userTask = cacheSet.FindKey(UserID, taskInfo.TaskID); if (userTask == null) { userTask = new UserTask { TaskID = taskInfo.TaskID, UserID = UserID, TaskType = taskInfo.TaskType, TaskState = TaskState.AllowTake, CreateDate = DateTime.Now }; cacheSet.Add(userTask, GameEnvironment.CacheUserPeriod); } else { userTask.TaskState = TaskState.AllowTake; } } }
protected override void ProcessCmd(string[] args) { int taskID = args.Length > 0 ? args[0].Trim().ToInt() : 0; GameUser user = new GameDataCacheSet<GameUser>().FindKey(UserID); if (user == null) { UserCacheGlobal.Load(UserID); user = new GameDataCacheSet<GameUser>().FindKey(UserID); } var taskList = StoryTaskInfo.GetNextTask(taskID); foreach (StoryTaskInfo taskInfo in taskList) { if (taskInfo.CountryID != CountryType.None && user.CountryID != taskInfo.CountryID) { continue; } var cacheSet = new GameDataCacheSet<UserTask>(); UserTask userTask = cacheSet.FindKey(UserID, taskInfo.TaskID); if (userTask == null) { userTask = new UserTask { TaskID = taskInfo.TaskID, UserID = UserID, TaskType = taskInfo.TaskType, TaskState = TaskState.AllowTake, CreateDate = DateTime.Now }; cacheSet.Add(userTask); } else { userTask.TaskState = TaskState.AllowTake; } } }
/// <summary> /// 天地劫挑战次数 /// </summary> /// <param name="plotNPCInfo"></param> private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo) { var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); UserDailyRestrain userRestrain = cacheSet.FindKey(Uid); if (userRestrain == null) { userRestrain = new UserDailyRestrain() { UserID = Uid }; cacheSet.Add(userRestrain, GameEnvironment.CacheUserPeriod); userRestrain = cacheSet.FindKey(Uid); } if (userRestrain.UserExtend == null) { userRestrain.UserExtend = new DailyUserExtend(); //userRestrain.UserExtend.KalpaPlot = new List<FunPlot>(); } int plotNum = 0; FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID); if (funPlot == null) { plotNum = 1; funPlot = new FunPlot { PlotID = plotNPCInfo.PlotID, Num = plotNum }; userRestrain.UserExtend.UpdateNotify(obj => { userRestrain.UserExtend.KalpaPlot.Add(funPlot); return(true); }); } }
/// <summary> /// 添加玩家魂技 /// </summary> /// <param name="abilityId"></param> /// <param name="userId"></param> private void AddUserAbility(int abilityId, int userId, int generalID, int position) { GameDataCacheSet<UserAbility> _cacheSetAbility = new GameDataCacheSet<UserAbility>(); var userAbility = _cacheSetAbility.FindKey(userId.ToString()); var ability = userAbility != null && userAbility.AbilityList != null ? userAbility.AbilityList.Find(s => s.AbilityID == abilityId) : null; var abilityLv = new ConfigCacheSet<AbilityLvInfo>().FindKey(abilityId, 1); int experienceNum = abilityLv != null ? abilityLv.Experience : 0; if (userAbility == null) { userAbility = new UserAbility(userId); ability = new Ability(); userAbility.CreateDate = DateTime.Now; ability.UserItemID = Guid.NewGuid().ToString(); ability.AbilityID = abilityId; ability.AbilityLv = 1; ability.GeneralID = generalID; ability.ExperienceNum = experienceNum; ability.Position = position; userAbility.AbilityList.Add(ability); _cacheSetAbility.Add(userAbility); } else { ability = new Ability(); ability.UserItemID = Guid.NewGuid().ToString(); userAbility.CreateDate = DateTime.Now; ability.AbilityID = abilityId; ability.AbilityLv = 1; ability.GeneralID = generalID; ability.Position = position; ability.ExperienceNum = experienceNum; userAbility.AbilityList.Add(ability); } }
public override bool TakeAction() { PlantType pType = plantType.ToEnum <PlantType>(); UserPlantQuality userPlantQuality = new GameDataCacheSet <UserPlantQuality>().FindKey(ContextUser.UserID, generalID, pType); UserGeneral userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID); if (userPlantQuality == null) { return(false); } UserPlant userPlant = new GameDataCacheSet <UserPlant>().FindKey(ContextUser.UserID); if (userPlant == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } if (pType == PlantType.GameGoin && userPlant.DewNum == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St10004_DewNotEnough; return(false); } if (userGeneral != null && pType == PlantType.Experience) { if (UserHelper.GeneralIsUpLv(ContextUser.UserID, generalID, ContextUser.UserLv, landPsition)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St10004_GeneralNotUserLv; return(false); } } var cacheSet = new GameDataCacheSet <UserLand>(); UserLand land = cacheSet.FindKey(ContextUser.UserID, landPsition); if (land == null) { land = new UserLand(); land.UserID = ContextUser.UserID; land.LandPositon = landPsition; land.GeneralID = generalID; land.IsBlackLand = 2; land.IsRedLand = 2; land.IsGain = 1; land.PlantQuality = userPlantQuality.PlantQuality; land.GainDate = MathUtils.SqlMinDate; cacheSet.Add(land); } if (land.IsGain > 1 && ((DateTime.Now - land.GainDate).TotalSeconds > 28800)) { land.GeneralID = generalID; land.PlantType = pType; land.IsGain = 1; land.PlantQuality = userPlantQuality.PlantQuality; } else { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } if (pType == PlantType.GameGoin) { userPlant.DewNum = MathUtils.Subtraction(userPlant.DewNum, 1, 0); } userPlantQuality.PlantQuality = PlantQualityType.PuTong; //日常任务-庄园 TaskHelper.TriggerDailyTask(Uid, 4008); return(true); }
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 GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID); probabilityInfo = new ConfigCacheSet <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(false); } ProbabilityInfo probability1 = new ConfigCacheSet <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 GameDataCacheSet <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 GameDataCacheSet <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 GameDataCacheSet <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 ConfigCacheSet <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 GameDataCacheSet <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 GameDataCacheSet <UserLight>().Add(uLightInfo); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue); lightArray = new GameDataCacheSet <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 ConfigCacheSet <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); crystal = new ConfigCacheSet <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() { int sumGold = GetPostionUseGold(landPostion); UserPlant plant = new GameDataCacheSet<UserPlant>().FindKey(ContextUser.UserID); UserLand uLands = new GameDataCacheSet<UserLand>().FindKey(ContextUser.UserID, landPostion); if (uLands != null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St10008_LandPostionIsOpen; return false; } if (Ops == 1) { ErrorCode = 1; ErrorInfo = string.Format(LanguageManager.GetLang().St10008_OpenLandPostion, sumGold); return false; } else if (Ops == 2) { if (ContextUser.GoldNum < sumGold) { ErrorCode = 2; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return false; } if (ContextUser.GoldNum >= sumGold) { ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold, int.MaxValue); //ContextUser.Update(); plant.LandNum = landPostion; //plant.Update(); UserLand land = new UserLand() { UserID = ContextUser.UserID, GeneralID = 0, LandPositon = landPostion, PlantType = PlantType.Experience, IsRedLand = 2, IsBlackLand = 2, IsGain = 2, PlantQuality = PlantQualityType.PuTong }; var cacheSet = new GameDataCacheSet<UserLand>(); cacheSet.Add(land, GameEnvironment.CacheUserPeriod); UserLogHelper.AppenLandLog(ContextUser.UserID, 1, 0, landPostion, sumGold, 0, 0, 0); } } return true; }
public override bool TakeAction() { var cacheSet = new GameDataCacheSet <UserPlant>(); UserPlant plant = cacheSet.FindKey(ContextUser.UserID); var landCacheSet = new GameDataCacheSet <UserLand>(); List <UserLand> landArray = landCacheSet.FindAll(ContextUser.UserID); if (plant == null) { UserPlant uPlant = new UserPlant() { UserID = ContextUser.UserID, LandNum = 1, DewNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiMaxNum"), PayDewTime = 0, }; cacheSet.Add(uPlant); } if (landArray.Count == 0) { UserLand userLand = new UserLand() { UserID = ContextUser.UserID, PlantType = PlantType.Experience, LandPositon = 1, IsRedLand = 2, IsBlackLand = 2, IsGain = 2 }; landCacheSet.Add(userLand); } if (new GameDataCacheSet <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.Zhongzhijingqianshu) == null) { isShow = 2; } else { isShow = 1; } userPlant = new GameDataCacheSet <UserPlant>().FindKey(ContextUser.UserID); userLandArray = new GameDataCacheSet <UserLand>().FindAll(ContextUser.UserID); //圣水恢复 var queueCacheSet = new GameDataCacheSet <UserQueue>(); List <UserQueue> ShengShuiQueueArray = queueCacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.ShengShuiHuiFu); if (ShengShuiQueueArray.Count > 0) { UserQueue shengShuiQueue = ShengShuiQueueArray[0]; if (userPlant != null) { int shengshuiMaxNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiMaxNum"); int restorationDate = ConfigEnvSet.GetInt("UserQueue.ShengShuiRestorationDate"); //三小时 int restorationNum = ConfigEnvSet.GetInt("UserQueue.ShengShuiRestorationNum"); //恢复1点 int timeCount = (int)(DateTime.Now - shengShuiQueue.Timing).TotalSeconds / restorationDate; if (userPlant.DewNum < shengshuiMaxNum && timeCount > 0) { userPlant.DewNum = MathUtils.Addition(userPlant.DewNum, (timeCount * restorationNum), shengshuiMaxNum); //userPlant.Update(); shengShuiQueue.Timing = DateTime.Now; //shengShuiQueue.Update(); } } } else { UserQueue queue = new UserQueue() { QueueID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, QueueType = QueueType.ShengShuiHuiFu, QueueName = QueueType.ShengShuiHuiFu.ToString(), Timing = DateTime.Now, ColdTime = 0, TotalColdTime = 0, IsSuspend = false, StrengNum = 0 }; queueCacheSet.Add(queue); } return(true); }
private GameUser CreateRole() { GameUser user = new GameUser(UserId); user.SessionID = Sid; user.Pid = Pid; user.HeadIcon = HeadID; user.RetailId = RetailID; user.NickName = UserName; user.RealName = ""; user.Hobby = ""; user.Profession = ""; user.Sex = Sex.ToBool(); user.UserLv = (short)ConfigEnvSet.GetInt("User.Level", 1); user.GiftGold = ConfigEnvSet.GetInt("User.GiftGold", 100); user.GameCoin = ConfigEnvSet.GetInt("User.GameCoin", 1000); user.VipLv = ConfigEnvSet.GetInt("User.VipLv"); user.UserStatus = UserStatus.Normal; user.MsgState = true; user.MobileType = MobileType; user.ScreenX = ScreenX; user.ScreenY = ScreenY; user.ClientAppVersion = ReqAppVersion; user.LoginDate = DateTime.Now; user.CreateDate = DateTime.Now; user.TitleId = 1001; user.Property.GameId = GameID; user.Property.ServerId = ServerID; user.Birthday = new DateTime(1970, 1, 1); var cacheSet = new GameDataCacheSet<GameUser>(); cacheSet.Add(user); cacheSet.Update(); //增加初始背包、玩家任务表、玩家成就表 var itemCacheSet = new GameDataCacheSet<UserItemPackage>(); itemCacheSet.Add(new UserItemPackage(UserId)); itemCacheSet.Update(); var taskCacheSet = new GameDataCacheSet<UserTask>(); taskCacheSet.Add(new UserTask(UserId)); taskCacheSet.Update(); var achieveCacheSet = new GameDataCacheSet<UserAchieve>(); achieveCacheSet.Add(new UserAchieve(UserId)); achieveCacheSet.Update(); UserDailyRestrain restrain = new UserDailyRestrain(UserId); restrain.RefreshDate = DateTime.Now.AddDays(-1); var restrainCacheSet = new GameDataCacheSet<UserDailyRestrain>(); restrainCacheSet.Add(restrain); restrainCacheSet.Update(); return user; }
public static void TriggerWeekPack(string userID, int gameCoin) { int packType = 3; List<RechargePacks> rechargePackseArray = new ConfigCacheSet<RechargePacks>().FindAll(m => m.PacksType == packType); foreach (RechargePacks rechargePackse in rechargePackseArray) { if (rechargePackse.RechargeNum <= gameCoin) { var packCacheSet = new GameDataCacheSet<PackageReceive>(); List<PackageReceive> packageReceivess = packCacheSet.FindAll(userID, m => m.PacksID == rechargePackse.PacksID); if (packageReceivess.Count == 0) { PackageReceive receive = new PackageReceive(); receive.ReceiveID = Guid.NewGuid().ToString(); receive.PacksID = rechargePackse.PacksID; receive.UserID = userID; receive.IsReceive = false; receive.ReceiveDate = DateTime.Now; packCacheSet.Add(receive, GameEnvironment.CacheUserPeriod); } else if (!IsHaveWeek(packageReceivess)) { PackageReceive receive = packageReceivess[0]; if (receive.IsReceive) { receive.IsReceive = false; receive.ReceiveDate = DateTime.Now; //receive.Update(); } for (int i = 1; i <= packageReceivess.Count - 1; i++) { packCacheSet.Delete(packageReceivess[i]); } } } } }
/// <summary> /// 佣兵自动使用绷带补血 /// </summary> public static void UserGeneralPromptBlood(GameUser user) { int subLifeNum = 0; if (IsPromptBlood(user.UserID)) { var userItemArray = UserItemHelper.GetItems(user.UserID).FindAll(u => u.ItemType == ItemType.BengDai && u.ItemStatus != ItemStatus.Sell); if (userItemArray.Count > 0) { int itemID = userItemArray[0].ItemID; ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(itemID); var propsCacheSet = new GameDataCacheSet<UserProps>(); List<UserProps> propsArray = propsCacheSet.FindAll(user.UserID, u => u.PropType == 1); if (propsArray.Count > 0 && propsArray[0].SurplusNum == 0) { foreach (UserProps userPropse in propsArray) { if (userPropse.SurplusNum == 0) { propsCacheSet.Delete(userPropse); } } } //给佣兵补血 List<UserGeneral> userGeneralArray = new GameDataCacheSet<UserGeneral>().FindAll(user.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong); int effectNum = itemInfo.EffectNum; foreach (var userGeneral in userGeneralArray) { int maxLifeNum = GetMaxLife(user.UserID, userGeneral.GeneralID); if (userGeneral.LifeNum < maxLifeNum) { subLifeNum = MathUtils.Subtraction(maxLifeNum, userGeneral.LifeNum, 0); userGeneral.LifeNum = MathUtils.Addition(userGeneral.LifeNum, effectNum, maxLifeNum); //userGeneral.Update(); effectNum = MathUtils.Subtraction(effectNum, subLifeNum, 0); } } UserProps props = new UserProps(user.UserID, itemInfo.ItemID) { SurplusNum = effectNum }; propsCacheSet.Add(props, GameEnvironment.CacheUserPeriod); user.IsUseupItem = false; UserItemHelper.UseUserItem(user.UserID, itemInfo.ItemID, 1); } } }
public override bool TakeAction() { var cacheSet = new GameDataCacheSet<UserGeneral>(); if (recruitType == RecruitType.SoulRecruit) { general = new ConfigCacheSet<GeneralInfo>().FindKey(soulID); if (general == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, soulID); if (soulID == 0 || userGeneral != null) { UserItemHelper.AddUserItem(ContextUser.UserID, general.ItemID, 1); } else { userGeneral = new UserGeneral(); userGeneral.UserID = ContextUser.UserID; cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod); userGeneral.GeneralID = general.GeneralID; userGeneral.GeneralName = general.GeneralName; userGeneral.HeadID = general.HeadID; userGeneral.PicturesID = general.PicturesID; userGeneral.GeneralLv = (short)general.GeneralLv; userGeneral.LifeNum = general.LifeNum; userGeneral.GeneralType = GeneralType.YongBing; userGeneral.CareerID = general.CareerID; userGeneral.PowerNum = general.PowerNum; userGeneral.SoulNum = general.SoulNum; userGeneral.IntellectNum = general.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.AbilityID = general.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = general.Description; userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong; userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; } } else { RecruitRule recruitRule = new ConfigCacheSet<RecruitRule>().FindKey(recruitType); if (recruitRule == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } int surplusNum = GeneralHelper.SurplusNum(ContextUser.UserID, recruitRule.FreeNum, recruitRule.RecruitType.ToEnum<RecruitType>()); if (surplusNum > 0 && !GeneralHelper.GeneralRecruitColdTime(ContextUser.UserID, recruitType)) { GeneralHelper.UpdateDailyRecruitNum(ContextUser.UserID, recruitType); GeneralHelper.UpdateRecruitColdTime(ContextUser.UserID, recruitRule); } else { if (ContextUser.GoldNum < recruitRule.GoldNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return false; } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, recruitRule.GoldNum); } CacheList<RecruitInfo> recruitInfos = recruitRule.GeneralQuality; double[] probability = new double[recruitInfos.Count]; for (int i = 0; i < recruitInfos.Count; i++) { probability[i] = (double)recruitInfos[i].Probability; } int index2 = RandomUtils.GetHitIndex(probability); GeneralQuality quality = recruitInfos[index2].Quality; var generalList = new ConfigCacheSet<GeneralInfo>().FindAll(s => s.GeneralQuality == quality); if (generalList.Count > 0) { int indexradom = RandomUtils.GetRandom(0, generalList.Count); if (indexradom < 0 || indexradom >= generalList.Count) { return false; } general = generalList[indexradom]; UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, general.GeneralID); if (userGeneral != null && userGeneral.GeneralStatus != GeneralStatus.YinCang) { currSoulID = general.SoulID; gainNum = general.DemandNum; userGeneral = cacheSet.FindKey(ContextUser.UserID, currSoulID); if (userGeneral != null) { userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, gainNum); generalType = GeneralType.Soul; } else { userGeneral = new UserGeneral(); userGeneral.UserID = ContextUser.UserID; userGeneral.GeneralID = currSoulID; generalType = GeneralType.Soul; cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod); UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID,1); } } else if (userGeneral == null) { userGeneral = new UserGeneral(); userGeneral.UserID = ContextUser.UserID; userGeneral.GeneralID = general.GeneralID; generalType = GeneralType.YongBing; cacheSet.Add(userGeneral, GameEnvironment.CacheUserPeriod); UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID,1); } userGeneral.GeneralName = general.GeneralName; userGeneral.HeadID = general.HeadID; userGeneral.PicturesID = general.PicturesID; userGeneral.GeneralLv = (short)general.GeneralLv; userGeneral.LifeNum = general.LifeNum; userGeneral.GeneralType = generalType; userGeneral.CareerID = general.CareerID; userGeneral.PowerNum = general.PowerNum; userGeneral.SoulNum = general.SoulNum; userGeneral.IntellectNum = general.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.AbilityID = general.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = general.Description; userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong; userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; //玩家抽取到蓝色和紫色佣兵时,给予系统频道提示 //if (recruitType != RecruitType.SoulRecruit) //{ // if (general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Blue || general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Purple) // { // string content = string.Empty; // content = string.Format(LanguageManager.GetLang().St_UserGetGeneralQuality, ContextUser.NickName,recruitType, // general.GeneralQuality.ToEnum<GeneralQuality>(), general.GeneralName); // new TjxChatService().SystemSend(ChatType.System, content); // } //} } } return true; }
private GameUser CreateGameUser(bool userSex) { GameUser userEntity = new GameUser { UserID = Uid, CountryID = 0, CityID = ConfigEnvSet.GetInt("user.UserMinCityID"), PointX = (short)ConfigEnvSet.GetInt("User.CityPointX"), PointY = (short)ConfigEnvSet.GetInt("User.CityPointY"), SessionID = Sid, NickName = UserName, Sex = userSex, UserLv = (short)ConfigEnvSet.GetInt("User.Level"), ObtainNum = ConfigEnvSet.GetInt("User.ObtainNum"), EnergyNum = new GameUser().EnergyMaxNum, MercenariesID = string.Empty, GiftGold = ConfigEnvSet.GetInt("User.GiftGold"), PayGold = 0, UseGold = 0, ItemGold = 0, GameCoin = ConfigEnvSet.GetInt("User.GameCoin"), ExpNum = 0, VipLv = ConfigEnvSet.GetInt("User.VipLv"), UserStatus = UserStatus.Normal, MsgState = true, GridNum = new GameUser().GridMinNum, WarehouseNum = new GameUser().WarehouseMinNum, QueueNum = 0, RetailID = RetailID, Pid = Pid, MobileType = MobileType, ScreenX = ScreenX, ScreenY = ScreenY, ClientAppVersion = ReqAppVersion, CreateDate = DateTime.Now, UseMagicID = new GameUser().UserMagicID, CrystalNum = new GameUser().CrystalMinNum, UserLocation = Location.City, UserExtend = new GameUserExtend(), SweepPool = new SweepPoolInfo(), GameId = GameID, ServerId = ServerID, LoginTime = DateTime.Now, DailyLoginTime = DateTime.Now }; var cacheSet = new GameDataCacheSet <GameUser>(); cacheSet.Add(userEntity); cacheSet.Update(); //增加初始背包、灵件、水晶 new GameDataCacheSet <UserItemPackage>().Add(new UserItemPackage { UserID = userEntity.UserID }); new GameDataCacheSet <UserCrystalPackage>().Add(new UserCrystalPackage() { UserID = userEntity.UserID }); new GameDataCacheSet <UserSparePackage>().Add(new UserSparePackage() { UserID = userEntity.UserID }); //增加初始附魔符 new GameDataCacheSet <UserEnchant>().Add(new UserEnchant(userEntity.UserID)); //增加初始副本 new GameDataCacheSet <UserPlotPackage>().Add(new UserPlotPackage(userEntity.UserID)); // 增加初始集邮册 new GameDataCacheSet <UserAlbum>().Add(new UserAlbum(userEntity.UserID)); // 玩家圣吉塔 new GameDataCacheSet <UserShengJiTa>().Add(new UserShengJiTa(userEntity.UserID.ToInt())); return(userEntity); }
public override bool TakeAction() { ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(medicineID); var userItemArray = UserItemHelper.GetItems(Uid).FindAll(u => (u.ItemStatus == ItemStatus.BeiBao || u.ItemStatus == ItemStatus.CangKu)); if (userItemArray.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1407_MedicineNum; return(false); } UserGeneral general = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID); if (general == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St10006_DoesNotExistTheGeneral; return(false); } if (itemInfo.DemandLv > general.GeneralLv) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_LevelNotEnough; return(false); } int sum = 0; short baseNum = 0; //佣兵服用ID为medicineID的丹药 var generalMedicineArray = new GameDataCacheSet <GeneralMedicine>().FindAll(ContextUser.UserID, g => g.MedicineID.Equals(medicineID) && g.GeneralID == generalID); if (generalMedicineArray.Count > 0) { int mLv = itemInfo.MedicineLv; int mNum = generalMedicineArray.Count; if (mLv == 1 && mNum >= 2 || mLv == 2 && mNum >= 3 || mLv == 3 && mNum >= 4 || mLv == 4 && mNum >= 5 || mLv == 5 && mNum >= 6 || mLv == 6 && mNum >= 7) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1407_MedicineNumFull; return(false); } sum = mNum * 5; // baseNum = MathUtils.Subtraction(itemInfo.MedicineNum, (short)sum, (short)0); } else { baseNum = itemInfo.MedicineNum; } //vip int useGold = 0; int[] vipMeArray = { 30, 150, 300, 600, 1200, 2400 }; for (int i = 1; i <= vipMeArray.Length; i++) { if (itemInfo.MedicineLv == i) { useGold = vipMeArray[i - 1]; } } if (ops == 0) { GeneralMedicine generalMedicine = new GeneralMedicine() { GeneralMedicineID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, GeneralID = generalID, MedicineID = medicineID, BaseNum = (int)baseNum }; var cacheSet = new GameDataCacheSet <GeneralMedicine>(); cacheSet.Add(generalMedicine, GameEnvironment.CacheUserPeriod); UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1); if (itemInfo.MedicineType == 1) { general.PowerNum = MathUtils.Addition(general.PowerNum, baseNum, short.MaxValue); } else if (itemInfo.MedicineType == 2) { general.SoulNum = MathUtils.Addition(general.SoulNum, baseNum, short.MaxValue); } else if (itemInfo.MedicineType == 3) { general.IntellectNum = MathUtils.Addition(general.IntellectNum, baseNum, short.MaxValue); } //general.Update(); } else if (ops == 1) { ErrorCode = 1; ErrorInfo = string.Format(LanguageManager.GetLang().St1407_MedicineUseGold, useGold); return(false); } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } GeneralMedicine generalMedicine = new GeneralMedicine() { GeneralMedicineID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, GeneralID = generalID, MedicineID = medicineID, BaseNum = (int)baseNum }; var cacheSet = new GameDataCacheSet <GeneralMedicine>(); cacheSet.Add(generalMedicine, GameEnvironment.CacheUserPeriod); ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); //ContextUser.Update(); if (itemInfo.MedicineType == 1) { general.PowerNum = MathUtils.Addition(general.PowerNum, baseNum, short.MaxValue); } else if (itemInfo.MedicineType == 2) { general.SoulNum = MathUtils.Addition(general.SoulNum, baseNum, short.MaxValue); } else if (itemInfo.MedicineType == 3) { general.IntellectNum = MathUtils.Addition(general.IntellectNum, baseNum, short.MaxValue); } //general.Update(); } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().UrlElement; return(false); } return(true); }
public override bool TakeAction() { var cacheSetUserPack = new GameDataCacheSet <UserPack>(); var cacheSetBackPack = new ConfigCacheSet <BackpackConfigInfo>(); var backpackConfigInfo = cacheSetBackPack.FindKey(1); var userPack = cacheSetUserPack.FindKey(UserId.ToString()); var packType = userPack != null && userPack.PackTypeList != null?userPack.PackTypeList.Find(s => s.BackpackType.ToInt() == 1) : null; if (backpackConfigInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } if (ContextUser.GoldNum < backpackConfigInfo.RequiredGoldNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } if (packType != null && packType.OpenNum >= backpackConfigInfo.MaxOpenNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1110_OverExpansion; return(false); } if (userPack == null) { userPack = new UserPack(UserId); packType = new PackType(); userPack.CreateDate = DateTime.Now; packType.OpenNum = 1; packType.BackpackType = BackpackType.HunJi; packType.OpenNum = MathUtils.Addition(backpackConfigInfo.DefaultNum, backpackConfigInfo.EveryAddNum); userPack.PackTypeList.AddChildrenListener(packType); cacheSetUserPack.Add(userPack, UserId); } else { if (packType == null) { packType = new PackType(); userPack.CreateDate = DateTime.Now; packType.OpenNum = 1; packType.BackpackType = BackpackType.HunJi; packType.OpenNum = MathUtils.Addition(backpackConfigInfo.DefaultNum, backpackConfigInfo.EveryAddNum); cacheSetUserPack.Add(userPack, UserId); } else { userPack.UpdateNotify(obj => { packType.OpenNum = MathUtils.Subtraction(packType.OpenNum, 1); packType.OpenNum = MathUtils.Addition(packType.OpenNum, backpackConfigInfo.EveryAddNum); return(true); }); } } MathUtils.DiffDate(DateTime.Now.Date).TotalDays.ToInt(); return(true); }
/// <summary> /// 副本奖励,如果通关下发通关奖励 /// </summary> /// <param name="userID"></param> /// <param name="plotNpcInfo"></param> /// <param name="userPlotCombat"></param> internal static void DoPlotPrize(string userID, PlotNPCInfo plotNpcInfo, UserPlotCombat userPlotCombat, int npcGeneralNum, out int honourNum) { honourNum = 0; int experience = 0; PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(plotNpcInfo.PlotID); var package = UserPlotPackage.Get(userID); if (plotInfo == null || plotNpcInfo == null || userPlotCombat == null || package == null) { return; } GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID); if (user != null) { experience += plotNpcInfo.Experience; userPlotCombat.Experience = plotNpcInfo.Experience; if (!string.IsNullOrEmpty(user.MercenariesID)) { //公会技能加成 userPlotCombat.Experience = MathUtils.RoundCustom(experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt(); experience = userPlotCombat.Experience; } var cacheSetGeneral = new GameDataCacheSet<UserGeneral>(); var userMagic = new GameDataCacheSet<UserMagic>().Find(user.UserID, s => s.IsEnabled); int userMagicID = userMagic == null ? 0 : userMagic.MagicID; var userEmbattleList = new GameDataCacheSet<UserEmbattle>().FindAll(userID, s => s.MagicID == userMagicID && s.GeneralID > 0); int generalNum = 0; userEmbattleList.ForEach(userEmbattle => { var userGeneral = cacheSetGeneral.FindKey(userID, userEmbattle.GeneralID); generalNum = userGeneral != null && userGeneral.LifeNum > 0 ? MathUtils.Addition(generalNum, 1) : generalNum; }); user.GeneralAllCount = MathUtils.Addition(user.GeneralAllCount, userPlotCombat.GeneralNum); user.GeneralKillCount = MathUtils.Addition(user.GeneralKillCount, (userPlotCombat.GeneralNum - generalNum)); //怪物掉落物品) if (plotNpcInfo.IsBoss) { if (plotInfo.PlotType == PlotType.Normal && user.PlotProgress < plotInfo.PlotID) { user.PlotProgress = plotInfo.PlotID; } //日常任务-通关副本 TaskHelper.TriggerDailyTask(userID, 4005); DateTime currDate = DateTime.Now; //通关奖励 var userPlot = UserPlotHelper.GetUserPlotInfo(userID, plotNpcInfo.PlotID); if (userPlot == null) { userPlot = new UserPlotInfo(); userPlot.PlotID = plotNpcInfo.PlotID; userPlot.CreateDate = currDate; package.SaveItem(userPlot); } NoviceHelper.PlotFestivalList(user, plotInfo.PlotID); //活动集合 List<UserPlotCombat> preUserPlotList = new GameDataCacheSet<UserPlotCombat>().FindAll(userID, m => !m.PlotNpcID.Equals(userPlotCombat.PlotNpcID) && m.PlotID == plotNpcInfo.PlotID); preUserPlotList.Add(userPlotCombat); List<UserPlotCombat> plotCombatList = preUserPlotList; short starScore; PlotSuccessType plotSuccessType = PlotSuccessType.No; userPlot.ScoreNum = GetPlotScoreNum(plotCombatList, out starScore); userPlot.PlotStatus = PlotStatus.Completed; userPlot.AttackScore = 0; userPlot.DefenseScore = 0; userPlot.ItemID = 0; userPlot.EnchantID = 0; userPlot.PlotSuccessType = plotSuccessType; //获得星星等级 if (userPlotCombat.IsWin) { double pren = 0; GetStar(user, generalNum, out starScore, out plotSuccessType, out pren); userPlot.StarScore = starScore; userPlot.PlotSuccessType = plotSuccessType; //获得荣誉值 honourNum = plotInfo.HonourNum; userPlot.PlotNum = MathUtils.Addition(userPlot.PlotNum, 1); if (GetPlotChallengeNum(userID, plotNpcInfo.PlotID) == 1) { if (starScore >= 3) { if (plotInfo.PlotType==PlotType.Elite) // 如果是精英副本 { if (userPlot.FirstWin==false) // 如果是首次获得3星 { userPlot.FirstWin = true; userPlot.ExpNum = (int)(plotInfo.ExpNum * 2); userPlot.PennyNum = (int)(plotInfo.GameCoin * 2); } else { userPlot.ExpNum = plotInfo.ExpNum; userPlot.PennyNum = plotInfo.GameCoin; } } else { userPlot.ExpNum = (int)(plotInfo.ExpNum * 2); userPlot.PennyNum = (int)(plotInfo.GameCoin * 2); } } else { userPlot.ExpNum = plotInfo.ExpNum; userPlot.PennyNum = plotInfo.GameCoin; } honourNum = honourNum * starScore; } else { userPlot.ExpNum = plotInfo.ExpNum; userPlot.PennyNum = plotInfo.GameCoin; } userPlot.HonourNum = honourNum; GeneralEscalateHelper.AddUserLv(user, honourNum); } else { PlotFailureType plotFailureType; GetFailure(npcGeneralNum, out plotFailureType); userPlot.PlotFailureType = plotFailureType; } // userPlot.ExpNum = plotInfo.ExpNum; userPlot.GoldNum = plotInfo.GetRandomGold(); if (!string.IsNullOrEmpty(user.MercenariesID)) { //公会技能加成 userPlot.Experience = MathUtils.RoundCustom(userPlot.Experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt(); userPlot.ExpNum = MathUtils.RoundCustom(userPlot.ExpNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.ExpNum)).ToInt(); userPlot.PennyNum = MathUtils.RoundCustom(userPlot.PennyNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.CoinNum)).ToInt(); } CacheList<PrizeItemInfo> itemList = new CacheList<PrizeItemInfo>(); string itemName = string.Empty; if (plotInfo.PlotType != PlotType.Kalpa) { var copyList = GetPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, userPlot); copyList.Foreach(item => { if (item.Type == 0) { itemList.Add(item); } return true; }); if (itemList.Count > 0) { userPlot.ItemID = itemList[0].ItemID; var item = new ConfigCacheSet<ItemBaseInfo>().FindKey(userPlot.ItemID); itemName = item != null ? item.ItemName : string.Empty; } } if (!string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0) { var copyList = GetKalpaPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, userPlot); copyList.Foreach(item => { if (item.Type == 2) { itemList.Add(item); if (plotInfo.PlotType != PlotType.Kalpa) { userPlot.EnchantID = item.ItemID; EnchantAddUser(user, item.ItemID); } } return true; }); } if (plotInfo.PlotType == PlotType.Elite) { //精英副本奖励发聊天<label color='0,255,0' >{0}</label><label>{0}</label> string content = string.Format(LanguageManager.GetLang().St_PlotRewardNotice, user.NickName, plotNpcInfo.NpcName, itemName); new TjxChatService().SystemSend(ChatType.World, content); } //祝福加金币 if (UserHelper.GainBlessing(user, 0) > 0) { UserHelper.GainBlessing(user, 1); userPlot.BlessPennyNum = (int)Math.Floor(userPlot.PennyNum * new GuildMember().BlessingCionPercent); userPlot.PennyNum = MathUtils.Addition(userPlot.PennyNum, userPlot.BlessPennyNum); user.GameCoin = MathUtils.Addition(user.GameCoin, userPlot.PennyNum, int.MaxValue); } if (userPlot.CompleteDate <= MathUtils.SqlMinDate) { userPlot.CompleteDate = currDate; } userPlot.RefleshDate = currDate; //experience = userPlot.Experience; //userPlotCombat.Experience = experience; experience += userPlot.Experience + userPlot.BlessExperience; user.GameCoin = MathUtils.Addition(user.GameCoin, userPlot.PennyNum, int.MaxValue); user.ExpNum = MathUtils.Addition(user.ExpNum, userPlot.ExpNum, int.MaxValue); user.ItemGold = MathUtils.Addition(user.ItemGold, userPlot.GoldNum, int.MaxValue); //user.Update(); //奖励日志 UserPlotPrizeLog prizeLog = new UserPlotPrizeLog { PrizeLogID = Guid.NewGuid().ToString(), ScoreNum = userPlot.ScoreNum, StarScore = userPlot.StarScore, PrizeItem = itemList, Experience = userPlot.Experience, ExpNum = userPlot.ExpNum, GameCoin = userPlot.PennyNum, PlotID = userPlot.PlotID, UserID = userID, CreateDate = DateTime.Now }; var sender = DataSyncManager.GetDataSender(); sender.Send(prizeLog); //重置评价 foreach (UserPlotCombat plotCombat in plotCombatList) { //只有一个NPC时更新不了 //if (plotCombatList.Count > 1 && plotCombat.Equals(userPlotCombat)) continue; plotCombat.GeneralNum = 0; plotCombat.GeneralOverNum = 0; plotCombat.OverNum = 0; //plotCombat.Update(); } //通关副本 副本ID清空 if (user.UserExtend != null) { user.UserExtend.UpdateNotify(obj => { user.UserExtend.PlotStatusID = 0; user.UserExtend.PlotNpcID = 0; user.UserExtend.MercenarySeq = 0; return true; }); } package.SaveItem(userPlot); user.GeneralAllCount = 0; user.GeneralKillCount = 0; if (plotInfo.PlotType == PlotType.Normal) { int multiple = FestivalHelper.DuplicateDropDouble(user.UserID); if (multiple > 1) { FestivalHelper.DuplicateDropDoubleRestrain(user.UserID); } } } //佣兵经验 AddExprerience(user, experience); } }
public override bool TakeAction() { if (!UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.Trump)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_NoFun; return(false); } if (UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.TrumpPractice)) { return(false); } if (!TrumpHelper.IsTrumpPractice(ContextUser.UserID)) { return(false); } var cacheTrump = new GameDataCacheSet <UserTrump>(); UserTrump userTrump = cacheTrump.FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump == null) { TrumpInfo trumpInfo = new ConfigCacheSet <TrumpInfo>().FindKey(TrumpInfo.CurrTrumpID, 1); if (trumpInfo == null) { return(false); } StoryTaskInfo[] storyTaskArray = new ConfigCacheSet <StoryTaskInfo>().FindAll(m => m.TaskType == TaskType.Trump).ToArray(); foreach (StoryTaskInfo taskInfo in storyTaskArray) { UserItemHelper.UseUserItem(ContextUser.UserID, taskInfo.TargetItemID, taskInfo.TargetItemNum); } userTrump = new UserTrump(ContextUser.UserID, TrumpInfo.CurrTrumpID); userTrump.TrumpLv = 1; userTrump.WorshipLv = 1; userTrump.LiftNum = trumpInfo.MaxLift; userTrump.Experience = 0; userTrump.MatureNum = trumpInfo.BeseMature; userTrump.Zodiac = TrumpHelper.GetZodiacType(ZodiacType.NoZodiac); //userTrump.SkillInfo = new List<SkillInfo>(); //userTrump.PropertyInfo = new List<GeneralProperty>(); cacheTrump.Add(userTrump, GameEnvironment.CacheUserPeriod); cacheTrump.Update(); } var cacheSet = new GameDataCacheSet <UserFunction>(); UserFunction userFunction = cacheSet.FindKey(ContextUser.UserID, FunctionEnum.TrumpPractice); if (userFunction == null) { UserFunction function = new UserFunction() { FunEnum = FunctionEnum.TrumpPractice, UserID = ContextUser.UserID, CreateDate = DateTime.Now, }; cacheSet.Add(function, GameEnvironment.CacheUserPeriod); cacheSet.Update(); } var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID); if (userTrump.LiftNum > 0 && usergeneral != null) { usergeneral.RefreshMaxLife(); } return(true); }
public override bool TakeAction() { int subLifeNum = 0; var package = UserItemPackage.Get(Uid); UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID)); if (userItem == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } //wuzf modify 2012-05-19 ItemBaseInfo itemInfo = new ConfigCacheSet <ItemBaseInfo>().FindKey(userItem.ItemID); var propsArray = new GameDataCacheSet <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1); if (propsArray.Count > 0 && propsArray[0].SurplusNum > 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1605_BandageUse; return(false); } //判断背包是否有血包,没有提示去商城 var userItems = package.ItemPackage.FindAll(m => !m.IsRemove && new UserItemHelper(m).PropType == 1); if (userItems.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1605_UseTwoGold; return(false); } //给佣兵补血 var userGeneralArray = new GameDataCacheSet <UserGeneral>().FindAll(ContextUser.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong); int effectNum = itemInfo.EffectNum; foreach (var userGeneral in userGeneralArray) { int maxLifeNum = UserHelper.GetMaxLife(ContextUser.UserID, userGeneral.GeneralID); if (userGeneral.LifeNum < maxLifeNum) { subLifeNum = MathUtils.Subtraction(maxLifeNum, userGeneral.LifeNum, 0); userGeneral.LifeNum = MathUtils.Addition(userGeneral.LifeNum, effectNum, maxLifeNum); //userGeneral.Update(); effectNum = MathUtils.Subtraction(effectNum, subLifeNum, 0); } } var cacheSet = new GameDataCacheSet <UserProps>(); UserProps props = new GameDataCacheSet <UserProps>().FindKey(ContextUser.UserID, userItem.ItemID); if (props != null) { props.SurplusNum = effectNum; //props.Update(); } else { props = new UserProps(ContextUser.UserID, itemInfo.ItemID) { SurplusNum = effectNum }; cacheSet.Add(props); } ContextUser.IsUseupItem = false; UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1); foreach (UserProps userPropse in propsArray) { if (userPropse.SurplusNum == 0) { cacheSet.Delete(userPropse); } } return(true); }
public override bool TakeAction() { var cacheEnvSet = new ConfigCacheSet <ConfigEnvSet>(); var envset = cacheEnvSet.FindKey("CombatMaxBout"); if (envset != null) { } PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID); if (npcInfo == null) { return(false); } PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { return(false); } //判断是否有下一关 int nextLayerNum = MathUtils.Addition(ContextUser.UserExtend.LayerNum, 1); int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1); if ((UserHelper.IsLastLayer(plotInfo) || !IsGotoNextLayer(nextLayerNum))) { if (UserHelper.IsKill(ContextUser, npcInfo.PlotID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnableLayerNum; return(false); } } if (ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood; return(false); } //原因:灵件背包满时未提示 if (ops != 1 && UserHelper.IsSpareGridNum(ContextUser, 0)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St_User_SpareBeiBaoMsg; return(false); } if (ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull; return(false); } if (ContextUser.UserStatus == UserStatus.SaoDang) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4007_Saodanging; return(false); } if (ContextUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return(false); } if (new GameDataCacheSet <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty; return(false); } //PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); if (IsPlotOut(npcInfo)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnable; return(false); } UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血 //触发战斗 ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { return(false); } var cacheSet = new GameDataCacheSet <UserPlotCombat>(); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); if (userPlotCombat == null) { userPlotCombat = new UserPlotCombat() { UserID = ContextUser.UserID, PlotNpcID = PlotNpcID }; cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); } userPlotCombat.PlotID = npcInfo.PlotID; userPlotCombat.CombatDate = DateTime.Now; userPlotCombat.IsWin = plotCombater.Doing(); if (!userPlotCombat.IsWin) { userPlotCombat.OverNum += 1; } combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); if (userPlotCombat.IsWin) { int honourNum = 0; PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, 0, out honourNum); prizeItems = PlotHelper.GetKalpaPlotMonsterItems(Uid, npcInfo.PlotID, npcInfo.PlotNpcID); universalArray = GetUniversalList().ToArray(); if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); if (ContextUser.UserExtend == null) { ContextUser.UserExtend = new GameUserExtend(); } PlotInfo[] plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == ContextUser.UserExtend.LayerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { int layerNum = ContextUser.UserExtend.LayerNum; int hurdleNum = ContextUser.UserExtend.HurdleNum; if (CheckHurdleNum(ContextUser.UserID, layerNum, hurdleNum)) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.HurdleNum = nextHurdleNum; return(true); }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } else if (IsGotoNextLayer(nextLayerNum)) { //判断是否能到下一层 plotInfoList = new ConfigCacheSet <PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.LayerNum = nextLayerNum; ContextUser.UserExtend.HurdleNum = 1; return(true); }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } } } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = userPlotCombat.UserID; log.CityID = ContextUser.CityID; log.PlotID = userPlotCombat.PlotID; log.NpcID = userPlotCombat.PlotNpcID; log.CombatType = CombatType.Kalpa; log.HostileUser = string.Empty; log.IsWin = userPlotCombat.IsWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = prizeItems; log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); UserHelper.GetGeneralLife(ContextUser.UserID); return(true); }
/// <summary> /// 副本扫荡奖励 /// </summary> /// <param name="userID"></param> /// <param name="plotID"></param> /// <param name="turnsNum"></param> /// <param name="battleNum"></param> /// <param name="npcCount"></param> internal static void DoPlotSweepPrize(string userID, int plotID, int turnsNum, int battleNum, int npcCount) { GameUser user = new GameDataCacheSet<GameUser>().FindKey(userID); if (user == null) { return; } int experience = 0; var npcList = new ConfigCacheSet<PlotNPCInfo>().FindAll(m => m.PlotID == plotID && m.NpcSeqNo == battleNum); if (npcList.Count == 0) return; PlotNPCInfo npcInfo = npcList[0]; experience += npcInfo.Experience; var cacheSet = new GameDataCacheSet<UserSweepPool>(); UserSweepPool sweepPool = cacheSet.FindKey(userID, turnsNum, battleNum); if (sweepPool == null) { sweepPool = new UserSweepPool { UserID = userID, CreateDate = DateTime.Now }; } sweepPool.PlotID = plotID; sweepPool.TurnsNum = turnsNum; sweepPool.BattleNum = battleNum; sweepPool.Experience = npcInfo.Experience; sweepPool.ExpNum = npcInfo.ExpNum; sweepPool.GameCoin = npcInfo.GameCoin; sweepPool.Gold = npcInfo.GetRandomGold(); sweepPool.PrizeItems = GetPlotMonsterItems(userID, npcInfo.PlotNpcID); sweepPool.IsSend = false; if (cacheSet.FindKey(userID, turnsNum, battleNum) == null) { cacheSet.Add(sweepPool, GameEnvironment.CacheUserPeriod); } //else //{ // sweepPool.Update(); //} user.ExpNum = MathUtils.Addition(user.ExpNum, sweepPool.ExpNum, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, sweepPool.GameCoin + sweepPool.BlessPennyNum, int.MaxValue); user.ItemGold = MathUtils.Addition(user.ItemGold, sweepPool.Gold, int.MaxValue); if (battleNum == npcCount) { PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(plotID); experience += plotInfo.Experience; //通关奖励 int tempNum = 10; //var cacheSet = new GameDataCacheSet<UserSweepPool>(); if (cacheSet.FindKey(userID, turnsNum, tempNum) == null) { sweepPool = new UserSweepPool { UserID = userID, CreateDate = DateTime.Now }; } sweepPool.PlotID = plotID; sweepPool.TurnsNum = turnsNum; sweepPool.BattleNum = tempNum; sweepPool.Experience = plotInfo.Experience; sweepPool.ExpNum = plotInfo.ExpNum; sweepPool.GameCoin = plotInfo.GameCoin; sweepPool.Gold = plotInfo.GetRandomGold(); sweepPool.PrizeItems = GetPrizeItems(userID, plotInfo.ItemProbability, plotInfo.ItemRank, plotInfo.PlotID, null); sweepPool.IsSend = false; //祝福加金币 if (UserHelper.GainBlessing(user, 0) > 0) { UserHelper.GainBlessing(user, 1); sweepPool.BlessPennyNum = (int)Math.Floor(plotInfo.GameCoin * new GuildMember().BlessingCionPercent); } if (!string.IsNullOrEmpty(user.MercenariesID)) { //公会技能加成 sweepPool.Experience = MathUtils.RoundCustom(sweepPool.Experience * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.Experience)).ToInt(); sweepPool.ExpNum = MathUtils.RoundCustom(sweepPool.ExpNum * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.ExpNum)).ToInt(); sweepPool.GameCoin = MathUtils.RoundCustom(sweepPool.GameCoin * CombatHelper.GetGuildAbilityNum(user.UserID, GuildAbilityType.CoinNum)).ToInt(); } if (cacheSet.FindKey(userID, turnsNum, tempNum) == null) { cacheSet.Add(sweepPool, GameEnvironment.CacheUserPeriod); } user.ExpNum = MathUtils.Addition(user.ExpNum, sweepPool.ExpNum, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, sweepPool.GameCoin, int.MaxValue); user.ItemGold = MathUtils.Addition(user.ItemGold, sweepPool.Gold, int.MaxValue); //日常任务-通关副本 TaskHelper.TriggerDailyTask(userID, 4005); } //user.Update(); //佣兵经验 //UserHelper.UserGeneralExp(user.UserID, experience); TaskHelper.KillPlotMonster(userID, plotID, npcList[0].PlotNpcID); TrumpAbilityAttack.CombatTrumpLift(userID); }
public override bool TakeAction() { //if (ContextUser.EnergyNum <= 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} //if (ContextUser.EnergyNum <= 0 && ContextUser.TempEnergyNum == 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} if (ContextUser.UserStatus == UserStatus.SaoDang) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4007_Saodanging; return(false); } if (ContextUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return(false); } if (new GameDataCacheSet <UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty; return(false); } //if (ContextUser.TempEnergyNum == 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} ContextUser.UserStatus = UserStatus.Combat; try { //触发战斗 PlotNPCInfo npcInfo = new ConfigCacheSet <PlotNPCInfo>().FindKey(PlotNpcID); //原因:碰npc时掉线,再请求战斗详情 if (npcInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } //原因:最后一个npc时,清空玩家保存副本 if (ContextUser.UserExtend != null && ContextUser.UserExtend.MercenarySeq > npcInfo.NpcSeqNo) { ContextUser.UserStatus = UserStatus.Normal; ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 1; ContextUser.UserExtend.IsBoss = false; return(true); }); //ErrorCode = LanguageManager.GetLang().ErrorCode; //ErrorInfo = LanguageManager.GetLang().St4011_NoMonster; //return false; } PlotInfo plotInfo = new ConfigCacheSet <PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } var cacheSetUserPlot = new GameDataCacheSet <UserPlotPackage>(); var cacheSetItemInfo = new ShareCacheStruct <ItemBaseInfo>(); var cacheSet = new GameDataCacheSet <UserPlotCombat>(); var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID); var userPlot = userPlotPack != null?userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null; //PlotHelper.IsKill(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID) if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum) { if (plotInfo.PlotType == PlotType.Elite) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed; return(false); } else if (plotInfo.PlotType == PlotType.HeroPlot) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum; return(false); } } //if (userPlot != null && userPlot.ItemList != null) //{ // userPlot.UpdateNotify(obj => // { // userPlot.ItemList.Clear(); // return true; // }); //} if (npcInfo.NpcSeqNo == 1) { userPlot.ItemList.Clear(); ContextUser.IsItem = false; } userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); if (userPlotCombat != null && userPlotCombat.IsWin && ContextUser.UserExtend != null && PlotNpcID == ContextUser.UserExtend.PlotNpcID && !ContextUser.IsItem) { prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID); } else { ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return(false); } if (userPlotCombat == null) { userPlotCombat = new UserPlotCombat() { UserID = ContextUser.UserID, PlotNpcID = PlotNpcID }; cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); } userPlotCombat.PlotID = npcInfo.PlotID; userPlotCombat.CombatDate = DateTime.Now; userPlotCombat.IsWin = plotCombater.Doing(); if (!userPlotCombat.IsWin) { userPlotCombat.OverNum += 1; } ContextUser.IsItem = npcInfo.NpcSeqNo == 1 ? false : ContextUser.IsItem; combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); //userPlotCombat.CombatProcess = JsonUtils.Serialize(combatProcessList); int generalNum = combatProcessList.DefenseList.FindAll(s => s.LiveNum > 0).Count; if (userPlotCombat.IsWin) { if (ContextUser.UserExtend != null) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = npcInfo.PlotID; ContextUser.UserExtend.PlotNpcID = PlotNpcID; ContextUser.UserExtend.MercenarySeq = MathUtils.Addition(npcInfo.NpcSeqNo, (short)1); ContextUser.UserExtend.IsBoss = npcInfo.IsBoss; //是否最后一个副本npc return(true); }); } //玩家通过一个城市的所有副本时,增加聊天频道系统提示 if (userPlot.PlotStatus != PlotStatus.Completed && npcInfo.IsBoss) //玩家此副本胜利 { var city = new ConfigCacheSet <CityInfo>().FindKey(plotInfo.CityID); var nextPlot = new ConfigCacheSet <PlotInfo>().FindKey(plotInfo.AftPlotID); if (city != null && nextPlot != null && nextPlot.CityID != plotInfo.CityID) //此城市的最后一个副本 { string content = string.Format(LanguageManager.GetLang().St_systemprompts, ContextUser.NickName, city.CityName); new TjxChatService().SystemSend(ChatType.World, content); } } PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, generalNum, out _honourNum); if (npcInfo.NpcSeqNo == 1) { ContextUser.EnergyNum = MathUtils.Subtraction(ContextUser.EnergyNum, ContextUser.TempEnergyNum).ToShort(); //原因:刷晶石BUG ContextUser.TempEnergyNum = 0; } if (!ContextUser.IsItem) { prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID); } TaskHelper.KillPlotMonster(Uid, npcInfo.PlotID, PlotNpcID); //var stroyTaskList = new ConfigCacheSet<StoryTaskInfo>().FindAll(s => s.PlotID == plotInfo.AftPlotID); //foreach (var story in stroyTaskList) //{ // var usertask = new GameDataCacheSet<UserTask>().FindKey(ContextUser.UserID, story.PlotID); // if (usertask != null) // { PlotHelper.EnablePlot(Uid, plotInfo.AftPlotID); // } //} if (plotInfo.PlotType == PlotType.Elite) { EliteDailyRestrain(npcInfo); NoviceHelper.ElitePlotFestivalList(ContextUser); //通关精英副本获得奖励 } else if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); } else if (plotInfo.PlotType == PlotType.HeroPlot) { PlotHelper.EnableHeroPlot(ContextUser.UserID, plotInfo.PlotID); PlotHelper.HeroDailyRestrain(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID); } } else { ContextUser.GeneralAllCount = 0; ContextUser.GeneralKillCount = 0; } var restrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(Uid); if (restrain != null) { var restrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.PlotGoto); if (restrainSet != null) { GotoNum = MathUtils.Subtraction(restrainSet.MaxNum, restrain.Funtion14, 0); } } } //原因:最后一个npc时,清空玩家保存副本 if (ContextUser.UserExtend != null && ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = npcInfo.IsBoss; return(true); }); } if (!ContextUser.IsItem) { foreach (var prize in prizeItems) { if (prize.Type == 0 && userPlot != null) { var itemInfo = cacheSetItemInfo.FindKey(prize.ItemID); UniversalInfo universalInfo = new UniversalInfo(); universalInfo.HeadID = itemInfo != null ? itemInfo.HeadID : string.Empty; universalInfo.ItemID = itemInfo != null ? itemInfo.ItemID : 0; universalInfo.ItemDesc = itemInfo != null ? itemInfo.ItemDesc : string.Empty; universalInfo.MaxHeadID = itemInfo != null ? itemInfo.MaxHeadID : string.Empty; universalInfo.Name = itemInfo != null ? itemInfo.ItemName : string.Empty; universalInfo.Num = prize.Num; if (userPlot.ItemList != null && userPlot.ItemList.Count > 0) { var item = userPlot.ItemList.Find(s => s.ItemID == prize.ItemID); if (item != null) { item.UpdateNotify(obj => { item.Num = MathUtils.Addition(item.Num, prize.Num); return(true); }); } else { userPlot.UpdateNotify(obj => { userPlot.ItemList.Add(universalInfo); return(true); }); } } else { userPlot.UpdateNotify(obj => { userPlot.ItemList.Add(universalInfo); return(true); }); } } ContextUser.IsItem = true; } } var a = userPlot.ItemList; } finally { ContextUser.UserStatus = UserStatus.Normal; } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = userPlotCombat.UserID; log.CityID = ContextUser.CityID; log.PlotID = userPlotCombat.PlotID; log.NpcID = userPlotCombat.PlotNpcID; log.CombatType = CombatType.Plot; log.HostileUser = string.Empty; log.IsWin = userPlotCombat.IsWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = prizeItems; log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); UserHelper.GetGeneralLife(ContextUser.UserID); UserHelper.RegainGeneralLife(ContextUser.UserID); //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); // foreach (var userEmbattle in userEmbattleList) // { // _userTalPriority = MathUtils.Addition(_userTalPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); // } selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0); //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); return(true); }
public override bool TakeAction() { var cacheSet = new GameDataCacheSet <UserGeneral>(); if (recruitType == RecruitType.SoulRecruit) { general = new ConfigCacheSet <GeneralInfo>().FindKey(soulID); if (general == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, soulID); if (soulID == 0 || userGeneral != null) { UserItemHelper.AddUserItem(ContextUser.UserID, general.ItemID, 1); } else { userGeneral = new UserGeneral(); userGeneral.UserID = ContextUser.UserID; cacheSet.Add(userGeneral); userGeneral.GeneralID = general.GeneralID; userGeneral.GeneralName = general.GeneralName; userGeneral.HeadID = general.HeadID; userGeneral.PicturesID = general.PicturesID; userGeneral.GeneralLv = (short)general.GeneralLv; userGeneral.LifeNum = general.LifeNum; userGeneral.GeneralType = GeneralType.YongBing; userGeneral.CareerID = general.CareerID; userGeneral.PowerNum = general.PowerNum; userGeneral.SoulNum = general.SoulNum; userGeneral.IntellectNum = general.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.AbilityID = general.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = general.Description; userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong; userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; } } else { RecruitRule recruitRule = new ConfigCacheSet <RecruitRule>().FindKey(recruitType); if (recruitRule == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } int surplusNum = GeneralHelper.SurplusNum(ContextUser.UserID, recruitRule.FreeNum, recruitRule.RecruitType.ToEnum <RecruitType>()); if (surplusNum > 0 && !GeneralHelper.GeneralRecruitColdTime(ContextUser.UserID, recruitType)) { GeneralHelper.UpdateDailyRecruitNum(ContextUser.UserID, recruitType); GeneralHelper.UpdateRecruitColdTime(ContextUser.UserID, recruitRule); } else { if (ContextUser.GoldNum < recruitRule.GoldNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, recruitRule.GoldNum); } CacheList <RecruitInfo> recruitInfos = recruitRule.GeneralQuality; double[] probability = new double[recruitInfos.Count]; for (int i = 0; i < recruitInfos.Count; i++) { probability[i] = (double)recruitInfos[i].Probability; } int index2 = RandomUtils.GetHitIndex(probability); GeneralQuality quality = recruitInfos[index2].Quality; var generalList = new ConfigCacheSet <GeneralInfo>().FindAll(s => s.GeneralQuality == quality); if (generalList.Count > 0) { int indexradom = RandomUtils.GetRandom(0, generalList.Count); if (indexradom < 0 || indexradom >= generalList.Count) { return(false); } general = generalList[indexradom]; UserGeneral userGeneral = cacheSet.FindKey(ContextUser.UserID, general.GeneralID); if (userGeneral != null && userGeneral.GeneralStatus != GeneralStatus.YinCang) { currSoulID = general.SoulID; gainNum = general.DemandNum; userGeneral = cacheSet.FindKey(ContextUser.UserID, currSoulID); if (userGeneral != null) { userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, gainNum); generalType = GeneralType.Soul; } else { userGeneral = new UserGeneral(); userGeneral.UserID = ContextUser.UserID; userGeneral.GeneralID = currSoulID; generalType = GeneralType.Soul; cacheSet.Add(userGeneral); UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID, 1); } } else if (userGeneral == null) { userGeneral = new UserGeneral(); userGeneral.UserID = ContextUser.UserID; userGeneral.GeneralID = general.GeneralID; generalType = GeneralType.YongBing; cacheSet.Add(userGeneral); UserAbilityHelper.AddUserAbility(general.AbilityID, ContextUser.UserID.ToInt(), general.GeneralID, 1); } userGeneral.GeneralName = general.GeneralName; userGeneral.HeadID = general.HeadID; userGeneral.PicturesID = general.PicturesID; userGeneral.GeneralLv = (short)general.GeneralLv; userGeneral.LifeNum = general.LifeNum; userGeneral.GeneralType = generalType; userGeneral.CareerID = general.CareerID; userGeneral.PowerNum = general.PowerNum; userGeneral.SoulNum = general.SoulNum; userGeneral.IntellectNum = general.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.AbilityID = general.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = general.Description; userGeneral.GeneralStatus = GeneralStatus.DuiWuZhong; userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; //玩家抽取到蓝色和紫色佣兵时,给予系统频道提示 //if (recruitType != RecruitType.SoulRecruit) //{ // if (general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Blue || general.GeneralQuality.ToEnum<GeneralQuality>() == GeneralQuality.Purple) // { // string content = string.Empty; // content = string.Format(LanguageManager.GetLang().St_UserGetGeneralQuality, ContextUser.NickName,recruitType, // general.GeneralQuality.ToEnum<GeneralQuality>(), general.GeneralName); // new TjxChatService().SystemSend(ChatType.System, content); // } //} } } return(true); }
public override bool TakeAction() { PlantType pType = plantType.ToEnum<PlantType>(); UserPlantQuality userPlantQuality = new GameDataCacheSet<UserPlantQuality>().FindKey(ContextUser.UserID, generalID, pType); UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, generalID); if (userPlantQuality == null) { return false; } UserPlant userPlant = new GameDataCacheSet<UserPlant>().FindKey(ContextUser.UserID); if (userPlant == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return false; } if (pType == PlantType.GameGoin && userPlant.DewNum == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St10004_DewNotEnough; return false; } if (userGeneral != null && pType == PlantType.Experience) { if (UserHelper.GeneralIsUpLv(ContextUser.UserID, generalID, ContextUser.UserLv, landPsition)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St10004_GeneralNotUserLv; return false; } } var cacheSet = new GameDataCacheSet<UserLand>(); UserLand land = cacheSet.FindKey(ContextUser.UserID, landPsition); if (land == null) { land = new UserLand(); land.UserID = ContextUser.UserID; land.LandPositon = landPsition; land.GeneralID = generalID; land.IsBlackLand = 2; land.IsRedLand = 2; land.IsGain = 1; land.PlantQuality = userPlantQuality.PlantQuality; land.GainDate = MathUtils.SqlMinDate; cacheSet.Add(land); } if (land.IsGain > 1 && ((DateTime.Now - land.GainDate).TotalSeconds > 28800)) { land.GeneralID = generalID; land.PlantType = pType; land.IsGain = 1; land.PlantQuality = userPlantQuality.PlantQuality; } else { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } if (pType == PlantType.GameGoin) { userPlant.DewNum = MathUtils.Subtraction(userPlant.DewNum, 1, 0); } userPlantQuality.PlantQuality = PlantQualityType.PuTong; //日常任务-庄园 TaskHelper.TriggerDailyTask(Uid, 4008); return true; }
/// <summary> /// 玩家荣誉值升级 /// </summary> /// <param name="user"></param> /// <param name="honourNum"></param> public static void AddUserLv(GameUser user, int honourNum) { short generalMaxLv = GameConfigSet.CurrMaxLv.ToShort(); if (user.UserLv >= generalMaxLv) { CheckFun(user); return; } short rankLv = user.UserLv; user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum); short nextLv = MathUtils.Addition(user.UserLv, 1.ToShort()); while (nextLv <= generalMaxLv) { GeneralEscalateInfo generalEscalate = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(nextLv, GeneralType.YongHu); if (generalEscalate != null && user.HonourNum >= generalEscalate.UpExperience) { user.UserLv = nextLv; user.IsLv = true; UserHelper.OpenMagic(user.UserID, user.UserLv); user.HonourNum = MathUtils.Subtraction(user.HonourNum, generalEscalate.UpExperience); if (generalEscalate.FunctionEnum != null && generalEscalate.FunctionEnum != "") { var feArray = generalEscalate.FunctionEnum.Split(','); foreach (var fun in feArray) { var userFun = _cacheSetUserFun.FindKey(user.UserID, fun); if (userFun == null) { userFun = new UserFunction(); userFun.UserID = user.UserID; userFun.FunEnum = fun.ToEnum <FunctionEnum>(); userFun.CreateDate = DateTime.Now; _cacheSetUserFun.Add(userFun, GameEnvironment.CacheUserPeriod); _cacheSetUserFun.Update(); user.OpenFun.Add(userFun); } } } FestivalHelper.GetUpgradeGiveGift(user.UserID, nextLv); nextLv = MathUtils.Addition(user.UserLv, 1.ToShort()); } else { break; } } if (user.UserLv > rankLv) { Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey); UserRank rankInfo; int rankID; if (ranking.TryGetRankNo(m => m.UserID == user.UserID, out rankID)) { rankInfo = ranking.Find(s => s.UserID == user.UserID); if (rankInfo != null) { rankInfo.UserLv = user.UserLv; rankInfo.TotalCombatNum = user.CombatNum; rankInfo.ObtainNum = user.ObtainNum; } } } CheckFun(user); }
/// <summary> /// 累计消费活动 /// </summary> public static void TriggerFestivalConsume(string userID, int consumeNum, FestivalType festivalType) { FestivalInfo fest = GetInfo(festivalType); if (fest == null) { return; } var cacheSet = new GameDataCacheSet <UserConsume>(); UserConsume userConsume = cacheSet.FindKey(userID); if (userConsume == null) { userConsume = new UserConsume(); userConsume.UserID = userID; userConsume.GameCoin = 0; userConsume.GoldNum = 0; userConsume.EnergyNum = 0; cacheSet.Add(userConsume); cacheSet.Update(); userConsume = new GameDataCacheSet <UserConsume>().FindKey(userID); } //晶石 if (festivalType == FestivalType.SparConsumption) { if (userConsume.GoldDate < fest.StartDate) { userConsume.GoldDate = fest.StartDate; userConsume.GoldNum = consumeNum; } else { userConsume.GoldNum = MathUtils.Addition(userConsume.GoldNum, consumeNum); } } //金币 if (festivalType == FestivalType.GameCoin) { if (userConsume.CoinDate < fest.StartDate) { userConsume.CoinDate = fest.StartDate; userConsume.GameCoin = consumeNum; } else { userConsume.GameCoin = MathUtils.Addition(userConsume.GameCoin, consumeNum); } } //精力 if (festivalType == FestivalType.Energy) { if (userConsume.EnergyDate < fest.StartDate) { userConsume.EnergyDate = fest.StartDate; userConsume.EnergyNum = consumeNum; } else { userConsume.EnergyNum = MathUtils.Addition(userConsume.EnergyNum, consumeNum); } } FestivalInfo[] festivalInfosArray = new ShareCacheStruct <FestivalInfo>().FindAll(m => m.FestivalType == festivalType).ToArray(); foreach (FestivalInfo festivalInfo in festivalInfosArray) { FestivalConsumeCount(festivalInfo, userID); } }
/// <summary> /// 玩家升级开启魔术、阵法 /// </summary> public static void OpenMagic(string userID, int userLv) { var magicCacheSet = new GameDataCacheSet<UserMagic>(); var embattleCacheSet = new GameDataCacheSet<UserEmbattle>(); var magicArray = new ConfigCacheSet<MagicInfo>().FindAll(u => u.DemandLv <= userLv); foreach (MagicInfo magicInfo in magicArray) { UserMagic userMagic = magicCacheSet.FindKey(userID, magicInfo.MagicID); if (userMagic == null) { UserMagic magic = new UserMagic() { UserID = userID, MagicID = magicInfo.MagicID, MagicLv = magicInfo.MagicLv, MagicType = magicInfo.MagicType, IsEnabled = false }; magicCacheSet.Add(magic, GameEnvironment.CacheUserPeriod); if (magicInfo.MagicType == MagicType.MoFaZhen) { MagicLvInfo lvInfo = new ConfigCacheSet<MagicLvInfo>().FindKey(magicInfo.MagicID, magicInfo.MagicLv); if (lvInfo != null) { string[] magicRang = lvInfo.GridRange.Split(','); if (magicRang.Length > 0) { UserEmbattle embattle = new UserEmbattle() { UserID = userID, MagicID = magicInfo.MagicID, Position = Convert.ToInt16(magicRang[0]), GeneralID = 0 // LanguageManager.GetLang().GameUserGeneralID }; embattleCacheSet.Add(embattle, GameEnvironment.CacheUserPeriod); } } } } } }
/// <summary> /// 天地劫挑战次数 /// </summary> /// <param name="plotNPCInfo"></param> private void KalpaDailyRestrain(PlotNPCInfo plotNPCInfo) { var cacheSet = new GameDataCacheSet<UserDailyRestrain>(); UserDailyRestrain userRestrain = cacheSet.FindKey(Uid); if (userRestrain == null) { userRestrain = new UserDailyRestrain() { UserID = Uid }; cacheSet.Add(userRestrain); userRestrain = cacheSet.FindKey(Uid); } if (userRestrain.UserExtend == null) { userRestrain.UserExtend = new DailyUserExtend(); //userRestrain.UserExtend.KalpaPlot = new List<FunPlot>(); } int plotNum = 0; FunPlot funPlot = userRestrain.UserExtend.KalpaPlot.Find(m => m.PlotID == plotNPCInfo.PlotID); if (funPlot == null) { plotNum = 1; funPlot = new FunPlot { PlotID = plotNPCInfo.PlotID, Num = plotNum }; userRestrain.UserExtend.UpdateNotify(obj => { userRestrain.UserExtend.KalpaPlot.Add(funPlot); return true; }); } }
private static void AddUserLight(GameDataCacheSet<UserLight> cacheSet, string userID, int huntingID, int isLight) { var light = new UserLight() { UserID = userID, HuntingID = huntingID, IsLight = isLight }; cacheSet.Add(light, GameEnvironment.CacheUserPeriod); }
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 GameDataCacheSet<UserDailyRestrain>().FindKey(ContextUser.UserID); probabilityInfo = new ConfigCacheSet<ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return false; } ProbabilityInfo probability1 = new ConfigCacheSet<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 GameDataCacheSet<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 GameDataCacheSet<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 GameDataCacheSet<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 ConfigCacheSet<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 GameDataCacheSet<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 GameDataCacheSet<UserLight>().Add(uLightInfo); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, probabilityInfo.Price, int.MaxValue); lightArray = new GameDataCacheSet<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 ConfigCacheSet<CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= ContextUser.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); crystal = new ConfigCacheSet<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; }
/// <summary> /// 开启功能[未完成] /// </summary> /// <param name="user"></param> /// <param name="functionEnum"></param> public static void EnableFunction(GameUser user, FunctionEnum functionEnum) { if (functionEnum <= 0) { return; } var cacheSet = new GameDataCacheSet <UserFunction>(); UserFunction uf = cacheSet.FindKey(user.UserID, functionEnum); if (uf == null) { uf = new UserFunction { UserID = user.UserID, FunEnum = functionEnum, CreateDate = DateTime.Now }; cacheSet.Add(uf); uf = cacheSet.FindKey(user.UserID, functionEnum); } switch (functionEnum) { //case FunctionEnum.Qianghuaqueue: // user.QueueNum = 2; // user.Update(); // break; case FunctionEnum.Qianghua: user.QueueNum = (short)new GameUser().QueueMinNum; //user.Update(); break; case FunctionEnum.Shengmishangdian: UserHelper.RefrshShopsSparData(user, false); break; case FunctionEnum.Mofazheng: InitMagicEmbattle(user.UserID, user.UserLv); break; case FunctionEnum.Zhongzhijiyangshu: GetUserLand(user.UserID); break; case FunctionEnum.Zhongzhijingqianshu: GoinUserQueue(user.UserID); break; case FunctionEnum.Enchant: EnchantHelper.EnchantFunctionOpen(user); break; case FunctionEnum.ReplaceGeneral: GeneralHelper.OpenReplaceGeneral(user); break; default: break; } }
public override bool TakeAction() { //if (ContextUser.EnergyNum <= 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} //if (ContextUser.EnergyNum <= 0 && ContextUser.TempEnergyNum == 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} if (ContextUser.UserStatus == UserStatus.SaoDang) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4007_Saodanging; return false; } if (ContextUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return false; } if (new GameDataCacheSet<UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty; return false; } //if (ContextUser.TempEnergyNum == 0) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough; // return false; //} ContextUser.UserStatus = UserStatus.Combat; try { //触发战斗 PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); //原因:碰npc时掉线,再请求战斗详情 if (npcInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return false; } //原因:最后一个npc时,清空玩家保存副本 if (ContextUser.UserExtend != null && ContextUser.UserExtend.MercenarySeq > npcInfo.NpcSeqNo) { ContextUser.UserStatus = UserStatus.Normal; ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 1; ContextUser.UserExtend.IsBoss = false; return true; }); //ErrorCode = LanguageManager.GetLang().ErrorCode; //ErrorInfo = LanguageManager.GetLang().St4011_NoMonster; //return false; } PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return false; } var cacheSetUserPlot = new GameDataCacheSet<UserPlotPackage>(); var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>(); var cacheSet = new GameDataCacheSet<UserPlotCombat>(); var userPlotPack = cacheSetUserPlot.FindKey(ContextUser.UserID); var userPlot = userPlotPack != null ? userPlotPack.PlotPackage.Find(s => s.PlotID == npcInfo.PlotID) : null; //PlotHelper.IsKill(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID) if (userPlot != null && userPlot.PlotNum >= plotInfo.ChallengeNum) { if (plotInfo.PlotType == PlotType.Elite) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4002_EliteUsed; return false; } else if (plotInfo.PlotType == PlotType.HeroPlot) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4002_HeroPlotNum; return false; } } //if (userPlot != null && userPlot.ItemList != null) //{ // userPlot.UpdateNotify(obj => // { // userPlot.ItemList.Clear(); // return true; // }); //} if (npcInfo.NpcSeqNo == 1) { userPlot.ItemList.Clear(); ContextUser.IsItem = false; } userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); if (userPlotCombat != null && userPlotCombat.IsWin && ContextUser.UserExtend != null && PlotNpcID == ContextUser.UserExtend.PlotNpcID && !ContextUser.IsItem) { prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID); } else { ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().LoadDataError; return false; } if (userPlotCombat == null) { userPlotCombat = new UserPlotCombat() { UserID = ContextUser.UserID, PlotNpcID = PlotNpcID }; cacheSet.Add(userPlotCombat, GameEnvironment.CacheUserPeriod); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); } userPlotCombat.PlotID = npcInfo.PlotID; userPlotCombat.CombatDate = DateTime.Now; userPlotCombat.IsWin = plotCombater.Doing(); if (!userPlotCombat.IsWin) { userPlotCombat.OverNum += 1; } ContextUser.IsItem = npcInfo.NpcSeqNo == 1 ? false : ContextUser.IsItem; combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); //userPlotCombat.CombatProcess = JsonUtils.Serialize(combatProcessList); int generalNum = combatProcessList.DefenseList.FindAll(s => s.LiveNum > 0).Count; if (userPlotCombat.IsWin) { if (ContextUser.UserExtend != null) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = npcInfo.PlotID; ContextUser.UserExtend.PlotNpcID = PlotNpcID; ContextUser.UserExtend.MercenarySeq = MathUtils.Addition(npcInfo.NpcSeqNo, (short)1); ContextUser.UserExtend.IsBoss = npcInfo.IsBoss; //是否最后一个副本npc return true; }); } //玩家通过一个城市的所有副本时,增加聊天频道系统提示 if (userPlot.PlotStatus != PlotStatus.Completed && npcInfo.IsBoss) //玩家此副本胜利 { var city = new ConfigCacheSet<CityInfo>().FindKey(plotInfo.CityID); var nextPlot = new ConfigCacheSet<PlotInfo>().FindKey(plotInfo.AftPlotID); if (city != null && nextPlot != null && nextPlot.CityID != plotInfo.CityID) //此城市的最后一个副本 { string content = string.Format(LanguageManager.GetLang().St_systemprompts, ContextUser.NickName, city.CityName); new TjxChatService().SystemSend(ChatType.World, content); } } PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, generalNum, out _honourNum); if (npcInfo.NpcSeqNo == 1) { ContextUser.EnergyNum = MathUtils.Subtraction(ContextUser.EnergyNum, ContextUser.TempEnergyNum).ToShort(); //原因:刷晶石BUG ContextUser.TempEnergyNum = 0; } if (!ContextUser.IsItem) { prizeItems = PlotHelper.GetPlotMonsterItems(Uid, npcInfo.PlotNpcID); } TaskHelper.KillPlotMonster(Uid, npcInfo.PlotID, PlotNpcID); //var stroyTaskList = new ConfigCacheSet<StoryTaskInfo>().FindAll(s => s.PlotID == plotInfo.AftPlotID); //foreach (var story in stroyTaskList) //{ // var usertask = new GameDataCacheSet<UserTask>().FindKey(ContextUser.UserID, story.PlotID); // if (usertask != null) // { PlotHelper.EnablePlot(Uid, plotInfo.AftPlotID); // } //} if (plotInfo.PlotType == PlotType.Elite) { EliteDailyRestrain(npcInfo); NoviceHelper.ElitePlotFestivalList(ContextUser); //通关精英副本获得奖励 } else if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); } else if (plotInfo.PlotType == PlotType.HeroPlot) { PlotHelper.EnableHeroPlot(ContextUser.UserID, plotInfo.PlotID); PlotHelper.HeroDailyRestrain(ContextUser.UserID, plotInfo.PlotID, plotInfo.CityID); } } else { ContextUser.GeneralAllCount = 0; ContextUser.GeneralKillCount = 0; } var restrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid); if (restrain != null) { var restrainSet = new ShareCacheStruct<DailyRestrainSet>().FindKey(RestrainType.PlotGoto); if (restrainSet != null) GotoNum = MathUtils.Subtraction(restrainSet.MaxNum, restrain.Funtion14, 0); } } //原因:最后一个npc时,清空玩家保存副本 if (ContextUser.UserExtend != null && ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = npcInfo.IsBoss; return true; }); } if (!ContextUser.IsItem) { foreach (var prize in prizeItems) { if (prize.Type == 0 && userPlot != null) { var itemInfo = cacheSetItemInfo.FindKey(prize.ItemID); UniversalInfo universalInfo = new UniversalInfo(); universalInfo.HeadID = itemInfo != null ? itemInfo.HeadID : string.Empty; universalInfo.ItemID = itemInfo != null ? itemInfo.ItemID : 0; universalInfo.ItemDesc = itemInfo != null ? itemInfo.ItemDesc : string.Empty; universalInfo.MaxHeadID = itemInfo != null ? itemInfo.MaxHeadID : string.Empty; universalInfo.Name = itemInfo != null ? itemInfo.ItemName : string.Empty; universalInfo.Num = prize.Num; if (userPlot.ItemList != null && userPlot.ItemList.Count > 0) { var item = userPlot.ItemList.Find(s => s.ItemID == prize.ItemID); if (item != null) { item.UpdateNotify(obj => { item.Num = MathUtils.Addition(item.Num, prize.Num); return true; }); } else { userPlot.UpdateNotify(obj => { userPlot.ItemList.Add(universalInfo); return true; }); } } else { userPlot.UpdateNotify(obj => { userPlot.ItemList.Add(universalInfo); return true; }); } } ContextUser.IsItem = true; } } var a = userPlot.ItemList; } finally { ContextUser.UserStatus = UserStatus.Normal; } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = userPlotCombat.UserID; log.CityID = ContextUser.CityID; log.PlotID = userPlotCombat.PlotID; log.NpcID = userPlotCombat.PlotNpcID; log.CombatType = CombatType.Plot; log.HostileUser = string.Empty; log.IsWin = userPlotCombat.IsWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = prizeItems; log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); UserHelper.GetGeneralLife(ContextUser.UserID); UserHelper.RegainGeneralLife(ContextUser.UserID); //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); // foreach (var userEmbattle in userEmbattleList) // { // _userTalPriority = MathUtils.Addition(_userTalPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); // } selfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0); //var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0); return true; }
public void AppendSparePart(UserSparePart sparePart) { var cacheSet = new GameDataCacheSet<UserSparePackage>(); UserSparePackage package = null; if (cacheSet.FindKey(UserID) == null) { package = new UserSparePackage() { UserID = UserID }; cacheSet.Add(package, GameEnvironment.CacheUserPeriod); } package = cacheSet.FindKey(UserID); package.SparePackage.Add(sparePart); //package.Update(); }
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 GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID); var probabilityInfo = new ConfigCacheSet<ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return errStr; } ProbabilityInfo probability1 = new ConfigCacheSet<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 GameDataCacheSet<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 GameDataCacheSet<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 ConfigCacheSet<CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); var crystal = new ConfigCacheSet<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 }
/// <summary> /// 处理礼包 /// </summary> /// <param name="userID"></param> /// <param name="order"></param> private static void DoGiff(string userID, OrderInfo order) { int packType = 0; List<PackageReceive> packageReceivess = new List<PackageReceive>(); UserRechargeLog rechargeLog = new UserRechargeLog { LogID = Guid.NewGuid().ToString(), UserID = userID, OrderNo = order.OrderNO, ChargeAmount = order.Amount, PayGold = order.GameCoins, ReargeDate = DateTime.Now }; var sender = DataSyncManager.GetDataSender(); sender.Send(rechargeLog); UserRecharge recharge = new GameDataCacheSet<UserRecharge>().FindKey(userID); if (recharge == null) { recharge = new UserRecharge() { UserID = userID }; } //处理充值活动 recharge.LastNum = order.GameCoins; TriggerFestivalPack(recharge, order.GameCoins); if (IsCurrentWeek(recharge.ChargeDate)) { recharge.WeekNum = MathUtils.Addition(recharge.WeekNum, order.GameCoins, int.MaxValue); } else { recharge.WeekNum = order.GameCoins; } if (recharge.ChargeDate.Month == DateTime.Now.Month) { recharge.MonthNum = MathUtils.Addition(recharge.MonthNum, order.GameCoins, int.MaxValue); } else { recharge.MonthNum = order.GameCoins; } recharge.TotalGoldNum = MathUtils.Addition(recharge.TotalGoldNum, order.GameCoins, int.MaxValue); recharge.ChargeDate = DateTime.Now; var rechargeCacheSet = new GameDataCacheSet<UserRecharge>(); if (rechargeCacheSet.FindKey(userID) == null) { packType = 1; recharge.FirstNum = order.GameCoins; TriggerReceivePack(userID, packType, recharge.FirstNum); rechargeCacheSet.Add(recharge, GameEnvironment.CacheUserPeriod); FestivalHelper.GetFirstReward(userID, FestivalType.FirstReward); GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(userID); if (userInfo != null) { FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.FirstPayDoubleSpar); } } //触发总累计充值礼包 packType = 2; TriggerReceivePack(userID, packType, recharge.TotalGoldNum); List<RechargePacks> rechargePackseArray = new ConfigCacheSet<RechargePacks>().FindAll(m => m.PacksType == packType); foreach (RechargePacks rechargePackse in rechargePackseArray) { RemoveCharge(userID, rechargePackse.PacksID); } TriggerWeekPack(userID, recharge.WeekNum); //每周礼包 TriggerMonthPack(userID, recharge.MonthNum); //每月礼包 }
public override bool TakeAction() { int subLifeNum = 0; var package = UserItemPackage.Get(Uid); UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(userItemID)); if (userItem == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } //wuzf modify 2012-05-19 ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(userItem.ItemID); var propsArray = new GameDataCacheSet<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1); if (propsArray.Count > 0 && propsArray[0].SurplusNum > 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1605_BandageUse; return false; } //判断背包是否有血包,没有提示去商城 var userItems = package.ItemPackage.FindAll(m => !m.IsRemove && new UserItemHelper(m).PropType == 1); if (userItems.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1605_UseTwoGold; return false; } //给佣兵补血 var userGeneralArray = new GameDataCacheSet<UserGeneral>().FindAll(ContextUser.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong); int effectNum = itemInfo.EffectNum; foreach (var userGeneral in userGeneralArray) { int maxLifeNum = UserHelper.GetMaxLife(ContextUser.UserID, userGeneral.GeneralID); if (userGeneral.LifeNum < maxLifeNum) { subLifeNum = MathUtils.Subtraction(maxLifeNum, userGeneral.LifeNum, 0); userGeneral.LifeNum = MathUtils.Addition(userGeneral.LifeNum, effectNum, maxLifeNum); //userGeneral.Update(); effectNum = MathUtils.Subtraction(effectNum, subLifeNum, 0); } } var cacheSet = new GameDataCacheSet<UserProps>(); UserProps props = new GameDataCacheSet<UserProps>().FindKey(ContextUser.UserID, userItem.ItemID); if (props != null) { props.SurplusNum = effectNum; //props.Update(); } else { props = new UserProps(ContextUser.UserID, itemInfo.ItemID) { SurplusNum = effectNum }; cacheSet.Add(props, GameEnvironment.CacheUserPeriod); } ContextUser.IsUseupItem = false; UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1); foreach (UserProps userPropse in propsArray) { if (userPropse.SurplusNum == 0) { cacheSet.Delete(userPropse); } } return true; }
public override bool TakeAction() { if (!UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.Trump)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_NoFun; return false; } if (UserHelper.IsOpenFunction(ContextUser.UserID, FunctionEnum.TrumpPractice)) { return false; } if (!TrumpHelper.IsTrumpPractice(ContextUser.UserID)) { return false; } var cacheTrump = new GameDataCacheSet<UserTrump>(); UserTrump userTrump = cacheTrump.FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump == null) { TrumpInfo trumpInfo = new ConfigCacheSet<TrumpInfo>().FindKey(TrumpInfo.CurrTrumpID, 1); if (trumpInfo == null) { return false; } StoryTaskInfo[] storyTaskArray = new ConfigCacheSet<StoryTaskInfo>().FindAll(m => m.TaskType == TaskType.Trump).ToArray(); foreach (StoryTaskInfo taskInfo in storyTaskArray) { UserItemHelper.UseUserItem(ContextUser.UserID, taskInfo.TargetItemID, taskInfo.TargetItemNum); } userTrump = new UserTrump(ContextUser.UserID, TrumpInfo.CurrTrumpID); userTrump.TrumpLv = 1; userTrump.WorshipLv = 1; userTrump.LiftNum = trumpInfo.MaxLift; userTrump.Experience = 0; userTrump.MatureNum = trumpInfo.BeseMature; userTrump.Zodiac = TrumpHelper.GetZodiacType(ZodiacType.NoZodiac); //userTrump.SkillInfo = new List<SkillInfo>(); //userTrump.PropertyInfo = new List<GeneralProperty>(); cacheTrump.Add(userTrump); cacheTrump.Update(); } var cacheSet = new GameDataCacheSet<UserFunction>(); UserFunction userFunction = cacheSet.FindKey(ContextUser.UserID, FunctionEnum.TrumpPractice); if (userFunction == null) { UserFunction function = new UserFunction() { FunEnum = FunctionEnum.TrumpPractice, UserID = ContextUser.UserID, CreateDate = DateTime.Now, }; cacheSet.Add(function); cacheSet.Update(); } var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID); if (userTrump.LiftNum > 0 && usergeneral != null) { usergeneral.RefreshMaxLife(); } return true; }
public override bool TakeAction() { int energyNum = ConfigEnvSet.GetInt("User.EnergyNum"); UserHelper.ChechDailyRestrain(ContextUser.UserID); var cacheSet = new GameDataCacheSet <UserDailyRestrain>(); double addNum = FestivalHelper.SurplusPurchased(ContextUser.UserID, FestivalType.PurchasedEnergy);//活动加成 int payNum = FestivalHelper.SurplusEnergyNum(ContextUser.UserID); UserDailyRestrain userRestrain = cacheSet.FindKey(ContextUser.UserID); if (payNum == 0) { if (userRestrain != null && DateTime.Now.Date != userRestrain.RefreshDate.Date) { userRestrain.Funtion4 = 0; } if (userRestrain != null && userRestrain.Funtion4 >= VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.GouMaiJingLi) && DateTime.Now.Date == userRestrain.RefreshDate.Date) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St1010_JingliFull; return(false); } } int useGold = (GetPayEnergyGold(ContextUser.UserID, ContextUser.VipLv, payType) * addNum).ToInt(); if (payType == 1) { if (ops == 1) { this.ErrorCode = 1; this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, energyNum); return(false); } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType), short.MaxValue); if (payNum == 0) { if (userRestrain != null) { userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue); } else { userRestrain = new UserDailyRestrain(); userRestrain.UserID = ContextUser.UserID; userRestrain.RefreshDate = DateTime.Now; userRestrain.Funtion4 = 1; cacheSet.Add(userRestrain); } } UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, 0, userRestrain.Funtion4, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue)); FestivalHelper.PurchasedEnergy(ContextUser.UserID); } } else if (payType == 2) { short payEnergy = GetEnergyNum(ContextUser.UserID, ContextUser.VipLv, payType); if (!VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZiDongGouMaiJingLi)) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_VipNotEnoughNotFuntion; return(false); } if (ops == 1) { this.ErrorCode = 1; this.ErrorInfo = string.Format(LanguageManager.GetLang().St1010_PayEnergyUseGold, useGold, payEnergy); return(false); } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, payEnergy, short.MaxValue); if (userRestrain != null) { userRestrain.Funtion4 = MathUtils.Addition(userRestrain.Funtion4, 1, int.MaxValue); } else { userRestrain = new UserDailyRestrain(); userRestrain.UserID = ContextUser.UserID; userRestrain.RefreshDate = DateTime.Now; userRestrain.Funtion4 = 1; cacheSet.Add(userRestrain); } UserLogHelper.AppenUseGoldLog(ContextUser.UserID, 1, userRestrain.Funtion4, 1, useGold, ContextUser.GoldNum, MathUtils.Addition(ContextUser.GoldNum, useGold, int.MaxValue)); } } return(true); }
/// <summary> /// 获取大转盘列表ID /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int ChestDialGroupID(string userID, int itemID) { int groupID = 0; var dialFreeList = new ConfigCacheSet<DialInfo>().FindAll(m => m.DialType == itemID.ToShort()); if (dialFreeList.Count == 0) { return groupID; } UserDial userDial = new GameDataCacheSet<UserDial>().FindKey(userID); if (userDial == null) { userDial = new UserDial(); userDial.UserID = userID; var cacheSet = new GameDataCacheSet<UserDial>(); cacheSet.Add(userDial, GameEnvironment.CacheUserPeriod); } int postion = RandomUtils.GetRandom(0, dialFreeList.Count); var dialpostion = dialFreeList[postion]; if (dialpostion != null) { groupID = dialpostion.GroupID; userDial.GroupID = groupID; } userDial.HeadID = string.Empty; userDial.ReturnRatio = 0; userDial.DialNum = 0; userDial.RefreshDate = DateTime.Now; return groupID; }
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 GameDataCacheSet <UserDailyRestrain>().FindKey(user.UserID); var probabilityInfo = new ConfigCacheSet <ProbabilityInfo>().FindKey(huntingID); //当前猎命人物的概率 if (probabilityInfo == null) { return(errStr); } ProbabilityInfo probability1 = new ConfigCacheSet <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 GameDataCacheSet <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 GameDataCacheSet <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, GameEnvironment.CacheUserPeriod); } } 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 ConfigCacheSet <CrystalInfo>().FindAll(u => u.CrystalQuality == qualityType && u.DemandLv <= user.UserLv); if (crystalArray2.Count > 0) { int randomNum = RandomUtils.GetRandom(0, crystalArray2.Count); var crystal = new ConfigCacheSet <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() { GeneralHelper.StotyTaskFunction(ContextUser); //已完成替换佣兵功能开启 _userMagicArray = new GameDataCacheSet <UserMagic>().FindAll(ContextUser.UserID, u => u.MagicID != 1 && u.MagicType == MagicType.MoFaZhen); _userMagicArray.QuickSort((x, y) => { if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } return(x.MagicID.CompareTo(y.MagicID)); }); var userFunction = new GameDataCacheSet <UserFunction>().FindKey(ContextUser.UserID, FunctionEnum.ReplaceGeneral); foreach (UserMagic magic in _userMagicArray) { if (magic == null) { continue; } MagicLvInfo magicLv = new ConfigCacheSet <MagicLvInfo>().FindKey(magic.MagicID, magic.MagicLv); if (magicLv != null) { string gridPostion = magicLv.GridRange; if (magicLv.ReplacePostion > 0 && userFunction != null) { gridPostion = gridPostion.TrimEnd(',') + "," + magicLv.ReplacePostion; } string[] gridRangeArray = gridPostion.Split(','); foreach (string gridRange in gridRangeArray) { UserEmbattle userEmbattle = new GameDataCacheSet <UserEmbattle>().FindKey(ContextUser.UserID, magic.MagicID, gridRange.ToShort()); if (userEmbattle == null) { UserEmbattle embattle = new UserEmbattle() { UserID = ContextUser.UserID, MagicID = magic.MagicID, Position = gridRange.ToShort(), GeneralID = 0 }; var cacheSet = new GameDataCacheSet <UserEmbattle>(); cacheSet.Add(embattle); } } } } _userGeneralArray = new GameDataCacheSet <UserGeneral>().FindAll(ContextUser.UserID, u => u.GeneralStatus == GeneralStatus.DuiWuZhong && u.GeneralType != GeneralType.Soul); // 佣兵排序 GeneralSortHelper.GeneralSort(ContextUser.UserID, _userGeneralArray); return(true); }
public override bool TakeAction() { var cacheEnvSet = new ConfigCacheSet<ConfigEnvSet>(); var envset = cacheEnvSet.FindKey("CombatMaxBout"); if (envset != null) { } PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); if (npcInfo == null) { return false; } PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(npcInfo.PlotID); if (plotInfo == null) { return false; } //判断是否有下一关 int nextLayerNum = MathUtils.Addition(ContextUser.UserExtend.LayerNum, 1); int nextHurdleNum = MathUtils.Addition(ContextUser.UserExtend.HurdleNum, 1); if ((UserHelper.IsLastLayer(plotInfo) || !IsGotoNextLayer(nextLayerNum))) { if (UserHelper.IsKill(ContextUser, npcInfo.PlotID)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnableLayerNum; return false; } } if (ops != 1 && UserHelper.IsPromptBlood(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_PromptBlood; return false; } //原因:灵件背包满时未提示 if (ops != 1 && UserHelper.IsSpareGridNum(ContextUser, 0)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St_User_SpareBeiBaoMsg; return false; } if (ops != 1 && !string.IsNullOrEmpty(plotInfo.EnchantID) && plotInfo.EnchantProbability > 0 && EnchantHelper.IsEnchantPackage(ContextUser.UserID)) { ErrorCode = 1; ErrorInfo = LanguageManager.GetLang().St4002_EnchantPackageFull; return false; } if (ContextUser.UserStatus == UserStatus.SaoDang) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4007_Saodanging; return false; } if (ContextUser.UseMagicID == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic; return false; } if (new GameDataCacheSet<UserEmbattle>().FindAll(Uid, m => m.MagicID == ContextUser.UseMagicID).Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4004_EmbattleEmpty; return false; } //PlotNPCInfo npcInfo = new ConfigCacheSet<PlotNPCInfo>().FindKey(PlotNpcID); if (IsPlotOut(npcInfo)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4303_PlotNotEnable; return false; } UserHelper.UserGeneralPromptBlood(ContextUser);//佣兵自动使用绷带补血 //触发战斗 ISingleCombat plotCombater = CombatFactory.TriggerPlot(ContextUser, PlotNpcID); if (plotCombater == null) { return false; } var cacheSet = new GameDataCacheSet<UserPlotCombat>(); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); if (userPlotCombat == null) { userPlotCombat = new UserPlotCombat() { UserID = ContextUser.UserID, PlotNpcID = PlotNpcID }; cacheSet.Add(userPlotCombat); userPlotCombat = cacheSet.FindKey(ContextUser.UserID, PlotNpcID); } userPlotCombat.PlotID = npcInfo.PlotID; userPlotCombat.CombatDate = DateTime.Now; userPlotCombat.IsWin = plotCombater.Doing(); if (!userPlotCombat.IsWin) { userPlotCombat.OverNum += 1; } combatProcessList = (CombatProcessContainer)plotCombater.GetProcessResult(); userPlotCombat.GeneralNum = combatProcessList.AttackList.Count; userPlotCombat.GeneralOverNum = GetOverGeneralNum(combatProcessList.AttackList.ToList()); if (userPlotCombat.IsWin) { int honourNum = 0; PlotHelper.DoPlotPrize(Uid, npcInfo, userPlotCombat, 0, out honourNum); prizeItems = PlotHelper.GetKalpaPlotMonsterItems(Uid, npcInfo.PlotID, npcInfo.PlotNpcID); universalArray = GetUniversalList().ToArray(); if (plotInfo.PlotType == PlotType.Kalpa) { KalpaDailyRestrain(npcInfo); if (ContextUser.UserExtend == null) { ContextUser.UserExtend = new GameUserExtend(); } PlotInfo[] plotInfoList = new ConfigCacheSet<PlotInfo>().FindAll(m => m.LayerNum == ContextUser.UserExtend.LayerNum && m.PlotSeqNo == nextHurdleNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { int layerNum = ContextUser.UserExtend.LayerNum; int hurdleNum = ContextUser.UserExtend.HurdleNum; if (CheckHurdleNum(ContextUser.UserID, layerNum, hurdleNum)) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.HurdleNum = nextHurdleNum; return true; }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } else if (IsGotoNextLayer(nextLayerNum)) { //判断是否能到下一层 plotInfoList = new ConfigCacheSet<PlotInfo>().FindAll(m => m.LayerNum == nextLayerNum && m.PlotType == PlotType.Kalpa).ToArray(); if (plotInfoList.Length > 0) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.LayerNum = nextLayerNum; ContextUser.UserExtend.HurdleNum = 1; return true; }); //ContextUser.Update(); PlotHelper.EnablePlot(ContextUser.UserID, plotInfo.AftPlotID); } } } } //日志 UserCombatLog log = new UserCombatLog(); log.CombatLogID = Guid.NewGuid().ToString(); log.UserID = userPlotCombat.UserID; log.CityID = ContextUser.CityID; log.PlotID = userPlotCombat.PlotID; log.NpcID = userPlotCombat.PlotNpcID; log.CombatType = CombatType.Kalpa; log.HostileUser = string.Empty; log.IsWin = userPlotCombat.IsWin; log.CombatProcess = JsonUtils.Serialize(combatProcessList); log.PrizeItem = prizeItems; log.CreateDate = DateTime.Now; var sender = DataSyncManager.GetDataSender(); sender.Send(log); UserHelper.GetGeneralLife(ContextUser.UserID); return true; }