public override bool TakeAction() { receipt = new LotteryReceipt(); var timespan = DateTime.Now.Subtract(GetLottery.StartRestoreLotteryTimesDate); int sec = (int)Math.Floor(timespan.TotalSeconds); int canAddTimes = ConfigEnvSet.GetInt("User.LotteryTimesMax") - GetLottery.LotteryTimes; int addtimes = Math.Min(sec / RestoreLotteryTimesSec * 4, canAddTimes);// 一次恢复4次 GetLottery.LotteryTimes += addtimes; GetLottery.RemainTimeSec = RestoreLotteryTimesSec - sec % RestoreLotteryTimesSec; GetLottery.StartRestoreLotteryTimesDate = GetLottery.StartRestoreLotteryTimesDate.AddSeconds( Math.Min(sec / RestoreLotteryTimesSec, canAddTimes) * RestoreLotteryTimesSec ); UserHelper.RandomStealTarget(Current.UserId); UserHelper.RandomRobTarget(Current.UserId); receipt.Lottery = GetLottery; foreach (var v in GetLottery.StealList) { UserBasisCache basis = UserHelper.FindUserBasis(v.RivalUid); UserAttributeCache attribute = UserHelper.FindUserAttribute(v.RivalUid); UserEquipsCache equips = UserHelper.FindUserEquips(v.RivalUid); CombatMatchUserData data = new CombatMatchUserData() { UserId = basis.UserID, NickName = basis.NickName, Profession = basis.Profession, AvatarUrl = basis.AvatarUrl, RankId = basis.LevelRankID, UserLv = basis.UserLv, VipLv = basis.VipLv, FightingValue = attribute.FightValue, Equips = equips, // SkillCarryList = user.SkillCarryList }; receipt.StealList.Add(data); } return(true); }
public override bool TakeAction() { UserRank rankInfo = null; var ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey); rankInfo = UserHelper.FindRankUser(Current.UserId, RankType.Combat); if (rankInfo == null) { rankInfo = new UserRank() { UserID = Current.UserId, NickName = GetBasis.NickName, UserLv = GetBasis.UserLv, VipLv = GetBasis.VipLv, RankId = int.MaxValue, RankDate = DateTime.Now, }; ranking.TryAppend(rankInfo); rankInfo = ranking.Find(s => (s.UserID == Current.UserId)); } receipt = new CombatMatchData(); receipt.RankId = GetBasis.CombatRankID; receipt.CombatTimes = GetCombat.CombatTimes; receipt.LastFailedDate = Util.ConvertDateTimeStamp(GetCombat.LastFailedDate); //UserRank info = null; CacheList <int> MachList = new CacheList <int>(); if (rankInfo.RankId <= MaxCount) { for (int i = MaxCount; i > 0; --i) { MachList.Add(i); } } else if (rankInfo.RankId <= 30) {// 前30名去前5位 int num = 0; for (int i = rankInfo.RankId - 1; i > 0 && num < MaxCount; --i) { MachList.Add(i); num++; } } else if (rankInfo.RankId <= 100) {// 前100名去前10位 if (rankInfo.RankId <= 30 + MaxCount) { for (int i = rankInfo.RankId - 1; i > 30; --i) { MachList.Add(i); } int currcount = MachList.Count; for (int i = 30; i > 30 - (MaxCount - currcount); --i) { MachList.Add(i); } } else { int num = 0; for (int i = rankInfo.RankId - 1; i > 30 && num < 10; --i) { MachList.Add(i); num++; } } } else if (rankInfo.RankId <= 500) {// 前500名去前30位 if (rankInfo.RankId <= 100 + MaxCount) { for (int i = rankInfo.RankId - 1; i > 100; --i) { MachList.Add(i); } CacheList <int> temp = new CacheList <int>(); for (int i = 100; i > 90; --i) { temp.Add(i); } int mach; int currcount = MachList.Count; for (int i = 0; i < MaxCount - currcount; ++i) { RandMach(ref temp, out mach); MachList.Add(mach); } } else { int num = 0; for (int i = rankInfo.RankId - 1; i > 100 && num < 30; --i) { MachList.Add(i); num++; } } } else if (rankInfo.RankId <= 1000) { if (rankInfo.RankId <= 500 + MaxCount) { for (int i = rankInfo.RankId - 1; i > 500; --i) { MachList.Add(i); } CacheList <int> temp = new CacheList <int>(); for (int i = 500; i > 470; --i) { temp.Add(i); } int mach; int currcount = MachList.Count; for (int i = 0; i < MaxCount - currcount; ++i) { RandMach(ref temp, out mach); MachList.Add(mach); } } else { int num = 0; for (int i = rankInfo.RankId - 1; i > 500 && num < 100; --i) { MachList.Add(i); num++; } } } else { if (rankInfo.RankId <= 1000 + MaxCount) { for (int i = rankInfo.RankId - 1; i > 1000; --i) { MachList.Add(i); } CacheList <int> temp = new CacheList <int>(); for (int i = 1000; i > 900; --i) { temp.Add(i); } int mach; int currcount = MachList.Count; for (int i = 0; i < MaxCount - currcount; ++i) { RandMach(ref temp, out mach); MachList.Add(mach); } } else { int num = 0; for (int i = rankInfo.RankId - 1; i > 1000 && num < 200; --i) { MachList.Add(i); num++; } } } int mach_tops; for (int i = 0; MachList.Count > 0 && i < MaxCount; ++i) { RandMach(ref MachList, out mach_tops); int rankID = 0; UserRank machinfo = null; if (ranking.TryGetRankNo(m => (m.RankId == mach_tops), out rankID)) { machinfo = ranking.Find(s => (s.RankId == mach_tops)); } if (machinfo != null) { UserAttributeCache attribute = UserHelper.FindUserAttribute(machinfo.UserID); UserEquipsCache equips = UserHelper.FindUserEquips(machinfo.UserID); CombatMatchUserData data = new CombatMatchUserData() { UserId = machinfo.UserID, NickName = machinfo.NickName, Profession = machinfo.Profession, AvatarUrl = machinfo.AvatarUrl, RankId = machinfo.RankId, UserLv = machinfo.UserLv, VipLv = machinfo.VipLv, FightingValue = attribute.FightValue, Equips = equips, // SkillCarryList = user.SkillCarryList }; receipt.RivalList.Add(data); } } // 日志 //foreach (CombatLogData data in GetCombat.LogList) //{ // UserRank info = null; // if (ranking.TryGetRankNo(m => (m.UserID == data.UserId), out rankID)) // { // info = ranking.Find(s => (s.UserID == data.UserId)); // } // JPCombatLogData cld = new JPCombatLogData(); // cld.UserId = data.UserId; // if (info != null) // cld.RivalCurrRankId = info.RankId; // cld.Type = data.Type; // cld.FightResult = data.Status; // cld.Log = UserHelper.FormatCombatLog(data); // receipt.LogList.Add(cld); //} return(true); }
public static UserBasisCache CreateRole(int _UserId, string _Sid, int _ServerID, string _Pid, string _RetailID, string _UserName, int _profession, string _HeadID) { // Basis初始化 UserBasisCache basis = new UserBasisCache(_UserId); basis.IsRefreshing = true; basis.SessionID = _Sid; basis.ServerID = _ServerID; basis.Pid = _Pid; basis.RetailID = _RetailID; basis.NickName = _UserName; basis.UserLv = (short)ConfigEnvSet.GetInt("User.Level"); basis.RewardsDiamond = ConfigEnvSet.GetInt("User.InitDiamond"); //bisis.Vit = DataHelper.InitVit; basis.VipLv = ConfigEnvSet.GetInt("User.VipLv"); basis.Profession = _profession; basis.AvatarUrl = _HeadID; basis.UserStatus = UserStatus.MainUi; basis.LoginDate = DateTime.Now; basis.CreateDate = DateTime.Now; basis.OfflineDate = DateTime.Now; basis.Gold = ConfigEnvSet.GetString("User.InitGold"); basis.OfflineEarnings = "0"; var cacheSet = new PersonalCacheStruct <UserBasisCache>(); cacheSet.Add(basis); cacheSet.Update(); // 属性初始化 UserAttributeCache attcache = new UserAttributeCache(); attcache.UserID = basis.UserID; var attributeSet = new PersonalCacheStruct <UserAttributeCache>(); attributeSet.Add(attcache); attributeSet.Update(); // 装备初始化 UserEquipsCache equipcache = new UserEquipsCache(); equipcache.UserID = basis.UserID; equipcache.ResetCache(); var equipsSet = new PersonalCacheStruct <UserEquipsCache>(); equipsSet.Add(equipcache); equipsSet.Update(); // 背包初始化 UserPackageCache packagecache = new UserPackageCache(); packagecache.UserID = basis.UserID; packagecache.ResetCache(); var packageSet = new PersonalCacheStruct <UserPackageCache>(); packagecache.AddItem(20001, 1); packagecache.AddItem(20012, 1); packagecache.AddItem(20023, 1); packagecache.AddItem(20034, 1); packagecache.AddItem(20045, 1); packagecache.AddItem(20056, 1); packagecache.AddItem(20067, 1); //for (int i = 20001; i < 20077; ++i) // packagecache.AddItem(i, 10); //for (int i = 30001; i < 30005; ++i) // packagecache.AddItem(i, 9999); //for (int i = 40001; i < 40009; ++i) // packagecache.AddItem(i, 1); packageSet.Add(packagecache); packageSet.Update(); // 战魂初始化 UserSoulCache soulcache = new UserSoulCache(); soulcache.UserID = basis.UserID; soulcache.ResetCache(); var soulSet = new PersonalCacheStruct <UserSoulCache>(); soulSet.Add(soulcache); soulSet.Update(); // 技能初始化 UserSkillCache skillcache = new UserSkillCache(); skillcache.UserID = basis.UserID; skillcache.ResetCache(_profession); var skillSet = new PersonalCacheStruct <UserSkillCache>(); skillSet.Add(skillcache); skillSet.Update(); // 好友初始化 UserFriendsCache friendscache = new UserFriendsCache(); friendscache.UserID = basis.UserID; friendscache.ResetCache(); var friendsSet = new PersonalCacheStruct <UserFriendsCache>(); friendsSet.Add(friendscache); friendsSet.Update(); // 成就初始化 UserAchievementCache achievecache = new UserAchievementCache(); achievecache.UserID = basis.UserID; achievecache.ResetCache(); var achieveSet = new PersonalCacheStruct <UserAchievementCache>(); achieveSet.Add(achievecache); achieveSet.Update(); // 充值初始化 UserPayCache paycache = new UserPayCache(); paycache.UserID = basis.UserID; paycache.ResetCache(); var paySet = new PersonalCacheStruct <UserPayCache>(); paySet.Add(paycache); paySet.Update(); // 邮箱初始化 UserMailBoxCache mailcache = new UserMailBoxCache(); mailcache.UserID = basis.UserID; mailcache.ResetCache(); var mailSet = new PersonalCacheStruct <UserMailBoxCache>(); MailData mail = new MailData() { ID = Guid.NewGuid().ToString(), Title = "恭喜您已获得月卡免费体验资格", Sender = "系统", Date = DateTime.Now, Context = "恭喜您已获得月卡免费体验资格,月卡有效期为1天,为了您能获得更好的游戏体验,您可以在充值页面续费成为我们正式的月卡用户!", }; UserHelper.AddNewMail(basis.UserID, mail, false); mailSet.Add(mailcache); mailSet.Update(); // 任务初始化 UserTaskCache taskcache = new UserTaskCache(); taskcache.UserID = basis.UserID; taskcache.ResetCache(); var taskSet = new PersonalCacheStruct <UserTaskCache>(); taskSet.Add(taskcache); taskSet.Update(); // 竞技场初始化 UserCombatCache combatcache = new UserCombatCache(); combatcache.UserID = basis.UserID; combatcache.ResetCache(); var combatSet = new PersonalCacheStruct <UserCombatCache>(); combatSet.Add(combatcache); combatSet.Update(); // 活动相关初始化 UserEventAwardCache eventawardcache = new UserEventAwardCache(); eventawardcache.UserID = basis.UserID; eventawardcache.ResetCache(); var eventAwardSet = new PersonalCacheStruct <UserEventAwardCache>(); eventAwardSet.Add(eventawardcache); eventAwardSet.Update(); // 公会初始化 UserGuildCache guildcache = new UserGuildCache(); guildcache.UserID = basis.UserID; guildcache.ResetCache(); var guildSet = new PersonalCacheStruct <UserGuildCache>(); guildSet.Add(guildcache); guildSet.Update(); // 精灵初始化 UserElfCache elfcache = new UserElfCache(); elfcache.UserID = basis.UserID; elfcache.ResetCache(); var elfSet = new PersonalCacheStruct <UserElfCache>(); elfSet.Add(elfcache); elfSet.Update(); // 赠送物品初始化 UserTransferItemCache transfercache = new UserTransferItemCache(); transfercache.UserID = basis.UserID; transfercache.ResetCache(); var transferSet = new PersonalCacheStruct <UserTransferItemCache>(); transferSet.Add(transfercache); transferSet.Update(); // 仇人数据初始化 UserEnemysCache enemy = new UserEnemysCache(); enemy.UserID = basis.UserID; enemy.ResetCache(); var enemySet = new PersonalCacheStruct <UserEnemysCache>(); enemySet.Add(enemy); enemySet.Update(); // 抽奖数据初始化 UserLotteryCache lottery = new UserLotteryCache(); lottery.UserID = basis.UserID; lottery.ResetCache(); var lotterySet = new PersonalCacheStruct <UserLotteryCache>(); lotterySet.Add(lottery); lotterySet.Update(); UserHelper.RefreshUserFightValue(basis.UserID, false); // 排行榜初始化 UserRank combatRank = new UserRank() { UserID = basis.UserID, NickName = basis.NickName, Profession = basis.Profession, UserLv = basis.UserLv, AvatarUrl = basis.AvatarUrl, VipLv = basis.VipLv, FightValue = attcache.FightValue, RankId = int.MaxValue, RankDate = DateTime.Now, }; Ranking <UserRank> combatranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey); var combat = combatranking as CombatRanking; combat.TryAppend(combatRank); combat.rankList.Add(combatRank); UserRank levelRank = new UserRank(combatRank); Ranking <UserRank> levelranking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey); var level = levelranking as LevelRanking; level.TryAppend(levelRank); level.rankList.Add(levelRank); UserRank fightRank = new UserRank(combatRank); Ranking <UserRank> fightranking = RankingFactory.Get <UserRank>(FightValueRanking.RankingKey); var fight = fightranking as FightValueRanking; fight.TryAppend(fightRank); fight.rankList.Add(fightRank); UserRank comboRank = new UserRank(combatRank); Ranking <UserRank> comboranking = RankingFactory.Get <UserRank>(ComboRanking.RankingKey); var combo = comboranking as ComboRanking; combo.TryAppend(comboRank); combo.rankList.Add(comboRank); UserHelper.RestoreUserData(basis.UserID); UserHelper.EveryDayTaskProcess(basis.UserID, TaskType.Login, 1, false); //UserHelper.AddMouthCardMail(basis.UserID); return(basis); }
public override bool TakeAction() { receipt = new StealReceipt(); receipt.Result = false; if (GetLottery.StealTimes <= 0 || selectIndex >= 3) { return(true); } StealRobTarget target = GetLottery.StealList[selectIndex]; var rival = UserHelper.FindUserBasis(target.RivalUid); if (rival == null) { return(true); } var rivalEnemy = UserHelper.FindUserEnemy(rival.UserID); if (rivalEnemy == null) { return(true); } GetLottery.StealTimes--; receipt.Gold = target.Gold; UserHelper.RewardsGold(Current.UserId, target.Gold); BigInteger dummyGold = BigInteger.Parse(target.Gold); BigInteger realGold = rival.GoldNum <= dummyGold * 2 ? rival.GoldNum / 2 : dummyGold; UserHelper.ConsumeGold(rival.UserID, realGold); rivalEnemy.AddEnemy(new EnemyData() { UserId = Current.UserId }); EnemyLogData log = new EnemyLogData() { RivalUid = Current.UserId, RivalName = GetBasis.NickName, RivalAvatarUrl = GetBasis.AvatarUrl, LogTime = DateTime.Now, LossGold = realGold.ToString(), IsSteal = true, RivalProfession = GetBasis.Profession }; rivalEnemy.PushLog(log); PushMessageHelper.NewStealRobNotification(GameSession.Get(rival.UserID)); if (target.IsPrimary) { GetLottery.StealList.Clear(); UserHelper.RandomStealTarget(Current.UserId); } else { UserHelper.RandomStealTarget2(Current.UserId); } foreach (var v in GetLottery.StealList) { UserBasisCache basis = UserHelper.FindUserBasis(v.RivalUid); UserAttributeCache attribute = UserHelper.FindUserAttribute(v.RivalUid); UserEquipsCache equips = UserHelper.FindUserEquips(v.RivalUid); CombatMatchUserData data = new CombatMatchUserData() { UserId = basis.UserID, NickName = basis.NickName, Profession = basis.Profession, AvatarUrl = basis.AvatarUrl, RankId = basis.LevelRankID, UserLv = basis.UserLv, VipLv = basis.VipLv, FightingValue = attribute.FightValue, Equips = equips, // SkillCarryList = user.SkillCarryList }; receipt.StealList.Add(data); } receipt.Lottery = GetLottery; receipt.Result = true; return(true); }