• Resolve the single target combatant of an automated attack from the client's targeted tokens. Automated combat targets a combatant, not just a token: tokens that are not combatants of the current combat are ignored, so a player may have other (non-combatant) tokens targeted without ambiguity. Exactly one targeted token must map to a combatant — zero or more than one throws (with a user-facing message).

    Pure: targeted is the current target list and toCombatant maps a token to its combatant (or null), so the rule is unit-testable without canvas/combat globals.

    Type Parameters

    • Tok
    • Comb

    Parameters

    • targeted: Tok[]

      The client's currently targeted tokens.

    • toCombatant: (token: Tok) => null | Comb

      Maps a token to its combatant, or null if it is not one.

    Returns Comb

    The single targeted combatant.

    If zero or more than one targeted token maps to a combatant.