private static EPetSkillState PetSkillAwake(GameClient client, int petID, List <int> lockPitList, out string result) { result = ""; if (!IsGongNengOpened(client)) { return(EPetSkillState.EnoOpen); } GoodsData goodsData = DamonMgr.GetDamonGoodsDataByDbID(client, petID); if (null == goodsData || goodsData.GCount <= 0) { return(EPetSkillState.EnoPet); } if (goodsData.Site != (int)SaleGoodsConsts.UsingDemonGoodsID) { return(EPetSkillState.EnoUsing); } List <PetSkillInfo> petSkillList = GetPetSkillInfo(goodsData); //锁定,钻石 int diamondNeed = 0; if (lockPitList.Count > 0) { foreach (var lockPit in lockPitList) { if (lockPit > PIT_MAX) { return(EPetSkillState.EpitWrong); } if (!petSkillList[lockPit - 1].PitIsOpen) { return(EPetSkillState.EpitNoOpen); } } diamondNeed = GetPitLockCost(lockPitList.Count); if (diamondNeed > 0 && client.ClientData.UserMoney < diamondNeed) { return(EPetSkillState.EnoDiamond); } } //次数,灵晶 int awakeCount = GetUpCount(client); int lingJingNeed = GetSkillAwakeCost(awakeCount); long lingjingHave = GameManager.ClientMgr.GetMUMoHeValue(client); if (lingjingHave < lingJingNeed) { return(EPetSkillState.EnoLingJing); } //可领悟pit List <PetSkillInfo> canAwakeSkillList = null; List <PetSkillInfo> openList = petSkillList.FindAll(_g => _g.PitIsOpen == true); if (openList == null || openList.Count <= 0) { return(EPetSkillState.EpitNoOpen); } if (lockPitList != null && lockPitList.Count > 0) { var temp = from info in openList where info.PitIsOpen && lockPitList.IndexOf(info.Pit) < 0 select info; if (!temp.Any()) { return(EPetSkillState.EnoPitAwake); } canAwakeSkillList = temp.ToList <PetSkillInfo>(); } else { canAwakeSkillList = openList; } var t = from info in canAwakeSkillList where info.PitIsOpen && info.SkillID <= 0 select info; if (t.Any()) { List <PetSkillInfo> list = t.ToList <PetSkillInfo>(); canAwakeSkillList = list; } int skRand = Global.GetRandomNumber(0, canAwakeSkillList.Count); PetSkillInfo nowAwakeInfo = canAwakeSkillList[skRand]; //可领取技能 List <int> canAwakeSkillIDList = new List <int>(); var tt = _psDic.Where(p => !petSkillList.Select(g => g.SkillID).Contains(p.Value.SkillID)); if (!tt.Any()) { return(EPetSkillState.EnoSkillAwake); } int nowAwakeSkillID = 0; int seed = tt.Sum(_s => _s.Value.Rate); int skillRand = Global.GetRandomNumber(0, seed); int sum = 0; int rate = 0; foreach (var info in tt) { nowAwakeSkillID = info.Key; rate = info.Value.Rate; sum += info.Value.Rate; if (sum >= skillRand) { break; } } //LogManager.WriteLog(LogTypes.Error, string.Format("---------------------seed={0} random={1} sum={2} rate={3} skillID={4}", seed, skillRand, sum, rate, nowAwakeSkillID)); //foreach(var s in tt) // canAwakeSkillIDList.Add(s.Key); //if (canAwakeSkillIDList.Count<=0) return EPetSkillState.EnoSkillAwake; //int skillRand = Global.GetRandomNumber(0, canAwakeSkillIDList.Count); //int nowAwakeSkillID = canAwakeSkillIDList[skillRand]; int oldSkillID = nowAwakeInfo.SkillID; nowAwakeInfo.SkillID = nowAwakeSkillID; //扣除 if (diamondNeed > 0 && !GameManager.ClientMgr.SubUserMoney(client, diamondNeed, "精灵技能领悟")) { return(EPetSkillState.EnoDiamond); } GameManager.ClientMgr.ModifyMUMoHeValue(client, -lingJingNeed, "精灵技能领悟", true, true); ModifyUpCount(client, awakeCount + 1); //存盘并通知用户结果 UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs() { RoleID = client.ClientData.RoleID, DbID = petID, WashProps = null }; updateGoodsArgs.ElementhrtsProps = new List <int>(); foreach (var info in petSkillList) { updateGoodsArgs.ElementhrtsProps.Add(info.PitIsOpen ? 1 : 0); updateGoodsArgs.ElementhrtsProps.Add(info.Level); updateGoodsArgs.ElementhrtsProps.Add(info.SkillID); } Global.UpdateGoodsProp(client, goodsData, updateGoodsArgs); result = string.Join(",", updateGoodsArgs.ElementhrtsProps.ToArray()); UpdateRolePetSkill(client); EventLogManager.AddPetSkillEvent(client, LogRecordType.PetSkill, EPetSkillLog.Awake, petID, goodsData.GoodsID, nowAwakeInfo.Pit, oldSkillID, nowAwakeSkillID); return(EPetSkillState.Success); }
private static EPetSkillState PetSkillUp(GameClient client, int petID, int pit) { if (!IsGongNengOpened(client)) { return(EPetSkillState.EnoOpen); } //物品 GoodsData goodsData = DamonMgr.GetDamonGoodsDataByDbID(client, petID); if (null == goodsData || goodsData.GCount <= 0) { return(EPetSkillState.EnoPet); } if (goodsData.Site != (int)SaleGoodsConsts.UsingDemonGoodsID) { return(EPetSkillState.EnoUsing); } if (pit < PIT_MIN || pit > PIT_MAX) { return(EPetSkillState.EpitWrong); } //open List <PetSkillInfo> petSkillList = GetPetSkillInfo(goodsData); PetSkillInfo skillInfo = petSkillList.Find(_g => _g.Pit == pit); if (!skillInfo.PitIsOpen) { return(EPetSkillState.EpitNoOpen); } if (skillInfo.SkillID <= 0) { return(EPetSkillState.EpitSkillNull); } int maxLevel = GetPsUpMaxLevel(); if (skillInfo.Level >= maxLevel) { return(EPetSkillState.ElevelMax); } int oldLevel = skillInfo.Level; int nextLevel = skillInfo.Level + 1; int lingJingNeed = (int)GetPsUpCost(nextLevel); long lingjingHave = GameManager.ClientMgr.GetMUMoHeValue(client); if (lingjingHave < lingJingNeed) { return(EPetSkillState.EnoLingJing); } //扣除 GameManager.ClientMgr.ModifyMUMoHeValue(client, -lingJingNeed, "精灵技能升级", true, true); skillInfo.Level = nextLevel; //存盘并通知用户结果 UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs() { RoleID = client.ClientData.RoleID, DbID = petID, WashProps = null }; updateGoodsArgs.ElementhrtsProps = new List <int>(); foreach (var info in petSkillList) { updateGoodsArgs.ElementhrtsProps.Add(info.PitIsOpen ? 1 : 0); updateGoodsArgs.ElementhrtsProps.Add(info.Level); updateGoodsArgs.ElementhrtsProps.Add(info.SkillID); } Global.UpdateGoodsProp(client, goodsData, updateGoodsArgs); if (goodsData.Using > 0) { UpdateRolePetSkill(client); } EventLogManager.AddPetSkillEvent(client, LogRecordType.PetSkill, EPetSkillLog.Up, petID, goodsData.GoodsID, pit, oldLevel, nextLevel); return(EPetSkillState.Success); }
private static EPetSkillState PetSkillUp(GameClient client, int petID, int pit) { EPetSkillState result; if (!PetSkillManager.IsGongNengOpened(client)) { result = EPetSkillState.EnoOpen; } else { GoodsData goodsData = DamonMgr.GetDamonGoodsDataByDbID(client, petID); if (goodsData == null || goodsData.GCount <= 0) { result = EPetSkillState.EnoPet; } else if (goodsData.Site != 5000) { result = EPetSkillState.EnoUsing; } else if (pit < 1 || pit > 4) { result = EPetSkillState.EpitWrong; } else { List <PetSkillInfo> petSkillList = PetSkillManager.GetPetSkillInfo(goodsData); PetSkillInfo skillInfo = petSkillList.Find((PetSkillInfo _g) => _g.Pit == pit); if (!skillInfo.PitIsOpen) { result = EPetSkillState.EpitNoOpen; } else if (skillInfo.SkillID <= 0) { result = EPetSkillState.EpitSkillNull; } else { int maxLevel = PetSkillManager.GetPsUpMaxLevel(); if (skillInfo.Level >= maxLevel) { result = EPetSkillState.ElevelMax; } else { int oldLevel = skillInfo.Level; int nextLevel = skillInfo.Level + 1; int lingJingNeed = (int)PetSkillManager.GetPsUpCost(nextLevel); long lingjingHave = (long)GameManager.ClientMgr.GetMUMoHeValue(client); if (lingjingHave < (long)lingJingNeed) { result = EPetSkillState.EnoLingJing; } else { GameManager.ClientMgr.ModifyMUMoHeValue(client, -lingJingNeed, "精灵技能升级", true, true, false); skillInfo.Level = nextLevel; UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs { RoleID = client.ClientData.RoleID, DbID = petID, WashProps = null }; updateGoodsArgs.ElementhrtsProps = new List <int>(); foreach (PetSkillInfo info in petSkillList) { updateGoodsArgs.ElementhrtsProps.Add(info.PitIsOpen ? 1 : 0); updateGoodsArgs.ElementhrtsProps.Add(info.Level); updateGoodsArgs.ElementhrtsProps.Add(info.SkillID); } Global.UpdateGoodsProp(client, goodsData, updateGoodsArgs, true); PetSkillManager.UpdateRolePetSkill(client); EventLogManager.AddPetSkillEvent(client, LogRecordType.PetSkill, EPetSkillLog.Up, new object[] { petID, goodsData.GoodsID, pit, oldLevel, nextLevel }); result = EPetSkillState.Success; } } } } } return(result); }
private static EPetSkillState PetSkillAwake(GameClient client, int petID, List <int> lockPitList, out string result) { result = ""; EPetSkillState result2; if (!PetSkillManager.IsGongNengOpened(client)) { result2 = EPetSkillState.EnoOpen; } else { GoodsData goodsData = DamonMgr.GetDamonGoodsDataByDbID(client, petID); if (goodsData == null || goodsData.GCount <= 0) { result2 = EPetSkillState.EnoPet; } else if (goodsData.Site != 5000) { result2 = EPetSkillState.EnoUsing; } else { List <PetSkillInfo> petSkillList = PetSkillManager.GetPetSkillInfo(goodsData); int diamondNeed = 0; if (lockPitList.Count > 0) { foreach (int lockPit in lockPitList) { if (lockPit > 4) { return(EPetSkillState.EpitWrong); } if (!petSkillList[lockPit - 1].PitIsOpen) { return(EPetSkillState.EpitNoOpen); } } diamondNeed = PetSkillManager.GetPitLockCost(lockPitList.Count); if (diamondNeed > 0 && client.ClientData.UserMoney < diamondNeed) { return(EPetSkillState.EnoDiamond); } } int awakeCount = PetSkillManager.GetUpCount(client); int lingJingNeed = PetSkillManager.GetSkillAwakeCost(awakeCount); long lingjingHave = (long)GameManager.ClientMgr.GetMUMoHeValue(client); if (lingjingHave < (long)lingJingNeed) { result2 = EPetSkillState.EnoLingJing; } else { List <PetSkillInfo> openList = petSkillList.FindAll((PetSkillInfo _g) => _g.PitIsOpen); if (openList == null || openList.Count <= 0) { result2 = EPetSkillState.EpitNoOpen; } else { List <PetSkillInfo> canAwakeSkillList; if (lockPitList != null && lockPitList.Count > 0) { IEnumerable <PetSkillInfo> temp = from info in openList where info.PitIsOpen && lockPitList.IndexOf(info.Pit) < 0 select info; if (!temp.Any <PetSkillInfo>()) { return(EPetSkillState.EnoPitAwake); } canAwakeSkillList = temp.ToList <PetSkillInfo>(); } else { canAwakeSkillList = openList; } IEnumerable <PetSkillInfo> t = from info in canAwakeSkillList where info.PitIsOpen && info.SkillID <= 0 select info; if (t.Any <PetSkillInfo>()) { List <PetSkillInfo> list = t.ToList <PetSkillInfo>(); canAwakeSkillList = list; } int skRand = Global.GetRandomNumber(0, canAwakeSkillList.Count); PetSkillInfo nowAwakeInfo = canAwakeSkillList[skRand]; List <int> canAwakeSkillIDList = new List <int>(); IEnumerable <KeyValuePair <int, PetSkillAwakeInfo> > tt = from p in PetSkillManager._psDic where !(from g in petSkillList select g.SkillID).Contains(p.Value.SkillID) select p; if (!tt.Any <KeyValuePair <int, PetSkillAwakeInfo> >()) { result2 = EPetSkillState.EnoSkillAwake; } else { int nowAwakeSkillID = 0; int seed = tt.Sum((KeyValuePair <int, PetSkillAwakeInfo> _s) => _s.Value.Rate); int skillRand = Global.GetRandomNumber(0, seed); int sum = 0; foreach (KeyValuePair <int, PetSkillAwakeInfo> info3 in tt) { nowAwakeSkillID = info3.Key; int rate = info3.Value.Rate; sum += info3.Value.Rate; if (sum >= skillRand) { break; } } int oldSkillID = nowAwakeInfo.SkillID; nowAwakeInfo.SkillID = nowAwakeSkillID; if (diamondNeed > 0 && !GameManager.ClientMgr.SubUserMoney(client, diamondNeed, "精灵技能领悟", true, true, true, true, DaiBiSySType.None)) { result2 = EPetSkillState.EnoDiamond; } else { GameManager.ClientMgr.ModifyMUMoHeValue(client, -lingJingNeed, "精灵技能领悟", true, true, false); PetSkillManager.ModifyUpCount(client, awakeCount + 1); UpdateGoodsArgs updateGoodsArgs = new UpdateGoodsArgs { RoleID = client.ClientData.RoleID, DbID = petID, WashProps = null }; updateGoodsArgs.ElementhrtsProps = new List <int>(); foreach (PetSkillInfo info2 in petSkillList) { updateGoodsArgs.ElementhrtsProps.Add(info2.PitIsOpen ? 1 : 0); updateGoodsArgs.ElementhrtsProps.Add(info2.Level); updateGoodsArgs.ElementhrtsProps.Add(info2.SkillID); } Global.UpdateGoodsProp(client, goodsData, updateGoodsArgs, true); result = string.Join <int>(",", updateGoodsArgs.ElementhrtsProps.ToArray()); PetSkillManager.UpdateRolePetSkill(client); EventLogManager.AddPetSkillEvent(client, LogRecordType.PetSkill, EPetSkillLog.Awake, new object[] { petID, goodsData.GoodsID, nowAwakeInfo.Pit, oldSkillID, nowAwakeSkillID }); result2 = EPetSkillState.Success; } } } } } } return(result2); }
private static EPetSkillState PetSkillInherit(GameClient client, int srcPetID, int tarPetID, int userMoney, out string outProps) { outProps = ""; EPetSkillState result; if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System2Dot6)) { result = EPetSkillState.EnoOpen; } else if (!PetSkillManager.IsGongNengOpened(client)) { result = EPetSkillState.EnoOpen; } else { GoodsData srcGoodsData = DamonMgr.GetDamonGoodsDataByDbID(client, srcPetID); GoodsData tarGoodsData = DamonMgr.GetDamonGoodsDataByDbID(client, tarPetID); if (null == srcGoodsData) { srcGoodsData = Global.GetGoodsByDbID(client, srcPetID); } else if (srcGoodsData.Site != 5000) { return(EPetSkillState.EnoUsing); } if (null == tarGoodsData) { tarGoodsData = Global.GetGoodsByDbID(client, tarPetID); } else if (tarGoodsData.Site != 5000) { return(EPetSkillState.EnoUsing); } if (srcGoodsData == null || srcGoodsData.GCount <= 0 || tarGoodsData == null || tarGoodsData.GCount <= 0) { result = EPetSkillState.EnoPet; } else { if (1 == userMoney) { if (client.ClientData.UserMoney < PetSkillManager.JingLingChuanChengXiaoHaoZhuanShi && !HuanLeDaiBiManager.GetInstance().HuanledaibiEnough(client, PetSkillManager.JingLingChuanChengXiaoHaoZhuanShi)) { return(EPetSkillState.EnoDiamond); } } else if (Global.GetTotalBindTongQianAndTongQianVal(client) < PetSkillManager.JingLingChuanChengXiaoHaoJinBi) { return(EPetSkillState.EnoGold); } List <PetSkillInfo> srcSkillList = PetSkillManager.GetPetSkillInfo(srcGoodsData); List <PetSkillInfo> tarSkillList = PetSkillManager.GetPetSkillInfo(tarGoodsData); int pitLoop; for (pitLoop = 1; pitLoop < 4; pitLoop++) { PetSkillInfo srcSkill = srcSkillList.Find((PetSkillInfo _g) => _g.Pit == pitLoop); PetSkillInfo tarSkill = tarSkillList.Find((PetSkillInfo _g) => _g.Pit == pitLoop); if (srcSkill == null || null == tarSkill) { return(EPetSkillState.EpitWrong); } if (srcSkill.PitIsOpen && !tarSkill.PitIsOpen) { return(EPetSkillState.EpitWrong); } } if (1 == userMoney) { if (!GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, PetSkillManager.JingLingChuanChengXiaoHaoZhuanShi, "精灵技能传承", true, true, false, DaiBiSySType.JingLingJiNengChuanCheng)) { return(EPetSkillState.EnoDiamond); } } else if (!Global.SubBindTongQianAndTongQian(client, PetSkillManager.JingLingChuanChengXiaoHaoJinBi, "精灵技能传承")) { return(EPetSkillState.EnoGold); } int random = Global.GetRandomNumber(1, 101); if (random > PetSkillManager.JingLingChuanChengGoodsRate) { result = EPetSkillState.EnoInheritFail; } else { long returnMoHe = PetSkillManager.DelGoodsReturnLingJing(tarGoodsData); UpdateGoodsArgs tarGoodsArgs = new UpdateGoodsArgs { RoleID = client.ClientData.RoleID, DbID = tarPetID, WashProps = null }; tarGoodsArgs.ElementhrtsProps = new List <int>(); for (int loop = 0; loop < tarSkillList.Count; loop++) { PetSkillInfo info = (loop < srcSkillList.Count) ? srcSkillList[loop] : tarSkillList[loop]; tarGoodsArgs.ElementhrtsProps.Add(info.PitIsOpen ? 1 : 0); tarGoodsArgs.ElementhrtsProps.Add(info.Level); tarGoodsArgs.ElementhrtsProps.Add((loop < srcSkillList.Count) ? info.SkillID : 0); } Global.UpdateGoodsProp(client, tarGoodsData, tarGoodsArgs, true); UpdateGoodsArgs srcGoodsArgs = new UpdateGoodsArgs { RoleID = client.ClientData.RoleID, DbID = srcPetID, WashProps = null }; srcGoodsArgs.ElementhrtsProps = new List <int>(); foreach (PetSkillInfo info in srcSkillList) { srcGoodsArgs.ElementhrtsProps.Add(info.PitIsOpen ? 1 : 0); srcGoodsArgs.ElementhrtsProps.Add(1); srcGoodsArgs.ElementhrtsProps.Add(0); } Global.UpdateGoodsProp(client, srcGoodsData, srcGoodsArgs, true); GameManager.ClientMgr.ModifyMUMoHeValue(client, (int)returnMoHe, "精灵技能传承", true, true, false); if (srcGoodsData.Using > 0 || tarGoodsData.Using > 0) { PetSkillManager.UpdateRolePetSkill(client); } outProps = string.Format("{0}:{1}", string.Join <int>(",", srcGoodsArgs.ElementhrtsProps.ToArray()), string.Join <int>(",", tarGoodsArgs.ElementhrtsProps.ToArray())); result = EPetSkillState.Success; } } } return(result); }