public override bool TakeAction() { var elf = GetElf.FindElf(elfId); if (elf == null) { return(false); } var elfSet = new ShareCacheStruct <Config_Elves>(); var elfcfg = elfSet.Find(t => (t.ElvesID == elf.ID && t.ElvesGrade == elf.Lv)); if (elfcfg == null) { return(false); } var elfNextCfg = elfSet.Find(t => (t.ElvesID == elf.ID && t.ElvesGrade == elf.Lv + 1)); if (elfNextCfg == null) { return(false); } BigInteger consumeNumber = BigInteger.Parse(elfNextCfg.GradeConsume); if (GetBasis.GoldNum < consumeNumber) { return(false); } else { UserHelper.ConsumeGold(Current.UserId, consumeNumber); } elf.Lv = elfNextCfg.ElvesGrade; if (GetElf.SelectID == elfId) { GetElf.SelectElfType = elfNextCfg.ElvesType; GetElf.SelectElfValue = elfNextCfg.ElvesNum; } UserHelper.RefreshUserFightValue(Current.UserId); // 每日 UserHelper.EveryDayTaskProcess(Current.UserId, TaskType.UpgradeElf, 1); // 成就 UserHelper.AchievementProcess(Current.UserId, AchievementType.UpgradeElf); receipt = true; return(true); }
/// <summary> /// 连接服准备关闭 /// </summary> static public void OnCloseCSBefore(GameSession session) { var serverInfo = sConnectServerSet.Find(m => m.CSSid == session.SessionId); if (serverInfo != null) { Console.WriteLine("连接服准备关闭,ServerId:{0}", serverInfo.ServerId); serverInfo.Status = ServerStatus.Closeing; } }
public override bool TakeAction() { var cache = new ShareCacheStruct<UserRanking>(); var ranking = cache.Find(m => m.UserName == UserName); if (ranking == null) { var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = UserName}; new PersonalCacheStruct<GameUser>().Add(user); ranking = new UserRanking(); ranking.UserID = user.UserId; ranking.UserName = UserName; ranking.Score = Score; if (!cache.Add(ranking)) { ErrorCode = Language.Instance.ErrorCode; ErrorInfo = string.Format("add fail, UserID {0} is exist.", ranking.UserID); return false; } } else { ranking.UserName = UserName; ranking.Score = Score; } return true; }
void doAdd_finishOrder(string parm) { string [] theParms = parm.Split(','); string orderId = theParms[0]; string typeUser = theParms[1]; var payCache = new ShareCacheStruct <PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) { return(true); } return(false); }); if (null == payData) { ConsoleLog.showErrorInfo(0, "error doAdd_finishOrder:" + orderId); } payData.ModifyLocked(() => { payData.state = PayOrder.PayStatus.paySuccess; payData.process = true; payData.typeUser = typeUser; payData.hasGetPayReward = true; }); addProductOnServer(payData); }
public override bool TakeAction() { var cache = new ShareCacheStruct <UserRanking>(); var ranking = cache.Find(m => m.UserName == requestPack.UserName); if (ranking == null) { var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = requestPack.UserName }; new PersonalCacheStruct <GameUser>().Add(user); ranking = new UserRanking(); ranking.UserID = user.UserId; ranking.UserName = requestPack.UserName; ranking.Score = requestPack.Score; cache.Add(ranking); } else { ranking.UserName = requestPack.UserName; ranking.Score = requestPack.Score; } return(true); }
void doCheck_order() { string orderId = requestPack.infoExt; var payCache = new ShareCacheStruct <PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) { return(true); } return(false); }); if (payData == null) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find; return; } if (payData.hasGetPayReward) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.hasGetPayReward; return; } string productId = payData.ProductId; responsePack.extInfo = GameConfigMgr.Instance().getProductInfo(productId, orderId); // add 道具发放信息。 responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok; }
public override bool TakeAction() { var achievement = GetAchievement.AchievementList.Find(t => (t.ID == id)); var config = new ShareCacheStruct <Config_Achievement>().FindKey(id); if (achievement == null || config == null || achievement.ID == 0 || achievement.Status != TaskStatus.Finished) { return(false); } type = achievement.Type; switch (config.RewardsType) { case TaskAwardType.Gold: { BigInteger bi = BigInteger.Parse(config.RewardsItemNum); UserHelper.RewardsGold(Current.UserId, bi); } break; case TaskAwardType.Diamond: { UserHelper.RewardsDiamond(Current.UserId, Convert.ToInt32(config.RewardsItemNum)); } break; case TaskAwardType.Item: { UserHelper.RewardsItem(Current.UserId, config.RewardsItemID, Convert.ToInt32(config.RewardsItemNum)); } break; } // 新成就 var stock = new ShareCacheStruct <Config_Achievement>().FindAll(t => (t.AchievementType == achievement.Type)); var select = stock.Find(t => (t.id > achievement.ID)); if (select != null) { achievement.ID = select.id; achievement.Status = TaskStatus.No; } else { achievement.Status = TaskStatus.Received; } //achievement.Count = 0; if (type == AchievementType.Gem) { achievement.Count = "0"; } //else if (type == AchievementType.OpenSoul) // achievement.Count = "0"; receipt = achievement; return(true); }
public override bool TakeAction() { var purlist = new ShareCacheStruct <Config_Purchase>().FindAll(); var pur = purlist.Find(t => t.id == GetPay.BuyVitTimes + 1); if (pur == null) { pur = purlist[purlist.Count - 1]; } if (/*vip == null || */ pur == null) { return(false); } //int canBuyTimes = vip.BuyStamina; //if (GetPay.BuyVitTimes >= canBuyTimes) //{ // return true; //} int needDiamond = pur.SpendDiamond; if (GetBasis.DiamondNum < needDiamond) { return(true); } UserHelper.ConsumeDiamond(Current.UserId, needDiamond); UserHelper.RewardsVit(Current.UserId, pur.Stamina); GetPay.BuyVitTimes++; receipt = true; return(true); }
private int getID() { var cache = new ShareCacheStruct <ServerInfoMode>(); var info = cache.Find((o) => { if (o.userd == false && o.type == serverType) { return(true); } return(false); }); int id = -1; if (info != null) { info.ModifyLocked(() => { if (info.userd == false) { id = info.id; info.userd = true; } }); } return(id < 0 ? (int)cache.GetNextNo() : id); }
public override bool TakeAction() { var cache = new ShareCacheStruct <UserRanking>(); var ranking = cache.Find(m => m.UserName == UserName); if (ranking == null) { var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = UserName }; new PersonalCacheStruct <GameUser>().Add(user); ranking = new UserRanking(); ranking.UserID = user.UserId; ranking.UserName = UserName; ranking.Score = Score; if (!cache.Add(ranking)) { ErrorCode = Language.Instance.ErrorCode; ErrorInfo = string.Format("add fail, UserID {0} is exist.", ranking.UserID); return(false); } } else { ranking.UserName = UserName; ranking.Score = Score; } return(true); }
private bool FindUser(out User user, out ShareCacheStruct <User> userCache) { userCache = new ShareCacheStruct <User>(); user = userCache.Find(u => u.Username == _loginData.Username); //@TODO //Authentication return(user != null); }
public void ResetCache() { ElfList.Clear(); SelectElfType = ElfSkillType.None; SelectElfValue = 0; var elvesSet = new ShareCacheStruct <Config_Elves>(); var first = elvesSet.Find(t => (t.ElvesGrade == 1)); AddElf(first.ElvesID, false, 0); }
/// <summary> /// 增加仇敌 /// </summary> /// <param name="user"></param> /// <param name="toUser"></param> private static void AddFoe(GameUser user, GameUser toUser) { var cacheSet = new ShareCacheStruct <UserFriends>(); var friends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.Friend); var choudiFriends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi); if (friends == null && choudiFriends == null) { var list = cacheSet.FindAll(s => s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi); if (list.Count >= 50) { list.QuickSort((x, y) => { if (x == null && y == null) { return(0); } if (x != null && y == null) { return(1); } if (x == null) { return(-1); } return((x.FightTime).CompareTo(y.FightTime)); }); int count = list.Count - 49 + 1; for (int i = 0; i < count; i++) { cacheSet.Delete(list[i]); } } var userFriends = new UserFriends(); userFriends.UserID = toUser.UserID; userFriends.FriendID = user.UserID; userFriends.FightTime = DateTime.Now; userFriends.FriendType = FriendType.ChouDi; userFriends.ChatTime = DateTime.Now; cacheSet.Add(userFriends); } }
public static tb_Notice GetLastNotice() { var notice = new tb_Notice(); var cacheSettable = new ShareCacheStruct <tb_Notice>(); cacheSettable.ReLoad(); notice = cacheSettable.Find(w => w.isStart == 1); if (notice == null) { SchemaTable schema = EntitySchemaSet.Get <tb_Notice>(); DbBaseProvider provider = DbConnectionProvider.CreateDbProvider(schema); DbDataFilter filter = new DbDataFilter(0); filter.Condition = provider.FormatFilterParam("isStart"); filter.Parameters.Add("isStart", 1); cacheSettable.TryRecoverFromDb(filter);//从数据库中恢复数据 notice = cacheSettable.Find(w => w.isStart == 1); } return(notice); }
bool authoriyCheck() { var cache = new ShareCacheStruct <Authority>(); var auth = cache.Find((o) => { return(o.name == requestPack.name && o.pwd == requestPack.pwd); }); if (null == auth) { return(false); } return(0 != (auth.level & getCmdLevel(requestPack.param))); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////其它/////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// 其它服断开处理 /// </summary> /// <param name="session"></param> public static void OnOtherServerDisconnected(GameSession session) { string serverSid = session.SessionId; do { var serverInfo = sConnectServerSet.Find(m => m.CSSid == serverSid); if (serverInfo != null) { Console.WriteLine("连接服断开连接,ServerId:{0},剩余:{1}", serverInfo.ServerId, sConnectServerSet.FindAll(false).Count - 1); sConnectServerSet.Delete(serverInfo); break; } if (ServerSsMgr.GetLobbySession() != null && ServerSsMgr.GetLobbySession().SessionId == session.SessionId) { Console.WriteLine("大厅服断开连接"); ServerSsMgr.SetLobbySession(null); break; } if (session.UserId == GlobalDefine.ServerIdType.SocialId.ToInt()) { Console.WriteLine("社交服断开连接"); SocialHelper.SocialSession = null; break; } if (session.UserId == GlobalDefine.ServerIdType.SuperMonreyId.ToInt()) { Console.WriteLine("拉霸机服断开连接"); SuperMonreyHelper.SuperMonreySession = null; break; } if (session.UserId == GlobalDefine.ServerIdType.WabaoziId.ToInt()) { Console.WriteLine("挖豹子服断开连接"); WbzServerHelper.WabaoziSession = null; break; } var rsInfo = sRoomServerSet.Find(m => m.RSSid == serverSid); if (rsInfo != null) { Console.WriteLine("房间服断开连接,ServerId:{0},剩余:{1}", rsInfo.ServerId, sRoomServerSet.FindAll(false).Count - 1); sRoomServerSet.Delete(rsInfo); break; } } while (false); // ServerSsMgr.DelSession(session); }
int checkBlack() { //01 blacklist var blackCache = new ShareCacheStruct <BlackListData>(); BlackListData blackD = blackCache.Find((o) => { return(o.Identify == requestPack.Identify); }); if (null != blackD) { return((int)ErrorCodeEx.DataCheck_BlackList); } return((int)ErrorCodeEx.None); }
public override bool TakeAction() { var cache = new ShareCacheStruct<UserRanking>(); var ranking = cache.Find(m => m.UserName == userName); if (ranking == null) { var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = userName }; new PersonalCacheStruct<GameUser>().Add(user); ranking = new UserRanking(); ranking.UserId = user.UserId; ranking.UserName = userName; ranking.Score = score; cache.Add(ranking); } else { ranking.UserName = userName; ranking.Score = score; } return true; }
/// 获得灵魂 /// </summary> /// <param name="userId"></param> /// <param name="itemId"></param> /// <param name="num"></param> public static void AddGeneralSoul(string userId, int itemId, int num) { var cacheSetGeneral = new PersonalCacheStruct <UserGeneral>(); var cacheSetGeneralInfo = new ShareCacheStruct <GeneralInfo>(); var generalInfo = cacheSetGeneralInfo.Find(s => s.SoulID == itemId); var userGeneral = cacheSetGeneral.FindKey(userId, itemId); if (userGeneral != null && generalInfo != null) { userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, num).ToShort(); } else { if (generalInfo != null) { userGeneral = new UserGeneral(); userGeneral.UserID = userId; userGeneral.GeneralID = itemId; userGeneral.AtmanNum = num; userGeneral.GeneralName = generalInfo.GeneralName; userGeneral.HeadID = generalInfo.HeadID; userGeneral.PicturesID = generalInfo.PicturesID; userGeneral.GeneralLv = generalInfo.GeneralLv; userGeneral.LifeNum = generalInfo.LifeNum; userGeneral.GeneralType = generalInfo.GeneralType; userGeneral.CareerID = generalInfo.CareerID; userGeneral.PowerNum = generalInfo.PowerNum; userGeneral.SoulNum = generalInfo.SoulNum; userGeneral.IntellectNum = generalInfo.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.AbilityID = generalInfo.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = generalInfo.Description; userGeneral.AddGeneralStatus(2); userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; userGeneral.AbilityNum = 3; cacheSetGeneral.Add(userGeneral); } } }
bool processCache(string orderId, bool bSuccess, string jrRet, bool hasGet) { // cache order var payCache = new ShareCacheStruct <PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) { return(true); } return(false); }); if (null == payData) { //ConsoleLog.showErrorInfo(0, "PayLog not find order:" + orderId); TraceLog.WriteError("PayLog not find order:" + orderId); return(false); } PayOrder.PayStatus payStatus = PayOrder.PayStatus.payFailed; if (bSuccess) { payStatus = PayOrder.PayStatus.paySuccess; } if (false == payData.process) { payData.ModifyLocked(() => { payData.userParms = urlParams; // save .. payData.the3rdOrderId = order_id; // dic["order_id"]; payData.state = payStatus; payData.process = true; payData.typeUser = jrRet; payData.hasGetPayReward = hasGet; }); } //ConsoleLog.showNotifyInfo("process HttpPost:" + jrRet); //TraceLog.ReleaseWrite("process HttpPost:" + jrRet); return(true); }
public override bool TakeAction() { var cache = new ShareCacheStruct<UserRanking>(); var ranking = cache.Find(m => m.UserName == UserName); if (ranking == null) { ranking = new UserRanking(); ranking.UserID = (int)cache.GetNextNo(); ranking.UserName = UserName; ranking.Score = Score; cache.Add(ranking); } else { ranking.UserName = UserName; ranking.Score = Score; } return true; }
public override bool TakeAction() { var cache = new ShareCacheStruct <UserRanking>(); var ranking = cache.Find(m => m.UserName == UserName); if (ranking == null) { ranking = new UserRanking(); ranking.UserID = (int)cache.GetNextNo(); ranking.UserName = UserName; ranking.Score = Score; cache.Add(ranking); } else { ranking.UserName = UserName; ranking.Score = Score; } return(true); }
public override bool TakeAction() { var cache = new ShareCacheStruct<UserScore>(); var ranking = cache.Find(m => m.username == _username); if (ranking == null) { var user = new User() { userid = (int)cache.GetNextNo(), nickname = _username }; new PersonalCacheStruct<User>().Add(user); ranking = new UserScore(); ranking.userid = user.userid; ranking.username = _username; ranking.score = _score; cache.Add(ranking); } else { ranking.username = _username; ranking.score = _score; } return true; }
public override bool TakeAction() { //var vip = new ShareCacheStruct<Config_Vip>().FindKey(GetBasis.VipLv); var purlist = new ShareCacheStruct <Config_Purchase>().FindAll(); var pur = purlist.Find(t => t.id == GetPay.BuyGoldTimes + 1); if (pur == null) { pur = purlist[purlist.Count - 1]; } if (/*vip == null || */ pur == null) { return(false); } //int canBuyTimes = vip.BuyStamina; //if (GetPay.BuyGoldTimes >= canBuyTimes) //{ // return true; //} int needDiamond = pur.SpendDiamond; if (GetBasis.DiamondNum < needDiamond) { return(true); } BigInteger gold = BigInteger.Parse(pur.Gold); BigInteger value = Math.Ceiling(GetBasis.UserLv / 50.0).ToInt() * gold; UserHelper.ConsumeDiamond(Current.UserId, needDiamond); UserHelper.RewardsGold(Current.UserId, value); GetPay.BuyGoldTimes++; // 每日 UserHelper.EveryDayTaskProcess(Current.UserId, TaskType.BuyGold, 1); receipt = true; return(true); }
void doAdd_order(string parm) { string[] strS = parm.Split(','); string ordderId = strS[0]; int stat = int.Parse(strS[1]); var cache = new ShareCacheStruct <PayOrder>(); PayOrder payData = cache.Find((o) => { return(o.ServerOrderId == ordderId); }); if (payData == null) { ConsoleLog.showErrorInfo(0, "doAdd_order:" + ordderId); return; } payData.ModifyLocked(() => { ConsoleLog.showNotifyInfo(string.Format("payData state change {0}=>{1}", payData.state, stat)); payData.state = (PayOrder.PayStatus)stat; }); }
public void ResetCache() { Liveness = 0; DailyQuestList.Clear(); ReceiveBoxList.Clear(); var taskSet = new ShareCacheStruct <Config_Task>(); for (TaskType type = TaskType.Login; type <= TaskType.BuyGold; ++type) { var taskcfg = taskSet.Find(t => (t.id == type)); if (taskcfg == null) { continue; } var dailyQuest = new UserDailyQuestData(); dailyQuest.ID = type; dailyQuest.Count = 0; dailyQuest.Status = TaskStatus.No; DailyQuestList.Add(dailyQuest); } }
void doEnd_order() { string orderId = requestPack.infoExt; var payCache = new ShareCacheStruct <PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) { return(true); } return(false); }); if (payData == null) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find; } payData.ModifyLocked(() => { payData.hasGetPayReward = true; }); responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok; }
/// <summary> /// 增加仇敌 /// </summary> /// <param name="user"></param> /// <param name="toUser"></param> private static void AddFoe(GameUser user, GameUser toUser) { var cacheSet = new ShareCacheStruct<UserFriends>(); var friends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.Friend); var choudiFriends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi); if (friends == null && choudiFriends == null) { var list = cacheSet.FindAll(s => s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi); if (list.Count >= 50) { list.QuickSort((x, y) => { if (x == null && y == null) return 0; if (x != null && y == null) return 1; if (x == null) return -1; return (x.FightTime).CompareTo(y.FightTime); }); int count = list.Count - 49 + 1; for (int i = 0; i < count; i++) { cacheSet.Delete(list[i]); } } var userFriends = new UserFriends(); userFriends.UserID = toUser.UserID; userFriends.FriendID = user.UserID; userFriends.FightTime = DateTime.Now; userFriends.FriendType = FriendType.ChouDi; userFriends.ChatTime = DateTime.Now; cacheSet.Add(userFriends, GameEnvironment.CacheGlobalPeriod); } }
int checkBlack() { //01 blacklist var blackCache = new ShareCacheStruct<BlackListData>(); BlackListData blackD = blackCache.Find((o) => { return (o.Identify == requestPack.Identify); }); if (null != blackD) return (int)ErrorCodeEx.DataCheck_BlackList; return (int)ErrorCodeEx.None; }
public override bool TakeAction() { var skillSet = new ShareCacheStruct <Config_Skill>(); var skillGradeSet = new ShareCacheStruct <Config_SkillGrade>(); var skillcfg = skillSet.FindKey(skillId); if (skillcfg == null) { return(false); } var skill = GetSkill.SkillList.Find(t => t.ID == skillId); if (skill == null) { return(false); } var skillGradeCfg = skillGradeSet.Find(t => (t.SkillId == skillId && t.SkillGrade == skill.Lv + 1)); if (skillGradeCfg == null) { return(false); } switch (skillGradeCfg.ConsumeType) { case CoinType.Gold: { BigInteger consumeNumber = BigInteger.Parse(skillGradeCfg.ConsumeNumber); if (GetBasis.GoldNum < consumeNumber) { return(false); } else { UserHelper.ConsumeGold(Current.UserId, consumeNumber); } } break; case CoinType.Diamond: { if (GetBasis.DiamondNum < Convert.ToInt32(skillGradeCfg.ConsumeNumber)) { return(false); } else { UserHelper.ConsumeDiamond(Current.UserId, Convert.ToInt32(skillGradeCfg.ConsumeNumber)); } } break; } skill.Lv = skillGradeCfg.SkillGrade; // 每日 UserHelper.EveryDayTaskProcess(Current.UserId, TaskType.UpgradeSkill, 1); // 成就 UserHelper.AchievementProcess(Current.UserId, AchievementType.UpgradeSkill); receipt = true; return(true); }
public override bool TakeAction() { short currMaxLv = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort(); //NoviceHelper.CheckFestival(ContextUser); NoviceHelper.GetFunctionEnum(Uid); //默认开启金币,精力大作战功能 if (!string.IsNullOrEmpty(ContextUser.MercenariesID)) { UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID); } PaymentService.Trigger(ContextUser); if (ContextUser.UserLv > currMaxLv) { genlv = currMaxLv; } else { genlv = ContextUser.UserLv; } var cacheSetGeneralEscalate = new ShareCacheStruct<GeneralEscalateInfo>(); GeneralEscalateHelper.AddUserLv(ContextUser, 0); _honourNum = ContextUser.HonourNum; int lv = ContextUser.UserLv; lv = lv < 0 ? 1 : lv + 1; var generalEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv); if (generalEscalate != null) { _nextHonourNum = generalEscalate.UpExperience; } guildID = ContextUser.MercenariesID; var userGeneralList = new PersonalCacheStruct<UserGeneral>().FindAll(ContextUser.UserID); if (userGeneralList.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; return false; } userGeneralInfo = userGeneralList[0]; //UserGeneral.GetMainGeneral(ContextUser.UserID); if (userGeneralInfo != null) { //wuzf 去掉刷新血量,其它改变血量接口有触发刷新 //userGeneralInfo.RefreshMaxLife(); generalID = userGeneralInfo.GeneralID; //careerInfo = new ShareCacheStruct<CareerInfo>().FindKey(userGeneralInfo.CareerID); headID = userGeneralInfo.HeadID; //ContextUser.Sex ? careerInfo.HeadID2 : careerInfo.HeadID; escalateInfo = new ShareCacheStruct<GeneralEscalateInfo>().FindKey(genlv); lifeNum = userGeneralInfo.LifeNum; careerID = userGeneralInfo.CareerID; } lifeMaxNum = UserHelper.GetMaxLife(ContextUser.UserID, generalID); maxEnergyNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); sex = ContextUser.Sex ? 1 : 0; //道具图标 _blessingList = UserHelper.BlessingInfoList(ContextUser); //变身卡图标 List<UserProps> userPropsList = new PersonalCacheStruct<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003); if (userPropsList.Count > 0) { UserProps props = userPropsList[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { pictureID = itemInfo.PictrueID; pictureTime = pTime; } } //兼容客户端上已版本血量图标 List<UserProps> userPropsList2 = new PersonalCacheStruct<UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1); if (userPropsList2.Count > 0) { UserProps props = userPropsList2[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { _itemLiveNum = props.SurplusNum; _itemLiveMaxNum = itemInfo.EffectNum; } } //加量,领土战不能加血wuzf) if (ContextUser.UserStatus != UserStatus.CountryCombat) { UserHelper.GetGeneralLife(ContextUser.UserID); } //精力恢复 List<UserQueue> energyQueueArray = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EnergyHuiFu); if (energyQueueArray.Count > 0) { UserQueue energyQueue = energyQueueArray[0]; short energyMaxNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); int restorationDate = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationDate"); //半小时 int restorationNum = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationNum"); //恢复5点 if (energyQueue.Timing > DateTime.Now) { energyQueue.Timing = DateTime.Now; } //原因:玩家满精力时,精力恢复累加 int timeCount = (int)(DateTime.Now - energyQueue.Timing).TotalSeconds / restorationDate; if (timeCount > 0) { short energyNum = (short)(timeCount * restorationNum); if (ContextUser.EnergyNum < energyMaxNum) { ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, energyNum, energyMaxNum); } energyQueue.Timing = DateTime.Now; } else { if (energyMaxNum > ContextUser.EnergyNum) { rstore = (int)(energyQueue.Timing.AddSeconds(restorationDate) - DateTime.Now).TotalSeconds; totalRstore = (energyQueue.Timing.AddSeconds((energyMaxNum - ContextUser.EnergyNum) * restorationDate) - DateTime.Now).TotalSeconds.ToInt(); } } } else { UserQueue queue = new UserQueue() { QueueID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, QueueType = QueueType.EnergyHuiFu, QueueName = QueueType.EnergyHuiFu.ToString(), Timing = DateTime.Now, ColdTime = 0, TotalColdTime = 0, IsSuspend = false, StrengNum = 0 }; new PersonalCacheStruct<UserQueue>().Add(queue); } VipLvInfo lvInfo = new ShareCacheStruct<VipLvInfo>().FindKey(MathUtils.Addition(ContextUser.VipLv, 1, int.MaxValue)); if (lvInfo != null) { demandGold = MathUtils.Subtraction(lvInfo.PayGold, ContextUser.PayGold, 0); demandGold = MathUtils.Subtraction(demandGold, ContextUser.ExtGold, 0); } UserHelper.GetGameUserCombat(ContextUser.UserID); if ((int)(DateTime.Now - ContextUser.DailyLoginTime).TotalSeconds <= 5 && ContextUser.UserLv > 10) { isHelper = 1; } FestivalHelper.DoFestival(ContextUser); if (ContextUser.UserExtend != null) { if ((plotstatucID > 0 || ContextUser.TempEnergyNum == 0) && !ContextUser.UserExtend.IsBoss) { ContextUser.TempEnergyNum = 1; } if ((plotstatucID == 0 && ContextUser.TempEnergyNum == 0) || ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = false; return true; }); } plotstatucID = ContextUser.UserExtend.PlotStatusID; mercenarySeq = ContextUser.UserExtend.MercenarySeq; cardUserID = ContextUser.UserExtend.CardUserID; } //公会晨练结束,退出公会晨练 int activeID = 11; GameActive active = new ShareCacheStruct<GameActive>().FindKey(activeID); if (active != null) { DateTime stratTime = active.BeginTime; DateTime endTime = active.BeginTime.AddMinutes(active.Minutes); if (ContextUser.UserLocation == Location.GuildExercise && (DateTime.Now < stratTime || DateTime.Now > endTime)) { ContextUser.UserLocation = Location.Guid; } } DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); //公会战结束后 if (stage == FightStage.Apply && ContextUser.UserStatus == UserStatus.FightCombat) { ContextUser.UserStatus = UserStatus.Normal; } battleNum = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true).Count; totalBattle = EmbattleHelper.CurrEmbattle(ContextUser.UserID, false).Count; var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); foreach (var userEmbattle in userEmbattleList) { _talPriority = MathUtils.Addition(_talPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); } functionList = new PersonalCacheStruct<UserFunction>().FindAll(ContextUser.UserID); // 精灵祝福 if (ContextUser != null) { if (MathUtils.SqlMinDate == ContextUser.WizardDate) // 玩家第一次进入 { ContextUser.WizardDate = DateTime.Now; ContextUser.WizardNum = 1; } else { double diffHours = (DateTime.Now - ContextUser.WizardDate).TotalHours; if (diffHours >= 1) { ContextUser.WizardNum = MathUtils.Addition(ContextUser.WizardNum, Convert.ToInt32(diffHours), 3); ContextUser.WizardDate = DateTime.Now; } } } // 未读信件的数量 TjxMailService tjxMailService = new TjxMailService(ContextUser); tjxMailService.GetMail(out unReadCount); return true; }
public void AppandEquipAttribute(int userLv, EquipData equip) { var equipSet = new ShareCacheStruct <Config_Equip>(); var weaponcfg = equipSet.Find(t => (t.EquipID == equip.ID && t.Grade == equip.Lv)); if (weaponcfg == null) { TraceLog.WriteError("AppandEquipAttribute: No found equip! code={0}_{1}", equip.ID, equip.Lv); return; } Hp += weaponcfg.hp; Atk += weaponcfg.attack; Def += weaponcfg.defense; Dodge += weaponcfg.dodge; Crit += weaponcfg.crit; Hit += weaponcfg.hit; Tenacity += weaponcfg.tenacity; // 宝石属性 var itemSet = new ShareCacheStruct <Config_Item>(); if (equip.AtkGem != 0) { var gem = itemSet.FindKey(equip.AtkGem); if (gem != null) { Atk += (Math.Ceiling(userLv / 50.0).ToInt() * gem.attack); } } if (equip.DefGem != 0) { var gem = itemSet.FindKey(equip.DefGem); if (gem != null) { Def += (Math.Ceiling(userLv / 50.0).ToInt() * gem.defense); } } if (equip.HpGem != 0) { var gem = itemSet.FindKey(equip.HpGem); if (gem != null) { Hp += (Math.Ceiling(userLv / 50.0).ToInt() * gem.hp); } } if (equip.CritGem != 0) { var gem = itemSet.FindKey(equip.CritGem); if (gem != null) { Crit += gem.crit; } } if (equip.HitGem != 0) { var gem = itemSet.FindKey(equip.HitGem); if (gem != null) { Hit += gem.hit; } } if (equip.DodgeGem != 0) { var gem = itemSet.FindKey(equip.DodgeGem); if (gem != null) { Dodge += gem.dodge; } } if (equip.TenacityGem != 0) { var gem = itemSet.FindKey(equip.TenacityGem); if (gem != null) { Tenacity += gem.tenacity; } } }
bool processCache(string orderId,bool bSuccess, string jrRet, bool hasGet) { // cache order var payCache = new ShareCacheStruct<PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) return true; return false; }); if (null == payData) { //ConsoleLog.showErrorInfo(0, "PayLog not find order:" + orderId); TraceLog.WriteError("PayLog not find order:" + orderId); return false; } PayOrder.PayStatus payStatus = PayOrder.PayStatus.payFailed; if (bSuccess) { payStatus = PayOrder.PayStatus.paySuccess; } if (false == payData.process) { payData.ModifyLocked(() => { payData.userParms = urlParams; // save .. payData.the3rdOrderId = order_id; // dic["order_id"]; payData.state = payStatus; payData.process = true; payData.typeUser = jrRet; payData.hasGetPayReward = hasGet; }); } //ConsoleLog.showNotifyInfo("process HttpPost:" + jrRet); //TraceLog.ReleaseWrite("process HttpPost:" + jrRet); return true; }
public bool FindPachinkoData(int pachinkoId, out PachinkoData pachinkoData) { pachinkoData = _pachinkoCache.Find(p => p.Id == pachinkoId); return(pachinkoData != null); }
public override bool TakeAction() { short currMaxLv = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort(); //NoviceHelper.CheckFestival(ContextUser); NoviceHelper.GetFunctionEnum(Uid); //默认开启金币,精力大作战功能 if (!string.IsNullOrEmpty(ContextUser.MercenariesID)) { UserHelper.ChecheDailyContribution(ContextUser.MercenariesID, ContextUser.UserID); } PaymentService.Trigger(ContextUser); if (ContextUser.UserLv > currMaxLv) { genlv = currMaxLv; } else { genlv = ContextUser.UserLv; } var cacheSetGeneralEscalate = new ShareCacheStruct <GeneralEscalateInfo>(); GeneralEscalateHelper.AddUserLv(ContextUser, 0); _honourNum = ContextUser.HonourNum; int lv = ContextUser.UserLv; lv = lv < 0 ? 1 : lv + 1; var generalEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv); if (generalEscalate != null) { _nextHonourNum = generalEscalate.UpExperience; } guildID = ContextUser.MercenariesID; var userGeneralList = new PersonalCacheStruct <UserGeneral>().FindAll(ContextUser.UserID); if (userGeneralList.Count == 0) { ErrorCode = LanguageManager.GetLang().ErrorCode; return(false); } userGeneralInfo = userGeneralList[0]; //UserGeneral.GetMainGeneral(ContextUser.UserID); if (userGeneralInfo != null) { //wuzf 去掉刷新血量,其它改变血量接口有触发刷新 //userGeneralInfo.RefreshMaxLife(); generalID = userGeneralInfo.GeneralID; //careerInfo = new ShareCacheStruct<CareerInfo>().FindKey(userGeneralInfo.CareerID); headID = userGeneralInfo.HeadID; //ContextUser.Sex ? careerInfo.HeadID2 : careerInfo.HeadID; escalateInfo = new ShareCacheStruct <GeneralEscalateInfo>().FindKey(genlv); lifeNum = userGeneralInfo.LifeNum; careerID = userGeneralInfo.CareerID; } lifeMaxNum = UserHelper.GetMaxLife(ContextUser.UserID, generalID); maxEnergyNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); sex = ContextUser.Sex ? 1 : 0; //道具图标 _blessingList = UserHelper.BlessingInfoList(ContextUser); //变身卡图标 List <UserProps> userPropsList = new PersonalCacheStruct <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 3 && u.ItemID != 5200 && u.ItemID != 7003); if (userPropsList.Count > 0) { UserProps props = userPropsList[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { pictureID = itemInfo.PictrueID; pictureTime = pTime; } } //兼容客户端上已版本血量图标 List <UserProps> userPropsList2 = new PersonalCacheStruct <UserProps>().FindAll(ContextUser.UserID, u => u.PropType == 1); if (userPropsList2.Count > 0) { UserProps props = userPropsList2[0]; int pTime = props.DoRefresh(); ItemBaseInfo itemInfo = new ShareCacheStruct <ItemBaseInfo>().FindKey(props.ItemID); if (itemInfo != null && pTime > pictureTime) { _itemLiveNum = props.SurplusNum; _itemLiveMaxNum = itemInfo.EffectNum; } } //加量,领土战不能加血wuzf) if (ContextUser.UserStatus != UserStatus.CountryCombat) { UserHelper.GetGeneralLife(ContextUser.UserID); } //精力恢复 List <UserQueue> energyQueueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.EnergyHuiFu); if (energyQueueArray.Count > 0) { UserQueue energyQueue = energyQueueArray[0]; short energyMaxNum = (short)ConfigEnvSet.GetInt("User.MaxEnergyNum"); int restorationDate = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationDate"); //半小时 int restorationNum = ConfigEnvSet.GetInt("UserQueue.EnergyRestorationNum"); //恢复5点 if (energyQueue.Timing > DateTime.Now) { energyQueue.Timing = DateTime.Now; } //原因:玩家满精力时,精力恢复累加 int timeCount = (int)(DateTime.Now - energyQueue.Timing).TotalSeconds / restorationDate; if (timeCount > 0) { short energyNum = (short)(timeCount * restorationNum); if (ContextUser.EnergyNum < energyMaxNum) { ContextUser.EnergyNum = MathUtils.Addition(ContextUser.EnergyNum, energyNum, energyMaxNum); } energyQueue.Timing = DateTime.Now; } else { if (energyMaxNum > ContextUser.EnergyNum) { rstore = (int)(energyQueue.Timing.AddSeconds(restorationDate) - DateTime.Now).TotalSeconds; totalRstore = (energyQueue.Timing.AddSeconds((energyMaxNum - ContextUser.EnergyNum) * restorationDate) - DateTime.Now).TotalSeconds.ToInt(); } } } else { UserQueue queue = new UserQueue() { QueueID = Guid.NewGuid().ToString(), UserID = ContextUser.UserID, QueueType = QueueType.EnergyHuiFu, QueueName = QueueType.EnergyHuiFu.ToString(), Timing = DateTime.Now, ColdTime = 0, TotalColdTime = 0, IsSuspend = false, StrengNum = 0 }; new PersonalCacheStruct <UserQueue>().Add(queue); } VipLvInfo lvInfo = new ShareCacheStruct <VipLvInfo>().FindKey(MathUtils.Addition(ContextUser.VipLv, 1, int.MaxValue)); if (lvInfo != null) { demandGold = MathUtils.Subtraction(lvInfo.PayGold, ContextUser.PayGold, 0); demandGold = MathUtils.Subtraction(demandGold, ContextUser.ExtGold, 0); } UserHelper.GetGameUserCombat(ContextUser.UserID); if ((int)(DateTime.Now - ContextUser.DailyLoginTime).TotalSeconds <= 5 && ContextUser.UserLv > 10) { isHelper = 1; } FestivalHelper.DoFestival(ContextUser); if (ContextUser.UserExtend != null) { if ((plotstatucID > 0 || ContextUser.TempEnergyNum == 0) && !ContextUser.UserExtend.IsBoss) { ContextUser.TempEnergyNum = 1; } if ((plotstatucID == 0 && ContextUser.TempEnergyNum == 0) || ContextUser.UserExtend.IsBoss) { ContextUser.UserExtend.UpdateNotify(obj => { ContextUser.UserExtend.PlotStatusID = 0; ContextUser.UserExtend.PlotNpcID = -1; ContextUser.UserExtend.MercenarySeq = 0; ContextUser.UserExtend.IsBoss = false; return(true); }); } plotstatucID = ContextUser.UserExtend.PlotStatusID; mercenarySeq = ContextUser.UserExtend.MercenarySeq; cardUserID = ContextUser.UserExtend.CardUserID; } //公会晨练结束,退出公会晨练 int activeID = 11; GameActive active = new ShareCacheStruct <GameActive>().FindKey(activeID); if (active != null) { DateTime stratTime = active.BeginTime; DateTime endTime = active.BeginTime.AddMinutes(active.Minutes); if (ContextUser.UserLocation == Location.GuildExercise && (DateTime.Now < stratTime || DateTime.Now > endTime)) { ContextUser.UserLocation = Location.Guid; } } DateTime nextDate; FightStage stage = GuildFightCombat.GetStage(out nextDate); //公会战结束后 if (stage == FightStage.Apply && ContextUser.UserStatus == UserStatus.FightCombat) { ContextUser.UserStatus = UserStatus.Normal; } battleNum = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true).Count; totalBattle = EmbattleHelper.CurrEmbattle(ContextUser.UserID, false).Count; var userEmbattleList = EmbattleHelper.CurrEmbattle(ContextUser.UserID, true); foreach (var userEmbattle in userEmbattleList) { _talPriority = MathUtils.Addition(_talPriority, PriorityHelper.GeneralTotalPriority(ContextUser.UserID, userEmbattle.GeneralID)); } functionList = new PersonalCacheStruct <UserFunction>().FindAll(ContextUser.UserID); // 精灵祝福 if (ContextUser != null) { if (MathUtils.SqlMinDate == ContextUser.WizardDate) // 玩家第一次进入 { ContextUser.WizardDate = DateTime.Now; ContextUser.WizardNum = 1; } else { double diffHours = (DateTime.Now - ContextUser.WizardDate).TotalHours; if (diffHours >= 1) { ContextUser.WizardNum = MathUtils.Addition(ContextUser.WizardNum, Convert.ToInt32(diffHours), 3); ContextUser.WizardDate = DateTime.Now; } } } // 未读信件的数量 TjxMailService tjxMailService = new TjxMailService(ContextUser); tjxMailService.GetMail(out unReadCount); return(true); }
public override bool TakeAction() { PlotInfo plotInfo = new ShareCacheStruct<PlotInfo>().FindKey(PlotID); if (plotInfo != null) { plotName = plotInfo.PlotName; } var cacheSetGeneralEscalate = new ShareCacheStruct<GeneralEscalateInfo>(); GeneralEscalateHelper.AddUserLv(ContextUser, 0); int lv = ContextUser.UserLv; lv = lv < 0 ? 1 : lv + 1; var generalEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv); if (generalEscalate != null) { maxHonourNum = generalEscalate.UpExperience; } var lastGeneralEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == (lv-1)); if (lastGeneralEscalate!=null) { lastMaxHonourNum = lastGeneralEscalate.UpExperience; } embattleList = new PersonalCacheStruct<UserEmbattle>().FindAll(ContextUser.UserID, m => m.MagicID == ContextUser.UseMagicID); embattleList.QuickSort((x, y) => x.GeneralID.CompareTo(y.GeneralID)); List<UniversalInfo> universalList = new List<UniversalInfo>(); userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, PlotID); //var cacheSetPlotInfo = new ShareCacheStruct<PlotInfo>(); //var cacheSetItem = new ShareCacheStruct<ItemBaseInfo>(); //var plotInfo = cacheSetPlotInfo.FindKey(PlotID); if (userPlot != null && userPlot.ItemList.Count > 0) { universalList.AddRange(userPlot.ItemList); //if (plotInfo != null && userPlot.PlotStatus == PlotStatus.Completed && plotInfo.ItemRank != "" && plotInfo.ItemRank != null) //{ // var itemArray = plotInfo.ItemRank.Split(','); // foreach (var s in itemArray) // { // int itemId = s.Split('=')[0].ToInt(); // var item = cacheSetItem.FindKey(itemId); // if (item != null) // { // universalList.Add(new UniversalInfo() { Name = item.ItemName, HeadID = item.HeadID, Num = s.Split('=')[1].ToInt() }); // } // } //} //if (userPlot.ItemID > 0) //{ // itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(userPlot.ItemID); // if (itemInfo != null) // { // universalList.Add(new UniversalInfo() { Name = itemInfo.ItemName, HeadID = itemInfo.HeadID, Num = 1 }); // } //} //if (userPlot.EnchantID > 0) //{ // enchant = new ShareCacheStruct<EnchantInfo>().FindKey(userPlot.EnchantID); // if (enchant != null) // { // universalList.Add(new UniversalInfo() { Name = enchant.EnchantName, HeadID = enchant.HeadID, Num = 1 }); // } //} userPlot.ItemList.Clear(); } universalArray = universalList.ToArray(); return true; }
public override bool TakeAction() { PlotInfo plotInfo = new ShareCacheStruct <PlotInfo>().FindKey(PlotID); if (plotInfo != null) { plotName = plotInfo.PlotName; } var cacheSetGeneralEscalate = new ShareCacheStruct <GeneralEscalateInfo>(); GeneralEscalateHelper.AddUserLv(ContextUser, 0); int lv = ContextUser.UserLv; lv = lv < 0 ? 1 : lv + 1; var generalEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == lv); if (generalEscalate != null) { maxHonourNum = generalEscalate.UpExperience; } var lastGeneralEscalate = cacheSetGeneralEscalate.Find(s => s.GeneralType == GeneralType.YongHu && s.GeneralLv == (lv - 1)); if (lastGeneralEscalate != null) { lastMaxHonourNum = lastGeneralEscalate.UpExperience; } embattleList = new PersonalCacheStruct <UserEmbattle>().FindAll(ContextUser.UserID, m => m.MagicID == ContextUser.UseMagicID); embattleList.QuickSort((x, y) => x.GeneralID.CompareTo(y.GeneralID)); List <UniversalInfo> universalList = new List <UniversalInfo>(); userPlot = UserPlotHelper.GetUserPlotInfo(ContextUser.UserID, PlotID); //var cacheSetPlotInfo = new ShareCacheStruct<PlotInfo>(); //var cacheSetItem = new ShareCacheStruct<ItemBaseInfo>(); //var plotInfo = cacheSetPlotInfo.FindKey(PlotID); if (userPlot != null && userPlot.ItemList.Count > 0) { universalList.AddRange(userPlot.ItemList); //if (plotInfo != null && userPlot.PlotStatus == PlotStatus.Completed && plotInfo.ItemRank != "" && plotInfo.ItemRank != null) //{ // var itemArray = plotInfo.ItemRank.Split(','); // foreach (var s in itemArray) // { // int itemId = s.Split('=')[0].ToInt(); // var item = cacheSetItem.FindKey(itemId); // if (item != null) // { // universalList.Add(new UniversalInfo() { Name = item.ItemName, HeadID = item.HeadID, Num = s.Split('=')[1].ToInt() }); // } // } //} //if (userPlot.ItemID > 0) //{ // itemInfo = new ShareCacheStruct<ItemBaseInfo>().FindKey(userPlot.ItemID); // if (itemInfo != null) // { // universalList.Add(new UniversalInfo() { Name = itemInfo.ItemName, HeadID = itemInfo.HeadID, Num = 1 }); // } //} //if (userPlot.EnchantID > 0) //{ // enchant = new ShareCacheStruct<EnchantInfo>().FindKey(userPlot.EnchantID); // if (enchant != null) // { // universalList.Add(new UniversalInfo() { Name = enchant.EnchantName, HeadID = enchant.HeadID, Num = 1 }); // } //} userPlot.ItemList.Clear(); } universalArray = universalList.ToArray(); return(true); }
void doCheck_order() { string orderId = requestPack.infoExt; var payCache = new ShareCacheStruct<PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) return true; return false; }); if(payData == null) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find; return; } if (payData.hasGetPayReward) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.hasGetPayReward; return; } string productId = payData.ProductId; responsePack.extInfo = GameConfigMgr.Instance().getProductInfo(productId,orderId); // add 道具发放信息。 responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok; }
/// 获得灵魂 /// </summary> /// <param name="userId"></param> /// <param name="itemId"></param> /// <param name="num"></param> public static void AddGeneralSoul(string userId, int itemId, int num) { var cacheSetGeneral = new PersonalCacheStruct<UserGeneral>(); var cacheSetGeneralInfo = new ShareCacheStruct<GeneralInfo>(); var generalInfo = cacheSetGeneralInfo.Find(s => s.SoulID == itemId); var userGeneral = cacheSetGeneral.FindKey(userId, itemId); if (userGeneral != null && generalInfo != null) { userGeneral.AtmanNum = MathUtils.Addition(userGeneral.AtmanNum, num).ToShort(); } else { if (generalInfo != null) { userGeneral = new UserGeneral(); userGeneral.UserID = userId; userGeneral.GeneralID = itemId; userGeneral.AtmanNum = num; userGeneral.GeneralName = generalInfo.GeneralName; userGeneral.HeadID = generalInfo.HeadID; userGeneral.PicturesID = generalInfo.PicturesID; userGeneral.GeneralLv = generalInfo.GeneralLv; userGeneral.LifeNum = generalInfo.LifeNum; userGeneral.GeneralType = generalInfo.GeneralType; userGeneral.CareerID = generalInfo.CareerID; userGeneral.PowerNum = generalInfo.PowerNum; userGeneral.SoulNum = generalInfo.SoulNum; userGeneral.IntellectNum = generalInfo.IntellectNum; userGeneral.TrainingPower = 0; userGeneral.TrainingSoul = 0; userGeneral.TrainingIntellect = 0; userGeneral.HitProbability = ConfigEnvSet.GetDecimal("Combat.HitiNum"); userGeneral.AbilityID = generalInfo.AbilityID; userGeneral.Momentum = 0; userGeneral.Description = generalInfo.Description; userGeneral.AddGeneralStatus(2); userGeneral.CurrExperience = 0; userGeneral.Experience1 = 0; userGeneral.Experience2 = 0; userGeneral.AbilityNum = 3; cacheSetGeneral.Add(userGeneral); } } }
public override bool TakeAction() { var guildsSet = new ShareCacheStruct <GuildsCache>(); if (!GetGuild.GuildID.IsEmpty()) { var oldguild = guildsSet.FindKey(GetGuild.GuildID); if (oldguild != null && oldguild.FindMember(Current.UserId) != null) { return(false); } } int needDiamond = ConfigEnvSet.GetInt("User.CreateGuildNeedDiamond"); if (GetBasis.DiamondNum < needDiamond) { receipt = RequestGuildResult.NoDiamond; return(true); } if (guildsSet.Find(t => t.GuildName == _guildName) != null) { receipt = RequestGuildResult.HadName; return(true); } GuildsCache guild = new GuildsCache() { GuildID = Guid.NewGuid().ToString(), GuildName = _guildName, Liveness = 0, RankID = 0, CreateDate = DateTime.Now, Lv = 1 }; GuildCharacter member = new GuildCharacter() { UserID = Current.UserId, JobTitle = GuildJobTitle.Atevent, Liveness = 0 }; guild.AddNewMember(member); GuildLogData log = new GuildLogData() { UserId = Current.UserId, UserName = GetBasis.NickName, LogTime = DateTime.Now, Content = string.Format("玩家 {0} 创建了公会。", GetBasis.NickName), }; guild.NewLog(log); guildsSet.Add(guild); guildsSet.Update(); GetGuild.GuildID = guild.GuildID; PushMessageHelper.JoinGuildNotification(Current); GlobalRemoteService.SendUserData(GetBasis, GetGuild.GuildID); receipt = RequestGuildResult.Successfully; return(true); }
void doEnd_order() { string orderId = requestPack.infoExt; var payCache = new ShareCacheStruct<PayOrder>(); PayOrder payData = payCache.Find((o) => { if (orderId == o.ServerOrderId) return true; return false; }); if (payData == null) { responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.order_not_find; } payData.ModifyLocked(() => { payData.hasGetPayReward = true; }); responsePack.errorCode = (byte)Response1004Pack.EnumErrorCode.ok; }
public override bool TakeAction() { receipt = new LotteryData(); var itemSet = new ShareCacheStruct <Config_Item>(); int times = isFiveTimes ? 5 : 1; if (GetLottery.LotteryTimes <= times) { int needDiamond = ConfigEnvSet.GetInt("User.BuyLotteryTimesNeedDiamond") * (times - GetLottery.LotteryTimes); if (GetBasis.DiamondNum < needDiamond) { receipt.Result = RequestLotteryResult.NoDiamond; return(true); } UserHelper.ConsumeDiamond(Current.UserId, needDiamond); //receipt.Result = RequestLotteryResult.NoTimes; //return true; } BigInteger awardGold = 0; int awardDiamond = 0; List <ItemData> awardItem = new List <ItemData>(); int lotteryId = 0; LotteryAwardType awardType = LotteryAwardType.Gold; GetLottery.StealTimes = 0; GetLottery.RobTimes = 0; for (int i = 0; i < times; ++i) { if (GetLottery.TotalCount == 0) { lotteryId = 7; awardType = LotteryAwardType.Steal; } else if (GetLottery.TotalCount == 1) { lotteryId = 8; awardType = LotteryAwardType.Rob; } else { var randlottery = UserHelper.RandomLottery(GetBasis.UserLv); if (randlottery != null) { lotteryId = randlottery.ID; awardType = randlottery.Type; } } Config_Lottery lott = new ShareCacheStruct <Config_Lottery>().FindKey(lotteryId); if (lott == null) { return(false); } LottItem item = new LottItem(); item.ID = lotteryId; item.Type = awardType; switch (lott.Type) { case LotteryAwardType.Gold: { BigInteger resourceNum = BigInteger.Parse(lott.Content); BigInteger value = Math.Ceiling(GetBasis.UserLv / 50.0).ToInt() * resourceNum; awardGold += value; item.ItemID = 0; item.Num = value.ToString(); } break; case LotteryAwardType.Diamond: { awardDiamond += lott.Content.ToInt(); item.ItemID = 0; item.Num = lott.Content; } break; case LotteryAwardType.Gem: { int maxCount = lott.Content.ToInt(); if (maxCount > 0) { var lotteryGem = UserHelper.RandomLotteryGem(); item.ItemID = lotteryGem.ID; item.Num = maxCount.ToString(); awardItem.Add(new ItemData() { ID = lotteryGem.ID, Num = maxCount }); } } break; case LotteryAwardType.Debris: { var debris = itemSet.FindAll(t => (t.ItemType == ItemType.Debris)); foreach (var v in GetElf.ElfList) { var elfCard = itemSet.Find(t => t.ResourceNum.ToInt() == v.ID); if (elfCard == null) { continue; } debris.RemoveAll(t => (t.ResourceNum.ToInt() == elfCard.ItemID)); } if (debris.Count == 0) { debris = itemSet.FindAll(t => (t.ItemType == ItemType.Debris)); } int maxCount = lott.Content.ToInt(); if (maxCount > 0) { int index = random.Next(debris.Count); int awardId = debris[index].ItemID; item.ItemID = awardId; item.Num = maxCount.ToString(); awardItem.Add(new ItemData() { ID = awardId, Num = maxCount }); } } break; case LotteryAwardType.Elf: { item.ItemID = lott.Content.ToInt(); item.Num = "1"; awardItem.Add(new ItemData() { ID = lott.Content.ToInt(), Num = 1 }); var itemcfg = new ShareCacheStruct <Config_Item>().FindKey(item.ItemID); if (itemcfg != null) { string context = string.Format("恭喜 {0} 在幸运大夺宝中获得精灵 {1}", GetBasis.NickName, itemcfg.ItemName); GlobalRemoteService.SendNotice(NoticeMode.World, context); } } break; case LotteryAwardType.Steal: { GetLottery.StealTimes++; UserHelper.RandomStealTarget(Current.UserId); } break; case LotteryAwardType.Rob: { GetLottery.RobTimes++; UserHelper.RandomRobTarget(Current.UserId); } break; case LotteryAwardType.Vit: { GetBasis.Vit += lott.Content.ToInt(); PushMessageHelper.UserVitChangedNotification(Current); } break; } receipt.AwardList.Add(item); GetLottery.TotalCount++; } UserHelper.RewardsGold(Current.UserId, awardGold, UpdateCoinOperate.NormalReward, true); UserHelper.RewardsDiamond(Current.UserId, awardDiamond); UserHelper.RewardsItems(Current.UserId, awardItem); if (GetLottery.LotteryTimes == ConfigEnvSet.GetInt("User.LotteryTimesMax")) { GetLottery.StartRestoreLotteryTimesDate = DateTime.Now; } if (GetLottery.LotteryTimes > 0) { GetLottery.LotteryTimes = MathUtils.Subtraction(GetLottery.LotteryTimes, times, 0); } UserHelper.EveryDayTaskProcess(Current.UserId, TaskType.Lottery, times); receipt.Result = RequestLotteryResult.OK; return(true); }