From 13b4f4899acab6b118450d8e48b8d39c3ee98a0b Mon Sep 17 00:00:00 2001 From: Somebody Date: Tue, 13 Aug 2024 21:42:22 +0800 Subject: [PATCH] Build Structure for Divergent Universe --- Common/Data/Excel/RogueBuffGroupExcel.cs | 14 +- Common/Data/Excel/RogueTournAreaExcel.cs | 39 ++++ Common/Data/Excel/RogueTournBuffExcel.cs | 28 +++ Common/Data/Excel/RogueTournBuffGroupExcel.cs | 53 +++++ .../Excel/RogueTournDifficultyCompExcel.cs | 18 ++ Common/Data/Excel/RogueTournFormulaExcel.cs | 39 ++++ .../Excel/RogueTournHandBookEventExcel.cs | 17 ++ .../Excel/RogueTournHandbookMiracleExcel.cs | 18 ++ .../Excel/RogueTournHexAvatarBaseTypeExcel.cs | 17 ++ .../Excel/RogueTournPermanentTalentExcel.cs | 18 ++ Common/Data/GameData.cs | 14 ++ Common/Data/ResourceManager.cs | 212 +++++++++--------- .../TournRogue/RogueFormulaCategoryEnum.cs | 10 + .../TournRogue/RogueTournAreaGroupIDEnum.cs | 9 + .../RogueTournDifficultyTypeEnum.cs | 11 + Common/Enums/TournRogue/RogueTournModeEnum.cs | 8 + GameServer/Game/Challenge/ChallengeManager.cs | 32 +-- GameServer/Game/Player/PlayerInstance.cs | 3 + .../Game/RogueTourn/RogueTournManager.cs | 131 +++++++++++ .../HandlerGetRogueCollectionCsReq.cs | 12 + ...dlerRogueTournGetArchiveRepositoryCsReq.cs | 12 + ...erRogueTournGetPermanentTalentInfoCsReq.cs | 13 ++ .../RogueTourn/HandlerRogueTournQueryCsReq.cs | 13 ++ ...etRogueTournGetPermanentTalentInfoScRsp.cs | 19 ++ .../RogueTourn/PacketRogueTournQueryScRsp.cs | 18 ++ 25 files changed, 642 insertions(+), 136 deletions(-) create mode 100644 Common/Data/Excel/RogueTournAreaExcel.cs create mode 100644 Common/Data/Excel/RogueTournBuffExcel.cs create mode 100644 Common/Data/Excel/RogueTournBuffGroupExcel.cs create mode 100644 Common/Data/Excel/RogueTournDifficultyCompExcel.cs create mode 100644 Common/Data/Excel/RogueTournFormulaExcel.cs create mode 100644 Common/Data/Excel/RogueTournHandBookEventExcel.cs create mode 100644 Common/Data/Excel/RogueTournHandbookMiracleExcel.cs create mode 100644 Common/Data/Excel/RogueTournHexAvatarBaseTypeExcel.cs create mode 100644 Common/Data/Excel/RogueTournPermanentTalentExcel.cs create mode 100644 Common/Enums/TournRogue/RogueFormulaCategoryEnum.cs create mode 100644 Common/Enums/TournRogue/RogueTournAreaGroupIDEnum.cs create mode 100644 Common/Enums/TournRogue/RogueTournDifficultyTypeEnum.cs create mode 100644 Common/Enums/TournRogue/RogueTournModeEnum.cs create mode 100644 GameServer/Game/RogueTourn/RogueTournManager.cs create mode 100644 GameServer/Server/Packet/Recv/RogueTourn/HandlerGetRogueCollectionCsReq.cs create mode 100644 GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetArchiveRepositoryCsReq.cs create mode 100644 GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetPermanentTalentInfoCsReq.cs create mode 100644 GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournQueryCsReq.cs create mode 100644 GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournGetPermanentTalentInfoScRsp.cs create mode 100644 GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournQueryScRsp.cs diff --git a/Common/Data/Excel/RogueBuffGroupExcel.cs b/Common/Data/Excel/RogueBuffGroupExcel.cs index 9a6cfaa9..92e66afc 100644 --- a/Common/Data/Excel/RogueBuffGroupExcel.cs +++ b/Common/Data/Excel/RogueBuffGroupExcel.cs @@ -34,8 +34,8 @@ public class RogueBuffGroupExcel : ExcelResource { if (IsLoaded) return; var count = 0; - foreach (var buffID in BuffTagList) - if (GameData.RogueBuffData.FirstOrDefault(x => x.Value.RogueBuffTag == buffID).Value is RogueBuffExcel buff) + foreach (var buffId in BuffTagList) + if (GameData.RogueBuffData.FirstOrDefault(x => x.Value.RogueBuffTag == buffId).Value is RogueBuffExcel buff) { BuffList.SafeAdd(buff); count++; @@ -43,12 +43,10 @@ public class RogueBuffGroupExcel : ExcelResource else { // might is group id - if (GameData.RogueBuffGroupData.TryGetValue(buffID, out var group)) - { - group.LoadBuff(); - BuffList.SafeAddRange(group.BuffList); - count++; - } + if (!GameData.RogueBuffGroupData.TryGetValue(buffId, out var group)) continue; + group.LoadBuff(); + BuffList.SafeAddRange(group.BuffList); + count++; } if (count == BuffTagList.Count) IsLoaded = true; diff --git a/Common/Data/Excel/RogueTournAreaExcel.cs b/Common/Data/Excel/RogueTournAreaExcel.cs new file mode 100644 index 00000000..62c737c3 --- /dev/null +++ b/Common/Data/Excel/RogueTournAreaExcel.cs @@ -0,0 +1,39 @@ +using EggLink.DanhengServer.Enums.TournRogue; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournArea.json")] +public class RogueTournAreaExcel : ExcelResource +{ + public List MonsterDisplayItemList { get; set; } = []; + public List LayerIDList { get; set; } = []; + public List DifficultyIDList { get; set; } = []; + public int WorldLevelLimit { get; set; } + public int FirstReward { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public RogueTournDifficultyTypeEnum Difficulty { get; set; } + public int ExpScoreID { get; set; } + public int UnlockID { get; set; } + public int AreaID { get; set; } + public HashName AreaNameID { get; set; } = new(); + public bool IsHard { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public RogueTournModeEnum TournMode { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public RogueTournAreaGroupIDEnum AreaGroupID { get; set; } + + public override int GetId() + { + return AreaID; + } + + public override void Loaded() + { + GameData.RogueTournAreaData.TryAdd(AreaID, this); + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournBuffExcel.cs b/Common/Data/Excel/RogueTournBuffExcel.cs new file mode 100644 index 00000000..3820ffce --- /dev/null +++ b/Common/Data/Excel/RogueTournBuffExcel.cs @@ -0,0 +1,28 @@ +using EggLink.DanhengServer.Enums.Rogue; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournBuff.json")] +public class RogueTournBuffExcel : ExcelResource +{ + public int MazeBuffID { get; set; } + public int MazeBuffLevel { get; set; } + public int RogueBuffType { get; set; } + [JsonConverter(typeof(StringEnumConverter))] + public RogueBuffCategoryEnum RogueBuffCategory { get; set; } + public int RogueBuffTag { get; set; } + + public bool IsInHandbook { get; set; } + + public override int GetId() + { + return MazeBuffID * 100 + MazeBuffLevel; + } + + public override void Loaded() + { + GameData.RogueTournBuffData.TryAdd(GetId(), this); + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournBuffGroupExcel.cs b/Common/Data/Excel/RogueTournBuffGroupExcel.cs new file mode 100644 index 00000000..df015ce1 --- /dev/null +++ b/Common/Data/Excel/RogueTournBuffGroupExcel.cs @@ -0,0 +1,53 @@ +using EggLink.DanhengServer.Util; +using Newtonsoft.Json; + +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournBuffGroup.json")] +public class RogueTournBuffGroupExcel : ExcelResource +{ + public int RogueBuffGroupID { get; set; } + public List RogueBuffDrop { get; set; } = []; + + [JsonIgnore] public List BuffList { get; set; } = []; + [JsonIgnore] public bool IsLoaded { get; set; } + + + public override int GetId() + { + return RogueBuffGroupID; + } + + public override void Loaded() + { + GameData.RogueTournBuffGroupData.Add(GetId(), this); + LoadBuff(); + } + + public override void AfterAllDone() + { + LoadBuff(); + } + + public void LoadBuff() + { + if (IsLoaded) return; + var count = 0; + foreach (var buffId in RogueBuffDrop) + if (GameData.RogueTournBuffData.FirstOrDefault(x => x.Value.RogueBuffTag == buffId).Value is { } buff) + { + BuffList.SafeAdd(buff); + count++; + } + else + { + // might is group id + if (!GameData.RogueTournBuffGroupData.TryGetValue(buffId, out var group)) continue; + group.LoadBuff(); + BuffList.SafeAddRange(group.BuffList); + count++; + } + + if (count == RogueBuffDrop.Count) IsLoaded = true; + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournDifficultyCompExcel.cs b/Common/Data/Excel/RogueTournDifficultyCompExcel.cs new file mode 100644 index 00000000..fbeec287 --- /dev/null +++ b/Common/Data/Excel/RogueTournDifficultyCompExcel.cs @@ -0,0 +1,18 @@ +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournDifficultyComp.json")] +public class RogueTournDifficultyCompExcel : ExcelResource +{ + public int DifficultyCompID { get; set; } + public int Level { get; set; } + + public override int GetId() + { + return DifficultyCompID; + } + + public override void Loaded() + { + GameData.RogueTournDifficultyCompData.TryAdd(DifficultyCompID, this); + } +} diff --git a/Common/Data/Excel/RogueTournFormulaExcel.cs b/Common/Data/Excel/RogueTournFormulaExcel.cs new file mode 100644 index 00000000..45ed4cc2 --- /dev/null +++ b/Common/Data/Excel/RogueTournFormulaExcel.cs @@ -0,0 +1,39 @@ +using EggLink.DanhengServer.Enums.TournRogue; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournFormula.json")] +public class RogueTournFormulaExcel : ExcelResource +{ + public string FormulaIcon{ get; set; } + public string UltraFormulaIcon { get; set; } + public string FormulaSubIcon { get; set; } + public string FormulaStoryJson { get; set; } + public int MazeBuffID { get; set; } + public int SubBuffNum { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public RogueTournModeEnum TournMode { get; set; } + public int UnlockDisplayID { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public RogueFormulaCategoryEnum FormulaCategory { get; set; } + public bool IsInHandbook { get; set; } + public int MainBuffTypeID { get; set; } + public int FormulaDisplayID { get; set; } + public int FormulaID { get; set; } + public int MainBuffNum { get; set; } + public int SubBuffTypeID { get; set; } + + public override int GetId() + { + return FormulaID; + } + + public override void Loaded() + { + GameData.RogueTournFormulaData.TryAdd(GetId(), this); + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournHandBookEventExcel.cs b/Common/Data/Excel/RogueTournHandBookEventExcel.cs new file mode 100644 index 00000000..40627e97 --- /dev/null +++ b/Common/Data/Excel/RogueTournHandBookEventExcel.cs @@ -0,0 +1,17 @@ +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournHandBookEvent.json")] +public class RogueTournHandBookEventExcel : ExcelResource +{ + public int EventHandbookID { get; set; } + + public override int GetId() + { + return EventHandbookID; + } + + public override void Loaded() + { + GameData.RogueTournHandBookEventData.TryAdd(GetId(), this); + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournHandbookMiracleExcel.cs b/Common/Data/Excel/RogueTournHandbookMiracleExcel.cs new file mode 100644 index 00000000..24692df4 --- /dev/null +++ b/Common/Data/Excel/RogueTournHandbookMiracleExcel.cs @@ -0,0 +1,18 @@ +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournHandbookMiracle.json")] +public class RogueTournHandbookMiracleExcel : ExcelResource +{ + public int HandbookMiracleID { get; set; } + public int MiracleDisplayID { get; set; } + + public override int GetId() + { + return HandbookMiracleID; + } + + public override void Loaded() + { + GameData.RogueTournHandbookMiracleData.TryAdd(GetId(), this); + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournHexAvatarBaseTypeExcel.cs b/Common/Data/Excel/RogueTournHexAvatarBaseTypeExcel.cs new file mode 100644 index 00000000..ff4940fa --- /dev/null +++ b/Common/Data/Excel/RogueTournHexAvatarBaseTypeExcel.cs @@ -0,0 +1,17 @@ +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournHexAvatarBaseType.json")] +public class RogueTournHexAvatarBaseTypeExcel : ExcelResource +{ + public int MiracleID { get; set; } + + public override int GetId() + { + return MiracleID; + } + + public override void Loaded() + { + GameData.RogueTournHexAvatarBaseTypeData.TryAdd(MiracleID, this); + } +} \ No newline at end of file diff --git a/Common/Data/Excel/RogueTournPermanentTalentExcel.cs b/Common/Data/Excel/RogueTournPermanentTalentExcel.cs new file mode 100644 index 00000000..56c8b214 --- /dev/null +++ b/Common/Data/Excel/RogueTournPermanentTalentExcel.cs @@ -0,0 +1,18 @@ +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueTournPermanentTalent.json")] +public class RogueTournPermanentTalentExcel : ExcelResource +{ + public int TalentID { get; set; } + public List NextTalentIDList { get; set; } = []; + + public override int GetId() + { + return TalentID; + } + + public override void Loaded() + { + GameData.RogueTournPermanentTalentData.TryAdd(TalentID, this); + } +} \ No newline at end of file diff --git a/Common/Data/GameData.cs b/Common/Data/GameData.cs index a44d641f..852b7a0f 100644 --- a/Common/Data/GameData.cs +++ b/Common/Data/GameData.cs @@ -207,6 +207,20 @@ public static class GameData #endregion + #region TournRogue + + public static Dictionary RogueTournAreaData { get; private set; } = []; + public static Dictionary RogueTournBuffData { get; private set; } = []; + public static Dictionary RogueTournFormulaData { get; private set; } = []; + public static Dictionary RogueTournBuffGroupData { get; private set; } = []; + public static Dictionary RogueTournHexAvatarBaseTypeData { get; private set; } = []; + public static Dictionary RogueTournHandBookEventData { get; private set; } = []; + public static Dictionary RogueTournHandbookMiracleData { get; private set; } = []; + public static Dictionary RogueTournDifficultyCompData { get; private set; } = []; + public static Dictionary RogueTournPermanentTalentData { get; private set; } = []; + + #endregion + #region Actions public static void GetFloorInfo(int planeId, int floorId, out FloorInfo outer) diff --git a/Common/Data/ResourceManager.cs b/Common/Data/ResourceManager.cs index 76afcdd2..5fb7b687 100644 --- a/Common/Data/ResourceManager.cs +++ b/Common/Data/ResourceManager.cs @@ -43,29 +43,30 @@ public class ResourceManager var resList = new List(); foreach (var cls in classes) { - var attribute = (ResourceEntity)Attribute.GetCustomAttribute(cls, typeof(ResourceEntity))!; + var attribute = (ResourceEntity?)Attribute.GetCustomAttribute(cls, typeof(ResourceEntity)); - if (attribute != null) - { - var resource = (ExcelResource)Activator.CreateInstance(cls)!; - var count = 0; - foreach (var fileName in attribute.FileName) - try + if (attribute == null) continue; + var resource = (ExcelResource)Activator.CreateInstance(cls)!; + var count = 0; + foreach (var fileName in attribute.FileName) + try + { + var path = ConfigManager.Config.Path.ResourcePath + "/ExcelOutput/" + fileName; + var file = new FileInfo(path); + if (!file.Exists) { - var path = ConfigManager.Config.Path.ResourcePath + "/ExcelOutput/" + fileName; - var file = new FileInfo(path); - if (!file.Exists) - { - Logger.Error(I18nManager.Translate("Server.ServerInfo.FailedToReadItem", fileName, - I18nManager.Translate("Word.NotFound"))); - continue; - } + Logger.Error(I18nManager.Translate("Server.ServerInfo.FailedToReadItem", fileName, + I18nManager.Translate("Word.NotFound"))); + continue; + } - var json = file.OpenText().ReadToEnd(); - using (var reader = new JsonTextReader(new StringReader(json))) + var json = file.OpenText().ReadToEnd(); + using (var reader = new JsonTextReader(new StringReader(json))) + { + reader.Read(); + switch (reader.TokenType) { - reader.Read(); - if (reader.TokenType == JsonToken.StartArray) + case JsonToken.StartArray: { // array var jArray = JArray.Parse(json); @@ -76,15 +77,15 @@ public class ResourceManager ((ExcelResource?)res)?.Loaded(); count++; } + + break; } - else if (reader.TokenType == JsonToken.StartObject) + case JsonToken.StartObject: { // dictionary var jObject = JObject.Parse(json); - foreach (var item in jObject) + foreach (var (_, obj) in jObject) { - var id = int.Parse(item.Key); - var obj = item.Value; var instance = JsonConvert.DeserializeObject(obj!.ToString(), cls); if (((ExcelResource?)instance)?.GetId() == 0 || (ExcelResource?)instance == null) @@ -103,26 +104,28 @@ public class ResourceManager } else { - resList.Add((ExcelResource)instance!); + resList.Add((ExcelResource)instance); ((ExcelResource)instance).Loaded(); } count++; } + + break; } } - - resource.Finalized(); - } - catch (Exception ex) - { - Logger.Error( - I18nManager.Translate("Server.ServerInfo.FailedToReadItem", fileName, - I18nManager.Translate("Word.Error")), ex); } - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", count.ToString(), cls.Name)); - } + resource.Finalized(); + } + catch (Exception ex) + { + Logger.Error( + I18nManager.Translate("Server.ServerInfo.FailedToReadItem", fileName, + I18nManager.Translate("Word.Error")), ex); + } + + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", count.ToString(), cls.Name)); } foreach (var cls in resList) cls.AfterAllDone(); @@ -189,11 +192,8 @@ public class ResourceManager using StreamReader graphReader2 = new(graphReader); var graphText = graphReader2.ReadToEnd().Replace("$type", "Type"); var graphObj = JObject.Parse(graphText); - if (graphObj != null) - { - var graphInfo = LevelGraphConfigInfo.LoadFromJsonObject(graphObj); - group.LevelGraphConfig = graphInfo; - } + var graphInfo = LevelGraphConfigInfo.LoadFromJsonObject(graphObj); + group.LevelGraphConfig = graphInfo; } } } @@ -250,16 +250,6 @@ public class ResourceManager if (missionInfo != null) { GameData.MainMissionData[missionExcel.Key].MissionInfo = missionInfo; - foreach (var subMission in missionInfo.SubMissionList) - { - // load mission json - var missionJsonPath = ConfigManager.Config.Path.ResourcePath + "/" + subMission.MissionJsonPath; - if (File.Exists(missionJsonPath)) - { - var missionJson = File.ReadAllText(missionJsonPath).Replace("$type", "Type"); - } - } - count++; } else @@ -302,19 +292,28 @@ public class ResourceManager Logger.Error("Error in reading " + file.Name, ex); } - if (customFile is Dictionary d) - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", d.Count.ToString(), filetype)); - else if (customFile is Dictionary> di) - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", di.Count.ToString(), filetype)); - else if (customFile is BannersConfig c) - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", c.Banners.Count.ToString(), filetype)); - else if (customFile is RogueMiracleEffectConfig r) - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", r.Miracles.Count.ToString(), filetype)); - else if (customFile is ActivityConfig a) - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", a.ScheduleData.Count.ToString(), - filetype)); - else - Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItem", filetype)); + switch (customFile) + { + case Dictionary d: + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", d.Count.ToString(), filetype)); + break; + case Dictionary> di: + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", di.Count.ToString(), filetype)); + break; + case BannersConfig c: + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", c.Banners.Count.ToString(), filetype)); + break; + case RogueMiracleEffectConfig r: + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", r.Miracles.Count.ToString(), filetype)); + break; + case ActivityConfig a: + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItems", a.ScheduleData.Count.ToString(), + filetype)); + break; + default: + Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadedItem", filetype)); + break; + } return customFile; } @@ -421,12 +420,9 @@ public class ResourceManager using StreamReader reader2 = new(reader); var text = reader2.ReadToEnd().Replace("$type", "Type"); var obj = JObject.Parse(text); - if (obj != null) - { - var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); - performance.ActInfo = info; - count++; - } + var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); + performance.ActInfo = info; + count++; } catch (Exception ex) { @@ -453,12 +449,9 @@ public class ResourceManager using StreamReader reader2 = new(reader); var text = reader2.ReadToEnd().Replace("$type", "Type"); var obj = JObject.Parse(text); - if (obj != null) - { - var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); - performance.ActInfo = info; - count++; - } + var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); + performance.ActInfo = info; + count++; } catch (Exception ex) { @@ -496,12 +489,9 @@ public class ResourceManager using StreamReader reader2 = new(reader); var text = reader2.ReadToEnd().Replace("$type", "Type"); var obj = JObject.Parse(text); - if (obj != null) - { - var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); - subMission.SubMissionTaskInfo = info; - count++; - } + var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); + subMission.SubMissionTaskInfo = info; + count++; } catch (Exception ex) { @@ -599,39 +589,37 @@ public class ResourceManager customFile = json; foreach (var room in customFile!) - if (room.BlockType == RogueDLCBlockTypeEnum.MonsterNormal) + switch (room.BlockType) { - AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterNormal, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterSwarm, room); - count += 2; - } - else if (room.BlockType == RogueDLCBlockTypeEnum.MonsterBoss) - { - AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterBoss, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterNousBoss, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterSwarmBoss, room); - count += 3; - } - else if (room.BlockType == RogueDLCBlockTypeEnum.Event) - { - AddRoomToGameData(RogueDLCBlockTypeEnum.Event, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.Reward, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.Adventure, room); // adventure is not this type - AddRoomToGameData(RogueDLCBlockTypeEnum.NousSpecialEvent, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.SwarmEvent, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.NousEvent, room); - count += 6; - } - else if (room.BlockType == RogueDLCBlockTypeEnum.Trade) - { - AddRoomToGameData(RogueDLCBlockTypeEnum.Trade, room); - AddRoomToGameData(RogueDLCBlockTypeEnum.BlackMarket, room); - count += 2; - } - else - { - AddRoomToGameData(room.BlockType, room); - count++; + case RogueDLCBlockTypeEnum.MonsterNormal: + AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterNormal, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterSwarm, room); + count += 2; + break; + case RogueDLCBlockTypeEnum.MonsterBoss: + AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterBoss, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterNousBoss, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.MonsterSwarmBoss, room); + count += 3; + break; + case RogueDLCBlockTypeEnum.Event: + AddRoomToGameData(RogueDLCBlockTypeEnum.Event, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.Reward, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.Adventure, room); // adventure is not this type + AddRoomToGameData(RogueDLCBlockTypeEnum.NousSpecialEvent, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.SwarmEvent, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.NousEvent, room); + count += 6; + break; + case RogueDLCBlockTypeEnum.Trade: + AddRoomToGameData(RogueDLCBlockTypeEnum.Trade, room); + AddRoomToGameData(RogueDLCBlockTypeEnum.BlackMarket, room); + count += 2; + break; + default: + AddRoomToGameData(room.BlockType, room); + count++; + break; } } catch (Exception ex) diff --git a/Common/Enums/TournRogue/RogueFormulaCategoryEnum.cs b/Common/Enums/TournRogue/RogueFormulaCategoryEnum.cs new file mode 100644 index 00000000..d83a2d87 --- /dev/null +++ b/Common/Enums/TournRogue/RogueFormulaCategoryEnum.cs @@ -0,0 +1,10 @@ +namespace EggLink.DanhengServer.Enums.TournRogue; + +public enum RogueFormulaCategoryEnum +{ + Common = 1, + Rare = 2, + Epic = 3, + Legendary = 4, + PathEcho = 5 +} \ No newline at end of file diff --git a/Common/Enums/TournRogue/RogueTournAreaGroupIDEnum.cs b/Common/Enums/TournRogue/RogueTournAreaGroupIDEnum.cs new file mode 100644 index 00000000..d6a99ecb --- /dev/null +++ b/Common/Enums/TournRogue/RogueTournAreaGroupIDEnum.cs @@ -0,0 +1,9 @@ +namespace EggLink.DanhengServer.Enums.TournRogue; + +public enum RogueTournAreaGroupIDEnum +{ + None = 0, + Guide = 1, + Formal = 2, + WeekChallenge = 3 +} \ No newline at end of file diff --git a/Common/Enums/TournRogue/RogueTournDifficultyTypeEnum.cs b/Common/Enums/TournRogue/RogueTournDifficultyTypeEnum.cs new file mode 100644 index 00000000..7c5eb325 --- /dev/null +++ b/Common/Enums/TournRogue/RogueTournDifficultyTypeEnum.cs @@ -0,0 +1,11 @@ +namespace EggLink.DanhengServer.Enums.TournRogue; + +public enum RogueTournDifficultyTypeEnum +{ + None = 0, + Difficulty_1 = 1, + Difficulty_2 = 2, + Difficulty_3 = 3, + Difficulty_4 = 4, + Difficulty_5 = 5 +} \ No newline at end of file diff --git a/Common/Enums/TournRogue/RogueTournModeEnum.cs b/Common/Enums/TournRogue/RogueTournModeEnum.cs new file mode 100644 index 00000000..ce0b8b4f --- /dev/null +++ b/Common/Enums/TournRogue/RogueTournModeEnum.cs @@ -0,0 +1,8 @@ +namespace EggLink.DanhengServer.Enums.TournRogue; + +public enum RogueTournModeEnum +{ + Permanent = 0, + Tourn1 = 1, + Tourn2 = 2 +} \ No newline at end of file diff --git a/GameServer/Game/Challenge/ChallengeManager.cs b/GameServer/Game/Challenge/ChallengeManager.cs index 20b71d00..945fb0c7 100644 --- a/GameServer/Game/Challenge/ChallengeManager.cs +++ b/GameServer/Game/Challenge/ChallengeManager.cs @@ -31,57 +31,57 @@ public class ChallengeManager(PlayerInstance player) : BasePlayerManager(player) return; } - var Excel = value; + var excel = value; // Sanity check lineups - if (Excel.StageNum > 0) + if (excel.StageNum > 0) { // Get lineup - var Lineup = Player.LineupManager!.GetExtraLineup(ExtraLineupType.LineupChallenge)!; + var lineup = Player.LineupManager!.GetExtraLineup(ExtraLineupType.LineupChallenge)!; // Make sure this lineup has avatars set - if (Lineup.AvatarData!.Avatars.Count == 0) + if (lineup.AvatarData!.Avatars.Count == 0) { await Player.SendPacket(new PacketStartChallengeScRsp((uint)Retcode.RetChallengeLineupEmpty)); return; } // Reset hp/sp - foreach (var avatar in Lineup.AvatarData!.Avatars) + foreach (var avatar in lineup.AvatarData!.Avatars) { avatar.SetCurHp(10000, true); - avatar.SetCurSp(avatar.GetCurSp(true) / 2, true); + avatar.SetCurSp(5000, true); } // Set technique points to full - Lineup.Mp = 5; // Max Mp + lineup.Mp = 5; // Max Mp } - if (Excel.StageNum >= 2) + if (excel.StageNum >= 2) { // Get lineup - var Lineup = Player.LineupManager!.GetExtraLineup(ExtraLineupType.LineupChallenge2)!; + var lineup = Player.LineupManager!.GetExtraLineup(ExtraLineupType.LineupChallenge2)!; // Make sure this lineup has avatars set - if (Lineup.AvatarData!.Avatars.Count == 0) + if (lineup.AvatarData!.Avatars.Count == 0) { await Player.SendPacket(new PacketStartChallengeScRsp((uint)Retcode.RetChallengeLineupEmpty)); return; } // Reset hp/sp - foreach (var avatar in Lineup.AvatarData!.Avatars) + foreach (var avatar in lineup.AvatarData!.Avatars) { avatar.SetCurHp(10000, true); - avatar.SetCurSp(avatar.GetCurSp(true) / 2, true); + avatar.SetCurSp(5000, true); } // Set technique points to full - Lineup.Mp = 5; // Max Mp + lineup.Mp = 5; // Max Mp } // Set challenge data for player - ChallengeInstance instance = new(Player, Excel); + ChallengeInstance instance = new(Player, excel); ChallengeInstance = instance; // Set first lineup before we enter scenes @@ -90,7 +90,7 @@ public class ChallengeManager(PlayerInstance player) : BasePlayerManager(player) // Enter scene try { - await Player.EnterScene(Excel.MapEntranceID, 0, false); + await Player.EnterScene(excel.MapEntranceID, 0, false); } catch { @@ -107,7 +107,7 @@ public class ChallengeManager(PlayerInstance player) : BasePlayerManager(player) instance.StartRot = Player.Data.Rot!; instance.SavedMp = Player.LineupManager.GetCurLineup()!.Mp; - if (Excel.IsStory() && storyBuffs != null) + if (excel.IsStory() && storyBuffs != null) { instance.StoryBuffs.Add((int)storyBuffs.BuffOne); instance.StoryBuffs.Add((int)storyBuffs.BuffTwo); diff --git a/GameServer/Game/Player/PlayerInstance.cs b/GameServer/Game/Player/PlayerInstance.cs index e0a835ed..6cdb7ede 100644 --- a/GameServer/Game/Player/PlayerInstance.cs +++ b/GameServer/Game/Player/PlayerInstance.cs @@ -23,6 +23,7 @@ using EggLink.DanhengServer.GameServer.Game.Mission; using EggLink.DanhengServer.GameServer.Game.Quest; using EggLink.DanhengServer.GameServer.Game.Raid; using EggLink.DanhengServer.GameServer.Game.Rogue; +using EggLink.DanhengServer.GameServer.Game.RogueTourn; using EggLink.DanhengServer.GameServer.Game.Scene; using EggLink.DanhengServer.GameServer.Game.Scene.Entity; using EggLink.DanhengServer.GameServer.Game.Shop; @@ -61,6 +62,7 @@ public class PlayerInstance(PlayerData data) public FriendManager? FriendManager { get; private set; } public RogueManager? RogueManager { get; private set; } public ChessRogueManager? ChessRogueManager { get; private set; } + public RogueTournManager? RogueTournManager { get; private set; } public ShopService? ShopService { get; private set; } public ChallengeManager? ChallengeManager { get; private set; } @@ -138,6 +140,7 @@ public class PlayerInstance(PlayerData data) RogueManager = new RogueManager(this); ShopService = new ShopService(this); ChessRogueManager = new ChessRogueManager(this); + RogueTournManager = new RogueTournManager(this); ChallengeManager = new ChallengeManager(this); TaskManager = new TaskManager(this); RaidManager = new RaidManager(this); diff --git a/GameServer/Game/RogueTourn/RogueTournManager.cs b/GameServer/Game/RogueTourn/RogueTournManager.cs new file mode 100644 index 00000000..cda3f4d0 --- /dev/null +++ b/GameServer/Game/RogueTourn/RogueTournManager.cs @@ -0,0 +1,131 @@ +using EggLink.DanhengServer.Data; +using EggLink.DanhengServer.Enums.TournRogue; +using EggLink.DanhengServer.GameServer.Game.Player; +using EggLink.DanhengServer.GameServer.Game.Rogue; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Game.RogueTourn; + +public class RogueTournManager(PlayerInstance player) : BasePlayerManager(player) +{ + #region Serialization + + public RogueTournInfo ToProto() + { + var proto = new RogueTournInfo + { + ExtraScoreInfo = ToExtraScoreProto(), + InspirationCircuit = ToInspirationCircuitProto(), + RogueSeasonInfo = ToSeasonProto(), + RogueTournAreaInfo = { ToAreaProtoList() }, + RogueTournDifficultyInfo = { ToDifficultyProtoList() }, + RogueTournExpInfo = ToExpProto(), + RogueTournHandbook = ToHandbookProto(), + RogueTournSaveList = + { + Capacity = 0 + } + }; + + return proto; + } + + public ExtraScoreInfo ToExtraScoreProto() + { + return new ExtraScoreInfo + { + EndTime = RogueManager.GetCurrentRogueTime().Item2, + Week = 1 + }; + } + + public InspirationCircuitInfo ToInspirationCircuitProto() + { + return new InspirationCircuitInfo + { + TalentInfoList = new RogueTalentInfoList + { + TalentInfo = { GameData.RogueTournPermanentTalentData.Values.Select(x => new RogueTalentInfo + { + TalentId = (uint)x.TalentID, + Status = RogueTalentStatus.Enable + }) } + } + }; + } + + public RogueTournSeasonInfo ToSeasonProto() + { + return new RogueTournSeasonInfo + { + SubTournId = 1, + MainTournId = 1 + }; + } + + public List ToAreaProtoList() + { + return (from areaExcel in GameData.RogueTournAreaData + where areaExcel.Value.AreaGroupID != RogueTournAreaGroupIDEnum.WeekChallenge + select new RogueTournAreaInfo + { AreaId = (uint)areaExcel.Value.AreaID, IsFinish = true, IsTakenReward = true, IsUnlock = true }) + .ToList(); + } + + public List ToDifficultyProtoList() + { + return (from difficultyExcel in GameData.RogueTournDifficultyCompData.Values + select new RogueTournDifficultyInfo + { DifficultyId = (uint)difficultyExcel.DifficultyCompID, IsUnlock = true }).ToList(); + } + + public RogueTournExpInfo ToExpProto() + { + return new RogueTournExpInfo + { + Exp = 0, + TakenLevelRewards = + { + Capacity = 0 + } + }; + } + + public RogueTournHandbookInfo ToHandbookProto() + { + var proto = new RogueTournHandbookInfo + { + ONPBIAFFJJK = 1 + }; + + foreach (var hexAvatar in GameData.RogueTournHexAvatarBaseTypeData.Keys) + { + proto.HandbookAvatarBaseList.Add((uint)hexAvatar); + } + + foreach (var buff in GameData.RogueTournBuffData.Values) + { + if (buff.IsInHandbook) + proto.HandbookBuffList.Add((uint)buff.MazeBuffID); + } + + foreach (var formulaId in GameData.RogueTournFormulaData.Keys) + { + proto.HandbookFormulaList.Add((uint)formulaId); + } + + foreach (var miracleId in GameData.RogueTournHandbookMiracleData.Keys) + { + proto.HandbookMiracleList.Add((uint)miracleId); + } + + foreach (var eventId in GameData.RogueTournHandBookEventData.Keys) + { + proto.TakeHandbookRewardList.Add((uint)eventId); // should be HandbookEventList + } + + return proto; + } + + #endregion +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Recv/RogueTourn/HandlerGetRogueCollectionCsReq.cs b/GameServer/Server/Packet/Recv/RogueTourn/HandlerGetRogueCollectionCsReq.cs new file mode 100644 index 00000000..6f706c4a --- /dev/null +++ b/GameServer/Server/Packet/Recv/RogueTourn/HandlerGetRogueCollectionCsReq.cs @@ -0,0 +1,12 @@ +using EggLink.DanhengServer.Kcp; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.RogueTourn; + +[Opcode(CmdIds.GetRogueCollectionCsReq)] +public class HandlerGetRogueCollectionCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + await connection.SendPacket(CmdIds.GetRogueCollectionScRsp); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetArchiveRepositoryCsReq.cs b/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetArchiveRepositoryCsReq.cs new file mode 100644 index 00000000..2e0f61e5 --- /dev/null +++ b/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetArchiveRepositoryCsReq.cs @@ -0,0 +1,12 @@ +using EggLink.DanhengServer.Kcp; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.RogueTourn; + +[Opcode(CmdIds.RogueTournGetArchiveRepositoryCsReq)] +public class HandlerRogueTournGetArchiveRepositoryCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + await connection.SendPacket(CmdIds.RogueTournGetArchiveRepositoryScRsp); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetPermanentTalentInfoCsReq.cs b/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetPermanentTalentInfoCsReq.cs new file mode 100644 index 00000000..7469149b --- /dev/null +++ b/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournGetPermanentTalentInfoCsReq.cs @@ -0,0 +1,13 @@ +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueTourn; +using EggLink.DanhengServer.Kcp; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.RogueTourn; + +[Opcode(CmdIds.RogueTournGetPermanentTalentInfoCsReq)] +public class HandlerRogueTournGetPermanentTalentInfoCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + await connection.SendPacket(new PacketRogueTournGetPermanentTalentInfoScRsp(connection.Player!)); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournQueryCsReq.cs b/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournQueryCsReq.cs new file mode 100644 index 00000000..5037a00d --- /dev/null +++ b/GameServer/Server/Packet/Recv/RogueTourn/HandlerRogueTournQueryCsReq.cs @@ -0,0 +1,13 @@ +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueTourn; +using EggLink.DanhengServer.Kcp; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.RogueTourn; + +[Opcode(CmdIds.RogueTournQueryCsReq)] +public class HandlerRogueTournQueryCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + await connection.SendPacket(new PacketRogueTournQueryScRsp(connection.Player!)); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournGetPermanentTalentInfoScRsp.cs b/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournGetPermanentTalentInfoScRsp.cs new file mode 100644 index 00000000..bb73719b --- /dev/null +++ b/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournGetPermanentTalentInfoScRsp.cs @@ -0,0 +1,19 @@ +using EggLink.DanhengServer.GameServer.Game.Player; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueTourn; + +public class PacketRogueTournGetPermanentTalentInfoScRsp : BasePacket +{ + public PacketRogueTournGetPermanentTalentInfoScRsp(PlayerInstance player) : base( + CmdIds.RogueTournGetPermanentTalentInfoScRsp) + { + var proto = new RogueTournGetPermanentTalentInfoScRsp + { + InspirationCircuit = player.RogueTournManager!.ToInspirationCircuitProto() + }; + + SetData(proto); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournQueryScRsp.cs b/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournQueryScRsp.cs new file mode 100644 index 00000000..50f9be50 --- /dev/null +++ b/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournQueryScRsp.cs @@ -0,0 +1,18 @@ +using EggLink.DanhengServer.GameServer.Game.Player; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueTourn; + +public class PacketRogueTournQueryScRsp : BasePacket +{ + public PacketRogueTournQueryScRsp(PlayerInstance player) : base(CmdIds.RogueTournQueryScRsp) + { + var proto = new RogueTournQueryScRsp + { + RogueGetInfo = player.RogueTournManager!.ToProto() + }; + + SetData(proto); + } +} \ No newline at end of file