fixed stages with robots

This commit is contained in:
rfi 2023-12-10 09:01:51 +07:00
parent 1075d70546
commit 847b3efd4a
3 changed files with 91 additions and 46 deletions

View File

@ -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, Id = NextEquipId,
TemplateId = equipId, TemplateId = equipId,
@ -207,7 +207,7 @@ namespace AscNet.Common.Database
return equipData; 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); var equip = Equips.FirstOrDefault(x => x.Id == equipId);
EquipTable? equipData = TableReaderV2.Parse<EquipTable>().FirstOrDefault(x => x.Id == equip?.TemplateId); EquipTable? equipData = TableReaderV2.Parse<EquipTable>().FirstOrDefault(x => x.Id == equip?.TemplateId);
@ -258,7 +258,7 @@ namespace AscNet.Common.Database
[BsonElement("equips")] [BsonElement("equips")]
[BsonRequired] [BsonRequired]
public List<NotifyEquipDataList.NotifyEquipDataListEquipData> Equips { get; set; } public List<EquipData> Equips { get; set; }
[BsonElement("fashions")] [BsonElement("fashions")]
[BsonRequired] [BsonRequired]
@ -305,7 +305,7 @@ namespace AscNet.Common.Database
public struct AddCharacterRet public struct AddCharacterRet
{ {
public NotifyCharacterDataList.CharacterData Character { get; set; } public NotifyCharacterDataList.CharacterData Character { get; set; }
public NotifyEquipDataList.NotifyEquipDataListEquipData Equip { get; set; } public EquipData Equip { get; set; }
public FashionList Fashion { get; set; } public FashionList Fashion { get; set; }
} }
} }

View File

@ -102,23 +102,6 @@ namespace AscNet.Common.MsgPack
public long Level { get; set; } 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> ResonanceInfo { get; set; } = new();
public List<object> UnconfirmedResonanceInfo { get; set; } = new();
public List<object> AwakeSlotList { get; set; } = new();
public bool IsLock { get; set; }
public long CreateTime { get; set; }
public bool IsRecycle { get; set; }
}
[MessagePackObject(true)] [MessagePackObject(true)]
public partial class ResonanceInfo public partial class ResonanceInfo
{ {
@ -322,7 +305,7 @@ namespace AscNet.Common.MsgPack
public List<Item> ItemList { get; set; } = new(); public List<Item> ItemList { get; set; } = new();
public Dictionary<int, List<ItemRecycleData>> ItemRecycleDict { get; set; } = new(); public Dictionary<int, List<ItemRecycleData>> ItemRecycleDict { get; set; } = new();
public List<LoginCharacterList> CharacterList { get; set; } = new(); public List<LoginCharacterList> CharacterList { get; set; } = new();
public List<EquipList> EquipList { get; set; } = new(); public List<EquipData> EquipList { get; set; } = new();
public List<FashionList> FashionList { get; set; } = new(); public List<FashionList> FashionList { get; set; } = new();
public List<HeadPortraitList> HeadPortraitList { get; set; } = new(); public List<HeadPortraitList> HeadPortraitList { get; set; } = new();
public BaseEquipLoginData BaseEquipLoginData { get; set; } public BaseEquipLoginData BaseEquipLoginData { get; set; }
@ -2428,7 +2411,7 @@ namespace AscNet.Common.MsgPack
public Boolean IsRobot { get; set; } public Boolean IsRobot { get; set; }
public Int32 CaptainIndex { get; set; } public Int32 CaptainIndex { get; set; }
public Int32 FirstFightPos { get; set; } public Int32 FirstFightPos { get; set; }
public Dictionary<dynamic, dynamic> NpcData { get; set; } public Dictionary<int, dynamic> NpcData { get; set; }
public dynamic? CustomNpc { get; set; } public dynamic? CustomNpc { get; set; }
public dynamic? AssistNpcData { get; set; } public dynamic? AssistNpcData { get; set; }
} }
@ -2647,28 +2630,27 @@ namespace AscNet.Common.MsgPack
public List<NotifyArchiveMonsterRecordMonster> Monsters { get; set; } = new(); public List<NotifyArchiveMonsterRecordMonster> 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> ResonanceInfo { get; set; } = new();
public List<dynamic> UnconfirmedResonanceInfo { get; set; } = new();
public List<dynamic> AwakeSlotList { get; set; } = new();
public Boolean IsLock { get; set; }
public UInt32 CreateTime { get; set; }
public Boolean IsRecycle { get; set; }
}
[global::MessagePack.MessagePackObject(true)] [global::MessagePack.MessagePackObject(true)]
public class NotifyEquipDataList public class NotifyEquipDataList
{ {
[global::MessagePack.MessagePackObject(true)] public List<EquipData> EquipDataList { get; set; } = new();
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<dynamic> ResonanceInfo { get; set; } = new();
public List<dynamic> UnconfirmedResonanceInfo { get; set; } = new();
public List<dynamic> AwakeSlotList { get; set; } = new();
public Boolean IsLock { get; set; }
public UInt32 CreateTime { get; set; }
public Boolean IsRecycle { get; set; }
}
public List<NotifyEquipDataListEquipData> EquipDataList { get; set; } = new();
} }

View File

@ -2,11 +2,14 @@
using AscNet.Common.MsgPack; using AscNet.Common.MsgPack;
using AscNet.Common.Util; using AscNet.Common.Util;
using AscNet.Common; 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.item;
using AscNet.Table.V2.share.reward; using AscNet.Table.V2.share.reward;
using MessagePack; using MessagePack;
using AscNet.GameServer.Handlers.Drops; 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 namespace AscNet.GameServer.Handlers
{ {
@ -138,7 +141,7 @@ namespace AscNet.GameServer.Handlers
{ {
PreFightRequest req = MessagePackSerializer.Deserialize<PreFightRequest>(packet.Content); PreFightRequest req = MessagePackSerializer.Deserialize<PreFightRequest>(packet.Content);
StageTable? stageTable = StageTableReader.Instance.FromStageId((int)req.PreFightData.StageId); StageTable? stageTable = TableReaderV2.Parse<StageTable>().Find(x => x.StageId == req.PreFightData.StageId);
if (stageTable is null) if (stageTable is null)
{ {
// FubenManagerCheckPreFightStageInfoNotFound // FubenManagerCheckPreFightStageInfoNotFound
@ -158,8 +161,8 @@ namespace AscNet.GameServer.Handlers
OnlineMode = 0, OnlineMode = 0,
Seed = (uint)Random.Shared.NextInt64(0, uint.MaxValue), Seed = (uint)Random.Shared.NextInt64(0, uint.MaxValue),
StageId = req.PreFightData.StageId, StageId = req.PreFightData.StageId,
RebootId = Miscs.ParseIntOr(stageTable.RebootId, 0), RebootId = stageTable.RebootId ?? 0,
PassTimeLimit = Miscs.ParseIntOr(stageTable.PassTimeLimit, 300), PassTimeLimit = stageTable.PassTimeLimit ?? 300,
StarsMark = 0, StarsMark = 0,
MonsterLevel = levelControl?.MonsterLevel ?? new() 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<RobotTable>().Find(x => x.Id == robotId);
if (robot is null)
continue;
CharacterSkillTable? characterSkill = TableReaderV2.Parse<CharacterSkillTable>().Find(x => x.CharacterId == robot.CharacterId);
IEnumerable<int> skills = characterSkill?.SkillGroupId.SelectMany(x => TableReaderV2.Parse<CharacterSkillGroupTable>().Find(y => y.Id == x)?.SkillId ?? new List<int>()) ?? new List<int>();
List<EquipData> 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.fight = new(req);
session.SendResponse(rsp, packet.Id); session.SendResponse(rsp, packet.Id);
} }