From 847b3efd4a334613f949586190d9fb75b918ce78 Mon Sep 17 00:00:00 2001 From: rfi Date: Sun, 10 Dec 2023 09:01:51 +0700 Subject: [PATCH] fixed stages with robots --- AscNet.Common/Database/Character.cs | 10 ++-- AscNet.Common/MsgPack/Types.cs | 56 ++++++------------ AscNet.GameServer/Handlers/FightModule.cs | 71 +++++++++++++++++++++-- 3 files changed, 91 insertions(+), 46 deletions(-) diff --git a/AscNet.Common/Database/Character.cs b/AscNet.Common/Database/Character.cs index 9dc4e47..0212c14 100644 --- a/AscNet.Common/Database/Character.cs +++ b/AscNet.Common/Database/Character.cs @@ -185,9 +185,9 @@ namespace AscNet.Common.Database }; } - public NotifyEquipDataList.NotifyEquipDataListEquipData AddEquip(uint equipId, int characterId = 0) + public EquipData AddEquip(uint equipId, int characterId = 0) { - NotifyEquipDataList.NotifyEquipDataListEquipData equipData = new() + EquipData equipData = new() { Id = NextEquipId, TemplateId = equipId, @@ -207,7 +207,7 @@ namespace AscNet.Common.Database return equipData; } - public NotifyEquipDataList.NotifyEquipDataListEquipData? AddEquipExp(int equipId, int exp) + public EquipData? AddEquipExp(int equipId, int exp) { var equip = Equips.FirstOrDefault(x => x.Id == equipId); EquipTable? equipData = TableReaderV2.Parse().FirstOrDefault(x => x.Id == equip?.TemplateId); @@ -258,7 +258,7 @@ namespace AscNet.Common.Database [BsonElement("equips")] [BsonRequired] - public List Equips { get; set; } + public List Equips { get; set; } [BsonElement("fashions")] [BsonRequired] @@ -305,7 +305,7 @@ namespace AscNet.Common.Database public struct AddCharacterRet { public NotifyCharacterDataList.CharacterData Character { get; set; } - public NotifyEquipDataList.NotifyEquipDataListEquipData Equip { get; set; } + public EquipData Equip { get; set; } public FashionList Fashion { get; set; } } } diff --git a/AscNet.Common/MsgPack/Types.cs b/AscNet.Common/MsgPack/Types.cs index 945dddf..f0d8828 100644 --- a/AscNet.Common/MsgPack/Types.cs +++ b/AscNet.Common/MsgPack/Types.cs @@ -102,23 +102,6 @@ namespace AscNet.Common.MsgPack public long Level { get; set; } } - [MessagePackObject(true)] - public partial class EquipList - { - public long Id { get; set; } - public long TemplateId { get; set; } - public long CharacterId { get; set; } - public long Level { get; set; } - public long Exp { get; set; } - public long Breakthrough { get; set; } - public List ResonanceInfo { get; set; } = new(); - public List UnconfirmedResonanceInfo { get; set; } = new(); - public List AwakeSlotList { get; set; } = new(); - public bool IsLock { get; set; } - public long CreateTime { get; set; } - public bool IsRecycle { get; set; } - } - [MessagePackObject(true)] public partial class ResonanceInfo { @@ -322,7 +305,7 @@ namespace AscNet.Common.MsgPack public List ItemList { get; set; } = new(); public Dictionary> ItemRecycleDict { get; set; } = new(); public List CharacterList { get; set; } = new(); - public List EquipList { get; set; } = new(); + public List EquipList { get; set; } = new(); public List FashionList { get; set; } = new(); public List HeadPortraitList { get; set; } = new(); public BaseEquipLoginData BaseEquipLoginData { get; set; } @@ -2428,7 +2411,7 @@ namespace AscNet.Common.MsgPack public Boolean IsRobot { get; set; } public Int32 CaptainIndex { get; set; } public Int32 FirstFightPos { get; set; } - public Dictionary NpcData { get; set; } + public Dictionary NpcData { get; set; } public dynamic? CustomNpc { get; set; } public dynamic? AssistNpcData { get; set; } } @@ -2647,28 +2630,27 @@ namespace AscNet.Common.MsgPack public List Monsters { get; set; } = new(); } + [global::MessagePack.MessagePackObject(true)] + public class EquipData + { + public UInt32 Id { get; set; } + public UInt32 TemplateId { get; set; } + public Int32 CharacterId { get; set; } + public Int32 Level { get; set; } + public Int32 Exp { get; set; } + public Int32 Breakthrough { get; set; } + public List ResonanceInfo { get; set; } = new(); + public List UnconfirmedResonanceInfo { get; set; } = new(); + public List AwakeSlotList { get; set; } = new(); + public Boolean IsLock { get; set; } + public UInt32 CreateTime { get; set; } + public Boolean IsRecycle { get; set; } + } [global::MessagePack.MessagePackObject(true)] public class NotifyEquipDataList { - [global::MessagePack.MessagePackObject(true)] - public class NotifyEquipDataListEquipData - { - public UInt32 Id { get; set; } - public UInt32 TemplateId { get; set; } - public Int32 CharacterId { get; set; } - public Int32 Level { get; set; } - public Int32 Exp { get; set; } - public Int32 Breakthrough { get; set; } - public List ResonanceInfo { get; set; } = new(); - public List UnconfirmedResonanceInfo { get; set; } = new(); - public List AwakeSlotList { get; set; } = new(); - public Boolean IsLock { get; set; } - public UInt32 CreateTime { get; set; } - public Boolean IsRecycle { get; set; } - } - - public List EquipDataList { get; set; } = new(); + public List EquipDataList { get; set; } = new(); } diff --git a/AscNet.GameServer/Handlers/FightModule.cs b/AscNet.GameServer/Handlers/FightModule.cs index ac7e0af..c8b5802 100644 --- a/AscNet.GameServer/Handlers/FightModule.cs +++ b/AscNet.GameServer/Handlers/FightModule.cs @@ -2,11 +2,14 @@ using AscNet.Common.MsgPack; using AscNet.Common.Util; using AscNet.Common; -using AscNet.Table.share.fuben; +using AscNet.Table.V2.share.fuben; using AscNet.Table.V2.share.item; using AscNet.Table.V2.share.reward; using MessagePack; using AscNet.GameServer.Handlers.Drops; +using AscNet.Table.V2.share.robot; +using static AscNet.Common.MsgPack.NotifyCharacterDataList; +using AscNet.Table.V2.share.character.skill; namespace AscNet.GameServer.Handlers { @@ -138,7 +141,7 @@ namespace AscNet.GameServer.Handlers { PreFightRequest req = MessagePackSerializer.Deserialize(packet.Content); - StageTable? stageTable = StageTableReader.Instance.FromStageId((int)req.PreFightData.StageId); + StageTable? stageTable = TableReaderV2.Parse().Find(x => x.StageId == req.PreFightData.StageId); if (stageTable is null) { // FubenManagerCheckPreFightStageInfoNotFound @@ -158,8 +161,8 @@ namespace AscNet.GameServer.Handlers OnlineMode = 0, Seed = (uint)Random.Shared.NextInt64(0, uint.MaxValue), StageId = req.PreFightData.StageId, - RebootId = Miscs.ParseIntOr(stageTable.RebootId, 0), - PassTimeLimit = Miscs.ParseIntOr(stageTable.PassTimeLimit, 300), + RebootId = stageTable.RebootId ?? 0, + PassTimeLimit = stageTable.PassTimeLimit ?? 300, StarsMark = 0, MonsterLevel = levelControl?.MonsterLevel ?? new() } @@ -191,6 +194,66 @@ namespace AscNet.GameServer.Handlers } } + if (req.PreFightData?.CardIds is null || (req.PreFightData.CardIds.Count + stageTable.RobotId.Count) == 3) + { + int npcKey = rsp.FightData.RoleData.First(x => x.Id == session.player.PlayerData.Id).NpcData.Keys.Count; + foreach (var robotId in stageTable.RobotId) + { + RobotTable? robot = TableReaderV2.Parse().Find(x => x.Id == robotId); + if (robot is null) + continue; + + CharacterSkillTable? characterSkill = TableReaderV2.Parse().Find(x => x.CharacterId == robot.CharacterId); + IEnumerable skills = characterSkill?.SkillGroupId.SelectMany(x => TableReaderV2.Parse().Find(y => y.Id == x)?.SkillId ?? new List()) ?? new List(); + List equips = new() + { + new() + { + TemplateId = (uint)robot.WeaponId, + Level = robot.WeaponLevel, + Breakthrough = robot.WeaponBeakThrough, + } + }; + + for (int i = 0; i < robot.WaferId.Count; i++) + { + equips.Add(new() + { + TemplateId = (uint)robot.WaferId[i], + Level = robot.WaferLevel[i], + Breakthrough = robot.WaferBreakThrough[i] + }); + } + + rsp.FightData.RoleData.First(x => x.Id == session.player.PlayerData.Id).NpcData.Add(npcKey, new + { + Character = new CharacterData() + { + Id = (uint)robot.CharacterId, + Level = robot.CharacterLevel, + Exp = 0, + Quality = robot.CharacterQuality, + InitQuality = robot.CharacterQuality, + Star = robot.CharacterStar, + Grade = robot.CharacterGrade, + SkillList = skills.Where(x => robot.RemoveSkillId.Contains(x)).Select(x => new CharacterData.CharacterSkill() { Id = (uint)x, Level = robot.SkillLevel}).ToList(), + FashionId = (uint)robot.FashionId, + CreateTime = 0, + TrustLv = 1, + TrustExp = 0, + Ability = robot.ShowAbility ?? 0, + LiberateLv = robot.LiberateLv ?? 0, + CharacterHeadInfo = new() + { + HeadFashionId = (uint)robot.FashionId + } + }, + Equips = equips + }); + npcKey++; + } + } + session.fight = new(req); session.SendResponse(rsp, packet.Id); }