punish v6.8.18.0

This commit is contained in:
alydev 2025-10-09 07:47:19 +10:00
commit 060278c1b7
317 changed files with 554155 additions and 0 deletions

View file

@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Linq;
using Questionable.Data;
using Questionable.Model;
using Questionable.Model.Questing;
namespace Questionable.Validation.Validators;
internal sealed class SinglePlayerInstanceValidator : IQuestValidator
{
private readonly Dictionary<ElementId, List<byte>> _questIdToDutyIndexes;
public SinglePlayerInstanceValidator(TerritoryData territoryData)
{
_questIdToDutyIndexes = (from x in territoryData.GetAllQuestsWithQuestBattles()
group x by x.QuestId).ToDictionary((IGrouping<ElementId, (ElementId QuestId, byte Index, TerritoryData.ContentFinderConditionData Data)> x) => x.Key, (IGrouping<ElementId, (ElementId QuestId, byte Index, TerritoryData.ContentFinderConditionData Data)> x) => x.Select(((ElementId QuestId, byte Index, TerritoryData.ContentFinderConditionData Data) y) => y.Index).ToList());
}
public IEnumerable<ValidationIssue> Validate(Quest quest)
{
if (!_questIdToDutyIndexes.TryGetValue(quest.Id, out List<byte> value))
{
yield break;
}
foreach (byte index in value)
{
if (!quest.AllSteps().Any<(QuestSequence, int, QuestStep)>(((QuestSequence Sequence, int StepId, QuestStep Step) x) => x.Step.InteractionType == EInteractionType.SinglePlayerDuty && x.Step.SinglePlayerDutyIndex == index))
{
yield return new ValidationIssue
{
ElementId = quest.Id,
Sequence = null,
Step = null,
Type = EIssueType.UnusedSinglePlayerInstance,
Severity = EIssueSeverity.Error,
Description = $"Single player instance {index} not used"
};
}
}
}
}