Ability Range fix
This commit is contained in:
@@ -431,9 +431,10 @@ public static class AbilitySystem
|
||||
if (selector.Filters is { Length: > 0 })
|
||||
candidates = candidates.Where(c => FiltersMatch(selector.Filters, c, ctx)).ToList();
|
||||
|
||||
HashSet<string> clientIds = [];
|
||||
if (clientTargets is not null)
|
||||
{
|
||||
var clientIds = clientTargets
|
||||
clientIds = clientTargets
|
||||
.Where(t => t.ActionIndex == actionIndex && t.InstanceId is not null)
|
||||
.Select(t => t.InstanceId!).ToHashSet();
|
||||
if (clientIds.Count > 0)
|
||||
@@ -446,9 +447,24 @@ public static class AbilitySystem
|
||||
}
|
||||
|
||||
if (activationRange is not null)
|
||||
{
|
||||
// If the client explicitly picked unit targets, validate range before filtering so the
|
||||
// error is unambiguous (TARGET_OUT_OF_RANGE rather than INSUFFICIENT_TARGETS).
|
||||
if (clientIds.Count > 0 && ctx.Source is FieldCard srcFc && srcFc.Position.HasValue)
|
||||
{
|
||||
bool anyOutOfRange = candidates
|
||||
.OfType<FieldCard>()
|
||||
.Where(fc => clientIds.Contains(fc.InstanceId))
|
||||
.Any(fc => !fc.Position.HasValue ||
|
||||
!IsTargetInAbilityRange(ctx.State, srcFc.Position.Value, fc.Position.Value, activationRange));
|
||||
if (anyOutOfRange)
|
||||
throw new GameException("TARGET_OUT_OF_RANGE");
|
||||
}
|
||||
|
||||
candidates = FilterTargetsByAbilityRange(candidates.Cast<object>().ToList(), ctx, activationRange)
|
||||
.OfType<CardInstance>()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
if (!selector.Count.All)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user