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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user