//回答题目 result=0:错误 1:正确 public ErrorCodes AnswerQuestion(CharacterController character, bool result, QuestionMessage msg) { var hour = DateTime.Now.Hour; if (hour < AnswerQuestions.BeginTime || hour >= AnswerQuestions.EndTime) { return(ErrorCodes.Error_AnswerNotTime); } var qIndex = character.GetExData(436); //当前题目索引 if (qIndex >= AnswerQuestions.MaxQuestionCount) { msg.QuestionId = -1; return(ErrorCodes.OK); } if (result) { character.AddExData(437, 1); //正确奖励 var addExp = (int) (AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.ExpParam * Table.GetLevelData(character.GetLevel()).DynamicExp); character.AddExData(66, addExp); character.mBag.AddItem(1, addExp, eCreateItemType.AnswerQuestion); var addMoney = (int)(AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.MoneyCount); character.AddExData(67, addMoney); character.mBag.AddItem(2, addMoney, eCreateItemType.AnswerQuestion); } else { //错误奖励 var addExp = (int) (AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.ExpParam * Table.GetLevelData(character.GetLevel()).DynamicExp *AnswerQuestions.ErrorResCount); character.AddExData(66, addExp); character.mBag.AddItem(1, addExp, eCreateItemType.AnswerQuestion); var addMoney = (int) (AnswerQuestions.ModifyReward[qIndex] * AnswerQuestions.MoneyCount * AnswerQuestions.ErrorResCount); character.AddExData(67, addMoney); character.mBag.AddItem(2, addMoney, eCreateItemType.AnswerQuestion); } qIndex = qIndex + 1; character.SetExData(436, qIndex); //当前题目索引+1 var nextExdataId = qIndex - 1 + 459; var nextQ = RandomQuestion(character, qIndex); //int nextQ = character.RandomQuestion(qIndex); character.SetExData(nextExdataId, nextQ); GetQuestionData(msg, nextQ); return(ErrorCodes.OK); }
//精灵分解 public ErrorCodes ResolveElf(CharacterController character, int bagIndex, ref ulong resolveValue) { var item = character.GetItemByBagByIndex((int)eBagType.Elf, bagIndex) as ElfItem; if (item == null) { return(ErrorCodes.Error_ItemNotFind); } var tbElf = Table.GetElf(item.GetId()); if (tbElf == null) { return(ErrorCodes.Error_ElfNotFind); } if (item.GetIndex() < MaxElfFightCount) { return(ErrorCodes.Error_ElfAlreadyBattle); } var oldLevel = item.GetExdata(0); resolveValue = (ulong)CalcResolveElf(tbElf.Id, oldLevel, item.GetStarLevel()); character.mBag.AddRes(eResourcesType.ElfPiece, (int)resolveValue, eCreateItemType.ResolveElf); character.mBag.mBags[(int)eBagType.Elf].ReduceCountByIndex(bagIndex, 1, eDeleteItemType.ResolveElf); character.AddExData((int)eExdataDefine.e327, 1); ResolveElfLog(character, 1); return(ErrorCodes.OK); }
//增加玩家装备位置上的强化继承价值 private void AddEquipTypeEnchanceValue(CharacterController character, int nType, int nValue) { var nIndex = nType - 9900; character.AddExData(nIndex, nValue); //switch (nType) //{ // case 10000: // case 10001: // case 10002: // case 10003: // case 10004: // case 10005: // case 10006: // case 10007: // case 10008: // case 10009: // case 10010: // case 10011: // case 10012: // case 10013: // { // } // break; // default: // break; //} }
//给予P1vP1胜利奖励 public void GiveP1vP1Win(CharacterController character, int rank, Dictionary <int, int> items, int level = 0) { if (character != null) { level = character.GetLevel(); } ArenaLevelRecord tbAl = null; Table.ForeachArenaLevel(record => { if (level <= record.Id) { tbAl = record; return(false); } return(true); }); if (tbAl == null) { Logger.Error("GiveP1vP1Win not find ArenaLevel rank={0}", rank); return; } if (character != null) { character.mBag.AddExp(tbAl.SuccessExp, eCreateItemType.P1vP1Win); character.mBag.AddRes(eResourcesType.GoldRes, tbAl.SuccessMoney, eCreateItemType.P1vP1Win); character.mBag.AddItem(tbAl.SuccessItemID, tbAl.SuccessCount, eCreateItemType.P1vP1Win); character.AddExData((int)eExdataDefine.e49, 1); //character.mCity.CityAddExp(tbAl.SuccessGetExp); } items[(int)eResourcesType.ExpRes] = tbAl.SuccessExp; items[(int)eResourcesType.GoldRes] = tbAl.SuccessMoney; //items[(int) eResourcesType.HomeExp] = tbAl.SuccessGetExp; items[tbAl.SuccessItemID] = tbAl.SuccessCount; }
public ErrorCodes ResolveElfList(CharacterController character, List <int> bagIndexList, ref int resolveGet) { var error = ErrorCodes.OK; var count = 0; var resolveValue = 0; for (var i = 0; i < bagIndexList.Count; ++i) { var bagIndex = bagIndexList[i]; if (bagIndex < 3) { continue; } var item = character.GetItemByBagByIndex((int)eBagType.Elf, bagIndex) as ElfItem; if (item == null) { error = ErrorCodes.Error_ItemNotFind; break; } var tbElf = Table.GetElf(item.GetId()); if (tbElf == null) { error = ErrorCodes.Error_ElfNotFind; break; } if (item.GetIndex() < MaxElfFightCount) { error = ErrorCodes.Error_ElfAlreadyBattle; break; } var oldLevel = item.GetExdata(0); resolveValue += CalcResolveElf(tbElf.Id, oldLevel, item.GetStarLevel()); character.mBag.mBags[(int)eBagType.Elf].ReduceCountByIndex(bagIndex, 1, eDeleteItemType.ResolveElf); ++count; } if (count > 0) { character.mBag.AddRes(eResourcesType.ElfPiece, resolveValue, eCreateItemType.ResolveElf); character.AddExData((int)eExdataDefine.e327, count); ResolveElfLog(character, count); } resolveGet = resolveValue; return(error); }
public ErrorCodes ComposeItem(CharacterController character, int id, int count, ref int rewardId) { var tbCompose = Table.GetItemCompose(id); if (tbCompose == null) { return(ErrorCodes.Error_ItemComposeID); } //黄金检查 if (tbCompose.NeedRes > 0 && tbCompose.NeedRes < 10) { if (character.mBag.GetRes((eResourcesType)tbCompose.NeedRes) < tbCompose.NeedValue * count) { return(ErrorCodes.MoneyNotEnough); } } //物品数量检查 for (var i = 0; i != tbCompose.NeedId.Length; ++i) { var itemId = tbCompose.NeedId[i]; var itemCount = tbCompose.NeedCount[i] * count; if (itemId == -1) { continue; } if (character.mBag.GetItemCount(itemId) < itemCount) { return(ErrorCodes.ItemNotEnough); } } //奖励物品 var items = new Dictionary <int, int>(); var RewardId = -1; for (var i = 0; i != count; ++i) { var r = MyRandom.Random(10000); var tr = 0; for (var j = 0; j != 8; ++j) { tr += tbCompose.ProId[j]; if (r < tr) { RewardId = tbCompose.ComposeId[j]; items.Add(tbCompose.ComposeId[j], count); break; } } } //包裹空位是否足够 //ErrorCodes result= BagManager.CheckAddItemList(character.mBag, items); var result = character.mBag.CheckAddItem(RewardId, count); if (result != ErrorCodes.OK) { return(result); } //执行 if (tbCompose.NeedRes > 0 && tbCompose.NeedRes < 10) { character.mBag.DeleteItem(tbCompose.NeedRes, tbCompose.NeedValue * count, eDeleteItemType.Compose); } for (var i = 0; i != tbCompose.NeedId.Length; ++i) { var itemId = tbCompose.NeedId[i]; var itemCount = tbCompose.NeedCount[i] * count; if (itemId == -1) { continue; } character.mBag.DeleteItem(itemId, itemCount, eDeleteItemType.Compose); } var isTrue = false; if (character.GetExData((int)eExdataDefine.e342) == 0) { isTrue = true; } else { var pro = tbCompose.Pro /*+ character.mCity.GetComposePro()*/; if (MyRandom.Random(10000) < pro) { isTrue = true; } } if (isTrue) { character.mBag.AddItem(RewardId, count, eCreateItemType.Compose); rewardId = RewardId; var e = new ComposeItemEvent(character, id, RewardId); EventDispatcher.Instance.DispatchEvent(e); character.BroadCastGetEquip(RewardId, 100002167); /* * var build = character.mCity.GetBuildByType((int) BuildingType.CompositeHouse); * if (build != null) * { * build.GiveReward(407, 1, build.TbBs, 121, eCreateItemType.Compose); * var addexp = build.TbBs.Param[2]; * var okCount = character.GetExData((int) eExdataDefine.e556); * if (okCount < build.TbBs.Param[3]) * { * character.mCity.CityAddExp(addexp); * character.AddExData((int) eExdataDefine.e556, 1); * } * } * */ } //var build=character.mCity.GetBuildByType((int) BuildingType.CompositeHouse); character.AddExData((int)eExdataDefine.e342, 1); character.AddExData((int)eExdataDefine.e415, 1); return(ErrorCodes.OK); }
//给予奖励 public ErrorCodes GiveGift(CharacterController character, eActivationRewardType type, int giftId) { var result = ErrorCodes.OK; switch (type) { case eActivationRewardType.TableGift: { var tbGift = Table.GetGift(giftId); if (tbGift == null) { return(ErrorCodes.Error_GiftID); } if (character.GetFlag(tbGift.Flag)) { return(ErrorCodes.Error_GiftAlreadyReceive); } //执行领取 switch ((eRewardType)tbGift.Type) { //固定礼包 case eRewardType.GiftBag: { //Dictionary<int, int> items = new Dictionary<int, int>(); for (var i = 0; i != 4; ++i) { if (tbGift.Param[i * 2] != -1) { character.mBag.AddItem(tbGift.Param[i * 2], tbGift.Param[i * 2 + 1], eCreateItemType.Gift); } } } break; //在线时长 case eRewardType.OnlineReward: { result = character.mBag.AddItem(tbGift.Param[1], tbGift.Param[2], eCreateItemType.Online); } break; //等级奖励 case eRewardType.LevelReward: { for (var i = 1; i <= 5; ++i) { var count = tbGift.Param[i + 5]; if (tbGift.Param[i] != -1) { character.mBag.AddItem(tbGift.Param[i], count, eCreateItemType.LevelUp); } } } break; //连续登陆 case eRewardType.ContinuesLoginReward: { //result = character.mBag.AddItem(tbGift.Param[1], tbGift.Param[2]); var days = character.GetExData(17); if (days > 5) { days = 5; } for (var i = 0; i < days; ++i) { var tbGift2 = Table.GetGift(13 + i); if (character.GetFlag(tbGift2.Flag)) { continue; } character.mBag.AddItem(tbGift2.Param[1], tbGift2.Param[2], eCreateItemType.ContinueDay); character.SetFlag(tbGift2.Flag); } return(ErrorCodes.OK); } //签到 case eRewardType.MonthCheckinReward: { if (character.GetFlag(466)) { //补签 var SupplementCount = character.GetExData(18); var needGold = (int) (tbGift.Param[4] * SkillExtension.Pow(tbGift.Param[5] / 10000.0f, SupplementCount)); needGold = needGold - needGold % 5; character.mBag.DeleteItem((int)eResourcesType.DiamondRes, needGold, eDeleteItemType.ReSign); character.SetExData(18, SupplementCount + 1); character.AddExData(tbGift.Exdata, 1); result = character.mBag.AddItem(tbGift.Param[2], tbGift.Param[3], eCreateItemType.ReSign); } else { //签到 character.SetFlag(466); character.AddExData(tbGift.Exdata, 1); result = character.mBag.AddItem(tbGift.Param[2], tbGift.Param[3], eCreateItemType.Sign); } } break; ////每日活跃度 //case eRewardType.DailyActivity: // { // character.AddExData(tbGift.Param[3], tbGift.Param[0]); // } // break; //每日活跃奖励 case eRewardType.DailyActivityReward: { result = character.mBag.AddItem(tbGift.Param[0], tbGift.Param[1], eCreateItemType.Activity); } break; //七天登录奖励 case eRewardType.SevenDayReward: { for (var i = 0; i != 3; i++) { character.mBag.AddItem(tbGift.Param[i * 2 + 1], tbGift.Param[i * 2 + 2], eCreateItemType.SevenDayReward); } character.mBag.AddItem(tbGift.Param[7], tbGift.Param[8], eCreateItemType.SevenDayReward); character.SetFlag(tbGift.Flag); } break; default: Logger.Warn("Gift[{0}] type is overflow", giftId); break; } if (result == ErrorCodes.OK) { character.SetFlag(tbGift.Flag); } } break; case eActivationRewardType.DailyVipGift: { var vipLevel = character.mBag.GetRes(eResourcesType.VipLevel); var tbVip = Table.GetVIP(vipLevel); Dictionary <int, int> dic = new Dictionary <int, int>(); Utils.GetVipReward(vipLevel, ref dic); if (dic.Count == 0) { return(ErrorCodes.Error_NoVipGift); } var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_VipGiftGained); } result = BagManager.CheckAddItemList(character.mBag, dic); if (result != ErrorCodes.OK) { return(result); } character.SetFlag(flag); result = character.mBag.AddItems(dic, eCreateItemType.DailyVipGift); } break; case eActivationRewardType.MonthCard: { var diaCount = Table.GetServerConfig(419).ToInt(); result = character.mBag.AddRes(eResourcesType.DiamondRes, diaCount, eCreateItemType.MonthCard); var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_MonthCardGained); } character.SetFlag(flag); character.SetFlag(tbDA.CommonParam[0]); character.AddExData((int)eExdataDefine.e778, 1); } break; case eActivationRewardType.WeekCard: { var tbRecharge = Table.GetRecharge(43); var diaCount = tbRecharge.Param[0]; //策划配置到此列 result = character.mBag.AddRes(eResourcesType.DiamondRes, diaCount, eCreateItemType.WeekCard); var tbDA = Table.GetDailyActivity(giftId); var flag = tbDA.CommonParam[0]; if (character.GetFlag(flag)) { return(ErrorCodes.Error_WeekCardGained); } character.SetFlag(flag); character.AddExData((int)eExdataDefine.e779, 1); } break; case eActivationRewardType.LifeCard: { var tbRecharge = Table.GetRecharge(giftId); if (null == tbRecharge) { return(ErrorCodes.Error_GiftID); } var flagId = tbRecharge.Param[2]; if (character.GetFlag(flagId)) { return(ErrorCodes.Error_LifeCardGained); } var diaCount = tbRecharge.Param[0]; result = character.mBag.AddRes(eResourcesType.DiamondRes, diaCount, eCreateItemType.LifeCard); if (result == ErrorCodes.OK) { character.SetFlag(flagId); } else { return(result); } } break; } return(result); }
//掉落母表 public void DropMother(CharacterController character, int nId, Dictionary <int, int> Droplist) { var tbdropmo = Table.GetDropMother(nId); if (tbdropmo == null) { return; } //惊喜掉落 if (tbdropmo.SurprisePro > 0 && tbdropmo.SurpriseDrop >= 0) { if (MyRandom.Random(10000) < tbdropmo.SurprisePro) { //走惊喜掉落 Logger.Info("DropMother Surprise={0}", nId); character.DropSon(nId, Droplist); return; } } //计数掉落 if (tbdropmo.ExdataId >= 0 && tbdropmo.ExdataCount > 0 && tbdropmo.ExdataDropId >= 0) { character.AddExData(tbdropmo.ExdataId, 1); if (character.GetExData(tbdropmo.ExdataId) >= tbdropmo.ExdataCount) { //累积掉落 Logger.Info("DropMother Exdata={0}", nId); character.SetExData(tbdropmo.ExdataId, 0); character.DropMother(tbdropmo.ExdataDropId, Droplist); return; } } //正常掉落 var Grouplist = new Dictionary <int, int>(); for (var i = 0; i != tbdropmo.DropSon.Length; ++i) { var GroupId = tbdropmo.Group[i]; if (GroupId == -1) { //单独组 if (tbdropmo.Pro[i] > 0 && tbdropmo.DropSon[i] >= 0) { if (tbdropmo.DropMin[i] < 1 || tbdropmo.DropMax[i] < tbdropmo.DropMin[i]) { Logger.Error("DropMother DropSon={0},Index={1},Min={2},Max={3}", nId, i, tbdropmo.DropMin[i], tbdropmo.DropMax[i]); continue; } var nCount = MyRandom.Random(tbdropmo.DropMin[i], tbdropmo.DropMax[i]); Logger.Info("DropMother DropSon={0},DropSon={1},Count={2}", nId, tbdropmo.DropSon[i], nCount); for (var j = 0; j != nCount; ++j) { character.DropSon(tbdropmo.DropSon[i], Droplist); } } } else { int pro; if (!Grouplist.TryGetValue(GroupId, out pro)) { pro = MyRandom.Random(10000); Grouplist[GroupId] = pro; } if (pro <= 0) { continue; } if (pro <= tbdropmo.Pro[i]) { //随机中了 var nCount = tbdropmo.DropMin[i]; if (nCount < 0 || nCount > tbdropmo.DropMax[i]) { Logger.Error("DropMother CountError DropId={0},Group={1},Index={2},DropSon={3}", nId, GroupId, i, tbdropmo.DropSon[i]); return; } if (tbdropmo.DropMin[i] < tbdropmo.DropMax[i]) { nCount = MyRandom.Random(tbdropmo.DropMin[i], tbdropmo.DropMax[i]); } Logger.Info("DropMother DropId={0},Group={1},Index={2},DropSon={3},Count={4}", nId, GroupId, i, tbdropmo.DropSon[i], nCount); for (var j = 0; j != nCount; ++j) { character.DropSon(tbdropmo.DropSon[i], Droplist); } } Grouplist[GroupId] = pro - tbdropmo.Pro[i]; } } }
static WeightRandom wRandom = new WeightRandom();//加权随机函数 //翅膀升阶(成长和突破) public ErrorCodes WingFormation(CharacterController character, ref int result) { var wing = character.GetWing(); if (wing == null) { return(ErrorCodes.Error_WingNotFind); } var tbWing = Table.GetWingQuality(wing.GetId()); if (tbWing == null) { return(ErrorCodes.Error_WingID); } //进阶最大等级 if (tbWing.Segment == WingQualityMax) { return(ErrorCodes.Error_WingLevelMax); } //玩家等级 if (character.GetLevel() < tbWing.LevelLimit) { return(ErrorCodes.Error_LevelNoEnough); } var needGold = 0; var needItemId = -1; var needItemCount = 0; var isBreak = (wing.GetGrowValue() >= tbWing.GrowProgress); if (isBreak) { // 突破 if (tbWing.Segment + 1 >= 4) { var item = Table.GetItemBase(wing.GetId() + 1); if (null == item) { return(ErrorCodes.Error_WingID); } var args = new List <string> { Utils.AddCharacter(character.mGuid, character.GetName()), (tbWing.Segment + 1).ToString(), item.Name, }; var exExdata = new List <int>(); character.SendSystemNoticeInfo(291000, args, exExdata); } needItemId = tbWing.BreakNeedItem; needItemCount = tbWing.BreakNeedCount; needGold = tbWing.BreakNeedMoney; } else { // 成长 needItemId = tbWing.MaterialNeed; needItemCount = tbWing.MaterialCount; needGold = tbWing.UsedMoney; } //材料判断 if (character.mBag.GetItemCount(needItemId) < needItemCount) { return(ErrorCodes.ItemNotEnough); } if (character.mBag.GetRes(eResourcesType.GoldRes) < needGold) { return(ErrorCodes.MoneyNotEnough); } //消耗 character.mBag.DeleteItem(needItemId, needItemCount, eDeleteItemType.WingFormation); character.mBag.DeleteItem((int)eResourcesType.GoldRes, needGold, eDeleteItemType.WingFormation); if (isBreak) { // 突破 character.SetRankFlag(RankType.WingsFight); wing.SetId(tbWing.Id + 1); wing.SetGrowValue(0); wing.ClearGrowProperty(); wing.MarkDirty(); character.EquipChange(2, (int)eBagType.Wing, 0, wing); character.AddExData((int)eExdataDefine.e308, 1); result = 1; } else { // 成长属性 character.SetRankFlag(RankType.WingsFight); var curValue = System.Math.Min(wing.GetGrowValue() + tbWing.GrowAddValue, tbWing.GrowProgress); wing.SetGrowValue(curValue); for (var i = 0; i < tbWing.GrowPropID.Length; ++i) { var attrId = tbWing.GrowPropID[i]; var minProp = tbWing.GrowMinProp[i]; var maxProp = tbWing.GrowMaxProp[i]; if (attrId > 0 && minProp > 0 && maxProp > 0) { var prop = MyRandom.Random(minProp, maxProp); wing.SetGrowProperty(attrId, prop); } } character.EquipChange(2, (int)eBagType.Wing, 0, wing); wing.MarkDirty(); result = 0; } try { character.mOperActivity.OnWingFormation(); } catch (Exception e) { Logger.Fatal("OnWingFormation {0}\n{1}", e, e.Message); throw; } try { var klog = string.Format("wingadvance#{0}|{1}|{2}|{3}|{4}|{5}", character.mGuid, character.GetLevel(), character.serverId, tbWing.Segment, isBreak ? (tbWing.Segment + 1) : tbWing.Segment, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); PlayerLog.Kafka(klog, 2); } catch (Exception e) { Logger.Error(e.Message); } return(ErrorCodes.OK); }
//翅膀培养 public ErrorCodes WingTrain(CharacterController character, int _type, ref int result) { int type = 0;//永远都用部位0 //数据溢出 if (type < 0 || type >= 5) { return(ErrorCodes.Error_DataOverflow); } //查询翅膀 var wing = character.GetWing(); if (wing == null) { return(ErrorCodes.Error_WingNotFind); } //表格取值 var tbWing = Table.GetWingQuality(wing.GetId()); if (tbWing == null) { return(ErrorCodes.Error_WingID); } //获取类型ID var typeId = wing.GetTypeId(type); var tbWingTrain = Table.GetWingTrain(typeId); if (tbWingTrain == null) { Logger.Error("EnchanceFormation Id={0}", typeId); return(ErrorCodes.Unknow); } //这个类型的培养是否到头了 if (tbWingTrain.UpStarID == -1) { return(ErrorCodes.Error_WingTypeLevelMax); } //需求翅膀阶段等级 if (tbWingTrain.Condition > tbWing.Segment) { return(ErrorCodes.Error_NeedWingLevelMore); } //材料判断 if (character.mBag.GetItemCount(tbWingTrain.MaterialID) < tbWingTrain.MaterialCount) { return(ErrorCodes.ItemNotEnough); } if (character.mBag.GetRes(eResourcesType.GoldRes) < tbWingTrain.UsedMoney) { return(ErrorCodes.MoneyNotEnough); } //消耗 character.mBag.DeleteItem(tbWingTrain.MaterialID, tbWingTrain.MaterialCount, eDeleteItemType.WingTrain); character.mBag.DeleteItem((int)eResourcesType.GoldRes, tbWingTrain.UsedMoney, eDeleteItemType.WingTrain); //经验计算 var NowExp = wing.GetExp(type); wRandom.Clear(); wRandom.AddTargets(new WeightRandomItem() { Index = -1, Target = tbWingTrain.AddExp, Weight = tbWingTrain.CommonProb }); for (int i = 0; i < tbWingTrain.CritAddExp.Length; i++) { wRandom.AddTargets(new WeightRandomItem() { Index = i, Target = tbWingTrain.CritAddExp[i], Weight = tbWingTrain.CritProb[i] }); } wRandom.Ready(); WeightRandomItem resWR = wRandom.Random(); NowExp += Convert.ToInt32(resWR.Target); result = resWR.Index + 1;//0.普通,1.暴击1,2.暴击2,3.暴击3 //if (MyRandom.Random(10000) < tbWingTrain.CritProb) //{ // NowExp += tbWingTrain.CritAddExp; // result = 1; //} //else //{ // NowExp += tbWingTrain.AddExp; // result = 0; //} //升级计算 var oldId = tbWingTrain.Id; var oldTrainCount = tbWingTrain.TrainCount; var newId = -1; var levelup = 0; while (NowExp >= tbWingTrain.ExpLimit) { levelup++; if (tbWingTrain.UpStarID == -1) { NowExp = 0; break; } NowExp -= tbWingTrain.ExpLimit; tbWingTrain = Table.GetWingTrain(tbWingTrain.UpStarID); if (tbWingTrain == null) { break; } } if (tbWingTrain != null) { newId = tbWingTrain.Id; } //计算升级 if (levelup > 0) { character.SetRankFlag(RankType.WingsFight); wing.SetTypeId(type, tbWingTrain.Id); character.EquipChange(2, (int)eBagType.Wing, 0, wing); var newTrainCount = tbWingTrain.TrainCount; for (int upCount = oldTrainCount; upCount < newTrainCount; upCount++) { character.AddExData((int)eExdataDefine.e679, 1); } } character.AddExData((int)eExdataDefine.e326, 1); character.AddExData((int)eExdataDefine.e419, 1); wing.SetExp(type, NowExp); wing.MarkDbDirty(); try { character.mOperActivity.OnWingTrainEvent(); } catch (Exception e) { Logger.Fatal("OnWingFormation {0}\n{1}", e, e.Message); throw; } try { var klog = string.Format("wingtrain#{0}|{1}|{2}|{3}|{4}|{5}|{6}", character.mGuid, character.GetLevel(), character.serverId, type, oldId, newId, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); PlayerLog.Kafka(klog, 2); } catch (Exception e) { Logger.Error(e.Message); } return(ErrorCodes.OK); }