diff --git a/Common/Data/Config/AdventureAbility/AdventureModifierConfig.cs b/Common/Data/Config/AdventureAbility/AdventureModifierConfig.cs new file mode 100644 index 00000000..bcc02f60 --- /dev/null +++ b/Common/Data/Config/AdventureAbility/AdventureModifierConfig.cs @@ -0,0 +1,126 @@ +using EggLink.DanhengServer.Data.Config.Task; +using Newtonsoft.Json.Linq; + +namespace EggLink.DanhengServer.Data.Config.AdventureAbility; + +public class AdventureModifierConfig +{ + public float LifeTime { get; set; } + public int Level { get; set; } + public int LevelMax { get; set; } + public bool IsCountDownAfterBattle { get; set; } + + public bool ApplyBehaviorFlagBindEffects { get; set; } + + //public AdventureModifierBehaviorFlag[] BehaviorFlagList{ get; set; } + public float TickInterval { get; set; } + public List OnInterval { get; set; } = []; + public List OnAdd { get; set; } = []; + public List OnCreate { get; set; } = []; + public List OnDestroy { get; set; } = []; + public List OnStack { get; set; } = []; + public List OnAttack { get; set; } = []; + public List OnBeforeBattle { get; set; } = []; + public List OnAfterBattle { get; set; } = []; + public List OnStage { get; set; } = []; + public List OnUnstage { get; set; } = []; + public List OnForeGround { get; set; } = []; + public List OnBackGround { get; set; } = []; + public List OnStageByStory { get; set; } = []; + public List OnNpcMonsterCreate { get; set; } = []; + public List OnTeamLeaderChange { get; set; } = []; + public List OnBeforeAttack { get; set; } = []; + public List OnBeAttack { get; set; } = []; + public List OnModifierAdd { get; set; } = []; + public List OnModifierRemove { get; set; } = []; + public List OnOwnerBeKilled { get; set; } = []; + public List OnAfterLocalPlayerUseSkill { get; set; } = []; + public List ModifierTaskList { get; set; } = []; + + public List OnCounterAttack { get; set; } = []; + + //public MazeBuffType MazeBuffType { get; set; } + public int Priority { get; set; } + + public int Count { get; set; } + //public ModifierStacking Stacking { get; set; } + + + public static AdventureModifierConfig LoadFromJObject(JObject obj) + { + var info = new AdventureModifierConfig(); + + if (obj.ContainsKey(nameof(Level))) + info.Level = obj[nameof(Level)]!.ToObject(); + + if (obj.ContainsKey(nameof(LevelMax))) + info.LevelMax = obj[nameof(LevelMax)]!.ToObject(); + + if (obj.ContainsKey(nameof(LifeTime))) + info.LifeTime = obj[nameof(LifeTime)]!.ToObject(); + + if (obj.ContainsKey(nameof(Count))) + info.Count = obj[nameof(Count)]!.ToObject(); + + if (obj.ContainsKey(nameof(TickInterval))) + info.TickInterval = obj[nameof(TickInterval)]!.ToObject(); + + if (obj.ContainsKey(nameof(IsCountDownAfterBattle))) + info.IsCountDownAfterBattle = obj[nameof(IsCountDownAfterBattle)]!.ToObject(); + + if (obj.ContainsKey(nameof(ApplyBehaviorFlagBindEffects))) + info.ApplyBehaviorFlagBindEffects = obj[nameof(ApplyBehaviorFlagBindEffects)]!.ToObject(); + + if (obj.ContainsKey(nameof(OnInterval))) + info.OnInterval = obj[nameof(OnInterval)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnAdd))) + info.OnAdd = obj[nameof(OnAdd)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnCreate))) + info.OnCreate = obj[nameof(OnCreate)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnDestroy))) + info.OnDestroy = obj[nameof(OnDestroy)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnStack))) + info.OnStack = obj[nameof(OnStack)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnAttack))) + info.OnAttack = obj[nameof(OnAttack)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnBeforeBattle))) + info.OnBeforeBattle = obj[nameof(OnBeforeBattle)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnAfterBattle))) + info.OnAfterBattle = obj[nameof(OnAfterBattle)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnStage))) + info.OnStage = obj[nameof(OnStage)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnUnstage))) + info.OnUnstage = obj[nameof(OnUnstage)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnForeGround))) + info.OnForeGround = obj[nameof(OnForeGround)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + if (obj.ContainsKey(nameof(OnBackGround))) + info.OnBackGround = obj[nameof(OnBackGround)]?.Select(x => TaskConfigInfo.LoadFromJsonObject((x as JObject)!)) + .ToList() ?? []; + + // TODO: others + + return info; + } +} \ No newline at end of file diff --git a/Common/Data/Config/AdventureAbility/AdventureModifierLookupTableConfig.cs b/Common/Data/Config/AdventureAbility/AdventureModifierLookupTableConfig.cs new file mode 100644 index 00000000..695b1480 --- /dev/null +++ b/Common/Data/Config/AdventureAbility/AdventureModifierLookupTableConfig.cs @@ -0,0 +1,23 @@ +using EggLink.DanhengServer.Data.Config.Task; +using NetTaste; +using Newtonsoft.Json.Linq; +using System.Diagnostics; + +namespace EggLink.DanhengServer.Data.Config.AdventureAbility; + +public class AdventureModifierLookupTableConfig +{ + public Dictionary ModifierMap { get; set; } = []; + + public static AdventureModifierLookupTableConfig LoadFromJObject(JObject obj) + { + var info = new AdventureModifierLookupTableConfig(); + + if (!obj.ContainsKey(nameof(ModifierMap))) return info; + foreach (var jObject in obj[nameof(ModifierMap)]!.ToObject>()!) + { + info.ModifierMap.Add(jObject.Key, AdventureModifierConfig.LoadFromJObject(jObject.Value)); + } + return info; + } +} \ No newline at end of file diff --git a/Common/Data/Excel/MazeBuffExcel.cs b/Common/Data/Excel/MazeBuffExcel.cs index 9151dd0c..3cbdc7b5 100644 --- a/Common/Data/Excel/MazeBuffExcel.cs +++ b/Common/Data/Excel/MazeBuffExcel.cs @@ -7,6 +7,7 @@ public class MazeBuffExcel : ExcelResource { public int ID { get; set; } public int Lv { get; set; } + public string ModifierName { get; set; } = string.Empty; public override int GetId() { diff --git a/Common/Data/GameData.cs b/Common/Data/GameData.cs index 248a96b6..9c88f4f5 100644 --- a/Common/Data/GameData.cs +++ b/Common/Data/GameData.cs @@ -1,4 +1,5 @@ using System.Collections.Concurrent; +using EggLink.DanhengServer.Data.Config.AdventureAbility; using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Custom; using EggLink.DanhengServer.Data.Excel; @@ -111,6 +112,8 @@ public static class GameData public static Dictionary GroupSystemUnlockDataData { get; private set; } = []; public static Dictionary FuncUnlockDataData { get; private set; } = []; + public static Dictionary AdventureModifierData { get; set; } = []; + #endregion #region Items diff --git a/Common/Data/ResourceManager.cs b/Common/Data/ResourceManager.cs index 39d9d065..09f3e195 100644 --- a/Common/Data/ResourceManager.cs +++ b/Common/Data/ResourceManager.cs @@ -1,5 +1,6 @@ using System.Reflection; using EggLink.DanhengServer.Data.Config; +using EggLink.DanhengServer.Data.Config.AdventureAbility; using EggLink.DanhengServer.Data.Config.Rogue; using EggLink.DanhengServer.Data.Config.Scene; using EggLink.DanhengServer.Data.Config.SummonUnit; @@ -33,6 +34,7 @@ public class ResourceManager var t5 = Task.Run(LoadPerformanceInfo); var t6 = Task.Run(LoadDialogueInfo); var t7 = Task.Run(LoadRogueChestMapInfo); + var t8 = Task.Run(LoadAdventureModifier); GameData.ActivityConfig = LoadCustomFile("Activity", "ActivityConfig") ?? new ActivityConfig(); GameData.BannersConfig = LoadCustomFile("Banner", "Banners") ?? new BannersConfig(); GameData.RogueMapGenData = LoadCustomFile>>("Rogue Map", "RogueMapGen") ?? []; @@ -45,7 +47,7 @@ public class ResourceManager LoadRogueTournRoomData(); LoadChessRogueDiceSurfaceEffectData(); - Task.WaitAll(t1, t2, t3, t4, t5, t6, t7); + Task.WaitAll(t1, t2, t3, t4, t5, t6, t7, t8); } public static void LoadExcel() @@ -656,6 +658,59 @@ public class ResourceManager I18NManager.Translate("Word.RogueChestMapInfo"))); } + public static void LoadAdventureModifier() + { + Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadingItem", + I18NManager.Translate("Word.AdventureModifierInfo"))); + var count = 0; + + // list the files in folder + var directory = new DirectoryInfo($"{ConfigManager.Config.Path.ResourcePath}/Config/ConfigAdventureModifier"); + if (!directory.Exists) + { + Logger.Warn(I18NManager.Translate("Server.ServerInfo.ConfigMissing", + I18NManager.Translate("Word.AdventureModifierInfo"), + $"{ConfigManager.Config.Path.ResourcePath}/Config/ConfigAdventureModifier", + I18NManager.Translate("Word.Buff"))); + + return; + } + var files = directory.GetFiles(); + + foreach (var file in files) + { + 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 = AdventureModifierLookupTableConfig.LoadFromJObject(obj); + + foreach (var config in info.ModifierMap) + { + GameData.AdventureModifierData.Add(config.Key, config.Value); + count++; + } + } + catch (Exception ex) + { + Logger.Error( + I18NManager.Translate("Server.ServerInfo.FailedToReadItem", file.Name, + I18NManager.Translate("Word.Error")), ex); + } + } + + //if (count < boardList.Count) + // Logger.Warn(I18NManager.Translate("Server.ServerInfo.ConfigMissing", + // I18NManager.Translate("Word.AdventureModifierInfo"), + // $"{ConfigManager.Config.Path.ResourcePath}/Config/ConfigAdventureModifier", + // I18NManager.Translate("Word.Buff"))); + + Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadedItems", count.ToString(), + I18NManager.Translate("Word.AdventureModifierInfo"))); + } + public static void LoadChessRogueRoomData() { Logger.Info(I18NManager.Translate("Server.ServerInfo.LoadingItem", diff --git a/Config/ChessRogueDiceSurfaceEffect.json b/Config/ChessRogueDiceSurfaceEffect.json index e17f52af..4c809622 100644 --- a/Config/ChessRogueDiceSurfaceEffect.json +++ b/Config/ChessRogueDiceSurfaceEffect.json @@ -136,7 +136,7 @@ "EffectType": "SetBlockTypeToAround", "Params": { "SourceType": "3", - "TargetType": "3", + "TargetType": "0", "Count": "1" } } @@ -161,7 +161,7 @@ { "EffectType": "SwapCellToCurAround", "Params": { - "SourceType": "3,5" + "SourceType": "3;5" } } ] @@ -172,6 +172,7 @@ { "EffectType": "ReplicateCurCellToRandom", "Params": { + "SourceType": "1;2;3;4;5;6;7;8;9;10;13;14;16;17", "Count": 2 } } @@ -183,7 +184,7 @@ { "EffectType": "SetColCanMove", "Params": { - "Count": "~1;~2;~3" + "Column": "~1;~2;~3" } } ] @@ -223,7 +224,7 @@ "SurfaceId": 2063, "ContentEffects": [ { - "EffectType": "SetRandomCellToTargeType", + "EffectType": "TurnRandomCellBlockType", "Params": { "SourceType": "1;2;3;4;5;6;7;8;9;10;14;16;17", "TargetType": "13", diff --git a/GameServer/Game/ChessRogue/ChessRogueInstance.cs b/GameServer/Game/ChessRogue/ChessRogueInstance.cs index f77ab82e..bc416888 100644 --- a/GameServer/Game/ChessRogue/ChessRogueInstance.cs +++ b/GameServer/Game/ChessRogue/ChessRogueInstance.cs @@ -1,4 +1,5 @@ using EggLink.DanhengServer.Data; +using EggLink.DanhengServer.Data.Config.AdventureAbility; using EggLink.DanhengServer.Data.Custom; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Enums.Rogue; @@ -74,6 +75,7 @@ public class ChessRogueInstance : BaseRogueInstance public Dictionary RogueCells { get; set; } = []; public ChessRogueCellInstance? CurCell { get; set; } + public List CanMoveCellIdList { get; set; } = []; public List HistoryCell { get; set; } = []; public int StartCell { get; set; } @@ -209,6 +211,38 @@ public class ChessRogueInstance : BaseRogueInstance #region Buff Management + public override void HandleMazeBuffModifier(AdventureModifierConfig config, MazeBuff buff) + { + var task = config.OnBeforeBattle; + + foreach (var info in task) + { + if (!info.Type.Replace("RPG.GameCore.", "").StartsWith("SetDynamicValueBy")) continue; + var key = info.Type.Replace("RPG.GameCore.SetDynamicValueBy", ""); + var value = key switch + { + "ItemNum" => CurMoney, + "RogueMiracleNum" => RogueMiracles.Count, + "RogueBuffNumWithType" => RogueBuffs.Count, + "RogueModifierCount" => DiceInstance.Modifier == null ? 0: 1, + "RogueLayer" => Layers.IndexOf(CurLayer) + 1, + _ => 0 + }; + + key = key switch + { + "ItemNum" => "ItemNumber", + "RogueMiracleNum" => "RogueMiracleNumber", + "RogueBuffNumWithType" => "RogueBuffNumberWithType", + "RogueModifierCount" => "RogueModifierCount", + "RogueLayer" => "_RogueLayer", + _ => key + }; + + buff.DynamicValues.Add(key, value); + } + } + public override async ValueTask RollBuff(int amount) { if (CurCell!.BlockType == RogueDLCBlockTypeEnum.MonsterBoss) @@ -691,6 +725,10 @@ public class ChessRogueInstance : BaseRogueInstance canSelected.Add((uint)cell.Value.GetCellId()); } + canSelected.AddRange(CanMoveCellIdList.Select(i => (uint)i)); + + CanMoveCellIdList.Clear(); // clear + var proto = new ChessRogueLevelInfo { LevelStatus = (uint)CurLevelStatus, diff --git a/GameServer/Game/ChessRogue/Modifier/ChessRogueDiceModifierInstance.cs b/GameServer/Game/ChessRogue/Modifier/ChessRogueDiceModifierInstance.cs index 36fc205f..f5d7e7ae 100644 --- a/GameServer/Game/ChessRogue/Modifier/ChessRogueDiceModifierInstance.cs +++ b/GameServer/Game/ChessRogue/Modifier/ChessRogueDiceModifierInstance.cs @@ -58,7 +58,7 @@ public class ChessRogueDiceModifierInstance(int modifierId, ChessRogueDiceSurfac instance.ModifierEffectHandlers.TryGetValue(effect, out var handler); if (handler != null) - handler.BeforeBattle(this, battle); + handler.BeforeBattle(this, battle, instance); else IsConfirmed = true; } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectAddMazeBuff.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectAddMazeBuff.cs new file mode 100644 index 00000000..7cae0bbd --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectAddMazeBuff.cs @@ -0,0 +1,58 @@ +using EggLink.DanhengServer.Data; +using EggLink.DanhengServer.Data.Excel; +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.AddMazeBuff)] +public class ModifierEffectAddMazeBuff : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + modifierInstance.IsConfirmed = true; + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + modifierInstance.EffectConfig.Params.TryGetValue("BuffId", out var buffId); + if (buffId == null) return; + + var buff = new MazeBuff(int.Parse(buffId), 1, -1) + { + WaveFlag = -1 + }; + + GameData.MazeBuffData.TryGetValue(int.Parse(buffId) * 10 + 1, out var buffExcel); + if (buffExcel != null) + { + var modifier = GameData.AdventureModifierData.GetValueOrDefault(buffExcel.ModifierName); + if (modifier != null) + { + // handle modifier + instance.HandleMazeBuffModifier(modifier, buff); + } + } + + battle.Buffs.Add(buff); + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectChangeSelectCellType.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectChangeSelectCellType.cs index 7bfab754..85835e37 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectChangeSelectCellType.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectChangeSelectCellType.cs @@ -46,7 +46,8 @@ public class ModifierEffectChangeSelectCellType : ModifierEffectHandler await ValueTask.CompletedTask; } - public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) { } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReRandomCellTypeGetMoney.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReRandomCellTypeGetMoney.cs new file mode 100644 index 00000000..923e7c1e --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReRandomCellTypeGetMoney.cs @@ -0,0 +1,72 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ChessRogue; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueModifier; +using EggLink.DanhengServer.Proto; +using EggLink.DanhengServer.Util; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.ReRandomCellTypeGetMoney)] +public class ModifierEffectReRandomCellTypeGetMoney : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); + + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed()); + modifierInstance.SelectableCells.AddRange(cells.Select(x => x.Key)); + } + + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, + ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await chessRogueInstance.Player.SendPacket( + new PacketRogueModifierStageStartNotify(modifierInstance.SourceType)); + modifierInstance.SelectedCell = selectCellId; + modifierInstance.IsConfirmed = true; + + var targetCell = chessRogueInstance.RogueCells[selectCellId]; + var reRandomType = targetCell.BlockType; + var refreshCell = chessRogueInstance.RogueCells.Values.Where(x => + x.BlockType == reRandomType && !x.IsCollapsed()).ToList(); + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("TargetType", "3").Split(";"); + var targetType = types.Select(x => (RogueDLCBlockTypeEnum)int.Parse(x)).ToList(); + + foreach (var cell in refreshCell) + { + cell.BlockType = targetType.RandomElement(); + } + + // get money + var money = int.Parse(modifierInstance.EffectConfig.Params.GetValueOrDefault("Count", "0")); + await chessRogueInstance.GainMoney(money); + + await chessRogueInstance.Player.SendPacket(new PacketChessRogueCellUpdateNotify(refreshCell, + chessRogueInstance.CurBoardExcel?.ChessBoardID ?? 0, modifierInstance.SourceType, + ChessRogueCellUpdateReason.Modifier)); + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToRandom.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToRandom.cs new file mode 100644 index 00000000..4c59cfb8 --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToRandom.cs @@ -0,0 +1,70 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; +using EggLink.DanhengServer.GameServer.Game.ChessRogue.Cell; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ChessRogue; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueModifier; +using EggLink.DanhengServer.Proto; +using EggLink.DanhengServer.Util; +using System.Collections.Generic; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.ReplicateCurCellToRandom)] +public class ModifierEffectReplicateCurCellToRandom : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + await chessRogueInstance.Player.SendPacket(new PacketRogueModifierStageStartNotify(modifierInstance.SourceType)); + + List targetCells = []; // list of cells can be changed + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); // get the target types + var count = int.Parse(modifierInstance.EffectConfig.Params.GetValueOrDefault("Count", "1")); // get the count of cells to change + var curCell = chessRogueInstance.CurCell; + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => // get all cells with the target type + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed()); + + targetCells.AddRange(cells.Select(x => x.Value)); // add the cells to the list + } + + List updated = []; + for (var i = 0; i < count; i++) + { + if (targetCells.Count == 0) // if there are no more cells to change, quit the loop + break; + var targetCell = targetCells.RandomElement(); // get a random cell from the list + targetCell.BlockType = curCell?.BlockType ?? RogueDLCBlockTypeEnum.Empty; // set the cell type to the current cell type + targetCells.Remove(targetCell); + updated.Add(targetCell); + } + + await chessRogueInstance.Player.SendPacket(new PacketChessRogueCellUpdateNotify(updated, + chessRogueInstance.CurBoardExcel?.ChessBoardID ?? 0, modifierInstance.SourceType, + ChessRogueCellUpdateReason.Modifier)); + + modifierInstance.IsConfirmed = true; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToSelectCell.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToSelectCell.cs index 1f13819e..d666b721 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToSelectCell.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateCurCellToSelectCell.cs @@ -43,7 +43,8 @@ public class ModifierEffectReplicateCurCellToSelectCell : ModifierEffectHandler await ValueTask.CompletedTask; } - public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) { } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToAround.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToAround.cs index f2418e29..71c2c947 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToAround.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToAround.cs @@ -68,7 +68,8 @@ public class ModifierEffectReplicateSelectCellToAround : ModifierEffectHandler await ValueTask.CompletedTask; } - public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) { } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToRandom.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToRandom.cs new file mode 100644 index 00000000..1b8fcbc1 --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectReplicateSelectCellToRandom.cs @@ -0,0 +1,78 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; +using EggLink.DanhengServer.GameServer.Game.ChessRogue.Cell; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ChessRogue; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueModifier; +using EggLink.DanhengServer.Proto; +using EggLink.DanhengServer.Util; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.ReplicateSelectCellToRandom)] +public class ModifierEffectReplicateSelectCellToRandom : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); + + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed()); + modifierInstance.SelectableCells.AddRange(cells.Select(x => x.Key)); + } + + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await chessRogueInstance.Player.SendPacket(new PacketRogueModifierStageStartNotify(modifierInstance.SourceType)); + modifierInstance.SelectedCell = selectCellId; + modifierInstance.IsConfirmed = true; + + var targetCell = chessRogueInstance.RogueCells[selectCellId]; + var count = int.Parse(modifierInstance.EffectConfig.Params.GetValueOrDefault("Count", "1")); + List targetCells = []; + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed()); // get all cells with the target type + + targetCells.AddRange(cells.Select(x => x.Value)); + } + targetCells.Remove(targetCell); + + List updated = []; + for (var i = 0; i < count; i++) + { + if (targetCells.Count == 0) + break; + var cell = targetCells.RandomElement(); + cell.BlockType = targetCell.BlockType; + targetCells.Remove(cell); + updated.Add(cell); + } + + // Send packet to update the cell + await chessRogueInstance.Player.SendPacket(new PacketChessRogueCellUpdateNotify(updated, chessRogueInstance.CurBoardExcel?.ChessBoardID ?? 0, modifierInstance.SourceType, ChessRogueCellUpdateReason.Modifier)); + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetBlockTypeToAround.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetBlockTypeToAround.cs new file mode 100644 index 00000000..ac4c7b89 --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetBlockTypeToAround.cs @@ -0,0 +1,81 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; +using EggLink.DanhengServer.GameServer.Game.ChessRogue.Cell; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ChessRogue; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueModifier; +using EggLink.DanhengServer.Proto; +using EggLink.DanhengServer.Util; +using System.Collections.Generic; +using System.Xml.Linq; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.SetBlockTypeToAround)] +public class ModifierEffectSetBlockTypeToAround : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); + + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed()); + modifierInstance.SelectableCells.AddRange(cells.Select(x => x.Key)); + } + + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await chessRogueInstance.Player.SendPacket(new PacketRogueModifierStageStartNotify(modifierInstance.SourceType)); + modifierInstance.SelectedCell = selectCellId; + modifierInstance.IsConfirmed = true; + + var targetCell = chessRogueInstance.RogueCells[selectCellId]; + var count = int.Parse(modifierInstance.EffectConfig.Params.GetValueOrDefault("Count", "1")); + List targetCells = []; + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed() && + Math.Abs(x.Value.PosX - targetCell.PosX) <= 1 && Math.Abs(x.Value.PosY - targetCell.PosY) <= 1); + + targetCells.AddRange(cells.Select(x => x.Value)); + } + targetCells.Remove(targetCell); + + List updated = []; + for (var i = 0; i < count; i++) + { + if (targetCells.Count == 0) + break; + var cell = targetCells.RandomElement(); + cell.BlockType = targetCell.BlockType; + targetCells.Remove(cell); + updated.Add(cell); + } + + // Send packet to update the cell + await chessRogueInstance.Player.SendPacket(new PacketChessRogueCellUpdateNotify(updated, chessRogueInstance.CurBoardExcel?.ChessBoardID ?? 0, modifierInstance.SourceType, ChessRogueCellUpdateReason.Modifier)); + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetCellTypeAndTakeReward.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetCellTypeAndTakeReward.cs index 7c7ce5b6..2b48a894 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetCellTypeAndTakeReward.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetCellTypeAndTakeReward.cs @@ -89,7 +89,8 @@ public class ModifierEffectSetCellTypeAndTakeReward : ModifierEffectHandler await ValueTask.CompletedTask; } - public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) { } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetColCanMove.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetColCanMove.cs new file mode 100644 index 00000000..ed7ea8b6 --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSetColCanMove.cs @@ -0,0 +1,56 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.SetColCanMove)] +public class ModifierEffectSetColCanMove : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + var curCol = chessRogueInstance.CurCell?.PosX ?? 0; + + var col = modifierInstance.EffectConfig.Params.GetValueOrDefault("Col", "0").Split(";"); + foreach (var c in col) + { + if (c.StartsWith("~")) // ~1 means cur + 1 + { + var offset = int.Parse(c[1..]); + foreach (var cell in chessRogueInstance.RogueCells.Values.Where(cell => cell.PosX == curCol + offset && !cell.IsCollapsed())) + { + chessRogueInstance.CanMoveCellIdList.Add(cell.CellId); + } + } + else + { + foreach (var cell in chessRogueInstance.RogueCells.Values.Where(cell => cell.PosX == int.Parse(c) && !cell.IsCollapsed())) + { + chessRogueInstance.CanMoveCellIdList.Add(cell.CellId); + } + } + } + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSwapCellToCurAround.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSwapCellToCurAround.cs new file mode 100644 index 00000000..843fd37b --- /dev/null +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectSwapCellToCurAround.cs @@ -0,0 +1,74 @@ +using EggLink.DanhengServer.Enums.Rogue; +using EggLink.DanhengServer.GameServer.Game.Battle; +using EggLink.DanhengServer.GameServer.Game.ChessRogue.Cell; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.ChessRogue; +using EggLink.DanhengServer.GameServer.Server.Packet.Send.RogueModifier; +using EggLink.DanhengServer.Proto; +using EggLink.DanhengServer.Util; + +namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffect.Effects; + +[ModifierEffect(ModifierEffectTypeEnum.SwapCellToCurAround)] +public class ModifierEffectSwapCellToCurAround : ModifierEffectHandler +{ + public override async ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance) + { + var types = modifierInstance.EffectConfig.Params.GetValueOrDefault("SourceType", "3").Split(";"); + + foreach (var type in types) + { + var cells = chessRogueInstance.RogueCells.Where(x => + x.Value.BlockType == (RogueDLCBlockTypeEnum)int.Parse(type) && !x.Value.IsCollapsed()); + modifierInstance.SelectableCells.AddRange(cells.Select(x => x.Key)); + } + + await ValueTask.CompletedTask; + } + + public override async ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, + ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await chessRogueInstance.Player.SendPacket( + new PacketRogueModifierStageStartNotify(modifierInstance.SourceType)); + modifierInstance.SelectedCell = selectCellId; + modifierInstance.IsConfirmed = true; + + var targetCell = chessRogueInstance.RogueCells[selectCellId]; + // get the cells around the current cell + var targetCells = chessRogueInstance.RogueCells.Values.Where(x => + Math.Abs(x.PosX - targetCell.PosX) <= 1 && Math.Abs(x.PosY - targetCell.PosY) <= 1 && + x.CellAdvanceInfo.Count == 0 && !x.IsCollapsed()).ToList(); // avoid to get boss cell + targetCells.Remove(targetCell); + + List updated = []; + + // swap the cell type + if (targetCells.Count == 0) return; // no cell to swap + var cell = targetCells.RandomElement(); + (cell.BlockType, targetCell.BlockType) = (targetCell.BlockType, cell.BlockType); + updated.Add(cell); + updated.Add(targetCell); + + // Send packet to update the cell + await chessRogueInstance.Player.SendPacket(new PacketChessRogueCellUpdateNotify(updated, + chessRogueInstance.CurBoardExcel?.ChessBoardID ?? 0, modifierInstance.SourceType, + ChessRogueCellUpdateReason.Modifier)); + } + + public override async ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, + int selectCellId) + { + await ValueTask.CompletedTask; + } + + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) + { + } + + public override async ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + { + await ValueTask.CompletedTask; + } +} \ No newline at end of file diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTrunAroundToEmptyGetBuff.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTrunAroundToEmptyGetBuff.cs index 0b159852..77e45877 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTrunAroundToEmptyGetBuff.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTrunAroundToEmptyGetBuff.cs @@ -58,7 +58,8 @@ public class ModifierEffectTrunAroundToEmptyGetBuff : ModifierEffectHandler } } - public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) { } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTurnRandomCellBlockType.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTurnRandomCellBlockType.cs index b1d0bcff..9fecfd59 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTurnRandomCellBlockType.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/Effects/ModifierEffectTurnRandomCellBlockType.cs @@ -57,7 +57,8 @@ public class ModifierEffectTurnRandomCellBlockType : ModifierEffectHandler await ValueTask.CompletedTask; } - public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle) + public override void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance) { } diff --git a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/ModifierEffectHandler.cs b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/ModifierEffectHandler.cs index 0431b9dc..2116295d 100644 --- a/GameServer/Game/ChessRogue/Modifier/ModifierEffect/ModifierEffectHandler.cs +++ b/GameServer/Game/ChessRogue/Modifier/ModifierEffect/ModifierEffectHandler.cs @@ -7,7 +7,8 @@ namespace EggLink.DanhengServer.GameServer.Game.ChessRogue.Modifier.ModifierEffe public abstract ValueTask OnConfirmed(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance); public abstract ValueTask SelectModifierCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, int selectCellId); public abstract ValueTask SelectCell(ChessRogueDiceModifierInstance modifierInstance, ChessRogueInstance chessRogueInstance, int selectCellId); - public abstract void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle); + public abstract void BeforeBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle, + ChessRogueInstance instance); public abstract ValueTask AfterBattle(ChessRogueDiceModifierInstance modifierInstance, BattleInstance battle); } } diff --git a/GameServer/Game/Rogue/BaseRogueInstance.cs b/GameServer/Game/Rogue/BaseRogueInstance.cs index 15230a2e..4ce66ccf 100644 --- a/GameServer/Game/Rogue/BaseRogueInstance.cs +++ b/GameServer/Game/Rogue/BaseRogueInstance.cs @@ -1,4 +1,5 @@ using EggLink.DanhengServer.Data; +using EggLink.DanhengServer.Data.Config.AdventureAbility; using EggLink.DanhengServer.Data.Custom; using EggLink.DanhengServer.Data.Excel; using EggLink.DanhengServer.Database.Inventory; @@ -240,6 +241,34 @@ public abstract class BaseRogueInstance(PlayerInstance player, RogueSubModeEnum } } + public virtual void HandleMazeBuffModifier(AdventureModifierConfig config, MazeBuff buff) + { + var task = config.OnBeforeBattle; + + foreach (var info in task) + { + if (!info.Type.Replace("RPG.GameCore.", "").StartsWith("SetDynamicValueBy")) continue; + var key = info.Type.Replace("RPG.GameCore.SetDynamicValueBy", ""); + var value = key switch + { + "ItemNum" => CurMoney, + "RogueMiracleNum" => RogueMiracles.Count, + "RogueBuffNumWithType" => RogueBuffs.Count, + _ => 0 + }; + + key = key switch + { + "ItemNum" => "ItemNumber", + "RogueMiracleNum" => "RogueMiracleNumber", + "RogueBuffNumWithType" => "RogueBuffNumberWithType", + _ => key + }; + + buff.DynamicValues.Add(key, value); + } + } + #endregion #region Money