From 06018b423a78d160be439ca6cfbb93ba4cfdbc3b Mon Sep 17 00:00:00 2001 From: milimoe Date: Tue, 13 Jan 2026 23:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BD=8D/=E5=8F=AC=E5=94=A4=E7=89=A9?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=AE=9E=E7=8E=B0=E5=92=8C=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Desktop/GameMapTesting/GameMapController.cs | 15 ++++ Desktop/GameMapTesting/GameMapTesting.cs | 20 +++++- Desktop/GameMapTesting/GameMapViewer.xaml | 51 ++++++++++++++ Desktop/GameMapTesting/GameMapViewer.xaml.cs | 73 ++++++++++++++++++++ Library/Main.cs | 8 +-- 5 files changed, 160 insertions(+), 7 deletions(-) diff --git a/Desktop/GameMapTesting/GameMapController.cs b/Desktop/GameMapTesting/GameMapController.cs index 034e0da..be6129c 100644 --- a/Desktop/GameMapTesting/GameMapController.cs +++ b/Desktop/GameMapTesting/GameMapController.cs @@ -15,6 +15,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting // 输入请求器实例 private readonly UserInputRequester _characterSelectionRequester = new(); + private readonly UserInputRequester _inquiryResponseSelectionRequester = new(); private readonly UserInputRequester _targetGridSelectionRequester = new(); private readonly UserInputRequester _actionTypeRequester = new(); private readonly UserInputRequester> _targetSelectionRequester = new(); @@ -84,6 +85,14 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting ); } + public async Task RequestInquiryResponseSelection(InquiryOptions options) + { + await WriteLine("请选择你的反应。"); + return await _inquiryResponseSelectionRequester.RequestInput( + async (callback) => await UI.InvokeAsync(() => UI.ShowInquiryResponseSelectionPrompt(options, callback)) + ); + } + public async Task RequestActionType(Character character, List availableItems) { await WriteLine($"现在是 {character.NickName} 的回合,请选择行动。"); @@ -161,6 +170,12 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting await UI.InvokeAsync(() => UI.HideCharacterSelectionPrompt()); } + public async Task ResolveInquiryResponseSelection(InquiryResponse? response) + { + _inquiryResponseSelectionRequester.ResolveInput(response); + await UI.InvokeAsync(() => UI.HideInquiryResponseSelectionPrompt()); + } + public async Task ResolveActionType(CharacterActionType actionType) { _actionTypeRequester.ResolveInput(actionType); diff --git a/Desktop/GameMapTesting/GameMapTesting.cs b/Desktop/GameMapTesting/GameMapTesting.cs index d456d34..804111e 100644 --- a/Desktop/GameMapTesting/GameMapTesting.cs +++ b/Desktop/GameMapTesting/GameMapTesting.cs @@ -246,6 +246,7 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting _gamingQueue.QueueUpdatedEvent += GamingQueue_QueueUpdated; _gamingQueue.TurnEndEvent += GamingQueue_TurnEnd; _gamingQueue.CharacterInquiryEvent += GamingQueue_CharacterInquiryEvent; + _gamingQueue.CharacterActionTakenEvent += GamingQueue_CharacterActionTakenEvent; // 总游戏时长 double totalTime = 0; @@ -538,6 +539,11 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting } } + private void GamingQueue_CharacterActionTakenEvent(GamingQueue queue, Character actor, DecisionPoints dp, CharacterActionType type, RoundRecord record) + { + SyncAwaiter.Wait(Controller.UpdateCharacterPositionsOnMap()); + } + private Grid GamingQueue_SelectTargetGrid(GamingQueue queue, Character character, List enemys, List teammates, GameMap map, List moveRange) { if (!IsPlayer_OnlyTest(queue, character) || _gamingQueue is null || _gamingQueue.Map is null) return Grid.Empty; @@ -709,8 +715,16 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting return CharacterActionType.None; // 非玩家角色,由AI处理,或默认None } - private InquiryResponse GamingQueue_CharacterInquiryEvent(GamingQueue character, Character actor, DecisionPoints dp, InquiryOptions options) + private InquiryResponse GamingQueue_CharacterInquiryEvent(GamingQueue queue, Character character, DecisionPoints dp, InquiryOptions options) { + if (IsPlayer_OnlyTest(queue, character)) + { + // 通过UI按钮请求行动类型 + SyncAwaiter.Wait(Controller.UpdateCharacterPositionsOnMap()); + InquiryResponse? response = SyncAwaiter.WaitResult(Controller.RequestInquiryResponseSelection(options)); + SyncAwaiter.Wait(Controller.ResolveInquiryResponseSelection(response)); + return response ?? new(options); + } return new(options); } @@ -731,12 +745,12 @@ namespace Milimoe.FunGame.Testing.Desktop.GameMapTesting private static bool IsPlayer_OnlyTest(GamingQueue queue, Character current) { - return queue.CustomData.TryGetValue("player", out object? value) && value is Character player && player == current && !queue.IsCharacterInAIControlling(current); + return queue.CustomData.TryGetValue("player", out object? value) && value is Character player && (player == current || current.Master == player) && !queue.IsCharacterInAIControlling(current); } private static bool IsRoundHasPlayer_OnlyTest(GamingQueue queue, Character current) { - return queue.CustomData.TryGetValue("player", out object? value) && value is Character player && (player == current || (current.CharacterState != CharacterState.Casting && queue.LastRound.Targets.Values.SelectMany(c => c).Any(c => c == player))); + return queue.CustomData.TryGetValue("player", out object? value) && value is Character player && (player == current || current.Master == player || (current.CharacterState != CharacterState.Casting && queue.LastRound.Targets.Values.SelectMany(c => c).Any(c => c == player))); } public void SetPreCastSuperSkill(Character character, Skill skill) diff --git a/Desktop/GameMapTesting/GameMapViewer.xaml b/Desktop/GameMapTesting/GameMapViewer.xaml index a73811b..19c4e9c 100644 --- a/Desktop/GameMapTesting/GameMapViewer.xaml +++ b/Desktop/GameMapTesting/GameMapViewer.xaml @@ -412,6 +412,57 @@ + + + + + + + + + + + + + + + + + + + + + + 将鼠标悬停在选项上以查看详情。 + + + +