feat(slay-the-spire-like): support source entity in effect targeting

Update `getEffectTargets` to accept a `sourceEntityKey`. This allows
"self" targets to correctly resolve to the entity triggering the
effect (e.g., a player or a specific enemy) rather than defaulting
to a hardcoded player reference.
This commit is contained in:
2026-04-22 08:56:06 +08:00
parent 6cb0626f05
commit 5235ba7def
3 changed files with 28 additions and 10 deletions
@@ -107,12 +107,16 @@ export function* getEffectTargets(
target: CardEffectTarget | EffectTarget,
game: CombatGameContext,
targetId?: string,
sourceEntityKey: "player" | string = "player",
) {
if (target === "all" || target === "team") {
for (const enemy of getAliveEnemies(game.value)) {
yield enemy;
}
} else if (target === "self") {
const entity = getCombatEntity(game.value, sourceEntityKey);
if (entity) yield entity;
} else if (target === "player") {
yield game.value.player;
} else if (target === "target") {
if (!targetId) return;