refactor(slay-the-spire-like): update combat targeting and effect logic
Refactor combat targeting types and effect application logic in the Slay the Spire-like sample. - Update `getEffectTargets` to use `IntentEffectTarget` and more descriptive target keys (e.g., `eachEnemy`, `randomEnemy`). - Update `promptMainAction` to use `enemy` instead of `single` for card target types. - Refactor `addInstantEffectTriggers` to remove unused effect loading and improve enemy/card instantiation logic
This commit is contained in:
@@ -33,6 +33,7 @@ import type {
|
||||
import type { GameItemMeta } from "@/samples/slay-the-spire-like/system/grid-inventory/types";
|
||||
import type { ParsedShape } from "@/samples/slay-the-spire-like/system/utils/parse-shape";
|
||||
import type { Transform2D } from "@/samples/slay-the-spire-like/system/utils/shape-collision";
|
||||
import { CardEffect } from "@/samples/slay-the-spire-like/data/desert";
|
||||
|
||||
function createRunContext(
|
||||
items: Map<string, InventoryItem<GameItemMeta>>,
|
||||
@@ -63,7 +64,7 @@ function createEffect(
|
||||
id: string,
|
||||
lifecycle: EffectData["lifecycle"],
|
||||
): EffectData {
|
||||
return { id, name: id, description: "", lifecycle };
|
||||
return { id, name: id, description: "", lifecycle, emoji: "" };
|
||||
}
|
||||
|
||||
function createCard(
|
||||
@@ -78,8 +79,8 @@ function createCard(
|
||||
type: "item" as const,
|
||||
costType,
|
||||
costCount,
|
||||
targetType: "none" as const,
|
||||
effects: [] as const,
|
||||
targetType: "player" as const,
|
||||
effects: [] as CardEffect[],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
} from "@/core/game";
|
||||
import { createRegion } from "@/core/region";
|
||||
import {
|
||||
createStartWith,
|
||||
createTriggers,
|
||||
Triggers,
|
||||
} from "@/samples/slay-the-spire-like/system/combat/triggers";
|
||||
@@ -30,6 +29,7 @@ import { GameItemMeta } from "@/samples/slay-the-spire-like/system/grid-inventor
|
||||
import { ParsedShape } from "@/samples/slay-the-spire-like/system/utils/parse-shape";
|
||||
import { Transform2D } from "@/samples/slay-the-spire-like/system/utils/shape-collision";
|
||||
import {
|
||||
CardEffect,
|
||||
getCards,
|
||||
getEffects,
|
||||
getEncounters,
|
||||
@@ -48,7 +48,7 @@ function createEffect(
|
||||
): EffectData {
|
||||
const found = effects.find((e) => e.id === id);
|
||||
if (found) return found;
|
||||
return { id, name: id, description: "", lifecycle };
|
||||
return { id, name: id, description: "", lifecycle, emoji: "" };
|
||||
}
|
||||
|
||||
function createDeckRegions(): DeckRegions {
|
||||
@@ -73,8 +73,8 @@ function createCard(
|
||||
type: "item" as const,
|
||||
costType,
|
||||
costCount,
|
||||
targetType: "none" as const,
|
||||
effects: [],
|
||||
targetType: "player" as const,
|
||||
effects: [] as CardEffect[],
|
||||
};
|
||||
return {
|
||||
id,
|
||||
@@ -285,7 +285,7 @@ describe("desert triggers", () => {
|
||||
}),
|
||||
);
|
||||
const triggers = getTriggers();
|
||||
const defendEffect = createEffect("defend", "posture");
|
||||
const defendEffect = createEffect("defend", "temporary");
|
||||
|
||||
ctx._state.produce((draft) => {
|
||||
draft.player.effects.defend = { data: defendEffect, stacks: 5 };
|
||||
|
||||
@@ -33,7 +33,7 @@ function createTestCardData(id: string, name: string, desc: string): CardData {
|
||||
type: "item",
|
||||
costType: "energy",
|
||||
costCount: 1,
|
||||
targetType: "single",
|
||||
targetType: "enemy",
|
||||
effects: [],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
getItemAtCell,
|
||||
getAdjacentItems,
|
||||
validatePlacement,
|
||||
type GridInventory,
|
||||
type InventoryItem,
|
||||
} from "@/samples/slay-the-spire-like/system/grid-inventory";
|
||||
import { createItemIn } from "@/samples/slay-the-spire-like/system/grid-inventory/factory";
|
||||
@@ -36,7 +35,7 @@ function createTestCardData(id: string, name: string, desc: string): CardData {
|
||||
type: "item",
|
||||
costType: "energy",
|
||||
costCount: 1,
|
||||
targetType: "single",
|
||||
targetType: "enemy",
|
||||
effects: [],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user