NEO-104: Use subset check for all-targets-defeated predicate.

Matches documented semantics; extra defeated ids via direct store
calls no longer block completion readiness (Bugbot PR #143).
pull/143/head
VinPropane 2026-05-31 16:44:48 -04:00
parent 91f74b7d6e
commit 0289930897
2 changed files with 23 additions and 1 deletions

View File

@ -180,6 +180,28 @@ public sealed class EncounterProgressOperationsTests
Assert.True(allDefeated);
}
[Fact]
public async Task IsAllRequiredTargetsDefeated_ShouldReturnTrue_WhenDefeatedSetIsSupersetOfRequired()
{
// Arrange
await using var factory = new InMemoryWebApplicationFactory();
var registry = factory.Services.GetRequiredService<IEncounterDefinitionRegistry>();
var progress = factory.Services.GetRequiredService<IEncounterProgressStore>();
_ = progress.TryActivate(PlayerId, EncounterId);
_ = progress.TryAddDefeatedTarget(PlayerId, EncounterId, MeleeNpc);
_ = progress.TryAddDefeatedTarget(PlayerId, EncounterId, RangedNpc);
_ = progress.TryAddDefeatedTarget(PlayerId, EncounterId, EliteNpc);
_ = progress.TryAddDefeatedTarget(PlayerId, EncounterId, "extra_non_required_npc");
// Act
var allDefeated = EncounterProgressOperations.IsAllRequiredTargetsDefeated(
PlayerId,
EncounterId,
registry,
progress);
// Assert
Assert.True(allDefeated);
}
[Fact]
public async Task TryMarkCompleted_ShouldReturnFalseOnSecondAttempt_WhenUsingCompletionStoreDirectly()
{

View File

@ -142,6 +142,6 @@ public static class EncounterProgressOperations
return false;
}
return required.SetEquals(progress.DefeatedNpcInstanceIds);
return required.IsSubsetOf(progress.DefeatedNpcInstanceIds);
}
}