/// <summary> /// 父亲节奖励 /// </summary> public static void FathersDay(GameUser user) { short energyNum = 30; int obtainNum = 50; int gameGoin = 20000; string fatherTime = "2012-06-17 00:00:00"; DateTime fatherDate = DateTime.Parse(fatherTime); UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID); if (dailyRestrain != null && dailyRestrain.Funtion13 < 1) { if (DateTime.Now.Date == fatherDate.Date) { dailyRestrain.Funtion13 = 1; //dailyRestrain.Update(); user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum, short.MaxValue); user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, gameGoin, int.MaxValue); //user.Update(); string content = string.Format(LanguageManager.GetLang().St_FathersDay, energyNum, obtainNum, gameGoin); new TjxChatService().SystemSendWhisper(user, content); } } }
public override void BuildPacket() { var cacheSetItemEqu = new ConfigCacheSet<ItemEquAttrInfo>(); PushIntoStack(_userItemArray.Count); foreach (UserItemInfo item in _userItemArray) { ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(item.ItemID); var general = new GameDataCacheSet<UserGeneral>().FindKey(Uid, item.GeneralID); var itemEquList = cacheSetItemEqu.FindAll(e => e.ItemID.Equals(item.ItemID)); DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(item.UserItemID.ToNotNullString()); dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.ItemName.ToNotNullString()); dsItem.PushIntoStack(itemInfo == null ? string.Empty : itemInfo.HeadID.ToNotNullString()); dsItem.PushIntoStack(item.ItemLv); dsItem.PushIntoStack(itemInfo == null ? LanguageManager.GetLang().shortInt : (short)itemInfo.QualityType); dsItem.PushIntoStack(general != null ? general.GeneralName : string.Empty); PushIntoStack(dsItem); dsItem.PushIntoStack(itemEquList.Count); foreach (var itemEquAttrInfo in itemEquList) { DataStruct dsItem1 = new DataStruct(); dsItem1.PushIntoStack(itemEquAttrInfo.AttributeID.ToInt()); int strengNum = 0; strengNum = MathUtils.Addition(itemEquAttrInfo.BaseNum, (itemEquAttrInfo.IncreaseNum * item.ItemLv), int.MaxValue); // dsItem1.PushIntoStack(itemEqu.BaseNum); dsItem1.PushIntoStack(strengNum); dsItem.PushIntoStack(dsItem1); } } }
public override bool TakeAction() { GeneralProperty property = null; UserTrump userTrump = new GameDataCacheSet<UserTrump>().FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump != null && userTrump.PropertyInfo.Count > 0) { property = userTrump.PropertyInfo.Find(m => m.AbilityType == propertyID); } if (property == null) { return false; } if (ops == 1) { ErrorCode = ops; ErrorInfo = LanguageManager.GetLang().St1467_WorshipGridNotEnough; return false; } else if (ops == 2) { ErrorCode = ops; userTrump.PropertyInfo.Remove(property); var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID); if (usergeneral != null) { usergeneral.RefreshMaxLife(); } } return true; }
/// <summary> /// 天地劫副本关数 /// </summary> /// <param name="user"></param> public static int CheckUserPlotHurdleNum(GameUser user) { int hurdleNum = 0; PlotInfo plotInfo = CheckUserPlotKalpa(user); if (plotInfo != null) { UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID); if (dailyRestrain != null && dailyRestrain.UserExtend != null && dailyRestrain.UserExtend.KalpaDate.Date == DateTime.Now.Date) { hurdleNum = user.UserExtend.HurdleNum; } else { hurdleNum = plotInfo.PlotSeqNo; if (user.UserExtend != null && hurdleNum > 0) { user.UserExtend.UpdateNotify(obj => { user.UserExtend.HurdleNum = hurdleNum; return true; }); //user.Update(); } } } else { hurdleNum = 1; } return hurdleNum; }
private GameTable() { _cardRole = new CardRole(); _pokerConfig = new ShareCacheStruct<PokerInfo>(); _userCacheSet = new GameDataCacheSet<GameUser>(); _roomStruct = new MemoryCacheStruct<RoomData>(); }
public override bool TakeAction() { string host = httpGet.RemoteAddress ?? ""; string bindHost = ContextUser != null ? ContextUser.RemoteAddress : ""; if (!string.IsNullOrEmpty(host) && !host.Equals(bindHost)) { UserConnection con; if (_roomStruct.TryGet(host, out con)) { var tempUser = new GameDataCacheSet<GameUser>().FindKey(Uid); if (tempUser != null) { tempUser.RemoteAddress = string.Empty; Console.WriteLine("玩家:{0}-{1} Socket通道被解绑", tempUser.UserId, tempUser.NickName); } con.UserId = UserId; } else { _roomStruct.TryAdd(host, new UserConnection() { UserId = UserId, LocalHost = host }); } if (ContextUser != null) { ContextUser.RemoteAddress = host; } } //Console.WriteLine(httpGet.RemoteAddress); return true; }
public override bool TakeAction() { int useGold = ConfigEnvSet.GetInt("TrumpZodiac.ChangeZodiacUseGold"); if (ops == 1) { ErrorCode = ops; ErrorInfo = string.Format(LanguageManager.GetLang().St1471_ChangeZodiac, useGold); return false; } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return false; } var cacheSet = new GameDataCacheSet<UserTrump>(); UserTrump userTrump = cacheSet.FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump != null) { userTrump.Zodiac = TrumpHelper.GetZodiacType(userTrump.Zodiac); ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); } ErrorCode = ops; } return true; }
/// <summary> /// 法宝加经验,升级 /// </summary> /// <param name="userID"></param> /// <param name="experience"></param> public static void CheckTrumpEscalate(string userID, int experience) { UserTrump userTrump = new GameDataCacheSet<UserTrump>().FindKey(userID, TrumpInfo.CurrTrumpID); if (userTrump != null) { userTrump.Experience = MathUtils.Addition(userTrump.Experience, experience); while (userTrump.TrumpLv < GameConfigSet.MaxTrumpLv) { short upLv = MathUtils.Addition(userTrump.TrumpLv, (short)1, GameConfigSet.MaxTrumpLv.ToShort()); TrumpInfo trumpInfo = new ConfigCacheSet<TrumpInfo>().FindKey(TrumpInfo.CurrTrumpID, upLv); if (trumpInfo != null && userTrump.Experience >= trumpInfo.Experience) { userTrump.TrumpLv = MathUtils.Addition(userTrump.TrumpLv, (short)1, GameConfigSet.MaxTrumpLv.ToShort()); userTrump.Experience = MathUtils.Subtraction(userTrump.Experience, trumpInfo.Experience); if (trumpInfo.SkillID > 0) { SkillInfo skillInfo = new SkillInfo(); skillInfo.AbilityID = trumpInfo.SkillID.ToInt(); skillInfo.AbilityLv = 1; userTrump.SkillInfo.Add(skillInfo); } } else { break; } } if (userTrump.TrumpLv >= GameConfigSet.MaxTrumpLv) { userTrump.Experience = 0; } } }
public override bool TakeAction() { UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, generalID); if (userGeneral == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St1405_GeneralIDNotEnough; return false; } if (ops == 1) { //佣兵离队时,传承清空 if (ContextUser.HeritageList.Count > 0) { GeneralHeritage heritage = ContextUser.HeritageList.Find(m => m.GeneralID == generalID); if (heritage != null) { ContextUser.HeritageList = new CacheList<GeneralHeritage>(); } } List<UserEmbattle> embattleArray = new GameDataCacheSet<UserEmbattle>().FindAll(ContextUser.UserID, u => u.GeneralID == generalID); foreach (UserEmbattle embattle in embattleArray) { embattle.GeneralID = 0; } if (userGeneral.GeneralID == LanguageManager.GetLang().GameUserGeneralID) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St1405_LiDuiNotFilter; return false; } userGeneral.GeneralStatus = GeneralStatus.LiDui; } return true; }
public override bool TakeAction() { var cacheSet = new GameDataCacheSet<UserQueue>(); List<UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang); foreach (UserQueue queue in userQueueList) { if (queue != null) { int npcCount = new ConfigCacheSet<PlotNPCInfo>().FindAll(m => m.PlotID == plotID).Count; //战斗次数 int totalBattleNum = (int)Math.Floor((double)(queue.TotalColdTime - queue.DoRefresh()) / PlotInfo.BattleSpeedNum); int turnsNum = totalBattleNum / npcCount; int battleNum = totalBattleNum % npcCount; //没发生战斗或上未通关都返还精力 //if (turnsNum == 0 || battleNum > 0) //{ // ContextUser.EnergyNum = ContextUser.EnergyNum.Addition(PlotInfo.BattleEnergyNum, short.MaxValue); //} cacheSet.Delete(queue); } } if (ContextUser.UserStatus == UserStatus.SaoDang) { ContextUser.ResetSweepPool(0); ContextUser.UserStatus = UserStatus.Normal; //ContextUser.Update(); } return true; }
public override void BuildPacket() { PushIntoStack(isSuccess); PushIntoStack(memberArray.Count); foreach (GuildMember member in memberArray) { UserCacheGlobal.CheckLoadUser(member.UserID); GameUser gameUser = new GameDataCacheSet<GameUser>().FindKey(member.UserID); UserGeneral general = UserGeneral.GetMainGeneral(member.UserID); int isHelp = 0; if (member.DevilNum > 1) { isHelp = 1; } else { isHelp = 2; } DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(member.UserID); dsItem.PushIntoStack(gameUser == null ? string.Empty : gameUser.NickName.ToNotNullString()); dsItem.PushIntoStack(general == null ? string.Empty : general.HeadID.ToNotNullString()); dsItem.PushIntoStack(isHelp); PushIntoStack(dsItem); } PushIntoStack(currNum); PushIntoStack(isPilgrimage); PushIntoStack(chaoShengNum); }
public static List<SkillLvInfo> CreateSkillLvInfo(CombatGeneral general) { List<SkillLvInfo> _skillLvList = new List<SkillLvInfo>(); if (general.GeneralID == LanguageManager.GetLang().GameUserGeneralID) { var abilityCacheSet = new ConfigCacheSet<AbilityInfo>(); var skillLvSet = new ConfigCacheSet<SkillLvInfo>(); UserTrump userTrump = new GameDataCacheSet<UserTrump>().FindKey(general.UserID, TrumpInfo.CurrTrumpID) ?? new UserTrump(); if (userTrump.LiftNum > 0) { userTrump.SkillInfo.Foreach(obj => { var abilityInfo = abilityCacheSet.FindKey(obj.AbilityID) ?? new AbilityInfo(); if (abilityInfo.AttackType == AttackType.Trigger) { var temp = skillLvSet.FindKey(obj.AbilityID, obj.AbilityLv); if (temp != null) { _skillLvList.Add(temp); } } return true; }); } } return _skillLvList; }
public override bool TakeAction() { if (ops == 0) { UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, ContextUser.GeneralID); if (userGeneral == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } userGeneral.TrainingPower = ContextUser.TrainingPower; userGeneral.TrainingSoul = ContextUser.TrainingSoul; userGeneral.TrainingIntellect = ContextUser.TrainingIntellect; UserHelper.GetGameUserCombat(ContextUser.UserID); } else if (ops == 1) { this.ErrorCode = ops; } else { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().ServerBusy; return false; } return true; }
public override bool TakeAction() { if (ContextUser.TempEnergyNum > 0 && ContextUser.UserStatus != UserStatus.Combat) { List<UserPlotCombat> plotCombatList = new GameDataCacheSet<UserPlotCombat>().FindAll(ContextUser.UserID, m => m.PlotID == plotID); //没发生战斗或上次战斗失败都返还精力 if (plotCombatList.Count == 0 || (ContextUser.TempEnergyNum > 0 && IsNotCombat(plotCombatList))) { if (ContextUser.SurplusEnergy == 0 && !ContextUser.IsSurplus) //策划要求:领取的不返还 { if (ContextUser.UserExtend != null && ContextUser.UserExtend.PlotStatusID > 0 && ContextUser.UserExtend.MercenarySeq <= 1) { ContextUser.TempEnergyNum = 0; ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, PlotInfo.BattleEnergyNum, short.MaxValue); } //ContextUser.Update(); } } } if (ContextUser.UserExtend != null) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = false; return true; }); } return true; }
public override bool TakeAction() { if (new GameDataCacheSet<UserFunction>().FindKey(Uid, FunctionEnum.PetRun) == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_NoFun; return false; } UserDailyRestrain restrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(Uid); if (restrain != null && restrain.UserExtend != null) { var dailyCacheSet = new ShareCacheStruct<DailyRestrainSet>(); if (dailyCacheSet.FindKey(RestrainType.PetRun) != null) _runTimes = MathUtils.Subtraction(dailyCacheSet.FindKey(RestrainType.PetRun).MaxNum, restrain.UserExtend.PetRunTimes, 0); if (dailyCacheSet.FindKey(RestrainType.PetIntercept) != null) _interceptTimes = MathUtils.Subtraction(dailyCacheSet.FindKey(RestrainType.PetIntercept).MaxNum, restrain.UserExtend.PetIntercept, 0); if (dailyCacheSet.FindKey(RestrainType.PetHelp) != null) _helpTimes = MathUtils.Subtraction(dailyCacheSet.FindKey(RestrainType.PetHelp).MaxNum, restrain.UserExtend.PetHelp, 0); } var petRun = new ShareCacheStruct<PetRunPool>().FindKey(Uid); if (petRun != null) { //问题:在赛跑时有重刷点亮宠物后,等赛跑完服务端与客户端记录宠物ID不一致,原因是赛跑完有将宠物ID清除 if (petRun.PetID > 0 && petRun.ColdTime == 0) { UserHelper.ProcessPetPrize(petRun); } _coldTime = petRun.ColdTime; _petHead = (new ConfigCacheSet<PetInfo>().FindKey(petRun.PetID) ?? new PetInfo()).PetHead; if (ContextUser.UserExtend != null) _petId = ContextUser.UserExtend.LightPetID; } return true; }
public override bool TakeAction() { var package = UserItemPackage.Get(ContextUser.UserID); UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID == userItemID); if (userItem != null) { UserTrump userTrump = new GameDataCacheSet<UserTrump>().FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump != null && userTrump.TrumpLv >= GameConfigSet.MaxTrumpLv) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1456_OutTrumpMaxLv; return false; } ItemBaseInfo itemInfo = new ConfigCacheSet<ItemBaseInfo>().FindKey(userItem.ItemID); if (itemInfo != null && itemInfo.PropType == 10) { TrumpHelper.CheckTrumpEscalate(ContextUser.UserID, itemInfo.EffectNum); UserItemHelper.UseUserItem(ContextUser.UserID, itemInfo.ItemID, 1); var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID); if (usergeneral != null) { usergeneral.RefreshMaxLife(); } } } return true; }
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 void BuildPacket() { this.PushIntoStack(heritageList.Count); foreach (var item in heritageList) { UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(ContextUser.UserID, item.GeneralID); GeneralInfo general = new ConfigCacheSet<GeneralInfo>().FindKey(item.GeneralID); DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack((short)item.Type); dsItem.PushIntoStack(userGeneral == null ? 0 : userGeneral.GeneralID); dsItem.PushIntoStack(userGeneral == null ? string.Empty : ObjectExtend.ToNotNullString(userGeneral.GeneralName)); dsItem.PushIntoStack(general == null ? string.Empty : ObjectExtend.ToNotNullString(general.BattleHeadID)); dsItem.PushIntoStack(item.GeneralLv); dsItem.PushIntoStack(item.PowerNum); dsItem.PushIntoStack(item.SoulNum); dsItem.PushIntoStack(item.IntellectNum); dsItem.PushIntoStack(userGeneral == null ? (short)0 : (short)userGeneral.GeneralQuality); this.PushIntoStack(dsItem); } this.PushIntoStack(opsInfoList.Count); foreach (var item in opsInfoList) { DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(item.Type); dsItem.PushIntoStack(item.VipLv); dsItem.PushIntoStack(item.UseGold); dsItem.PushIntoStack(item.ItemID); dsItem.PushIntoStack(item.ItemNum); this.PushIntoStack(dsItem); } this.PushIntoStack(heritageName.ToNotNullString()); this.PushIntoStack(heritageLv); this.PushIntoStack(disGeneralName.ToNotNullString()); }
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 override void BuildPacket() { PushIntoStack(moreTeam.MorePlot.PlotID); PushIntoStack(moreTeam.MorePlot.PlotName.ToNotNullString()); PushIntoStack(moreTeam.UserList.Count); PushIntoStack(PlotTeamCombat.TeamMaxPeople); PushIntoStack(moreTeam.MorePlot.ItemId); PushIntoStack(moreTeam.MorePlot.ItemName.ToNotNullString()); PushIntoStack(moreTeam.MorePlot.ItemNum); PushIntoStack(moreTeam.MorePlot.ExpNum); PushIntoStack(moreTeam.TeamUser != null && moreTeam.TeamUser.UserId.ToNotNullString().Equals(Uid) ? 1 : 0); PushIntoStack(moreTeam.Status); PushIntoStack(moreTeam.UserList.Count); foreach (var teamUser in moreTeam.UserList) { var gameUser = new GameDataCacheSet<GameUser>().FindKey(teamUser.UserId); UserGeneral general = UserGeneral.GetMainGeneral(teamUser.UserId); CareerInfo careerInfo = null; if (general != null) { careerInfo = new ConfigCacheSet<CareerInfo>().FindKey(general.CareerID); } DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(teamUser.UserId); dsItem.PushIntoStack(teamUser.NickName.ToNotNullString()); dsItem.PushIntoStack(careerInfo == null ? 0 : (int)careerInfo.CareerID); dsItem.PushIntoStack(careerInfo == null ? string.Empty : careerInfo.CareerName.ToNotNullString()); dsItem.PushIntoStack(gameUser == null ? (short)0 : gameUser.UserLv); PushIntoStack(dsItem); } }
private static bool GetPayment(int game, int server, string account, string userID) { try { GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(userID); if (userInfo == null) return false; var chatService = new TjxChatService(); OrderInfo[] model = PayManager.getPayment(game, server, account); foreach (OrderInfo order in model) { userInfo.PayGold = MathUtils.Addition(userInfo.PayGold, order.GameCoins, int.MaxValue); //userInfo.Update(); PayManager.Abnormal(order.OrderNO); DialHelper.ReturnRatioGold(userID, order.GameCoins); //大转盘抽奖奖励充值返还 chatService.SystemSendWhisper(userInfo, string.Format(LanguageManager.GetLang().PaySuccessMsg, order.GameCoins)); DoGiff(userID, order); FestivalHelper.GetPayReward(userInfo, order.GameCoins, FestivalType.PayReward); } return true; } catch (Exception ex) { BaseLog log = new BaseLog("PaymentLog"); log.SaveLog(ex); return false; } }
public override bool TakeAction() { int sumGold = 0; int userGold = ConfigEnvSet.GetInt("UserLand.UseGold"); int intervalDate = ConfigEnvSet.GetInt("UserLand.IntervalDate"); UserLand land = new GameDataCacheSet<UserLand>().FindKey(ContextUser.UserID, landPostion); if (land != null) { int subDate = (land.DoRefresh() / intervalDate); sumGold = (MathUtils.Addition(subDate, 1, int.MaxValue) * userGold); } if (Ops == 1) { this.ErrorCode = 1; this.ErrorInfo = string.Format(LanguageManager.GetLang().St10007_DoRefresh, sumGold); return false; } else if (Ops == 2) { if (ContextUser.GoldNum < sumGold) { this.ErrorCode = 2; this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return false; } if (land != null && (DateTime.Now - land.GainDate).TotalSeconds < 28800) { land.GainDate = MathUtils.SqlMinDate; ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold, int.MaxValue); } } return true; }
/// <summary> /// 竞技场每日奖励 /// </summary> /// <param name="user"></param> public static void DailySportsRankPrize(GameUser user) { UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(user.UserID); if (IsGainSportsReward(user.UserID) && dailyRestrain != null && dailyRestrain.UserExtend != null) { //var envSet = ServerEnvSet.Get(ServerEnvKey.JingJiChangReward, ""); SportsRewardInfo sportsInfo = new ConfigCacheSet<SportsRewardInfo>().FindKey(dailyRestrain.UserExtend.UserRankID); //if (envSet != null && sportsInfo != null && envSet.ToDateTime().Date > dailyRestrain.Funtion11.Date && // dailyRestrain.UserExtend.UserRankID > 0) if (sportsInfo != null && DateTime.Now.Date != dailyRestrain.Funtion11.Date && dailyRestrain.UserExtend.UserRankID > 0) { dailyRestrain.Funtion11 = DateTime.Now; dailyRestrain.UserExtend.UserRankID = 0; user.SportsIntegral = MathUtils.Addition(user.SportsIntegral, sportsInfo.RewardObtian, int.MaxValue); user.GameCoin = MathUtils.Addition(user.GameCoin, sportsInfo.RewardGoin, int.MaxValue); string sportContent = string.Format(LanguageManager.GetLang().St5106_JingJiChangRankReward, sportsInfo.RewardObtian, sportsInfo.RewardGoin); var chatService = new TjxChatService(); chatService.SystemSendWhisper(user, sportContent); } } }
public override void BuildPacket() { PushIntoStack(_chargePacksArray.Count); foreach (RechargePacks packs in _chargePacksArray) { short _isRevice = 0; short _isShow = 0; List<PackageReceive> receivesArray = new GameDataCacheSet<PackageReceive>().FindAll(ContextUser.UserID, u => u.IsReceive == false && u.PacksID == packs.PacksID); if (receivesArray.Count == 0) { _isRevice = 2; } else { _isRevice = 1; } SaveLog(receivesArray.Count + ContextUser.UserID + packs.PacksID); DataStruct dsItem = new DataStruct(); dsItem.PushIntoStack(packs.PacksID); dsItem.PushIntoStack(packs.PacksName); dsItem.PushIntoStack(_isRevice); dsItem.PushIntoStack(_isShow); dsItem.PushIntoStack(receivesArray.Count); PushIntoStack(dsItem); } }
public override bool TakeAction() { if (ContextUser.UserStatus == UserStatus.CountryCombat) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1902_CountryCombatNotUpEmbattle; return false; } var userMagicArray = new GameDataCacheSet<UserMagic>().FindAll(ContextUser.UserID, m => m.MagicType == MagicType.MoFaZhen); foreach (UserMagic magic in userMagicArray) { if (magic.MagicID == _magicID) { magic.IsEnabled = true; ContextUser.UseMagicID = _magicID; //ContextUser.Update(); } else { magic.IsEnabled = false; } //magic.Update(); UserHelper.GetGameUserCombat(ContextUser.UserID); } return true; }
public override bool TakeAction() { UserDailyRestrain dailyRestrain = new GameDataCacheSet<UserDailyRestrain>().FindKey(ContextUser.UserID); if (RankingHelper.IsGainSportsReward(ContextUser.UserID) && dailyRestrain != null && dailyRestrain.UserExtend != null) { var envSet = ServerEnvSet.Get(ServerEnvKey.JingJiChangReward, ""); SportsRewardInfo sportsInfo = new ConfigCacheSet<SportsRewardInfo>().FindKey(dailyRestrain.UserExtend.UserRankID); { if (envSet != null && sportsInfo != null) if (envSet.ToDateTime().Date > dailyRestrain.Funtion11.Date && dailyRestrain.UserExtend.UserRankID > 0) { dailyRestrain.Funtion11 = DateTime.Now; dailyRestrain.UserExtend.UserRankID = 0; //dailyRestrain.Update(); ContextUser.ObtainNum = MathUtils.Addition(ContextUser.ObtainNum, sportsInfo.RewardObtian, int.MaxValue); ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, sportsInfo.RewardGoin, int.MaxValue); //ContextUser.Update(); UserHelper.Contribution(ContextUser.UserID, sportsInfo.RewardObtian); ErrorInfo = string.Format(LanguageManager.GetLang().St5106_JingJiChangRankReward, sportsInfo.RewardObtian, sportsInfo.RewardGoin); } } } return true; }
public static void AddExprerience(GameUser user, int experience) { string userID = user.UserID; var userEmbattleList = new GameDataCacheSet<UserEmbattle>().FindAll(userID, m => m.MagicID == user.UseMagicID); HashSet<int> generalHash = new HashSet<int>(); foreach (UserEmbattle userEmbattle in userEmbattleList) { //wuzf 8-18 修复多个相同佣兵阵形数据 if (generalHash.Contains(userEmbattle.GeneralID)) { userEmbattle.GeneralID = 0; //userEmbattle.Update(); continue; } else { generalHash.Add(userEmbattle.GeneralID); } //UserGeneral userGeneral = new GameDataCacheSet<UserGeneral>().FindKey(userID, userEmbattle.GeneralID); //if (userGeneral != null) //{ // userGeneral.CurrExperience = MathUtils.Addition(userGeneral.CurrExperience, experience); //} } //UserHelper.UserGeneralExp(user.UserID, experience); }
public override bool TakeAction() { UserTrump userTrump = new GameDataCacheSet<UserTrump>().FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump != null && userTrump.PropertyInfo.Count > 0) { GeneralProperty property = userTrump.PropertyInfo.Find(m => m.AbilityType == propertyID); if (property != null) { if (property.AbilityLv >= TrumpPropertyInfo.MaxTrumpPropertyLv) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1466_OutPropertyMaxLv; return false; } TrumpPropertyInfo trumpProperty = new ConfigCacheSet<TrumpPropertyInfo>().FindKey(property.AbilityType, property.AbilityLv); if (trumpProperty != null) { int upItemNum = TrumpHelper.GetUserItemNum(ContextUser.UserID, trumpProperty.ItemID); if (upItemNum < trumpProperty.ItemNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1462_ItemNumNotEnough; return false; } if (ContextUser.GameCoin < trumpProperty.GameCoin) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GameCoinNotEnough; return false; } if (ContextUser.ObtainNum < trumpProperty.ObtainNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_ObtainNumNotEnough; return false; } ContextUser.ObtainNum = MathUtils.Subtraction(ContextUser.ObtainNum, trumpProperty.ObtainNum); ContextUser.GameCoin = MathUtils.Subtraction(ContextUser.GameCoin, trumpProperty.GameCoin); UserItemHelper.UseUserItem(ContextUser.UserID, trumpProperty.ItemID, trumpProperty.ItemNum); short upLv = MathUtils.Addition(property.AbilityLv, (short)1, (short)TrumpPropertyInfo.MaxTrumpPropertyLv); TrumpPropertyInfo uptrumpProperty = new ConfigCacheSet<TrumpPropertyInfo>().FindKey(property.AbilityType, upLv); property.UpdateNotify(obj => { property.AbilityLv = MathUtils.Addition(property.AbilityLv, (short)1, TrumpPropertyInfo.MaxTrumpPropertyLv); property.AbilityValue = uptrumpProperty.PropertyNum; return true; }); var usergeneral = UserGeneral.GetMainGeneral(ContextUser.UserID); if (usergeneral != null) { usergeneral.RefreshMaxLife(); } ErrorCode = 0; ErrorInfo = LanguageManager.GetLang().St1464_UpgradeWasSsuccessful; } } } return true; }
/// <summary> /// 增加刷新次数 /// </summary> /// <param name="userID"></param> /// <param name="cityID"></param> /// <returns></returns> public static void HeroRefreshNum(string userID, int cityID) { var cacheSet = new GameDataCacheSet<UserDailyRestrain>(); UserDailyRestrain dailyRestrain = cacheSet.FindKey(userID); if (dailyRestrain != null) { DailyUserExtend userExtend = new DailyUserExtend(); List<HeroPlot> heroList = new List<HeroPlot>(); if (dailyRestrain.UserExtend != null) { userExtend = dailyRestrain.UserExtend; if (dailyRestrain.UserExtend.HeroPlot.Count > 0) { heroList = dailyRestrain.UserExtend.HeroPlot; } } HeroPlot plot = heroList.Find(m => m.CityID.Equals(cityID)); if (plot != null) { plot.HeroNum = MathUtils.Addition(plot.HeroNum, 1); } else { heroList.Add(new HeroPlot() { CityID = cityID, HeroNum = 1, HeroList = new List<FunPlot>() }); } userExtend.HeroPlot = heroList; dailyRestrain.UserExtend = userExtend; } cacheSet.Update(); }
public override bool TakeAction() { int sumGold = 0; UserExpedition userExp = new GameDataCacheSet<UserExpedition>().FindKey(ContextUser.UserID); if (userExp == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } if (DateTime.Now.Date == userExp.InsertDate.Date) { sumGold = MathUtils.Addition(userExp.DoRefresh() / 60, 1, int.MaxValue); } if (ops == 1) { this.ErrorCode = 1; this.ErrorInfo = string.Format(LanguageManager.GetLang().St11003_DelCodeTime, sumGold); return false; } else if (ops == 2) { if (ContextUser.GoldNum < sumGold) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return false; } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, sumGold, int.MaxValue); userExp.CodeTime = 0; } return true; }
/// <summary> /// ����,�����Ա���ߵģ�ְ�������ܹ�������ʱ�併�� /// </summary> /// <param name="itemData"></param> /// <returns></returns> public override int CompareTo(ShareEntity itemData) { GuildMember other = itemData as GuildMember; int result = 0; if (this == null && other == null) { return(0); } if (this != null && other == null) { return(1); } if (this == null && other != null) { return(-1); } var cacheSet = new GameDataCacheSet <GameUser>(); GameUser otherUser = cacheSet.FindKey(other.UserID); if (otherUser == null) { otherUser = UserCacheGlobal.CheckLoadUser(other.UserID); } GameUser user = cacheSet.FindKey(UserID); if (user == null) { user = UserCacheGlobal.CheckLoadUser(UserID); } if (otherUser != null && user != null) { result = otherUser.IsOnline.CompareTo(user.IsOnline); } if (result == 0) { result = ((int)PostType).CompareTo((int)other.PostType); if (result == 0) { result = other.TotalContribution.CompareTo(TotalContribution); if (result == 0) { result = other.InsertDate.CompareTo(InsertDate); } } } return(result); }
public override bool TakeAction() { //消除冷却以分钟为单位 UserQueue queue = new GameDataCacheSet <UserQueue>().FindKey(ContextUser.UserID, queueID); if (queue == null) { return(false); } int queueColdTime = queue.DoRefresh(); queueColdTime = queueColdTime < 0 ? 0 : queueColdTime; if (ops == 1) { //加速所需晶石 ErrorCode = ops; ErrorInfo = string.Format(LanguageManager.GetLang().St1702_UseGold, GetPrice()); return(false); } else if (ops == 2) { if (ContextUser.GoldNum >= GetPrice()) { ErrorCode = ops; if (ContextUser.GoldNum >= GetPrice()) { ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, GetPrice(), int.MaxValue); //ContextUser.Update(); queue.ColdTime = 0; queue.TotalColdTime = 0; //queue.Update(); } } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } } else { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().UrlElement; return(false); } return(true); }
/// <summary> /// 获取我的战绩列表 /// </summary> /// <returns></returns> public static List <CombatGainInfoSD> GetCombatGainList(int _userid) { List <CombatGainInfoSD> _CombatGainList = new List <CombatGainInfoSD>(); //取指定userid最近一天的一次房间结算OVER的记录 var cacheSettable = new ShareCacheStruct <tb_TableMoneyLog>(); var cacheRank = new GameDataCacheSet <tb_Rank>(); DbDataFilter filter1 = new DbDataFilter(); cacheRank.TryRecoverFromDb(filter1); tb_Rank rank = cacheRank.FindKey(_userid.ToString()); if (rank == null || !rank.records.Any()) { return(_CombatGainList); } List <Record> records = rank.records.OrderByDescending(w => w.CreateDate).Take(10).ToList(); foreach (var record in records) { CombatGainInfoSD _tempGain = new CombatGainInfoSD(); _tempGain.tablenum = record.MatchCode; _tempGain._starttime = record.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"); _tempGain._tableRecord = new List <CombatTableRecordSD>(); //找到同桌的人 var cacheSettable2 = new ShareCacheStruct <tb_TableMoneyLog>(); DbDataFilter filter = new DbDataFilter(); filter.Condition = "MatchCode=@MatchCode"; filter.Parameters.Add("MatchCode", record.MatchCode); cacheSettable2.TryRecoverFromDb(filter); List <tb_TableMoneyLog> tablemoneylog2list = cacheSettable2.FindAll((r) => { return(r.MatchCode == record.MatchCode && r._isover); }); if (tablemoneylog2list.Any()) { foreach (var moneylog2 in tablemoneylog2list) { CombatTableRecordSD _combatTable = new CombatTableRecordSD(); _combatTable.userid = moneylog2.UserID; _combatTable._username = tb_UserEx.GetUserNameByUserID(moneylog2.UserID); _combatTable._winorlost = (int)moneylog2.AddorReduceMoney; _tempGain._tableRecord.Add(_combatTable); } } _CombatGainList.Add(_tempGain); //_lastCount++; //if (_lastCount >= 10) break;//暂时只取10条 } return(_CombatGainList); }
public override bool TakeAction() { int totalNum = 0; UserHelper.ChechDailyRestrain(ContextUser.UserID); UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID); if (VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.ZhongZhiJingYingPlot)) { totalNum = MathUtils.Addition(totalNum, 1, int.MaxValue); } if (VipHelper.GetVipOpenFun(ContextUser.VipLv, ExpandType.SecondZhongZhiJingYingPlot)) { totalNum = MathUtils.Addition(totalNum, 1, int.MaxValue); } if (totalNum <= 0 || (dailyRestrain != null && dailyRestrain.Funtion10 >= totalNum)) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St4012_JingYingPlotFull; return(false); } int useGold = ConfigEnvSet.GetInt("ResetElitePlot"); if (ops == 1) { ErrorCode = ops; ErrorInfo = string.Format(LanguageManager.GetLang().St4012_JingYingPlot, useGold); return(false); } else if (ops == 2) { if (ContextUser.GoldNum < useGold) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough; return(false); } if (dailyRestrain != null) { dailyRestrain.Funtion10 = MathUtils.Addition(dailyRestrain.Funtion10, 1, int.MaxValue); //dailyRestrain.Update(); } ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold, int.MaxValue); //ContextUser.Update(); } return(true); }
/// <summary> /// 活动奖励是否可领取 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static short FestivalIsReceive(GameUser user, int festID) { short isReceive = 0; FestivalInfo info = new ShareCacheStruct <FestivalInfo>().FindKey(festID); if (info != null) { FestivalRestrain fRest = new GameDataCacheSet <FestivalRestrain>().FindKey(user.UserID, info.FestivalID); if (info.FestivalType == FestivalType.UpgradeGiveGift && user.UserLv >= info.RestrainNum) { if (fRest == null) { return(0); } else if (!fRest.IsReceive) { return(1); } else { return(2); } } if (info.FestivalType == FestivalType.DuplicateDropDouble) { int num = FestivalSurplusNum(user.UserID, festID); if (fRest == null || fRest.RefreashDate.Date != DateTime.Now.Date || info.RestrainNum > num) { isReceive = 1; } } else if (info.FestivalType == FestivalType.StoreDiscount) { isReceive = 1; } else { if (fRest != null && !fRest.IsReceive) { isReceive = 1; } } if (fRest != null && fRest.IsReceive) { isReceive = 2; } } return(isReceive); }
/// <summary> /// 佣兵升级属性 /// </summary> /// <param name="userID"></param> /// <param name="generalID"></param> /// <param name="abilityType"></param> /// <returns></returns> private static decimal GeneralUpGradeProperty(string userID, int generalID, AbilityType abilityType) { decimal val = 0; UserGeneral general = new GameDataCacheSet <UserGeneral>().FindKey(userID, generalID); if (general != null && general.Attribute.Count > 0) { var property = general.Attribute.Find(s => s.AbilityType == abilityType); if (property != null) { val = property.AbilityValue; } } return(val); }
/// <summary> /// 判断背包是否已满 /// </summary> /// <param name="backpackType"></param> /// <returns></returns> public static bool PackIsFull(string userId, BackpackType backpackType, int buyNum) { var _cacheSetUserPack = new GameDataCacheSet <UserPack>(); bool isFull = false; var userPack = _cacheSetUserPack.FindKey(userId); var pack = userPack != null && userPack.PackTypeList != null ? userPack.PackTypeList.Find(s => s.BackpackType == backpackType) : null; int position = pack != null ? pack.Position : 0; int num = 0; return(isFull); }
/// <summary> /// 当前类型的活动是否都已经完成 /// </summary> /// <param name="userID"></param> /// <param name="ftype"></param> /// <returns></returns> public static bool FestivalCompleted(string userID, FestivalType ftype) { var list = new ShareCacheStruct <FestivalInfo>().FindAll(s => s.FestivalType == ftype); foreach (var festival in list) { var fRest = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festival.FestivalID); if (fRest != null && fRest.IsReceive) { continue; } return(false); } return(true); }
/// <summary> /// 增加挑战次数话费晶石 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int GetChallengeNum(string userID) { int openGold = 0; UserChallengeNum challengeNum = new GameDataCacheSet <UserChallengeNum>().FindKey(userID); if (challengeNum != null && DateTime.Now.Date == challengeNum.InsertDate.Date) { openGold = (MathUtils.Addition(challengeNum.ChallengeNum, 1, int.MaxValue) * 2); } else { openGold = 2; } return(openGold); }
/// <summary> /// 替换佣兵位置 /// </summary> /// <param name="userID"></param> /// <param name="magicID"></param> /// <returns></returns> public static short ReplacePostion(string userID, int magicID) { short replacePostion = 0; UserMagic userMagic = new GameDataCacheSet <UserMagic>().FindKey(userID, magicID); if (userMagic != null) { MagicLvInfo magicLv = new ConfigCacheSet <MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv); if (magicLv != null && magicLv.ReplacePostion > 0) { replacePostion = magicLv.ReplacePostion.ToShort(); } } return(replacePostion); }
public static bool isRecevies(string userID, int packID) { bool result = false; List <PackageReceive> receivesArray = new GameDataCacheSet <PackageReceive>().FindAll(userID, m => m.PacksID == packID); foreach (PackageReceive package in receivesArray) { if (!package.IsReceive) { result = true; break; } } return(result); }
public int GetExpCodeTime(string userID) { int coldTime = 0; UserExpedition userExp = new GameDataCacheSet <UserExpedition>().FindKey(userID); if (userExp == null) { return(coldTime); } if (DateTime.Now.Date == userExp.InsertDate.Date) { coldTime = MathUtils.Addition((userExp.ExpeditionNum * 60), 20, int.MaxValue); } return(coldTime); }
public override bool TakeAction() { if (string.IsNullOrEmpty(generalCard)) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } UserGeneral userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, generalID); if (userGeneral != null) { userGeneral.GeneralCard = generalCard; } return(true); }
/// <summary> /// 法宝附加属性 /// </summary> /// <param name="trumpInfo"></param> /// <param name="abilityType"></param> /// <returns></returns> public static decimal TrumpGeneralProperty(string userID, int generalID, AbilityType abilityType) { decimal propertyNum = 0; UserTrump userTrump = new GameDataCacheSet <UserTrump>().FindKey(userID, TrumpInfo.CurrTrumpID); if (userTrump != null && userTrump.LiftNum > 0 && generalID == LanguageManager.GetLang().GameUserGeneralID&& userTrump.PropertyInfo.Count > 0) { GeneralProperty property = userTrump.PropertyInfo.Find(m => m.AbilityType == abilityType); if (property != null) { propertyNum = property.AbilityValue; } } return(propertyNum); }
private static TList <CountryUser> FilterCombatUsers(CountryLvGroup lvGroup) { var list = new TList <CountryUser>(); var removeList = new TList <CountryUser>(); while (lvGroup.PairCombatQueue.Count > 0) { CountryUser cuser = lvGroup.PairCombatQueue.Get(); if (cuser == null) { continue; } GameUser gameUser = new GameDataCacheSet <GameUser>().FindKey(cuser.UserId); if (gameUser != null && gameUser.UserStatus == UserStatus.CountryCombat) { cuser.Status = 2; list.Add(cuser); } } while (lvGroup.CombaQueue.Count > 0) { CountryUser cuser = lvGroup.CombaQueue.Get(); if (cuser == null) { continue; } if (cuser.Status == 1 && cuser.Refresh.AddSeconds(CombatInterval) <= DateTime.Now) { GameUser gameUser = new GameDataCacheSet <GameUser>().FindKey(cuser.UserId); if (gameUser != null && gameUser.UserStatus == UserStatus.CountryCombat) { cuser.Status = 2; list.Add(cuser); } } else if (cuser.Status == 1) { removeList.Add(cuser); } } foreach (var countryUser in removeList) { lvGroup.CombaQueue.Add(countryUser); } return(list); }
/**************************************************************************** * Copyright (c) 2013-2015 scutgame.com * * http://www.scutgame.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ****************************************************************************/ /// <summary> /// 是否招募突破 /// </summary> /// <param name="userID"></param> /// <param name="generalID"></param> /// <param name="recruitNum">还需多少灵魂可招募或突破</param> /// <returns></returns> public static short IsGeneralRecruit(string userID, int generalID, out int recruitNum, out int demandNum) { short isRecruit = 0; recruitNum = 0; demandNum = 0; var general = new ConfigCacheSet <GeneralInfo>().Find(s => s.SoulID == generalID); if (general != null) { demandNum = general.DemandNum; recruitNum = demandNum; var soulGeneral = new GameDataCacheSet <UserGeneral>().FindKey(userID, generalID); var userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(userID, general.GeneralID); if (soulGeneral == null) { demandNum = general.DemandNum; recruitNum = demandNum; return(isRecruit); } if (userGeneral == null) { if (soulGeneral.AtmanNum >= recruitNum) { recruitNum = 0; isRecruit = 1; } else { recruitNum = MathUtils.Subtraction(general.DemandNum, soulGeneral.AtmanNum); } } else { if (soulGeneral.AtmanNum >= recruitNum) { recruitNum = 0; isRecruit = 3; } else { recruitNum = MathUtils.Subtraction(general.DemandNum, soulGeneral.AtmanNum); isRecruit = 2; } } } return(isRecruit); }
public override bool TakeAction() { int useGold = ConfigEnvSet.GetInt("TrumpSkill.WashIngUseGold"); if (ops == 1) { ErrorCode = ops; ErrorInfo = string.Format(LanguageManager.GetLang().St1460_WashingSkills, useGold); return(false); } else if (ops == 2) { if (useGold > ContextUser.GoldNum) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1460_WashingSkillsNotEnough; return(false); } UserTrump userTrump = new GameDataCacheSet <UserTrump>().FindKey(ContextUser.UserID, TrumpInfo.CurrTrumpID); if (userTrump == null || userTrump.SkillInfo.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1466_WorshipPropertyNotEnough; return(false); } SkillInfo trumpSkill = userTrump.SkillInfo.Find(m => m.AbilityID == skillID); if (trumpSkill == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St1460_SkillsNotEnough; return(false); } AbilityInfo abilityInfo = TrumpHelper.GetRandomAbility(ContextUser.UserID); if (abilityInfo != null) { ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, useGold); trumpSkill.UpdateNotify(obj => { trumpSkill.AbilityID = abilityInfo.AbilityID; trumpSkill.AbilityLv = 1; return(true); }); ErrorCode = ops; ErrorInfo = LanguageManager.GetLang().St1460_WashingSuccess; } } return(true); }
public override bool TakeAction() { List <UserQueue> queueArray = new GameDataCacheSet <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui); if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0 && queueArray[0].IsSuspend == false) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St6006_GuildMemberNotDate; return(false); } List <UserApply> applyArray = new ShareCacheStruct <UserApply>().FindAll(m => m.UserID == ContextUser.UserID); if (applyArray.Count > 3) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St6006_ApplyMaxGuild; return(false); } UserApply apply = new ShareCacheStruct <UserApply>().FindKey(guildID, ContextUser.UserID); if (apply != null) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St6006_ApplyMember; return(false); } List <GuildMember> guildMemberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.UserID == ContextUser.UserID); if (guildMemberArray.Count > 0) { this.ErrorCode = LanguageManager.GetLang().ErrorCode; this.ErrorInfo = LanguageManager.GetLang().St6006_AlreadyMember; return(false); } UserApply userApply = new UserApply() { GuildID = guildID, UserID = ContextUser.UserID, ApplyDate = DateTime.Now }; new ShareCacheStruct <UserApply>().Add(userApply, GameEnvironment.CacheGlobalPeriod); return(true); }
public override bool TakeAction() { UserHelper.GetUserLightOpen(ContextUser.UserID); prompt = CrystalHelper.AkeyHuntingLife(ContextUser); int saleNum; CrystalHelper.SellGrayCrystal(ContextUser, null, out saleNum); DailyRestrainSet dailyRestrainSet = new ShareCacheStruct <DailyRestrainSet>().FindKey(RestrainType.MianFeiLieMing); UserDailyRestrain userRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID); if (dailyRestrainSet != null && userRestrain != null) { if (DateTime.Now.Date == userRestrain.RefreshDate.Date) { freeNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing); freeNum = MathUtils.Subtraction(freeNum, userRestrain.Funtion2, 0); } else { freeNum = VipHelper.GetVipUseNum(ContextUser.VipLv, RestrainType.MianFeiLieMing); } } userLightArray = new GameDataCacheSet <UserLight>().FindAll(ContextUser.UserID); bool allowSale; bool allowTake; grayCrystalArray = CrystalHelper.GetNotSaleCrystalNum(ContextUser, out allowSale, out allowTake); grayCrystalArray.QuickSort((x, y) => { if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } return(x.CreateDate.CompareTo(y.CreateDate)); }); isSale = allowSale ? 1 : 2; issTelegrams = allowTake ? 1 : 2; return(true); }
/// <summary> /// 七夕、端午节奖励 /// </summary> public static void DragonBoatFestival(string userID, int festivalID) { GameUser userInfo = new GameDataCacheSet <GameUser>().FindKey(userID); FestivalRestrain restrain = new GameDataCacheSet <FestivalRestrain>().FindKey(userID, festivalID); FestivalInfo festival = new ShareCacheStruct <FestivalInfo>().FindKey(festivalID); var chatService = new TjxChatService(); if (festival != null) { CacheList <PrizeInfo> rewardsArray = festival.Reward; if (NoviceHelper.IsFestivalOpen(festivalID)) { if (restrain != null && restrain.RestrainNum <= festival.RestrainNum) { restrain.RestrainNum = MathUtils.Addition(restrain.RestrainNum, 1, int.MaxValue); restrain.RefreashDate = DateTime.Now; //restrain.Update(); foreach (PrizeInfo reward in rewardsArray) { GameUserReward(userID, reward.Type, reward.ItemID, reward.Num); } if (userInfo != null && festival.FestivalExtend != null) { chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc); } } else if (restrain == null) { foreach (PrizeInfo reward in rewardsArray) { GameUserReward(userID, reward.Type, reward.ItemID, reward.Num); } if (userInfo != null && festival.FestivalExtend != null) { chatService.SystemSendWhisper(userInfo, festival.FestivalExtend.Desc); } restrain = new FestivalRestrain { UserID = userID, FestivalID = festivalID, RefreashDate = DateTime.Now, RestrainNum = 1, }; new GameDataCacheSet <FestivalRestrain>().Add(restrain); } } } }
public static GameUser CheckLoadUser(string userId) { var cacheSet = new GameDataCacheSet <GameUser>(); GameUser gameUser = cacheSet.FindKey(userId); if (gameUser == null) { //bool isAuto = true; //bool ignoreError = true; //int periodTime = GameEnvironment.CacheUserPeriod; //todo 注释掉,由底层自动加载 //GameLoadManager.Add(new GameUserDataLoader<GameUser>(isAuto, "UserID", userId.ToInt(), 1, periodTime), ignoreError); //GameLoadManager.Add(new GameUserDataLoader<UserGeneral>(isAuto, "UserID", userId.ToInt(), LoadMaxCount, periodTime), ignoreError); } return(gameUser); }
/// <summary> /// 业务逻辑处理 /// </summary> /// <returns>false:中断后面的方式执行并返回Error</returns> public override bool TakeAction() { var cacheSet = new GameDataCacheSet<GameUser>(); _user = cacheSet.FindKey(Current.UserId.ToString()); Console.WriteLine(Current.UserId); if (_user == null) return false; //GameUser _user = Current.User as GameUser; //if (_user == null) //{ // Console.WriteLine("222222"); // return false; //} return true; }
/// <summary> /// 替换佣兵位置 /// </summary> /// <param name="userID"></param> /// <param name="magicID"></param> /// <returns></returns> public static short CheckReplacePostion(string userID) { short replacePostion = 0; var magicList = new GameDataCacheSet <UserMagic>().FindAll(userID, m => m.MagicType == MagicType.MoFaZhen && m.IsEnabled); if (magicList.Count > 0) { var userMagic = magicList[0]; MagicLvInfo magicLv = new ConfigCacheSet <MagicLvInfo>().FindKey(userMagic.MagicID, userMagic.MagicLv); if (magicLv != null && magicLv.ReplacePostion > 0) { replacePostion = magicLv.ReplacePostion.ToShort(); } } return(replacePostion); }
/// <summary> /// 获取某种类型背包格子数 /// </summary> /// <param name="abilityId"></param> /// <param name="userId"></param> public static int GetPackTypePositionNum(BackpackType backpackType, string userId) { GameDataCacheSet <UserPack> _cacheSetUserPack = new GameDataCacheSet <UserPack>(); var userPack = _cacheSetUserPack.FindKey(userId); var packType = userPack != null && userPack.PackTypeList != null ? userPack.PackTypeList.Find(s => s.BackpackType == backpackType) : null; int position = 0; if (packType != null) { position = packType.Position; } return(position); }
/// <summary> /// 副本倍数掉落活动 /// </summary> /// <param name="userID"></param> /// <returns></returns> public static int DuplicateDropDouble(string userID) { int multiple = 1; FestivalInfo info = GetInfo(FestivalType.DuplicateDropDouble); if (info != null && info.FestivalExtend != null && info.FestivalExtend.MinusNum > 0) { var cacheSet = new GameDataCacheSet <FestivalRestrain>(); FestivalRestrain fRest = cacheSet.FindKey(userID, info.FestivalID); if (fRest == null || fRest.RefreashDate.Date != DateTime.Now.Date || fRest.RestrainNum < info.RestrainNum) { multiple = info.FestivalExtend.MinusNum.ToInt(); } } return(multiple); }
/// <summary> /// 创建组队 /// </summary> /// <param name="plotId"></param> /// <param name="teamId"></param> /// <returns></returns> public bool CreateTeam(int plotId, out int teamId) { teamId = GetTeamId(_userId); if (teamId != -1) { //退出组队 if (!LeaveTeam(teamId)) { return(false); } } GameUser gameUser = new GameDataCacheSet <GameUser>().FindKey(_userId); teamId = Create(gameUser, plotId); return(true); }
/// <summary> /// 传承佣兵身上是否有魂技 /// </summary> /// <param name="general"></param> /// <returns></returns> public static bool IsGeneralAbility(string userID, int generalID) { var package = new GameDataCacheSet <UserAbility>().FindKey(userID); if (package != null) { var generalInfo = new ConfigCacheSet <GeneralInfo>().FindKey(generalID); int abilityID = generalInfo == null ? 0 : generalInfo.AbilityID; var usercrystalList = package.AbilityList.FindAll(s => s.GeneralID == generalID && s.AbilityID != abilityID); if (usercrystalList.Count > 0) { return(true); } } return(false); }
private void Process(string userID, int goldNum, int type) { GameUser currentUser = new GameDataCacheSet <GameUser>().FindKey(userID); if (currentUser != null) { if (type == 0) { currentUser.GiftGold = MathUtils.Addition(currentUser.GiftGold, goldNum, int.MaxValue); } else { currentUser.ExtGold = MathUtils.Addition(currentUser.ExtGold, goldNum); } } }
public override bool TakeAction() { int chatLeng = ConfigEnvSet.GetInt("Chat.ContentLeng"); if (_content.IndexOf("<label") >= 0) { chatLeng += 150; } GameUser toUser = new GameDataCacheSet <GameUser>().FindKey(_toUserID); if (toUser == null) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9103_DoesNotExistTheUser; return(false); } if (_content.Trim().Length == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9201_contentNotEmpty; return(false); } if (_content.Length > chatLeng) { ErrorCode = LanguageManager.GetLang().ErrorCode; ErrorInfo = LanguageManager.GetLang().St9201_TheInputTextTooLong; return(false); } //if (!CacheChat.IsAllow(ContextUser)) //{ // ErrorCode = LanguageManager.GetLang().ErrorCode; // ErrorInfo = LanguageManager.GetLang().St9203_ChatNotSend; // return false; //} var chatService = new TjxChatService(ContextUser); chatService.SendWhisper(toUser, _content); UserFriends friends = new ShareCacheStruct <UserFriends>().FindKey(ContextUser.UserID, _toUserID); if (friends != null) { friends.ChatTime = DateTime.Now; //friends.Update(); } return(true); }
public override bool TakeAction() { List <UserFriends> userFriendsesArray = new ShareCacheStruct <UserFriends>().FindAll(m => m.UserID == ContextUser.UserID && m.FriendType == _friendType); userFriendsesArray.QuickSort((x, y) => { if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } //普通的玩家根据等级来排序 如果是仇敌的话需要用最后战斗时间来排序 int result = 0; if (_friendType != FriendType.ChouDi) { GameUser userx = new GameDataCacheSet <GameUser>().FindKey(x.UserID); GameUser usery = new GameDataCacheSet <GameUser>().FindKey(y.UserID); int userLvx = userx == null ? 0 : userx.UserLv; int userLvy = usery == null ? 0 : usery.UserLv; int currExperiencex = (UserGeneral.GetMainGeneral(x.UserID) ?? new UserGeneral()).CurrExperience; int currExperiencey = (UserGeneral.GetMainGeneral(y.UserID) ?? new UserGeneral()).CurrExperience; result = userLvy.CompareTo(userLvx); if (result == 0) { result = currExperiencey.CompareTo(currExperiencex); } } else { result = x.FightTime.CompareTo(y.FightTime); if (result == 0) { result = x.UserID.CompareTo(y.UserID); } } return(result); }); _userFriendList = userFriendsesArray.GetPaging(_pageIndex, _pageSize, out _pageCount); return(true); }