muffin v6.12
This commit is contained in:
parent
e786325cda
commit
0950798597
64 changed files with 40100 additions and 58121 deletions
|
@ -502,14 +502,14 @@ internal sealed class InteractionUiController : IDisposable
|
|||
_logger.LogInformation("Unexpected excelPrompt: {ExcelPrompt}, actualPrompt: {ActualPrompt}", stringOrRegex, actualPrompt);
|
||||
continue;
|
||||
}
|
||||
for (int num3 = 0; num3 < answers.Count; num3++)
|
||||
if (dialogueChoice2.AnswerIsRegularExpression && stringOrRegex2 != null)
|
||||
{
|
||||
_logger.LogTrace("Checking if {ActualAnswer} == {ExpectedAnswer}", answers[num3], stringOrRegex2);
|
||||
if (!IsMatch(answers[num3], stringOrRegex2))
|
||||
int? num3 = FindBestRegexMatch(answers, stringOrRegex2, quest3, dialogueChoice2);
|
||||
if (!num3.HasValue)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_logger.LogInformation("Returning {Index}: '{Answer}' for '{Prompt}'", num3, answers[num3], actualPrompt);
|
||||
_logger.LogInformation("Returning {Index}: '{Answer}' for '{Prompt}' (best regex match)", num3.Value, answers[num3.Value], actualPrompt);
|
||||
if (quest3?.Id is SatisfactionSupplyNpcId)
|
||||
{
|
||||
if (_questController.GatheringQuest == null || _questController.GatheringQuest.Sequence == byte.MaxValue)
|
||||
|
@ -519,13 +519,72 @@ internal sealed class InteractionUiController : IDisposable
|
|||
_questController.GatheringQuest.SetSequence(1);
|
||||
_questController.StartGatheringQuest("SatisfactionSupply turn in");
|
||||
}
|
||||
return num3;
|
||||
return num3.Value;
|
||||
}
|
||||
for (int num4 = 0; num4 < answers.Count; num4++)
|
||||
{
|
||||
_logger.LogTrace("Checking if {ActualAnswer} == {ExpectedAnswer}", answers[num4], stringOrRegex2);
|
||||
if (!IsMatch(answers[num4], stringOrRegex2))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_logger.LogInformation("Returning {Index}: '{Answer}' for '{Prompt}'", num4, answers[num4], actualPrompt);
|
||||
if (quest3?.Id is SatisfactionSupplyNpcId)
|
||||
{
|
||||
if (_questController.GatheringQuest == null || _questController.GatheringQuest.Sequence == byte.MaxValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_questController.GatheringQuest.SetSequence(1);
|
||||
_questController.StartGatheringQuest("SatisfactionSupply turn in");
|
||||
}
|
||||
return num4;
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("No matching answer found for {Prompt}.", actualPrompt);
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int? FindBestRegexMatch(List<string?> answers, StringOrRegex expectedAnswer, Questionable.Model.Quest? quest, DialogueChoice dialogueChoice)
|
||||
{
|
||||
List<int> list = (from x in answers.Select((string answer, int index) => new { answer, index })
|
||||
where x.answer != null && expectedAnswer.IsMatch(x.answer)
|
||||
select x.index).ToList();
|
||||
return list.Count switch
|
||||
{
|
||||
0 => null,
|
||||
1 => list[0],
|
||||
_ => GetBestMatchFromQuestPath(answers, list, quest, dialogueChoice),
|
||||
};
|
||||
}
|
||||
|
||||
private static int GetBestMatchFromQuestPath(List<string?> answers, List<int> matchingIndexes, Questionable.Model.Quest? quest, DialogueChoice dialogueChoice)
|
||||
{
|
||||
if (quest != null && dialogueChoice.Answer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string questExpectedAnswer = null;
|
||||
if (dialogueChoice.Answer.Type == ExcelRef.EType.RawString)
|
||||
{
|
||||
questExpectedAnswer = dialogueChoice.Answer.AsRawString();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(questExpectedAnswer) && !dialogueChoice.AnswerIsRegularExpression)
|
||||
{
|
||||
int num = matchingIndexes.FirstOrDefault((int i) => string.Equals(answers[i], questExpectedAnswer, StringComparison.OrdinalIgnoreCase));
|
||||
if (num != 0)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
return matchingIndexes.OrderBy((int i) => answers[i]?.Length ?? int.MaxValue).First();
|
||||
}
|
||||
|
||||
private static bool IsMatch(string? actualAnswer, StringOrRegex? expectedAnswer)
|
||||
{
|
||||
if (actualAnswer == null && expectedAnswer == null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue