diff --git a/Common/Configuration/ConfigContainer.cs b/Common/Configuration/ConfigContainer.cs index aee110e7..7c0e6618 100644 --- a/Common/Configuration/ConfigContainer.cs +++ b/Common/Configuration/ConfigContainer.cs @@ -14,13 +14,19 @@ public class ConfigContainer public class HttpServerConfig { + public string BindAddress { get; set; } = "0.0.0.0"; public string PublicAddress { get; set; } = "127.0.0.1"; - public int PublicPort { get; set; } = 443; + public int Port { get; set; } = 443; public bool UseSSL { get; set; } = true; public string GetDisplayAddress() { - return (UseSSL ? "https" : "http") + "://" + PublicAddress + ":" + PublicPort; + return (UseSSL ? "https" : "http") + "://" + PublicAddress + ":" + Port; + } + + public string GetBindDisplayAddress() + { + return (UseSSL ? "https" : "http") + "://" + BindAddress + ":" + Port; } } @@ -32,16 +38,16 @@ public class KeyStoreConfig public class GameServerConfig { + public string BindAddress { get; set; } = "0.0.0.0"; public string PublicAddress { get; set; } = "127.0.0.1"; - public uint PublicPort { get; set; } = 23301; + public uint Port { get; set; } = 23301; public string GameServerId { get; set; } = "dan_heng"; public string GameServerName { get; set; } = "DanhengServer"; public string GameServerDescription { get; set; } = "A re-implementation of StarRail server"; - public int KcpInterval { get; set; } = 40; public string GetDisplayAddress() { - return PublicAddress + ":" + PublicPort; + return PublicAddress + ":" + Port; } } diff --git a/Common/Data/Config/AnchorInfo.cs b/Common/Data/Config/AnchorInfo.cs deleted file mode 100644 index 39b8e835..00000000 --- a/Common/Data/Config/AnchorInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace EggLink.DanhengServer.Data.Config; - -public class AnchorInfo : PositionInfo -{ -} \ No newline at end of file diff --git a/Common/Data/Config/Rogue/RogueDialogueBaseConfigInfo.cs b/Common/Data/Config/Rogue/RogueDialogueBaseConfigInfo.cs new file mode 100644 index 00000000..ef507652 --- /dev/null +++ b/Common/Data/Config/Rogue/RogueDialogueBaseConfigInfo.cs @@ -0,0 +1,62 @@ +using EggLink.DanhengServer.Internationalization; +using EggLink.DanhengServer.Util; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace EggLink.DanhengServer.Data.Config.Rogue; + +public class RogueDialogueBaseConfigInfo +{ + public string OptionPath { get; set; } = string.Empty; + public string DialoguePath { get; set; } = string.Empty; + + public LevelGraphConfigInfo? DialogueInfo { get; set; } + public RogueDialogueEventConfigInfo? OptionInfo { get; set; } + + public void Loaded() + { + var logger = Logger.GetByClassName(); + if (!string.IsNullOrEmpty(OptionPath)) + { + var path = ConfigManager.Config.Path.ResourcePath + "/" + OptionPath; + var file = new FileInfo(path); + if (!file.Exists) return; + try + { + using var reader = file.OpenRead(); + using StreamReader reader2 = new(reader); + var text = reader2.ReadToEnd(); + var info = JsonConvert.DeserializeObject(text); + OptionInfo = info; + } + catch (Exception ex) + { + logger.Error( + I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name, + I18nManager.Translate("Word.Error")), ex); + } + } + + if (!string.IsNullOrEmpty(DialoguePath)) + { + var path = ConfigManager.Config.Path.ResourcePath + "/" + DialoguePath; + var file = new FileInfo(path); + if (!file.Exists) return; + try + { + using var reader = file.OpenRead(); + using StreamReader reader2 = new(reader); + var text = reader2.ReadToEnd().Replace("$type", "Type"); + var obj = JObject.Parse(text); + var info = LevelGraphConfigInfo.LoadFromJsonObject(obj); + DialogueInfo = info; + } + catch (Exception ex) + { + logger.Error( + I18nManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name, + I18nManager.Translate("Word.Error")), ex); + } + } + } +} \ No newline at end of file diff --git a/Common/Data/Config/Rogue/RogueDialogueEventConfigInfo.cs b/Common/Data/Config/Rogue/RogueDialogueEventConfigInfo.cs new file mode 100644 index 00000000..a81f8896 --- /dev/null +++ b/Common/Data/Config/Rogue/RogueDialogueEventConfigInfo.cs @@ -0,0 +1,6 @@ +namespace EggLink.DanhengServer.Data.Config.Rogue; + +public class RogueDialogueEventConfigInfo +{ + public List OptionList { get; set; } = []; +} \ No newline at end of file diff --git a/Common/Data/Config/Rogue/RogueDialogueEventOptionConfigInfo.cs b/Common/Data/Config/Rogue/RogueDialogueEventOptionConfigInfo.cs new file mode 100644 index 00000000..8fceb1a1 --- /dev/null +++ b/Common/Data/Config/Rogue/RogueDialogueEventOptionConfigInfo.cs @@ -0,0 +1,13 @@ +namespace EggLink.DanhengServer.Data.Config.Rogue; + +public class RogueDialogueEventOptionConfigInfo +{ + public int OptionID { get; set; } + public int DisplayID { get; set; } + public int SpecialOptionID { get; set; } + public Dictionary DynamicMap { get; set; } = []; + public int DescValue { get; set; } + public int DescValue2 { get; set; } + public int DescValue3 { get; set; } + public int DescValue4 { get; set; } +} \ No newline at end of file diff --git a/Common/Data/Config/Rogue/RogueDialogueEventOptionDynamicConfigInfo.cs b/Common/Data/Config/Rogue/RogueDialogueEventOptionDynamicConfigInfo.cs new file mode 100644 index 00000000..dd8ab2d0 --- /dev/null +++ b/Common/Data/Config/Rogue/RogueDialogueEventOptionDynamicConfigInfo.cs @@ -0,0 +1,7 @@ +namespace EggLink.DanhengServer.Data.Config.Rogue; + +public class RogueDialogueEventOptionDynamicConfigInfo +{ + public int DisplayID { get; set; } + public int DisplayID2 { get; set; } +} \ No newline at end of file diff --git a/Common/Data/Config/Rogue/RogueNPCConfigInfo.cs b/Common/Data/Config/Rogue/RogueNPCConfigInfo.cs new file mode 100644 index 00000000..6725e5e2 --- /dev/null +++ b/Common/Data/Config/Rogue/RogueNPCConfigInfo.cs @@ -0,0 +1,20 @@ +using EggLink.DanhengServer.Enums.Rogue; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace EggLink.DanhengServer.Data.Config.Rogue; + +public class RogueNPCConfigInfo +{ + [JsonConverter(typeof(StringEnumConverter))] + public RogueDialogueTypeEnum DialogueType { get; set; } + + public List DialogueList { get; set; } = []; + + public void Loaded() + { + if (DialogueList.Count == 0) return; + + foreach (var info in DialogueList) info.Loaded(); + } +} \ No newline at end of file diff --git a/Common/Data/Config/Rogue/RogueNPCDialogueConfigInfo.cs b/Common/Data/Config/Rogue/RogueNPCDialogueConfigInfo.cs new file mode 100644 index 00000000..aa5aef8a --- /dev/null +++ b/Common/Data/Config/Rogue/RogueNPCDialogueConfigInfo.cs @@ -0,0 +1,8 @@ +namespace EggLink.DanhengServer.Data.Config.Rogue; + +public class RogueNPCDialogueConfigInfo : RogueDialogueBaseConfigInfo +{ + public int DialogueProgress { get; set; } + public int UnlockID { get; set; } + public int TalkNameID { get; set; } +} \ No newline at end of file diff --git a/Common/Data/Config/Scene/AnchorInfo.cs b/Common/Data/Config/Scene/AnchorInfo.cs new file mode 100644 index 00000000..5858afd2 --- /dev/null +++ b/Common/Data/Config/Scene/AnchorInfo.cs @@ -0,0 +1,5 @@ +namespace EggLink.DanhengServer.Data.Config.Scene; + +public class AnchorInfo : PositionInfo +{ +} \ No newline at end of file diff --git a/Common/Data/Config/FloorInfo.cs b/Common/Data/Config/Scene/FloorInfo.cs similarity index 98% rename from Common/Data/Config/FloorInfo.cs rename to Common/Data/Config/Scene/FloorInfo.cs index f2ae158b..09c30324 100644 --- a/Common/Data/Config/FloorInfo.cs +++ b/Common/Data/Config/Scene/FloorInfo.cs @@ -1,7 +1,7 @@ using EggLink.DanhengServer.Enums.Scene; using Newtonsoft.Json; -namespace EggLink.DanhengServer.Data.Config; +namespace EggLink.DanhengServer.Data.Config.Scene; public class FloorInfo { diff --git a/Common/Data/Config/GroupInfo.cs b/Common/Data/Config/Scene/GroupInfo.cs similarity index 98% rename from Common/Data/Config/GroupInfo.cs rename to Common/Data/Config/Scene/GroupInfo.cs index 29ba9af2..310b6fd4 100644 --- a/Common/Data/Config/GroupInfo.cs +++ b/Common/Data/Config/Scene/GroupInfo.cs @@ -6,7 +6,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace EggLink.DanhengServer.Data.Config; +namespace EggLink.DanhengServer.Data.Config.Scene; public class GroupInfo { diff --git a/Common/Data/Config/MonsterInfo.cs b/Common/Data/Config/Scene/MonsterInfo.cs similarity index 79% rename from Common/Data/Config/MonsterInfo.cs rename to Common/Data/Config/Scene/MonsterInfo.cs index fb90903f..f09da8b2 100644 --- a/Common/Data/Config/MonsterInfo.cs +++ b/Common/Data/Config/Scene/MonsterInfo.cs @@ -1,4 +1,4 @@ -namespace EggLink.DanhengServer.Data.Config; +namespace EggLink.DanhengServer.Data.Config.Scene; public class MonsterInfo : PositionInfo { diff --git a/Common/Data/Config/NpcInfo.cs b/Common/Data/Config/Scene/NpcInfo.cs similarity index 68% rename from Common/Data/Config/NpcInfo.cs rename to Common/Data/Config/Scene/NpcInfo.cs index 8f6e02eb..4c275e10 100644 --- a/Common/Data/Config/NpcInfo.cs +++ b/Common/Data/Config/Scene/NpcInfo.cs @@ -1,4 +1,4 @@ -namespace EggLink.DanhengServer.Data.Config; +namespace EggLink.DanhengServer.Data.Config.Scene; public class NpcInfo : PositionInfo { diff --git a/Common/Data/Config/PositionInfo.cs b/Common/Data/Config/Scene/PositionInfo.cs similarity index 94% rename from Common/Data/Config/PositionInfo.cs rename to Common/Data/Config/Scene/PositionInfo.cs index a0eae5a3..c8bce664 100644 --- a/Common/Data/Config/PositionInfo.cs +++ b/Common/Data/Config/Scene/PositionInfo.cs @@ -1,6 +1,6 @@ using EggLink.DanhengServer.Util; -namespace EggLink.DanhengServer.Data.Config; +namespace EggLink.DanhengServer.Data.Config.Scene; public class PositionInfo { diff --git a/Common/Data/Config/PropInfo.cs b/Common/Data/Config/Scene/PropInfo.cs similarity index 98% rename from Common/Data/Config/PropInfo.cs rename to Common/Data/Config/Scene/PropInfo.cs index 4562cb92..29e410a0 100644 --- a/Common/Data/Config/PropInfo.cs +++ b/Common/Data/Config/Scene/PropInfo.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; -namespace EggLink.DanhengServer.Data.Config; +namespace EggLink.DanhengServer.Data.Config.Scene; public class PropInfo : PositionInfo { 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 void LoadBuff() { 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 void LoadBuff() 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/RogueDLCAreaExcel.cs b/Common/Data/Excel/RogueDLCAreaExcel.cs index df2c83ae..d43c9252 100644 --- a/Common/Data/Excel/RogueDLCAreaExcel.cs +++ b/Common/Data/Excel/RogueDLCAreaExcel.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using EggLink.DanhengServer.Enums.Rogue; +using Newtonsoft.Json; namespace EggLink.DanhengServer.Data.Excel; @@ -13,7 +14,7 @@ public class RogueDLCAreaExcel : ExcelResource public List AreaScoreMap { get; set; } = []; - [JsonIgnore] public int RogueVersionId { get; set; } + [JsonIgnore] public RogueSubModeEnum RogueVersionId { get; set; } public override int GetId() { @@ -24,10 +25,7 @@ public override void Loaded() { GameData.RogueDLCAreaData[AreaID] = this; - if (SubType.Contains("Nous")) - RogueVersionId = 202; - else - RogueVersionId = 201; + RogueVersionId = SubType.Contains("Nous") ? RogueSubModeEnum.ChessRogueNous : RogueSubModeEnum.ChessRogue; } } diff --git a/Common/Data/Excel/RogueNPCDialogueExcel.cs b/Common/Data/Excel/RogueNPCDialogueExcel.cs deleted file mode 100644 index 3f9fc96a..00000000 --- a/Common/Data/Excel/RogueNPCDialogueExcel.cs +++ /dev/null @@ -1,31 +0,0 @@ -using EggLink.DanhengServer.Data.Config; -using Newtonsoft.Json; - -namespace EggLink.DanhengServer.Data.Excel; - -[ResourceEntity("RogueNPCDialogue.json")] -public class RogueNPCDialogueExcel : ExcelResource -{ - public int RogueNPCID { get; set; } - public int DialogueProgress { get; set; } - public int HandbookEventID { get; set; } - public string DialoguePath { get; set; } = ""; - - [JsonIgnore] public DialogueInfo? DialogueInfo { get; set; } - - public override int GetId() - { - return RogueNPCID * 100 + DialogueProgress; - } - - public override void Loaded() - { - GameData.RogueNPCDialogueData.Add(GetId(), this); - } - - public bool CanUseInVer(int version) - { - GameData.RogueHandBookEventData.TryGetValue(HandbookEventID, out var handbookEvent); - return DialogueInfo != null && handbookEvent != null && handbookEvent.EventTypeList.Contains(version); - } -} \ No newline at end of file diff --git a/Common/Data/Excel/RogueNPCExcel.cs b/Common/Data/Excel/RogueNPCExcel.cs new file mode 100644 index 00000000..8008a7cc --- /dev/null +++ b/Common/Data/Excel/RogueNPCExcel.cs @@ -0,0 +1,27 @@ +using EggLink.DanhengServer.Data.Config.Rogue; + +namespace EggLink.DanhengServer.Data.Excel; + +[ResourceEntity("RogueNPC.json")] +public class RogueNPCExcel : ExcelResource +{ + public int RogueNPCID { get; set; } + public string NPCJsonPath { get; set; } = string.Empty; + + public RogueNPCConfigInfo? RogueNpcConfig { get; set; } + + public override int GetId() + { + return RogueNPCID; + } + + public override void Loaded() + { + GameData.RogueNPCData.TryAdd(RogueNPCID, this); + } + + public bool CanUseInVer(int version) + { + return RogueNpcConfig != null; + } +} \ No newline at end of file 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 9879b3ba..852b7a0f 100644 --- a/Common/Data/GameData.cs +++ b/Common/Data/GameData.cs @@ -1,4 +1,4 @@ -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Custom; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Rogue; @@ -201,12 +201,26 @@ public static Dictionary> Dial public static Dictionary> RogueMiracleGroupData { get; set; } = []; public static Dictionary RogueMiracleDisplayData { get; private set; } = []; public static Dictionary RogueMonsterData { get; private set; } = []; - public static Dictionary RogueNPCDialogueData { get; private set; } = []; + public static Dictionary RogueNPCData { get; private set; } = []; public static Dictionary RogueRoomData { get; private set; } = []; public static Dictionary RogueTalentData { get; private set; } = []; #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 c5fcfaa9..5fb7b687 100644 --- a/Common/Data/ResourceManager.cs +++ b/Common/Data/ResourceManager.cs @@ -1,5 +1,7 @@ using System.Reflection; using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Rogue; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Custom; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Rogue; @@ -41,29 +43,30 @@ public static void LoadExcel() 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); @@ -74,15 +77,15 @@ public static void LoadExcel() ((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) @@ -101,26 +104,28 @@ public static void LoadExcel() } 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(); @@ -187,11 +192,8 @@ public static void LoadFloorInfo() 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; } } } @@ -248,16 +250,6 @@ public static void LoadMissionInfo() 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 @@ -300,19 +292,28 @@ public static void LoadMissionInfo() 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; } @@ -361,9 +362,9 @@ public static void LoadDialogueInfo() { Logger.Info(I18nManager.Translate("Server.ServerInfo.LoadingItem", I18nManager.Translate("Word.DialogueInfo"))); var count = 0; - foreach (var dialogue in GameData.RogueNPCDialogueData) + foreach (var dialogue in GameData.RogueNPCData) { - var path = ConfigManager.Config.Path.ResourcePath + "/" + dialogue.Value.DialoguePath; + var path = ConfigManager.Config.Path.ResourcePath + "/" + dialogue.Value.NPCJsonPath; var file = new FileInfo(path); if (!file.Exists) continue; try @@ -371,14 +372,11 @@ public static void LoadDialogueInfo() using var reader = file.OpenRead(); using StreamReader reader2 = new(reader); var text = reader2.ReadToEnd().Replace("$type", "Type"); - var dialogueInfo = JsonConvert.DeserializeObject(text); + var dialogueInfo = JsonConvert.DeserializeObject(text); if (dialogueInfo != null) { - dialogue.Value.DialogueInfo = dialogueInfo; + dialogue.Value.RogueNpcConfig = dialogueInfo; dialogueInfo.Loaded(); - if (dialogueInfo.DialogueIds.Count == 0) - // set to invalid - dialogue.Value.DialogueInfo = null; count++; } } @@ -390,7 +388,7 @@ public static void LoadDialogueInfo() } } - if (count < GameData.RogueNPCDialogueData.Count) + if (count < GameData.RogueNPCData.Count) Logger.Warn(I18nManager.Translate("Server.ServerInfo.ConfigMissing", I18nManager.Translate("Word.DialogueInfo"), $"{ConfigManager.Config.Path.ResourcePath}/Config/Level/Rogue/Dialogue", @@ -422,12 +420,9 @@ public static void LoadPerformanceInfo() 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) { @@ -454,12 +449,9 @@ public static void LoadPerformanceInfo() 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) { @@ -497,12 +489,9 @@ public static void LoadSubMissionInfo() 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) { @@ -600,39 +589,37 @@ public static void LoadChessRogueRoomData() customFile = json; foreach (var room in customFile!) - if (room.BlockType == RogueDLCBlockTypeEnum.MonsterNormal) - { - 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) + switch (room.BlockType) { - 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/Database/Lineup/LineupData.cs b/Common/Database/Lineup/LineupData.cs index d0b7e2cf..8a756359 100644 --- a/Common/Database/Lineup/LineupData.cs +++ b/Common/Database/Lineup/LineupData.cs @@ -49,9 +49,10 @@ public bool Heal(int count, bool allowRevive) if (avatarInfo != null) { if (avatarInfo.GetCurHp(IsExtraLineup()) <= 0 && !allowRevive) continue; - if (avatarInfo.GetCurHp(IsExtraLineup()) >= 10000 && count > 0) continue; // full hp - if (avatarInfo.GetCurHp(IsExtraLineup()) <= 0 && count < 0) continue; // dead - avatarInfo.SetCurHp(Math.Max(Math.Min(avatarInfo.GetCurHp(IsExtraLineup()) + count, 10000), 0), IsExtraLineup()); + if (avatarInfo.GetCurHp(IsExtraLineup()) >= 10000 && count > 0) continue; // full hp + if (avatarInfo.GetCurHp(IsExtraLineup()) <= 0 && count < 0) continue; // dead + avatarInfo.SetCurHp(Math.Max(Math.Min(avatarInfo.GetCurHp(IsExtraLineup()) + count, 10000), 0), + IsExtraLineup()); result = true; } } @@ -96,7 +97,7 @@ public bool AddPercentSp(int count) if (avatarInfo != null) { if (avatarInfo.CurrentHp <= 0) continue; - avatarInfo.SetCurSp((int)Math.Min(avatarInfo.GetCurSp(IsExtraLineup()) + count, 10000), IsExtraLineup()); + avatarInfo.SetCurSp(Math.Min(avatarInfo.GetCurSp(IsExtraLineup()) + count, 10000), IsExtraLineup()); result = true; } } diff --git a/Common/Database/Player/ServerPrefsData.cs b/Common/Database/Player/ServerPrefsData.cs new file mode 100644 index 00000000..314cc730 --- /dev/null +++ b/Common/Database/Player/ServerPrefsData.cs @@ -0,0 +1,37 @@ +using EggLink.DanhengServer.Proto; +using Google.Protobuf; +using SqlSugar; + +namespace EggLink.DanhengServer.Database.Player; + +[SugarTable("server_prefs_data")] +public class ServerPrefsData : BaseDatabaseDataHelper +{ + [SugarColumn(IsJson = true)] public Dictionary ServerPrefsDict { get; set; } = []; + + public double Version { get; set; } = 2.4; + + public void SetData(int prefsId, string b64Data) + { + ServerPrefsDict[prefsId] = new ServerPrefsInfo + { + ServerPrefsId = prefsId, + Data = b64Data + }; + } +} + +public class ServerPrefsInfo +{ + public int ServerPrefsId { get; set; } + public string Data { get; set; } = ""; + + public ServerPrefs ToProto() + { + return new ServerPrefs + { + Data = ByteString.FromBase64(Data), + ServerPrefsId = (uint)ServerPrefsId + }; + } +} \ No newline at end of file diff --git a/Common/Enums/Rogue/RogueDialogueTypeEnum.cs b/Common/Enums/Rogue/RogueDialogueTypeEnum.cs new file mode 100644 index 00000000..0e9809b0 --- /dev/null +++ b/Common/Enums/Rogue/RogueDialogueTypeEnum.cs @@ -0,0 +1,9 @@ +namespace EggLink.DanhengServer.Enums.Rogue; + +public enum RogueDialogueTypeEnum +{ + None = 0, + Story = 1, + Event = 2, + Store = 3 +} \ No newline at end of file diff --git a/Common/Enums/Rogue/RogueSubModeEnum.cs b/Common/Enums/Rogue/RogueSubModeEnum.cs new file mode 100644 index 00000000..a65dac7b --- /dev/null +++ b/Common/Enums/Rogue/RogueSubModeEnum.cs @@ -0,0 +1,11 @@ +namespace EggLink.DanhengServer.Enums.Rogue; + +public enum RogueSubModeEnum +{ + None = 0, + CosmosRogue = 101, + CosmosRogueEndless = 102, + ChessRogue = 201, + ChessRogueNous = 202, + TournRogue = 301 +} \ No newline at end of file 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/DanhengKcpSharp/DanhengKcpSharp.dll b/DanhengKcpSharp/DanhengKcpSharp.dll index 95dd54ac..a6d4e54e 100644 Binary files a/DanhengKcpSharp/DanhengKcpSharp.dll and b/DanhengKcpSharp/DanhengKcpSharp.dll differ diff --git a/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs b/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs index 7e5ed4d6..edfbc242 100644 --- a/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs +++ b/GameServer/Game/Activity/Loaders/TrialActivityEntityLoader.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Scene; using EggLink.DanhengServer.GameServer.Game.Player; diff --git a/GameServer/Game/Challenge/ChallengeEntityLoader.cs b/GameServer/Game/Challenge/ChallengeEntityLoader.cs index 08f463f5..52688d4a 100644 --- a/GameServer/Game/Challenge/ChallengeEntityLoader.cs +++ b/GameServer/Game/Challenge/ChallengeEntityLoader.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Scene; using EggLink.DanhengServer.GameServer.Game.Player; 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 async ValueTask StartChallenge(int challengeId, ChallengeStoryBuffInfo? s 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 async ValueTask StartChallenge(int challengeId, ChallengeStoryBuffInfo? s // Enter scene try { - await Player.EnterScene(Excel.MapEntranceID, 0, false); + await Player.EnterScene(excel.MapEntranceID, 0, false); } catch { @@ -107,7 +107,7 @@ public async ValueTask StartChallenge(int challengeId, ChallengeStoryBuffInfo? s 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/ChessRogue/Cell/ChessRogueEntityLoader.cs b/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs index 01d8ad57..cd5798a0 100644 --- a/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs +++ b/GameServer/Game/ChessRogue/Cell/ChessRogueEntityLoader.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Rogue; using EggLink.DanhengServer.Enums.Scene; diff --git a/GameServer/Game/ChessRogue/ChessRogueInstance.cs b/GameServer/Game/ChessRogue/ChessRogueInstance.cs index 0ce24f52..46fb5631 100644 --- a/GameServer/Game/ChessRogue/ChessRogueInstance.cs +++ b/GameServer/Game/ChessRogue/ChessRogueInstance.cs @@ -17,7 +17,7 @@ namespace EggLink.DanhengServer.GameServer.Game.ChessRogue; public class ChessRogueInstance : BaseRogueInstance { public ChessRogueInstance(PlayerInstance player, RogueDLCAreaExcel areaExcel, RogueNousAeonExcel aeonExcel, - int rogueVersionId, int branchId) : base(player, rogueVersionId, aeonExcel.RogueBuffType) + RogueSubModeEnum rogueSubMode, int branchId) : base(player, rogueSubMode, aeonExcel.RogueBuffType) { CurLineup = player.LineupManager!.GetCurLineup()!; Player = player; @@ -29,10 +29,7 @@ public ChessRogueInstance(PlayerInstance player, RogueDLCAreaExcel areaExcel, Ro CurLayer = Layers.First(); EventManager = new RogueEventManager(player, this); - if (rogueVersionId == 202) - RogueType = 160; - else - RogueType = 130; + RogueType = rogueSubMode == RogueSubModeEnum.ChessRogueNous ? 160 : 130; foreach (var difficulty in areaExcel.DifficultyID) if (GameData.RogueDLCDifficultyData.TryGetValue(difficulty, out var diff)) @@ -63,7 +60,7 @@ public ChessRogueInstance(PlayerInstance player, RogueDLCAreaExcel areaExcel, Ro public List HistoryCell { get; set; } = []; public int StartCell { get; set; } - public List Layers { get; set; } = []; + public List Layers { get; set; } public int CurLayer { get; set; } public RogueDLCChessBoardExcel? CurBoardExcel { get; set; } public ChessRogueLevelStatus CurLevelStatus { get; set; } = ChessRogueLevelStatus.ChessRogueLevelProcessing; @@ -167,16 +164,17 @@ public override async ValueTask OnBattleEnd(BattleInstance battle, PVEBattleResu await RollBuff(battle.Stages.Count); - if (CurCell!.CellType == RogueDLCBlockTypeEnum.MonsterBoss) - { - await Player.SendPacket(new PacketChessRogueLayerAccountInfoNotify(this)); - } - else if (CurCell!.CellType == RogueDLCBlockTypeEnum.MonsterNousBoss || - CurCell!.CellType == RogueDLCBlockTypeEnum.MonsterSwarmBoss) + switch (CurCell!.CellType) { - CurLevelStatus = ChessRogueLevelStatus.ChessRogueLevelFinish; - await Player.SendPacket(new PacketChessRogueLayerAccountInfoNotify(this)); - await Player.SendPacket(new PacketChessRogueUpdateLevelBaseInfoScNotify(CurLevelStatus)); + case RogueDLCBlockTypeEnum.MonsterBoss: + await Player.SendPacket(new PacketChessRogueLayerAccountInfoNotify(this)); + break; + case RogueDLCBlockTypeEnum.MonsterNousBoss: + case RogueDLCBlockTypeEnum.MonsterSwarmBoss: + CurLevelStatus = ChessRogueLevelStatus.ChessRogueLevelFinish; + await Player.SendPacket(new PacketChessRogueLayerAccountInfoNotify(this)); + await Player.SendPacket(new PacketChessRogueUpdateLevelBaseInfoScNotify(CurLevelStatus)); + break; } } @@ -290,10 +288,9 @@ public void GenerateLayer() LayerMap = GameConstants.AllowedChessRogueEntranceId.RandomElement(); - if (RogueVersionId == 201) - CurBoardExcel = GameData.RogueSwarmChessBoardData[level].RandomElement(); - else - CurBoardExcel = GameData.RogueNousChessBoardData[level].RandomElement(); + CurBoardExcel = RogueSubMode == RogueSubModeEnum.ChessRogue + ? GameData.RogueSwarmChessBoardData[level].RandomElement() + : GameData.RogueNousChessBoardData[level].RandomElement(); RogueCells.Clear(); CurCell = null; @@ -454,19 +451,17 @@ public ChessRogueCurrentInfo ToProto() GameMiracleInfo = ToMiracleInfo(), RogueBuffInfo = ToBuffInfo(), RogueAeonInfo = ToAeonInfo(), - RogueSubMode = (uint)RogueVersionId, + RogueSubMode = (uint)RogueSubMode, RogueDiceInfo = DiceInstance.ToProto(), RogueLineupInfo = ToLineupInfo(), RogueDifficultyInfo = ToDifficultyInfo(), VirtualItemInfo = ToVirtualItemInfo(), - LevelInfo = ToLevelInfo() + LevelInfo = ToLevelInfo(), + PendingAction = RogueActions.Count > 0 + ? RogueActions.First().Value.ToProto() + : new RogueCommonPendingAction() }; - if (RogueActions.Count > 0) - proto.PendingAction = RogueActions.First().Value.ToProto(); - else - proto.PendingAction = new RogueCommonPendingAction(); - proto.RogueCurrentGameInfo.AddRange(ToGameInfo()); return proto; @@ -487,7 +482,7 @@ public ChessRogueQueryGameInfo ToRogueGameInfo() { var proto = new ChessRogueQueryGameInfo { - RogueSubMode = (uint)RogueVersionId + RogueSubMode = (uint)RogueSubMode }; proto.RogueCurrentGameInfo.AddRange(ToGameInfo()); @@ -627,16 +622,15 @@ public RogueVirtualItem ToVirtualItemInfo() public ChessRogueLevelInfo ToLevelInfo() { List canSelected = []; - foreach (var cell in RogueCells) - if (cell.Value.CellStatus == ChessRogueBoardCellStatus.Idle) - { - if (cell.Value.PosY == CurCell!.PosY - 1 || cell.Value.PosY == CurCell!.PosY + 1) - if (cell.Value.PosX == CurCell!.PosX || cell.Value.PosX == CurCell!.PosX + 1) - canSelected.Add((uint)cell.Value.GetCellId()); - if (cell.Value.PosY == CurCell!.PosY) - if (cell.Value.PosX == CurCell!.PosX + 2) - canSelected.Add((uint)cell.Value.GetCellId()); - } + foreach (var cell in RogueCells.Where(cell => cell.Value.CellStatus == ChessRogueBoardCellStatus.Idle)) + { + if (cell.Value.PosY == CurCell!.PosY - 1 || cell.Value.PosY == CurCell!.PosY + 1) + if (cell.Value.PosX == CurCell!.PosX || cell.Value.PosX == CurCell!.PosX + 1) + canSelected.Add((uint)cell.Value.GetCellId()); + if (cell.Value.PosY != CurCell!.PosY) continue; + if (cell.Value.PosX == CurCell!.PosX + 2) + canSelected.Add((uint)cell.Value.GetCellId()); + } var proto = new ChessRogueLevelInfo { @@ -670,7 +664,7 @@ public ChessRogueFinishInfo ToFinishInfo() RogueLineup = CurLineup!.ToProto(), DifficultyLevel = uint.Parse(AreaExcel.AreaID.ToString().Substring(AreaExcel.AreaID.ToString().Length - 1, 1)), - RogueSubMode = (uint)RogueVersionId, + RogueSubMode = (uint)RogueSubMode, RogueBuffInfo = new ChessRogueBuff { BuffList = { RogueBuffs.Select(x => x.ToCommonProto()) } diff --git a/GameServer/Game/Inventory/InventoryManager.cs b/GameServer/Game/Inventory/InventoryManager.cs index 38681dab..552171e9 100644 --- a/GameServer/Game/Inventory/InventoryManager.cs +++ b/GameServer/Game/Inventory/InventoryManager.cs @@ -553,7 +553,8 @@ public async ValueTask> SellItem(ItemCostData costData) return items; } - public async ValueTask<(Retcode, List? returnItems)> UseItem(int itemId, int count = 1, int baseAvatarId = 0) + public async ValueTask<(Retcode, List? returnItems)> UseItem(int itemId, int count = 1, + int baseAvatarId = 0) { GameData.ItemConfigData.TryGetValue(itemId, out var itemConfig); if (itemConfig == null) return (Retcode.RetItemNotExist, null); @@ -561,12 +562,9 @@ public async ValueTask> SellItem(ItemCostData costData) GameData.ItemUseBuffDataData.TryGetValue(dataId, out var useConfig); if (useConfig == null) return (Retcode.RetItemUseConfigNotExist, null); - for (int i = 0; i < count; i++) // do count times + for (var i = 0; i < count; i++) // do count times { - if (useConfig.PreviewSkillPoint != 0) - { - await Player.LineupManager!.GainMp((int)useConfig.PreviewSkillPoint); - } + if (useConfig.PreviewSkillPoint != 0) await Player.LineupManager!.GainMp((int)useConfig.PreviewSkillPoint); if (baseAvatarId > 0) { @@ -578,25 +576,30 @@ public async ValueTask> SellItem(ItemCostData costData) if (useConfig.PreviewHPRecoveryPercent != 0) { - avatar.SetCurHp(Math.Min(Math.Max(avatar.CurrentHp + (int)(useConfig.PreviewHPRecoveryPercent * 10000), 0), 10000), extraLineup); + avatar.SetCurHp( + Math.Min(Math.Max(avatar.CurrentHp + (int)(useConfig.PreviewHPRecoveryPercent * 10000), 0), + 10000), extraLineup); await Player.SendPacket(new PacketSyncLineupNotify(Player.LineupManager.GetCurLineup()!)); } if (useConfig.PreviewHPRecoveryValue != 0) { - avatar.SetCurHp(Math.Min(Math.Max(avatar.CurrentHp + (int)useConfig.PreviewHPRecoveryValue, 0), 10000), extraLineup); + avatar.SetCurHp( + Math.Min(Math.Max(avatar.CurrentHp + (int)useConfig.PreviewHPRecoveryValue, 0), 10000), + extraLineup); await Player.SendPacket(new PacketSyncLineupNotify(Player.LineupManager.GetCurLineup()!)); } if (useConfig.PreviewPowerPercent != 0) { - avatar.SetCurSp(Math.Min(Math.Max(avatar.CurrentHp + (int)(useConfig.PreviewPowerPercent * 10000), 0), 10000), extraLineup); + avatar.SetCurSp( + Math.Min(Math.Max(avatar.CurrentHp + (int)(useConfig.PreviewPowerPercent * 10000), 0), 10000), + extraLineup); await Player.SendPacket(new PacketSyncLineupNotify(Player.LineupManager.GetCurLineup()!)); } - } else { @@ -626,22 +629,14 @@ public async ValueTask> SellItem(ItemCostData costData) //maze buff if (useConfig.MazeBuffID > 0) - { foreach (var info in Player.SceneInstance?.AvatarInfo.Values.ToList() ?? []) - { if (baseAvatarId == 0 || info.AvatarInfo.GetBaseAvatarId() == baseAvatarId) await info.AddBuff(new SceneBuff(useConfig.MazeBuffID, 1, info.AvatarInfo.AvatarId)); - } - } if (useConfig.MazeBuffID2 > 0) - { foreach (var info in Player.SceneInstance?.AvatarInfo.Values.ToList() ?? []) - { if (baseAvatarId == 0 || info.AvatarInfo.GetBaseAvatarId() == baseAvatarId) await info.AddBuff(new SceneBuff(useConfig.MazeBuffID2, 1, info.AvatarInfo.AvatarId)); - } - } // remove item await RemoveItem(itemId, count); diff --git a/GameServer/Game/Lineup/LineupManager.cs b/GameServer/Game/Lineup/LineupManager.cs index c1f984ea..e6ec64fa 100644 --- a/GameServer/Game/Lineup/LineupManager.cs +++ b/GameServer/Game/Lineup/LineupManager.cs @@ -359,7 +359,8 @@ public async ValueTask CostMp(int count, uint castEntityId = 1) await Player.SendPacket(new PacketSceneCastSkillMpUpdateScNotify(castEntityId, curLineup.Mp)); } - public async ValueTask GainMp(int count, bool sendPacket = true, SyncLineupReason reason = SyncLineupReason.SyncReasonNone) + public async ValueTask GainMp(int count, bool sendPacket = true, + SyncLineupReason reason = SyncLineupReason.SyncReasonNone) { var curLineup = GetCurLineup()!; curLineup.Mp += count; diff --git a/GameServer/Game/Mission/StoryLineEntityLoader.cs b/GameServer/Game/Mission/StoryLineEntityLoader.cs index 1b041b3f..764b872e 100644 --- a/GameServer/Game/Mission/StoryLineEntityLoader.cs +++ b/GameServer/Game/Mission/StoryLineEntityLoader.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Scene; using EggLink.DanhengServer.GameServer.Game.Scene; diff --git a/GameServer/Game/Player/PlayerInstance.cs b/GameServer/Game/Player/PlayerInstance.cs index 95e7ccca..6cdb7ede 100644 --- a/GameServer/Game/Player/PlayerInstance.cs +++ b/GameServer/Game/Player/PlayerInstance.cs @@ -23,6 +23,7 @@ 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; } @@ -76,6 +78,7 @@ public class PlayerInstance(PlayerData data) public HeartDialData? HeartDialData { get; private set; } public TutorialData? TutorialData { get; private set; } public TutorialGuideData? TutorialGuideData { get; private set; } + public ServerPrefsData? ServerPrefsData { get; private set; } public SceneInstance? SceneInstance { get; private set; } public int Uid { get; set; } public Connection? Connection { get; set; } @@ -137,6 +140,7 @@ private async ValueTask InitialPlayerManager() 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); @@ -148,6 +152,8 @@ private async ValueTask InitialPlayerManager() HeartDialData = InitializeDatabase(); TutorialData = InitializeDatabase(); TutorialGuideData = InitializeDatabase(); + ServerPrefsData = InitializeDatabase(); + Data.LastActiveTime = Extensions.GetUnixSec(); @@ -191,7 +197,7 @@ private async ValueTask InitialPlayerManager() foreach (var avatar in LineupManager.GetCurLineup()!.BaseAvatars!) { var avatarData = AvatarManager.GetAvatar(avatar.BaseAvatarId); - if (avatarData != null && avatarData.CurrentHp <= 0) + if (avatarData is { CurrentHp: <= 0 }) // revive avatarData.CurrentHp = 2000; } @@ -391,123 +397,116 @@ public async ValueTask OnMove() public async ValueTask InteractProp(int propEntityId, int interactId) { - if (SceneInstance != null) + if (SceneInstance == null) return null; + SceneInstance.Entities.TryGetValue(propEntityId, out var entity); + if (entity is not EntityProp prop) return null; + GameData.InteractConfigData.TryGetValue(interactId, out var config); + if (config == null || config.SrcState != prop.State) return prop; + var oldState = prop.State; + await prop.SetState(config.TargetState); + var newState = prop.State; + await SendPacket(new PacketGroupStateChangeScNotify(Data.EntryId, prop.GroupID, prop.State)); + + switch (prop.Excel.PropType) { - SceneInstance.Entities.TryGetValue(propEntityId, out var entity); - if (entity == null) return null; - if (entity is EntityProp prop) - { - GameData.InteractConfigData.TryGetValue(interactId, out var config); - if (config == null || config.SrcState != prop.State) return prop; - var oldState = prop.State; - await prop.SetState(config.TargetState); - var newState = prop.State; - await SendPacket(new PacketGroupStateChangeScNotify(Data.EntryId, prop.GroupID, prop.State)); - - switch (prop.Excel.PropType) + case PropTypeEnum.PROP_TREASURE_CHEST: + if (oldState == PropStateEnum.ChestClosed && newState == PropStateEnum.ChestUsed) { - case PropTypeEnum.PROP_TREASURE_CHEST: - if (oldState == PropStateEnum.ChestClosed && newState == PropStateEnum.ChestUsed) - { - // TODO: Filter treasure chest - var items = DropService.CalculateDropsFromProp(); - await SceneInstance.Player.InventoryManager!.AddItems(items); - } - - break; - case PropTypeEnum.PROP_DESTRUCT: - if (newState == PropStateEnum.Closed) await prop.SetState(PropStateEnum.Open); - break; - case PropTypeEnum.PROP_MAZE_JIGSAW: - case PropTypeEnum.PROP_MAZE_PUZZLE: - if (newState == PropStateEnum.Closed || newState == PropStateEnum.Open) - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) - { - if (p.Excel.PropType == PropTypeEnum.PROP_TREASURE_CHEST) - { - await p.SetState(PropStateEnum.ChestUsed); - } - else if (p.Excel.PropType == prop.Excel.PropType) - { - // Skip - } - else - { - await p.SetState(PropStateEnum.Open); - } - - await MissionManager!.OnPlayerInteractWithProp(); - } - - break; - case PropTypeEnum.PROP_ORDINARY: - if (prop.PropInfo.CommonConsole) - // set group - foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) - { - await p.SetState(newState); - - await MissionManager!.OnPlayerInteractWithProp(); - } - - break; + // TODO: Filter treasure chest + var items = DropService.CalculateDropsFromProp(); + await SceneInstance.Player.InventoryManager!.AddItems(items); } - // for door unlock - if (prop.PropInfo.UnlockDoorID.Count > 0) - foreach (var id in prop.PropInfo.UnlockDoorID) - foreach (var p in SceneInstance.GetEntitiesInGroup(id.Key)) - if (id.Value.Contains(p.PropInfo.ID)) + break; + case PropTypeEnum.PROP_DESTRUCT: + if (newState == PropStateEnum.Closed) await prop.SetState(PropStateEnum.Open); + break; + case PropTypeEnum.PROP_MAZE_JIGSAW: + case PropTypeEnum.PROP_MAZE_PUZZLE: + if (newState == PropStateEnum.Closed || newState == PropStateEnum.Open) + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) + { + if (p.Excel.PropType == PropTypeEnum.PROP_TREASURE_CHEST) + { + await p.SetState(PropStateEnum.ChestUsed); + } + else if (p.Excel.PropType == prop.Excel.PropType) + { + // Skip + } + else { await p.SetState(PropStateEnum.Open); - await MissionManager!.OnPlayerInteractWithProp(); } - // for mission - await MissionManager!.OnPlayerInteractWithProp(); + await MissionManager!.OnPlayerInteractWithProp(); + } - // plane event - InventoryManager!.HandlePlaneEvent(prop.PropInfo.EventID); + break; + case PropTypeEnum.PROP_ORDINARY: + if (prop.PropInfo.CommonConsole) + // set group + foreach (var p in SceneInstance.GetEntitiesInGroup(prop.GroupID)) + { + await p.SetState(newState); - // handle plugin event - InvokeOnPlayerInteract(this, prop); + await MissionManager!.OnPlayerInteractWithProp(); + } - var floorSavedKey = prop.PropInfo.Name.Replace("Controller_", ""); - var key = $"FSV_ML{floorSavedKey}{(config.TargetState == PropStateEnum.Open ? "Started" : "Complete")}"; + break; + } - if (prop.Group.GroupName.Contains("JigsawPuzzle") && prop.Group.GroupName.Contains("MainLine")) - { - var splits = prop.Group.GroupName.Split('_'); - key = - $"JG_ML_{splits[3]}_Puzzle{(config.TargetState == PropStateEnum.Open ? "Started" : "Complete")}"; - } + // for door unlock + if (prop.PropInfo.UnlockDoorID.Count > 0) + foreach (var p in prop.PropInfo.UnlockDoorID.SelectMany(id => + SceneInstance.GetEntitiesInGroup(id.Key) + .Where(p => id.Value.Contains(p.PropInfo.ID)))) + { + await p.SetState(PropStateEnum.Open); + await MissionManager!.OnPlayerInteractWithProp(); + } - if (SceneInstance?.FloorInfo?.SavedValues.Find(x => x.Name == key) != null) - { - // should save - var plane = SceneInstance.PlaneId; - var floor = SceneInstance.FloorId; - SceneData!.FloorSavedData.TryGetValue(floor, out var value); - if (value == null) - { - value = []; - SceneData.FloorSavedData[floor] = value; - } + // for mission + await MissionManager!.OnPlayerInteractWithProp(); - value[key] = 1; // ParamString[2] is the key - await SendPacket(new PacketUpdateFloorSavedValueNotify(key, 1)); + // plane event + InventoryManager!.HandlePlaneEvent(prop.PropInfo.EventID); - TaskManager?.SceneTaskTrigger.TriggerFloor(plane, floor); - MissionManager?.HandleFinishType(MissionFinishTypeEnum.FloorSavedValue); - } + // handle plugin event + InvokeOnPlayerInteract(this, prop); - if (prop.PropInfo.IsLevelBtn) await prop.SetState(PropStateEnum.Closed); + var floorSavedKey = prop.PropInfo.Name.Replace("Controller_", ""); + var key = $"FSV_ML{floorSavedKey}{(config.TargetState == PropStateEnum.Open ? "Started" : "Complete")}"; - return prop; + if (prop.Group.GroupName.Contains("JigsawPuzzle") && prop.Group.GroupName.Contains("MainLine")) + { + var splits = prop.Group.GroupName.Split('_'); + key = + $"JG_ML_{splits[3]}_Puzzle{(config.TargetState == PropStateEnum.Open ? "Started" : "Complete")}"; + } + + if (SceneInstance?.FloorInfo?.SavedValues.Find(x => x.Name == key) != null) + { + // should save + var plane = SceneInstance.PlaneId; + var floor = SceneInstance.FloorId; + SceneData!.FloorSavedData.TryGetValue(floor, out var value); + if (value == null) + { + value = []; + SceneData.FloorSavedData[floor] = value; } + + value[key] = 1; // ParamString[2] is the key + await SendPacket(new PacketUpdateFloorSavedValueNotify(key, 1)); + + TaskManager?.SceneTaskTrigger.TriggerFloor(plane, floor); + MissionManager?.HandleFinishType(MissionFinishTypeEnum.FloorSavedValue); } - return null; + if (prop.PropInfo.IsLevelBtn) await prop.SetState(PropStateEnum.Closed); + + return prop; } public async ValueTask EnterScene(int entryId, int teleportId, bool sendPacket, int storyLineId = 0, @@ -525,7 +524,6 @@ public async ValueTask EnterScene(int entryId, int teleportId, bool sendPa if (entrance == null) return false; GameData.GetFloorInfo(entrance.PlaneID, entrance.FloorID, out var floorInfo); - if (floorInfo == null) return false; // Record last plane id for train view if (entrance.PlaneID != 10000) LastWorldId = GameData.MazePlaneData[entrance.PlaneID].WorldID; @@ -569,7 +567,6 @@ public async ValueTask EnterMissionScene(int entranceId, int anchorGroupId, int if (entrance == null) return; GameData.GetFloorInfo(entrance.PlaneID, entrance.FloorID, out var floorInfo); - if (floorInfo == null) return; var startGroup = anchorGroupId == 0 ? entrance.StartGroupID : anchorGroupId; var startAnchor = anchorId == 0 ? entrance.StartAnchorID : anchorId; diff --git a/GameServer/Game/Rogue/BaseRogueInstance.cs b/GameServer/Game/Rogue/BaseRogueInstance.cs index d32ab47e..b0bb29d3 100644 --- a/GameServer/Game/Rogue/BaseRogueInstance.cs +++ b/GameServer/Game/Rogue/BaseRogueInstance.cs @@ -1,6 +1,7 @@ using EggLink.DanhengServer.Data; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Database.Inventory; +using EggLink.DanhengServer.Enums.Rogue; using EggLink.DanhengServer.GameServer.Game.Battle; using EggLink.DanhengServer.GameServer.Game.Player; using EggLink.DanhengServer.GameServer.Game.Rogue.Buff; @@ -16,11 +17,11 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue; -public abstract class BaseRogueInstance(PlayerInstance player, int rogueVersionId, int rogueBuffType) +public abstract class BaseRogueInstance(PlayerInstance player, RogueSubModeEnum rogueSubMode, int rogueBuffType) { public PlayerInstance Player { get; set; } = player; public LineupInfo? CurLineup { get; set; } - public int RogueVersionId { get; set; } = rogueVersionId; + public RogueSubModeEnum RogueSubMode { get; set; } = rogueSubMode; public int RogueType { get; set; } = 100; public int CurReviveCost { get; set; } = 80; public int CurRerollCost { get; set; } = 30; @@ -94,7 +95,7 @@ public virtual async ValueTask RollBuff(int amount, int buffGroupId, int buffHin var result = buff.ToResultProto(source); if (notify) - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, result, displayType)); + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, result, displayType)); if (updateMenu) await UpdateMenu(); @@ -112,7 +113,7 @@ public virtual async ValueTask AddBuffList(List excel) if (res != null) resultList.Add(res); } - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, resultList, + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, resultList, RogueCommonActionResultDisplayType.Multi)); await UpdateMenu(); @@ -129,7 +130,7 @@ public virtual async ValueTask EnhanceBuff(int buffId, if (excel != null) { buff.BuffLevel++; - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, buff.ToResultProto(source), RogueCommonActionResultDisplayType.Single)); } } @@ -160,7 +161,7 @@ public virtual async ValueTask HandleBuffSelect(int buffId) { var instance = new RogueBuffInstance(buff.MazeBuffID, buff.MazeBuffLevel); RogueBuffs.Add(instance); - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, instance.ToResultProto(RogueCommonActionResultSourceType.Select))); } } @@ -182,7 +183,7 @@ public virtual async ValueTask HandleRerollBuff() { await action.RogueBuffSelectMenu.RerollBuff(); // reroll await Player.SendPacket( - new PacketHandleRogueCommonPendingActionScRsp(RogueVersionId, menu: action.RogueBuffSelectMenu)); + new PacketHandleRogueCommonPendingActionScRsp(action.QueuePosition, menu: action.RogueBuffSelectMenu)); } } @@ -190,13 +191,12 @@ await Player.SendPacket( #region Money - public async ValueTask CostMoney(int amount, - RogueCommonActionResultDisplayType displayType = RogueCommonActionResultDisplayType.None) + public async ValueTask CostMoney(int amount, int displayType = 0) { CurMoney -= amount; await Player.SendPacket(new PacketSyncRogueCommonVirtualItemInfoScNotify(this)); - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, new RogueCommonActionResult { Source = RogueCommonActionResultSourceType.Dialogue, @@ -205,14 +205,13 @@ await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersi RemoveItemList = new RogueCommonMoney { Num = (uint)amount, - DisplayType = (uint)displayType + 1 + DisplayType = (uint)displayType } } - }, displayType)); + }, RogueCommonActionResultDisplayType.Single)); } - public async ValueTask GainMoney(int amount, int displayType = 2, - RogueCommonActionResultDisplayType display = RogueCommonActionResultDisplayType.None) + public async ValueTask GainMoney(int amount, int displayType = 0) { CurMoney += amount; await Player.SendPacket(new PacketSyncRogueCommonVirtualItemInfoScNotify(this)); @@ -222,7 +221,7 @@ await Player.SendPacket(new PacketScenePlaneEventScNotify(new ItemData Count = amount })); - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, new RogueCommonActionResult { Source = RogueCommonActionResultSourceType.Dialogue, @@ -234,7 +233,7 @@ await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersi DisplayType = (uint)displayType } } - }, display)); + }, RogueCommonActionResultDisplayType.Single)); } #endregion @@ -295,7 +294,7 @@ public virtual async ValueTask AddMiracle(int miracleId) var miracle = new RogueMiracleInstance(this, miracleId); RogueMiracles.Add(miracleId, miracle); - await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueVersionId, miracle.ToGetResult(), + await Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(RogueSubMode, miracle.ToGetResult(), RogueCommonActionResultDisplayType.Single)); } @@ -311,7 +310,7 @@ public virtual async ValueTask HandleBonusSelect(int bonusId) // TODO: handle bonus GameData.RogueBonusData.TryGetValue(bonusId, out var bonus); - if (bonus != null) TriggerEvent(null, bonus.BonusEvent); + if (bonus != null) await TriggerEvent(null, bonus.BonusEvent); RogueActions.Remove(action.QueuePosition); await UpdateMenu(); @@ -323,7 +322,7 @@ public virtual async ValueTask UpdateMenu() { if (RogueActions.Count > 0) await Player.SendPacket( - new PacketSyncRogueCommonPendingActionScNotify(RogueActions.First().Value, RogueVersionId)); + new PacketSyncRogueCommonPendingActionScNotify(RogueActions.First().Value, RogueSubMode)); } #endregion @@ -352,17 +351,18 @@ public virtual async ValueTask OnPropDestruct(EntityProp prop) #region Events - public void TriggerEvent(RogueEventInstance? rogueEvent, int eventId) + public async ValueTask TriggerEvent(RogueEventInstance? rogueEvent, int eventId) { - EventManager?.TriggerEvent(rogueEvent, eventId); + if (EventManager == null) return; + await EventManager.TriggerEvent(rogueEvent, eventId); } public async ValueTask GenerateEvent(RogueNpc npc) { - RogueNPCDialogueExcel? dialogue; + RogueNPCExcel? dialogue; do { - dialogue = GameData.RogueNPCDialogueData.Values.ToList().RandomElement(); + dialogue = GameData.RogueNPCData.Values.ToList().RandomElement(); } while (!dialogue.CanUseInVer(RogueType)); var instance = new RogueEventInstance(dialogue, npc, CurEventUniqueID++); diff --git a/GameServer/Game/Rogue/Buff/RogueBuffSelectMenu.cs b/GameServer/Game/Rogue/Buff/RogueBuffSelectMenu.cs index b5b71e49..fcd5fbb4 100644 --- a/GameServer/Game/Rogue/Buff/RogueBuffSelectMenu.cs +++ b/GameServer/Game/Rogue/Buff/RogueBuffSelectMenu.cs @@ -9,7 +9,7 @@ public class RogueBuffSelectMenu(BaseRogueInstance rogue) public int HintId { get; set; } = 1; public List Buffs { get; set; } = []; public int RollMaxCount { get; set; } = rogue.BaseRerollCount; - public int RollCount { get; set; } = rogue.BaseRerollCount; + public int RollCount { get; set; } public int RollFreeCount { get; set; } = rogue.BaseRerollFreeCount; public int RollCost { get; set; } = rogue.CurRerollCost; public int QueueAppend { get; set; } = 3; @@ -27,9 +27,9 @@ public void RollBuff(List buffs, int count = 3) foreach (var buff in buffs) if (buff.RogueBuffType == rogue.RogueBuffType) - list.Add(buff, (int)(20 / (int)buff.RogueBuffCategory * 2.5)); + list.Add(buff, (int)(20f / (int)buff.RogueBuffCategory * 2.5)); else - list.Add(buff, (int)(20 / (int)buff.RogueBuffCategory * 0.7)); + list.Add(buff, (int)(20f / (int)buff.RogueBuffCategory * 0.7)); var result = new List(); for (var i = 0; i < count; i++) @@ -55,12 +55,12 @@ public async ValueTask RerollBuff() } else { - if (RollCount <= 0) return; - RollCount--; // Paid reroll + if (RollMaxCount - RollCount <= 0) return; + RollCount++; // Paid reroll await rogue.CostMoney(RollCost); } - RollBuff(BuffPool); + RollBuff(BuffPool.ToList()); } public RogueActionInstance GetActionInstance() @@ -77,7 +77,7 @@ public RogueCommonBuffSelectInfo ToProto() { return new RogueCommonBuffSelectInfo { - CanRoll = RollCount > 0, + CanRoll = true, RollBuffCount = (uint)RollCount, RollBuffFreeCount = (uint)RollFreeCount, RollBuffMaxCount = (uint)RollMaxCount, diff --git a/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemPercent.cs b/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemPercent.cs index c3723d3a..229ab402 100644 --- a/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemPercent.cs +++ b/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemPercent.cs @@ -1,5 +1,4 @@ using EggLink.DanhengServer.Enums.Rogue; -using EggLink.DanhengServer.Proto; namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.CostHandler; @@ -9,7 +8,6 @@ public class EventHandlerCostItemPercent : RogueEventCostHandler public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList) { - await rogue.CostMoney((int)(rogue.CurMoney * (paramList[1] / 100f)), - RogueCommonActionResultDisplayType.Single); + await rogue.CostMoney((int)(rogue.CurMoney * (paramList[1] / 100f))); } } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemValue.cs b/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemValue.cs index c80c2044..d2887b62 100644 --- a/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemValue.cs +++ b/GameServer/Game/Rogue/Event/CostHandler/EventHandlerCostItemValue.cs @@ -1,5 +1,4 @@ using EggLink.DanhengServer.Enums.Rogue; -using EggLink.DanhengServer.Proto; namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.CostHandler; @@ -10,6 +9,6 @@ public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstan List paramList) { var decreaseMoney = paramList[1]; - await rogue.CostMoney(decreaseMoney, RogueCommonActionResultDisplayType.Single); + await rogue.CostMoney(decreaseMoney); } } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerEnhanceRogueBuff.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerEnhanceRogueBuff.cs index 135022b6..a543f239 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerEnhanceRogueBuff.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerEnhanceRogueBuff.cs @@ -7,8 +7,13 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.EnhanceRogueBuff)] public class EventHandlerEnhanceRogueBuff : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { var group = paramList[0]; GameData.RogueBuffGroupData.TryGetValue(group, out var buffGroup); diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroup.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroup.cs index 42b53fc5..2a4ce1ae 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroup.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroup.cs @@ -6,8 +6,13 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.GetAllRogueBuffInGroup)] public class EventHandlerGetAllRogueBuffInGroup : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { var group = paramList[0]; GameData.RogueBuffGroupData.TryGetValue(group, out var buffGroup); diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroupAndGetItem.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroupAndGetItem.cs index b6f36c0c..c8198ba6 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroupAndGetItem.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetAllRogueBuffInGroupAndGetItem.cs @@ -1,20 +1,23 @@ using EggLink.DanhengServer.Data; using EggLink.DanhengServer.Enums.Rogue; -using EggLink.DanhengServer.Proto; namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.GetAllRogueBuffInGroupAndGetItem)] public class EventHandlerGetAllRogueBuffInGroupAndGetItem : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { var group = paramList[0]; GameData.RogueBuffGroupData.TryGetValue(group, out var buffGroup); if (buffGroup == null) return; await rogue.AddBuffList(buffGroup.BuffList); - await rogue.GainMoney(paramList[2], paramList[3], - RogueCommonActionResultDisplayType.Single); + await rogue.GainMoney(paramList[2], paramList[3]); } } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetItem.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetItem.cs index 2354ff8b..2febb211 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetItem.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetItem.cs @@ -1,15 +1,18 @@ using EggLink.DanhengServer.Enums.Rogue; -using EggLink.DanhengServer.Proto; namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.GetItem)] public class EventHandlerGetItem : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { - await rogue.GainMoney(paramList[1], paramList[2], - RogueCommonActionResultDisplayType.Single); + await rogue.GainMoney(paramList[1], paramList[2]); } } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueBuff.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueBuff.cs index 0929930e..86eadd5c 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueBuff.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueBuff.cs @@ -7,8 +7,13 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.GetRogueBuff)] public class EventHandlerGetRogueBuff : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { var groupId = paramList[0]; GameData.RogueBuffGroupData.TryGetValue(groupId, out var buffGroup); diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueMiracle.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueMiracle.cs index 4410cbf8..81ba808f 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueMiracle.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerGetRogueMiracle.cs @@ -7,8 +7,13 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.GetRogueMiracle)] public class EventHandlerGetRogueMiracle : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { var miracleGroupId = paramList[0]; GameData.RogueMiracleGroupData.TryGetValue(miracleGroupId, out var miracleGroup); diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerRepeatableGamble.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerRepeatableGamble.cs new file mode 100644 index 00000000..227ec6ab --- /dev/null +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerRepeatableGamble.cs @@ -0,0 +1,39 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.Util; + +namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; + +[RogueEvent(DialogueEventTypeEnum.RepeatableGamble)] +public class EventHandlerRepeatableGamble : RogueEventEffectHandler +{ + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + if (option == null) return; + option.Ratio = paramList[1] / 100f; + } + + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, + List paramList, RogueEventParam? option) + { + if (option == null) return; + if (eventInstance == null) return; + var winRatio = option.Ratio * 10000; + var randomInt = Extensions.RandomInt(0, 10001); + if (randomInt <= winRatio) + { + // win + eventInstance.EffectEventId.SafeAdd(paramList[0]); + option.OverrideSelected = true; + await rogue.TriggerEvent(eventInstance, paramList[0]); + } + else + { + // lose + eventInstance.EffectEventId.SafeAdd(paramList[3]); + option.OverrideSelected = false; + option.Ratio += paramList[2] / 100f; + await rogue.TriggerEvent(eventInstance, paramList[3]); + } + } +} \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerBattle.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerBattle.cs new file mode 100644 index 00000000..0c74ed43 --- /dev/null +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerBattle.cs @@ -0,0 +1,24 @@ +using EggLink.DanhengServer.Enums.Rogue; + +namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; + +[RogueEvent(DialogueEventTypeEnum.TriggerBattle)] +public class EventHandlerTriggerBattle : RogueEventEffectHandler +{ + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, + List paramList, RogueEventParam? option) + { + if (option == null) return; + if (paramList.Count == 0) return; + option.Results.Add(new RogueEventResultInfo + { + BattleEventId = paramList[0] + }); + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerDialogueEventList.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerDialogueEventList.cs index 21461f30..6324b3b6 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerDialogueEventList.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerDialogueEventList.cs @@ -1,20 +1,23 @@ using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.Util; namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.TriggerDialogueEventList)] public class EventHandlerTriggerDialogueEventList : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { foreach (var param in paramList) { - eventInstance!.Options.Add(new RogueEventParam - { - OptionId = param - }); - rogue.TriggerEvent(eventInstance, param); + eventInstance?.EffectEventId.SafeAdd(param); + await rogue.TriggerEvent(eventInstance, param); } await System.Threading.Tasks.Task.CompletedTask; diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRandomEventList.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRandomEventList.cs index 4997fba7..36309222 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRandomEventList.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRandomEventList.cs @@ -6,18 +6,20 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.TriggerRandomEventList)] public class EventHandlerTriggerRandomEventList : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { var list = new RandomList(); for (var i = 0; i < paramList.Count; i += 2) list.Add(paramList[i], paramList[i + 1]); var randomEvent = list.GetRandom(); - eventInstance!.Options.Add(new RogueEventParam - { - OptionId = randomEvent - }); - rogue.TriggerEvent(eventInstance, randomEvent); + eventInstance?.EffectEventId.SafeAdd(randomEvent); + await rogue.TriggerEvent(eventInstance, randomEvent); await System.Threading.Tasks.Task.CompletedTask; } diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueBuffSelect.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueBuffSelect.cs index 28c38111..9298fc65 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueBuffSelect.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueBuffSelect.cs @@ -5,8 +5,13 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.TriggerRogueBuffSelect)] public class EventHandlerTriggerRogueBuffSelect : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { await rogue.RollBuff(paramList[2], paramList[0], paramList[1]); } diff --git a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueMiracleSelect.cs b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueMiracleSelect.cs index c67545b6..5fd31873 100644 --- a/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueMiracleSelect.cs +++ b/GameServer/Game/Rogue/Event/EffectHandler/EventHandlerTriggerRogueMiracleSelect.cs @@ -5,8 +5,13 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event.EffectHandler; [RogueEvent(DialogueEventTypeEnum.TriggerRogueMiracleSelect)] public class EventHandlerTriggerRogueMiracleSelect : RogueEventEffectHandler { + public override void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option) + { + } + public override async ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, - List paramList) + List paramList, RogueEventParam? option) { await rogue.RollMiracle(paramList[2], paramList[0]); } diff --git a/GameServer/Game/Rogue/Event/RogueEventEffectHandler.cs b/GameServer/Game/Rogue/Event/RogueEventEffectHandler.cs index 2a98edbf..f67546ba 100644 --- a/GameServer/Game/Rogue/Event/RogueEventEffectHandler.cs +++ b/GameServer/Game/Rogue/Event/RogueEventEffectHandler.cs @@ -2,5 +2,9 @@ public abstract class RogueEventEffectHandler { - public abstract ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList); + public abstract void Init(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option); + + public abstract ValueTask Handle(BaseRogueInstance rogue, RogueEventInstance? eventInstance, List paramList, + RogueEventParam? option); } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/RogueEventInstance.cs b/GameServer/Game/Rogue/Event/RogueEventInstance.cs index 60a7e296..79ab1cbe 100644 --- a/GameServer/Game/Rogue/Event/RogueEventInstance.cs +++ b/GameServer/Game/Rogue/Event/RogueEventInstance.cs @@ -8,12 +8,12 @@ namespace EggLink.DanhengServer.GameServer.Game.Rogue.Event; public class RogueEventInstance(int eventId, RogueNpc npc, List optionIds, int uniqueId) { - public RogueEventInstance(RogueNPCDialogueExcel excel, RogueNpc npc, int uniqueId) : this(excel.RogueNPCID, npc, [], + public RogueEventInstance(RogueNPCExcel excel, RogueNpc npc, int uniqueId) : this(excel.RogueNPCID, npc, [], uniqueId) // check in RogueInstance.cs { - foreach (var option in excel.DialogueInfo!.DialogueIds) + foreach (var option in excel.RogueNpcConfig!.DialogueList[0].OptionInfo?.OptionList ?? []) { - GameData.DialogueEventData.TryGetValue(option, out var dialogueEvent); + GameData.DialogueEventData.TryGetValue(option.OptionID, out var dialogueEvent); if (dialogueEvent == null) continue; var argId = 0; @@ -25,7 +25,7 @@ public RogueEventInstance(RogueNPCDialogueExcel excel, RogueNpc npc, int uniqueI Options.Add(new RogueEventParam { - OptionId = option, + OptionId = option.OptionID, ArgId = argId }); } @@ -37,6 +37,7 @@ public RogueEventInstance(RogueNPCDialogueExcel excel, RogueNpc npc, int uniqueI public List Options { get; set; } = optionIds; public int EventUniqueId { get; set; } = uniqueId; public int SelectedOptionId { get; set; } = 0; + public List EffectEventId { get; set; } = []; public async ValueTask Finish() { @@ -77,6 +78,8 @@ public class RogueEventParam public int ArgId { get; set; } public float Ratio { get; set; } public bool IsSelected { get; set; } = false; + public bool? OverrideSelected { get; set; } = null; + public List Results { get; set; } = []; public RogueCommonDialogueOptionInfo ToProto() { @@ -89,7 +92,8 @@ public RogueCommonDialogueOptionInfo ToProto() { DisplayFloatValue = Ratio }, - Confirm = IsSelected + OptionResultInfo = { Results.Select(x => x.ToProto()) }, + Confirm = OverrideSelected ?? IsSelected }; } @@ -101,4 +105,20 @@ public NpcDialogueEventParam ToNpcProto() ArgId = (uint)ArgId }; } +} + +public class RogueEventResultInfo +{ + public int BattleEventId { get; set; } + + public RogueCommonDialogueOptionResultInfo ToProto() + { + return new RogueCommonDialogueOptionResultInfo + { + BattleResultInfo = new RogueCommonDialogueOptionBattleResultInfo + { + BattleEventId = (uint)BattleEventId + } + }; + } } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Event/RogueEventManager.cs b/GameServer/Game/Rogue/Event/RogueEventManager.cs index 24d677eb..6205e2b5 100644 --- a/GameServer/Game/Rogue/Event/RogueEventManager.cs +++ b/GameServer/Game/Rogue/Event/RogueEventManager.cs @@ -23,20 +23,18 @@ public RogueEventManager(PlayerInstance player, BaseRogueInstance rogueInstance) foreach (var type in types) { var attr = type.GetCustomAttribute(); - if (attr != null) + if (attr == null) continue; + if (attr.EffectType != DialogueEventTypeEnum.None) { - if (attr.EffectType != DialogueEventTypeEnum.None) - { - // Effect - var effect = (RogueEventEffectHandler)Activator.CreateInstance(type, null)!; - EffectHandler.Add(attr.EffectType, effect); - } - else - { - // Cost - var cost = (RogueEventCostHandler)Activator.CreateInstance(type, null)!; - CostHandler.Add(attr.CostType, cost); - } + // Effect + var effect = (RogueEventEffectHandler)Activator.CreateInstance(type, null)!; + EffectHandler.Add(attr.EffectType, effect); + } + else + { + // Cost + var cost = (RogueEventCostHandler)Activator.CreateInstance(type, null)!; + CostHandler.Add(attr.CostType, cost); } } } @@ -49,6 +47,18 @@ public void OnNextRoom() public async ValueTask AddEvent(RogueEventInstance eventInstance) { RunningEvent.Add(eventInstance); + foreach (var option in eventInstance.Options) + { + GameData.DialogueEventData.TryGetValue(option.OptionId, out var dialogueEvent); + if (dialogueEvent == null) continue; + + var param = dialogueEvent.RogueEffectParamList; + + // Init option + if (EffectHandler.TryGetValue(dialogueEvent.RogueEffectType, out var effectHandler)) + effectHandler.Init(Rogue, eventInstance, param, option); + } + await Player.SendPacket(new PacketSyncRogueCommonDialogueDataScNotify(eventInstance)); } @@ -70,26 +80,23 @@ public async ValueTask NpcDisappear(RogueEventInstance eventInstance) public RogueEventInstance? FindEvent(int optionId) { - foreach (var eventInstance in RunningEvent) - if (eventInstance.Options.Exists(x => x.OptionId == optionId)) - return eventInstance; - return null; + return RunningEvent.FirstOrDefault(eventInstance => eventInstance.Options.Exists(x => x.OptionId == optionId)); } - public void TriggerEvent(RogueEventInstance? eventInstance, int eventId) + public async ValueTask TriggerEvent(RogueEventInstance? eventInstance, int eventId) { GameData.DialogueEventData.TryGetValue(eventId, out var dialogueEvent); if (dialogueEvent == null) return; - var Param = dialogueEvent.RogueEffectParamList; - - // Handle option - if (EffectHandler.TryGetValue(dialogueEvent.RogueEffectType, out var effectHandler)) - effectHandler.Handle(Rogue, eventInstance, Param); + var param = dialogueEvent.RogueEffectParamList; // Handle cost if (CostHandler.TryGetValue(dialogueEvent.CostType, out var costHandler)) - costHandler.Handle(Rogue, eventInstance, dialogueEvent.CostParamList); + await costHandler.Handle(Rogue, eventInstance, dialogueEvent.CostParamList); + + // Handle option + if (EffectHandler.TryGetValue(dialogueEvent.RogueEffectType, out var effectHandler)) + await effectHandler.Handle(Rogue, eventInstance, param, null); } public async ValueTask SelectOption(RogueEventInstance eventInstance, int optionId) @@ -109,7 +116,7 @@ public async ValueTask SelectOption(RogueEventInstance eventInstance, int option return; } - option.IsSelected = true; + await Player.SendPacket(new PacketSyncRogueCommonDialogueDataScNotify(eventInstance)); var param = dialogueEvent.RogueEffectParamList; if (option.ArgId > 0) @@ -128,16 +135,17 @@ public async ValueTask SelectOption(RogueEventInstance eventInstance, int option } } - // Handle option - if (EffectHandler.TryGetValue(dialogueEvent.RogueEffectType, out var effectHandler)) - await effectHandler.Handle(Rogue, eventInstance, param); - // Handle cost if (CostHandler.TryGetValue(dialogueEvent.CostType, out var costHandler)) await costHandler.Handle(Rogue, eventInstance, dialogueEvent.CostParamList); + // Handle option + if (EffectHandler.TryGetValue(dialogueEvent.RogueEffectType, out var effectHandler)) + await effectHandler.Handle(Rogue, eventInstance, param, option); + // send rsp await Player.SendPacket(new PacketSyncRogueCommonDialogueOptionFinishScNotify(eventInstance)); + option.IsSelected = true; await Player.SendPacket(new PacketSelectRogueCommonDialogueOptionScRsp(eventInstance)); } } \ No newline at end of file diff --git a/GameServer/Game/Rogue/Miracle/RogueMiracleInstance.cs b/GameServer/Game/Rogue/Miracle/RogueMiracleInstance.cs index 17511d32..e1b34b8c 100644 --- a/GameServer/Game/Rogue/Miracle/RogueMiracleInstance.cs +++ b/GameServer/Game/Rogue/Miracle/RogueMiracleInstance.cs @@ -119,7 +119,7 @@ public async ValueTask CostDurability(int value) } // send packet - await Instance.Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(Instance.RogueVersionId, + await Instance.Player.SendPacket(new PacketSyncRogueCommonActionResultScNotify(Instance.RogueSubMode, ToGetResult(), RogueCommonActionResultDisplayType.Single)); } } diff --git a/GameServer/Game/Rogue/RogueInstance.cs b/GameServer/Game/Rogue/RogueInstance.cs index fdb1f267..749039fa 100644 --- a/GameServer/Game/Rogue/RogueInstance.cs +++ b/GameServer/Game/Rogue/RogueInstance.cs @@ -1,5 +1,6 @@ using EggLink.DanhengServer.Data; using EggLink.DanhengServer.Data.Excel; +using EggLink.DanhengServer.Enums.Rogue; using EggLink.DanhengServer.GameServer.Game.Battle; using EggLink.DanhengServer.GameServer.Game.Player; using EggLink.DanhengServer.GameServer.Game.Rogue.Buff; @@ -16,7 +17,7 @@ public class RogueInstance : BaseRogueInstance #region Initialization public RogueInstance(RogueAreaConfigExcel areaExcel, RogueAeonExcel aeonExcel, PlayerInstance player) : base(player, - 101, aeonExcel.RogueBuffType) + RogueSubModeEnum.CosmosRogue, aeonExcel.RogueBuffType) { AreaExcel = areaExcel; AeonExcel = aeonExcel; diff --git a/GameServer/Game/Rogue/RogueManager.cs b/GameServer/Game/Rogue/RogueManager.cs index ff86c2a1..940381ee 100644 --- a/GameServer/Game/Rogue/RogueManager.cs +++ b/GameServer/Game/Rogue/RogueManager.cs @@ -19,7 +19,7 @@ public class RogueManager(PlayerInstance player) : BasePlayerManager(player) #region Information /// - /// Get the begin time and end time + /// Get the beginning time and end time /// /// public static (long, long) GetCurrentRogueTime() diff --git a/GameServer/Game/Rogue/Scene/Entity/RogueNpc.cs b/GameServer/Game/Rogue/Scene/Entity/RogueNpc.cs index cb9d3531..c7aefebd 100644 --- a/GameServer/Game/Rogue/Scene/Entity/RogueNpc.cs +++ b/GameServer/Game/Rogue/Scene/Entity/RogueNpc.cs @@ -1,4 +1,4 @@ -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.GameServer.Game.Rogue.Event; using EggLink.DanhengServer.GameServer.Game.Scene; using EggLink.DanhengServer.GameServer.Game.Scene.Entity; diff --git a/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs b/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs index 061f82f5..22b16624 100644 --- a/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs +++ b/GameServer/Game/Rogue/Scene/Entity/RogueProp.cs @@ -1,4 +1,4 @@ -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.GameServer.Game.Scene; using EggLink.DanhengServer.GameServer.Game.Scene.Entity; diff --git a/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs b/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs index 95e13b02..be3008aa 100644 --- a/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs +++ b/GameServer/Game/Rogue/Scene/RogueEntityLoader.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Enums.Scene; using EggLink.DanhengServer.GameServer.Game.Player; using EggLink.DanhengServer.GameServer.Game.Rogue.Scene.Entity; @@ -84,8 +84,6 @@ public override async ValueTask LoadEntity() npc.RogueNpcId = instance.EventId; npc.UniqueId = instance.EventUniqueId; } - - ; } await Scene.AddEntity(npc, sendPacket); diff --git a/GameServer/Game/RogueTourn/RogueTournInstance.cs b/GameServer/Game/RogueTourn/RogueTournInstance.cs new file mode 100644 index 00000000..facf08d8 --- /dev/null +++ b/GameServer/Game/RogueTourn/RogueTournInstance.cs @@ -0,0 +1,5 @@ +namespace EggLink.DanhengServer.GameServer.Game.RogueTourn; + +public class RogueTournInstance +{ +} \ No newline at end of file diff --git a/GameServer/Game/RogueTourn/RogueTournManager.cs b/GameServer/Game/RogueTourn/RogueTournManager.cs new file mode 100644 index 00000000..cf9d69be --- /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(), + PermanentInfo = ToPermanentTalentProto(), + 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 RogueTournPermanentTalentInfo ToPermanentTalentProto() + { + return new RogueTournPermanentTalentInfo + { + 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.HandbookEventList.Add((uint)eventId); + } + + return proto; + } + + #endregion +} \ No newline at end of file diff --git a/GameServer/Game/Scene/Entity/EntityMonster.cs b/GameServer/Game/Scene/Entity/EntityMonster.cs index e9879eb4..3bff8488 100644 --- a/GameServer/Game/Scene/Entity/EntityMonster.cs +++ b/GameServer/Game/Scene/Entity/EntityMonster.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Database.Inventory; using EggLink.DanhengServer.Enums.Mission; diff --git a/GameServer/Game/Scene/Entity/EntityNpc.cs b/GameServer/Game/Scene/Entity/EntityNpc.cs index 867da06e..6c19c81b 100644 --- a/GameServer/Game/Scene/Entity/EntityNpc.cs +++ b/GameServer/Game/Scene/Entity/EntityNpc.cs @@ -1,4 +1,4 @@ -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.GameServer.Game.Battle; using EggLink.DanhengServer.Proto; using EggLink.DanhengServer.Util; diff --git a/GameServer/Game/Scene/Entity/EntityProp.cs b/GameServer/Game/Scene/Entity/EntityProp.cs index e9a11782..fb946ab4 100644 --- a/GameServer/Game/Scene/Entity/EntityProp.cs +++ b/GameServer/Game/Scene/Entity/EntityProp.cs @@ -1,4 +1,4 @@ -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Scene; using EggLink.DanhengServer.GameServer.Game.Battle; diff --git a/GameServer/Game/Scene/SceneEntityLoader.cs b/GameServer/Game/Scene/SceneEntityLoader.cs index b7c2ac8b..ac4d5bff 100644 --- a/GameServer/Game/Scene/SceneEntityLoader.cs +++ b/GameServer/Game/Scene/SceneEntityLoader.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Enums; using EggLink.DanhengServer.Enums.Mission; using EggLink.DanhengServer.Enums.Scene; diff --git a/GameServer/Game/Scene/SceneInstance.cs b/GameServer/Game/Scene/SceneInstance.cs index 22195c1a..bb424fda 100644 --- a/GameServer/Game/Scene/SceneInstance.cs +++ b/GameServer/Game/Scene/SceneInstance.cs @@ -1,5 +1,5 @@ using EggLink.DanhengServer.Data; -using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Database.Avatar; using EggLink.DanhengServer.Enums.Scene; diff --git a/GameServer/Game/Task/LevelTask.cs b/GameServer/Game/Task/LevelTask.cs index 2ee20553..4b722a5b 100644 --- a/GameServer/Game/Task/LevelTask.cs +++ b/GameServer/Game/Task/LevelTask.cs @@ -1,4 +1,5 @@ using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Config.Task; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Mission; diff --git a/GameServer/Server/Packet/Recv/Item/HandlerUseItemCsReq.cs b/GameServer/Server/Packet/Recv/Item/HandlerUseItemCsReq.cs index 7bf151cf..229d86ae 100644 --- a/GameServer/Server/Packet/Recv/Item/HandlerUseItemCsReq.cs +++ b/GameServer/Server/Packet/Recv/Item/HandlerUseItemCsReq.cs @@ -10,8 +10,11 @@ public class HandlerUseItemCsReq : Handler public override async Task OnHandle(Connection connection, byte[] header, byte[] data) { var req = UseItemCsReq.Parser.ParseFrom(data); - var result = await connection.Player!.InventoryManager!.UseItem((int)req.UseItemId, (int)req.UseItemCount, (int)req.BaseAvatarId); + var result = + await connection.Player!.InventoryManager!.UseItem((int)req.UseItemId, (int)req.UseItemCount, + (int)req.BaseAvatarId); - await connection.SendPacket(new PacketUseItemScRsp(result.Item1, req.UseItemId, req.UseItemCount, result.returnItems)); + await connection.SendPacket(new PacketUseItemScRsp(result.Item1, req.UseItemId, req.UseItemCount, + result.returnItems)); } } \ 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/Recv/ServerPrefs/HandlerGetAllServerPrefsDataCsReq.cs b/GameServer/Server/Packet/Recv/ServerPrefs/HandlerGetAllServerPrefsDataCsReq.cs new file mode 100644 index 00000000..60167258 --- /dev/null +++ b/GameServer/Server/Packet/Recv/ServerPrefs/HandlerGetAllServerPrefsDataCsReq.cs @@ -0,0 +1,14 @@ +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ServerPrefs; +using EggLink.DanhengServer.Kcp; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.ServerPrefs; + +[Opcode(CmdIds.GetAllServerPrefsDataCsReq)] +public class HandlerGetAllServerPrefsDataCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + var infos = connection.Player?.ServerPrefsData?.ServerPrefsDict.Values.ToList() ?? []; + await connection.SendPacket(new PacketGetAllServerPrefsDataScRsp(infos)); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Recv/ServerPrefs/HandlerGetServerPrefsDataCsReq.cs b/GameServer/Server/Packet/Recv/ServerPrefs/HandlerGetServerPrefsDataCsReq.cs new file mode 100644 index 00000000..529176bb --- /dev/null +++ b/GameServer/Server/Packet/Recv/ServerPrefs/HandlerGetServerPrefsDataCsReq.cs @@ -0,0 +1,18 @@ +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ServerPrefs; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.ServerPrefs; + +[Opcode(CmdIds.GetServerPrefsDataCsReq)] +public class HandlerGetServerPrefsDataCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + var req = GetServerPrefsDataCsReq.Parser.ParseFrom(data); + + var info = connection.Player!.ServerPrefsData?.ServerPrefsDict.GetValueOrDefault((int)req.ServerPrefsId); + + await connection.SendPacket(new PacketGetServerPrefsDataScRsp(info, req.ServerPrefsId)); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Recv/ServerPrefs/HandlerUpdateServerPrefsDataCsReq.cs b/GameServer/Server/Packet/Recv/ServerPrefs/HandlerUpdateServerPrefsDataCsReq.cs new file mode 100644 index 00000000..16b75441 --- /dev/null +++ b/GameServer/Server/Packet/Recv/ServerPrefs/HandlerUpdateServerPrefsDataCsReq.cs @@ -0,0 +1,18 @@ +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ServerPrefs; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Recv.ServerPrefs; + +[Opcode(CmdIds.UpdateServerPrefsDataCsReq)] +public class HandlerUpdateServerPrefsDataCsReq : Handler +{ + public override async Task OnHandle(Connection connection, byte[] header, byte[] data) + { + var req = UpdateServerPrefsDataCsReq.Parser.ParseFrom(data); + + connection.Player?.ServerPrefsData?.SetData((int)req.ServerPrefs.ServerPrefsId, + req.ServerPrefs.Data.ToBase64()); + await connection.SendPacket(new PacketUpdateServerPrefsDataScRsp(req.ServerPrefs.ServerPrefsId)); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/Battle/PacketPVEBattleResultScRsp.cs b/GameServer/Server/Packet/Send/Battle/PacketPVEBattleResultScRsp.cs index 5d7e07b5..73bfe596 100644 --- a/GameServer/Server/Packet/Send/Battle/PacketPVEBattleResultScRsp.cs +++ b/GameServer/Server/Packet/Send/Battle/PacketPVEBattleResultScRsp.cs @@ -29,7 +29,7 @@ public PacketPVEBattleResultScRsp(PVEBattleResultCsReq req, PlayerInstance playe BattleId = req.BattleId, EndStatus = req.EndStatus, CheckIdentical = true, - Unk1 = new ItemList(), + MultipleDropData = new ItemList(), Unk2 = new ItemList(), Unk3 = new ItemList(), EventId = (uint)battle.EventId diff --git a/GameServer/Server/Packet/Send/Item/PacketUseItemScRsp.cs b/GameServer/Server/Packet/Send/Item/PacketUseItemScRsp.cs index c23fc180..d619969a 100644 --- a/GameServer/Server/Packet/Send/Item/PacketUseItemScRsp.cs +++ b/GameServer/Server/Packet/Send/Item/PacketUseItemScRsp.cs @@ -6,7 +6,8 @@ namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.Item; public class PacketUseItemScRsp : BasePacket { - public PacketUseItemScRsp(Retcode retCode, uint itemId, uint count, List? returnItems) : base(CmdIds.UseItemScRsp) + public PacketUseItemScRsp(Retcode retCode, uint itemId, uint count, List? returnItems) : base( + CmdIds.UseItemScRsp) { var proto = new UseItemScRsp { @@ -18,10 +19,7 @@ public PacketUseItemScRsp(Retcode retCode, uint itemId, uint count, List items) : base(CmdIds.MonthCardRewardNotify) + { + var proto = new MonthCardRewardNotify + { + Reward = new ItemList + { + ItemList_ = { items.Select(x => x.ToProto()) } + } + }; + + SetData(proto); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/Player/PacketPlayerLoginScRsp.cs b/GameServer/Server/Packet/Send/Player/PacketPlayerLoginScRsp.cs index 9ba1cfa1..9e7b6fc8 100644 --- a/GameServer/Server/Packet/Send/Player/PacketPlayerLoginScRsp.cs +++ b/GameServer/Server/Packet/Send/Player/PacketPlayerLoginScRsp.cs @@ -12,8 +12,8 @@ public PacketPlayerLoginScRsp(Connection connection) : base(CmdIds.PlayerLoginSc { CurTimezone = (int)TimeZoneInfo.Local.BaseUtcOffset.TotalHours, ServerTimestampMs = (ulong)Extensions.GetUnixMs(), - BasicInfo = connection?.Player?.ToProto(), // should not be null - Stamina = (uint)(connection?.Player?.Data.Stamina ?? 0) + BasicInfo = connection.Player?.ToProto(), // should not be null + Stamina = (uint)(connection.Player?.Data.Stamina ?? 0) }; SetData(rsp); diff --git a/GameServer/Server/Packet/Send/RogueCommon/PacketSelectRogueCommonDialogueOptionScRsp.cs b/GameServer/Server/Packet/Send/RogueCommon/PacketSelectRogueCommonDialogueOptionScRsp.cs index 65b46fe7..c95ec6ce 100644 --- a/GameServer/Server/Packet/Send/RogueCommon/PacketSelectRogueCommonDialogueOptionScRsp.cs +++ b/GameServer/Server/Packet/Send/RogueCommon/PacketSelectRogueCommonDialogueOptionScRsp.cs @@ -16,6 +16,19 @@ public PacketSelectRogueCommonDialogueOptionScRsp(RogueEventInstance rogueEvent) OptionId = (uint)rogueEvent.SelectedOptionId }; + if (rogueEvent.EffectEventId.Count > 0) + { + proto.EffectEventIdList.AddRange(rogueEvent.EffectEventId.Select(x => (uint)x)); + rogueEvent.EffectEventId.Clear(); + } + + foreach (var option in rogueEvent.Options) + if (option.OverrideSelected ?? option.IsSelected) + { + proto.EventHasEffect = true; + break; + } + SetData(proto); } diff --git a/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonActionResultScNotify.cs b/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonActionResultScNotify.cs index f7bf2855..f6d836c1 100644 --- a/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonActionResultScNotify.cs +++ b/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonActionResultScNotify.cs @@ -1,11 +1,12 @@ -using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.Kcp; using EggLink.DanhengServer.Proto; namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueCommon; public class PacketSyncRogueCommonActionResultScNotify : BasePacket { - public PacketSyncRogueCommonActionResultScNotify(int rogueSubmode, RogueCommonActionResult result, + public PacketSyncRogueCommonActionResultScNotify(RogueSubModeEnum rogueSubmode, RogueCommonActionResult result, RogueCommonActionResultDisplayType displayType = RogueCommonActionResultDisplayType.None) : base( CmdIds.SyncRogueCommonActionResultScNotify) { @@ -20,7 +21,8 @@ public PacketSyncRogueCommonActionResultScNotify(int rogueSubmode, RogueCommonAc SetData(proto); } - public PacketSyncRogueCommonActionResultScNotify(int rogueSubmode, List results, + public PacketSyncRogueCommonActionResultScNotify(RogueSubModeEnum rogueSubmode, + List results, RogueCommonActionResultDisplayType displayType = RogueCommonActionResultDisplayType.None) : base( CmdIds.SyncRogueCommonActionResultScNotify) { diff --git a/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonDialogueOptionFinishScNotify.cs b/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonDialogueOptionFinishScNotify.cs index 8e9a5f21..66093ec6 100644 --- a/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonDialogueOptionFinishScNotify.cs +++ b/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonDialogueOptionFinishScNotify.cs @@ -11,7 +11,6 @@ public PacketSyncRogueCommonDialogueOptionFinishScNotify(RogueEventInstance inst { var proto = new SyncRogueCommonDialogueOptionFinishScNotify { - DialogueData = instance.ToProto(), EventUniqueId = (uint)instance.EventUniqueId, OptionId = (uint)instance.SelectedOptionId, ResultOptionInfo = instance.Options.Find(o => o.OptionId == instance.SelectedOptionId)!.ToProto() diff --git a/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonPendingActionScNotify.cs b/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonPendingActionScNotify.cs index 06c9f914..a6a2acf4 100644 --- a/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonPendingActionScNotify.cs +++ b/GameServer/Server/Packet/Send/RogueCommon/PacketSyncRogueCommonPendingActionScNotify.cs @@ -1,4 +1,5 @@ -using EggLink.DanhengServer.GameServer.Game.Rogue; +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Rogue; using EggLink.DanhengServer.Kcp; using EggLink.DanhengServer.Proto; @@ -6,8 +7,9 @@ namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueCommon; public class PacketSyncRogueCommonPendingActionScNotify : BasePacket { - public PacketSyncRogueCommonPendingActionScNotify(RogueActionInstance actionInstance, int rogueSubmode) : base( - CmdIds.SyncRogueCommonPendingActionScNotify) + public PacketSyncRogueCommonPendingActionScNotify(RogueActionInstance actionInstance, RogueSubModeEnum rogueSubmode) + : base( + CmdIds.SyncRogueCommonPendingActionScNotify) { var proto = new SyncRogueCommonPendingActionScNotify { diff --git a/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournGetPermanentTalentInfoScRsp.cs b/GameServer/Server/Packet/Send/RogueTourn/PacketRogueTournGetPermanentTalentInfoScRsp.cs new file mode 100644 index 00000000..8e611679 --- /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 + { + PermanentInfo = player.RogueTournManager!.ToPermanentTalentProto() + }; + + 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 diff --git a/GameServer/Server/Packet/Send/ServerPrefs/PacketGetAllServerPrefsDataScRsp.cs b/GameServer/Server/Packet/Send/ServerPrefs/PacketGetAllServerPrefsDataScRsp.cs new file mode 100644 index 00000000..2030d259 --- /dev/null +++ b/GameServer/Server/Packet/Send/ServerPrefs/PacketGetAllServerPrefsDataScRsp.cs @@ -0,0 +1,17 @@ +using EggLink.DanhengServer.Database.Player; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.ServerPrefs; + +public class PacketGetAllServerPrefsDataScRsp : BasePacket +{ + public PacketGetAllServerPrefsDataScRsp(List infos) : base(CmdIds.GetAllServerPrefsDataScRsp) + { + var proto = new GetAllServerPrefsDataScRsp(); + + foreach (var info in infos) proto.CFHMFEBMJIK.Add(info.ToProto()); + + SetData(proto); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/ServerPrefs/PacketGetServerPrefsDataScRsp.cs b/GameServer/Server/Packet/Send/ServerPrefs/PacketGetServerPrefsDataScRsp.cs new file mode 100644 index 00000000..a915490e --- /dev/null +++ b/GameServer/Server/Packet/Send/ServerPrefs/PacketGetServerPrefsDataScRsp.cs @@ -0,0 +1,23 @@ +using EggLink.DanhengServer.Database.Player; +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; +using Google.Protobuf; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.ServerPrefs; + +public class PacketGetServerPrefsDataScRsp : BasePacket +{ + public PacketGetServerPrefsDataScRsp(ServerPrefsInfo? info, uint id) : base(CmdIds.GetServerPrefsDataScRsp) + { + var proto = new GetServerPrefsDataScRsp + { + ServerPrefs = info?.ToProto() ?? new Proto.ServerPrefs + { + Data = ByteString.Empty, + ServerPrefsId = id + } + }; + + SetData(proto); + } +} \ No newline at end of file diff --git a/GameServer/Server/Packet/Send/ServerPrefs/PacketUpdateServerPrefsDataScRsp.cs b/GameServer/Server/Packet/Send/ServerPrefs/PacketUpdateServerPrefsDataScRsp.cs new file mode 100644 index 00000000..3f92b6c0 --- /dev/null +++ b/GameServer/Server/Packet/Send/ServerPrefs/PacketUpdateServerPrefsDataScRsp.cs @@ -0,0 +1,17 @@ +using EggLink.DanhengServer.Kcp; +using EggLink.DanhengServer.Proto; + +namespace EggLink.DanhengServer.GameServer.Server.Packet.Send.ServerPrefs; + +public class PacketUpdateServerPrefsDataScRsp : BasePacket +{ + public PacketUpdateServerPrefsDataScRsp(uint prefsId) : base(CmdIds.UpdateServerPrefsDataScRsp) + { + var proto = new UpdateServerPrefsDataScRsp + { + ServerPrefsId = prefsId + }; + + SetData(proto); + } +} \ No newline at end of file diff --git a/Program/Program/EntryPoint.cs b/Program/Program/EntryPoint.cs index e5ece483..006c89cb 100644 --- a/Program/Program/EntryPoint.cs +++ b/Program/Program/EntryPoint.cs @@ -4,6 +4,7 @@ using EggLink.DanhengServer.Data; using EggLink.DanhengServer.Database; using EggLink.DanhengServer.Enums; +using EggLink.DanhengServer.Enums.Rogue; using EggLink.DanhengServer.GameServer.Command; using EggLink.DanhengServer.GameServer.Plugin; using EggLink.DanhengServer.GameServer.Server; @@ -26,12 +27,12 @@ public class EntryPoint public static void Main(string[] args) { - AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) => + AppDomain.CurrentDomain.ProcessExit += (_, _) => { Logger.Info(I18nManager.Translate("Server.ServerInfo.Shutdown")); PerformCleanup(); }; - Console.CancelKeyPress += (sender, eventArgs) => + Console.CancelKeyPress += (_, eventArgs) => { Logger.Info(I18nManager.Translate("Server.ServerInfo.CancelKeyPressed")); eventArgs.Cancel = true; @@ -161,10 +162,10 @@ public static void Main(string[] args) { status = PlayerStatusEnum.Rogue; if ((con as Connection)!.Player!.ChessRogueManager?.RogueInstance?.AreaExcel.RogueVersionId == - 202) + RogueSubModeEnum.ChessRogue) status = PlayerStatusEnum.ChessRogueNous; else if ((con as Connection)!.Player!.ChessRogueManager?.RogueInstance?.AreaExcel - .RogueVersionId == 201) + .RogueVersionId == RogueSubModeEnum.ChessRogueNous) status = PlayerStatusEnum.ChessRogue; } else if ((con as Connection)!.Player!.ChallengeManager?.ChallengeInstance != null) @@ -202,7 +203,7 @@ public static void Main(string[] args) HandlerManager.Init(); - WebProgram.Main([], GetConfig().HttpServer.PublicPort, GetConfig().HttpServer.GetDisplayAddress()); + WebProgram.Main([], GetConfig().HttpServer.Port, GetConfig().HttpServer.GetBindDisplayAddress()); Logger.Info(I18nManager.Translate("Server.ServerInfo.ServerRunning", I18nManager.Translate("Word.Dispatch"), GetConfig().HttpServer.GetDisplayAddress())); diff --git a/Proto/DanhengProto.dll b/Proto/DanhengProto.dll index 304b0dc0..d6b06050 100644 Binary files a/Proto/DanhengProto.dll and b/Proto/DanhengProto.dll differ diff --git a/WebServer/Handler/QueryGatewayHandler.cs b/WebServer/Handler/QueryGatewayHandler.cs index 3197ced8..fd8b1a2e 100644 --- a/WebServer/Handler/QueryGatewayHandler.cs +++ b/WebServer/Handler/QueryGatewayHandler.cs @@ -19,7 +19,7 @@ public QueryGatewayHandler() { RegionName = config.GameServer.GameServerId, Ip = config.GameServer.PublicAddress, - Port = config.GameServer.PublicPort, + Port = config.GameServer.Port, Msg = "Access verification failed. Please check if you have logged in to the correct account and server.", Unk1 = true, Unk2 = true,