feat(sts-viewer): add effect application logging and fix command error

handling

- Log effect application details in `CombatTestScene`
- Update `tryPlayCard` to use "global" scope and handle error reasons
- Register desert triggers in `createCombatModule`
This commit is contained in:
hyper 2026-04-23 16:28:10 +08:00
parent f893ac9ff7
commit ad2c808482
2 changed files with 11 additions and 3 deletions

View File

@ -126,6 +126,13 @@ export class CombatTestScene extends GameHostScene<
// Start the game loop // Start the game loop
this.gameHost.start(); this.gameHost.start();
this.gameHost.gameModule.triggers.onEffectApplied.use(async (ctx, next) => {
const { effect, entityId, stacks, targetId, cardId } = ctx;
console.log(
`${effect.name} x${stacks} ${entityId}/${cardId} :${targetId}`,
);
await next();
});
} }
private onCardClick(cardId: string): void { private onCardClick(cardId: string): void {
@ -158,12 +165,12 @@ export class CombatTestScene extends GameHostScene<
private tryPlayCard(cardId: string, targetId?: string): void { private tryPlayCard(cardId: string, targetId?: string): void {
const error = this.gameHost.prompts.tryCommit( const error = this.gameHost.prompts.tryCommit(
prompts.mainAction, prompts.mainAction,
"player", "global",
cardId, cardId,
targetId, targetId,
); );
if (error) { if (!error.ok) {
console.warn("Play failed:", error); console.warn("Play failed:", error.reason);
} }
this.clearTargeting(); this.clearTargeting();
} }

View File

@ -52,6 +52,7 @@ export function createCombatModule() {
}; };
const triggers = createTriggers(runContext); const triggers = createTriggers(runContext);
data.desert.addTriggers(triggers, runContext);
const start = createStart(triggers, runContext); const start = createStart(triggers, runContext);
return { return {