From d72ccb2dd33c56955afb9a24f6d2f34562c8274c Mon Sep 17 00:00:00 2001 From: milimoe Date: Sat, 10 Jan 2026 04:35:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E5=87=86=E5=8C=96=20Inquiry=20?= =?UTF-8?q?=E8=AF=A2=E9=97=AE=E4=BA=8B=E4=BB=B6=E5=92=8C=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Skill/Effect.cs | 12 ++++----- Interface/Base/IGamingQueue.cs | 5 ++-- Library/Constant/TypeEnum.cs | 11 ++++++++ Model/GamingQueue.cs | 18 ++++++------- Model/InquiryOptions.cs | 29 ++++++++++++++++++++ Model/InquiryResponse.cs | 49 ++++++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 20 deletions(-) create mode 100644 Model/InquiryOptions.cs create mode 100644 Model/InquiryResponse.cs diff --git a/Entity/Skill/Effect.cs b/Entity/Skill/Effect.cs index d6801bb..57755bb 100644 --- a/Entity/Skill/Effect.cs +++ b/Entity/Skill/Effect.cs @@ -890,10 +890,9 @@ namespace Milimoe.FunGame.Core.Entity /// 在角色取得询问反应的答复时触发 /// /// - /// - /// + /// /// - public virtual void OnCharacterInquiry(Character character, string topic, Dictionary args, Dictionary response) + public virtual void OnCharacterInquiry(Character character, InquiryOptions options, InquiryResponse response) { } @@ -1206,12 +1205,11 @@ namespace Milimoe.FunGame.Core.Entity /// 向角色发起询问反应事件 [ 尽可能的调用此方法而不是自己实现 ] /// /// - /// - /// + /// /// - public Dictionary Inquiry(Character character, string topic, Dictionary args) + public InquiryResponse Inquiry(Character character, InquiryOptions options) { - return GamingQueue?.Inquiry(character, topic, args) ?? []; + return GamingQueue?.Inquiry(character, options) ?? new(options); } /// diff --git a/Interface/Base/IGamingQueue.cs b/Interface/Base/IGamingQueue.cs index dcae70f..e7b2894 100644 --- a/Interface/Base/IGamingQueue.cs +++ b/Interface/Base/IGamingQueue.cs @@ -301,9 +301,8 @@ namespace Milimoe.FunGame.Core.Interface.Base /// 向角色(或控制该角色的玩家)进行询问并取得答复 /// /// - /// - /// + /// /// - public Dictionary Inquiry(Character character, string topic, Dictionary args); + public InquiryResponse Inquiry(Character character, InquiryOptions options); } } diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index 1ce0650..f4f03ae 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -1107,4 +1107,15 @@ namespace Milimoe.FunGame.Core.Library.Constant /// Sector } + + public enum InquiryType + { + None, + Choice, + MultipleChoice, + BinaryChoice, + TextInput, + NumberInput, + Custom + } } diff --git a/Model/GamingQueue.cs b/Model/GamingQueue.cs index 16f6ccc..b21ba66 100644 --- a/Model/GamingQueue.cs +++ b/Model/GamingQueue.cs @@ -4059,21 +4059,20 @@ namespace Milimoe.FunGame.Core.Model /// 向角色(或控制该角色的玩家)进行询问并取得答复 /// /// - /// - /// + /// /// - public Dictionary Inquiry(Character character, string topic, Dictionary args) + public InquiryResponse Inquiry(Character character, InquiryOptions options) { if (!_decisionPoints.TryGetValue(character, out DecisionPoints? dp) || dp is null) { dp = new(); _decisionPoints[character] = dp; } - Dictionary response = OnCharacterInquiryEvent(character, dp, topic, args); + InquiryResponse response = OnCharacterInquiryEvent(character, dp, options); Effect[] effects = [.. character.Effects.Where(e => e.IsInEffect)]; foreach (Effect effect in effects) { - effect.OnCharacterInquiry(character, topic, args, response); + effect.OnCharacterInquiry(character, options, response); } return response; } @@ -4597,7 +4596,7 @@ namespace Milimoe.FunGame.Core.Model CharacterDecisionCompletedEvent?.Invoke(this, actor, dp, record); } - public delegate Dictionary CharacterInquiryEventHandler(GamingQueue character, Character actor, DecisionPoints dp, string topic, Dictionary args); + public delegate InquiryResponse CharacterInquiryEventHandler(GamingQueue character, Character actor, DecisionPoints dp, InquiryOptions options); /// /// 角色询问反应事件 /// @@ -4607,12 +4606,11 @@ namespace Milimoe.FunGame.Core.Model /// /// /// - /// - /// + /// /// - protected Dictionary OnCharacterInquiryEvent(Character character, DecisionPoints dp, string topic, Dictionary args) + protected InquiryResponse OnCharacterInquiryEvent(Character character, DecisionPoints dp, InquiryOptions options) { - return CharacterInquiryEvent?.Invoke(this, character, dp, topic, args) ?? []; + return CharacterInquiryEvent?.Invoke(this, character, dp, options) ?? new(options); } #endregion diff --git a/Model/InquiryOptions.cs b/Model/InquiryOptions.cs new file mode 100644 index 0000000..b5784e4 --- /dev/null +++ b/Model/InquiryOptions.cs @@ -0,0 +1,29 @@ +using Milimoe.FunGame.Core.Library.Constant; + +namespace Milimoe.FunGame.Core.Model +{ + public class InquiryOptions + { + public InquiryType InquiryType { get; } = InquiryType.None; + public string Topic { get; set; } = ""; + public string Description { get; set; } = ""; + public Dictionary Choices { get; set; } = []; + public string DefaultChoice { get; set; } = ""; + public double MinNumberValue { get; set; } = 0; + public double MaxNumberValue { get; set; } = 0; + public double DefaultNumberValue { get; set; } = 0; + public Dictionary CustomArgs { get; set; } = []; + + public InquiryOptions(InquiryType type, string topic) + { + InquiryType = type; + Topic = topic; + if (type == InquiryType.BinaryChoice) + { + Choices.Add("是", ""); + Choices.Add("否", ""); + DefaultChoice = "否"; + } + } + } +} diff --git a/Model/InquiryResponse.cs b/Model/InquiryResponse.cs new file mode 100644 index 0000000..dbba58e --- /dev/null +++ b/Model/InquiryResponse.cs @@ -0,0 +1,49 @@ +using Milimoe.FunGame.Core.Library.Constant; + +namespace Milimoe.FunGame.Core.Model +{ + public class InquiryResponse + { + public InquiryType InquiryType { get; } = InquiryType.None; + public string Topic { get; set; } = ""; + public List Choices { get; set; } = []; + public string TextResult { get; set; } = ""; + public double NumberResult { get; set; } = 0; + public Dictionary CustomResponse { get; set; } = []; + + public InquiryResponse(InquiryType type, string topic) + { + InquiryType = type; + Topic = topic; + } + + public InquiryResponse(InquiryOptions options) + { + InquiryType = options.InquiryType; + Topic = options.Topic; + switch (options.InquiryType) + { + case InquiryType.Choice: + case InquiryType.MultipleChoice: + case InquiryType.BinaryChoice: + if (options.DefaultChoice != "") + { + Choices.Add(options.DefaultChoice); + } + else if (options.Choices.Count > 0) + { + Choices.Add(options.Choices.Keys.First()); + } + break; + case InquiryType.TextInput: + TextResult = ""; + break; + case InquiryType.NumberInput: + NumberResult = options.DefaultNumberValue; + break; + default: + break; + } + } + } +}