feat(engine): execute story actions via storyChoiceId

This commit is contained in:
ginnoir
2026-06-11 20:36:07 -05:00
parent b3940774c4
commit 8d9484171f
3 changed files with 58 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { describe, expect, it } from 'vitest';
import { content } from '../../content/index';
import { createGameState, executeStoryAction } from '../game';
import { enterStoryNode } from '../story';
describe('executeStoryAction()', () => {
it('applies the linked story choice', () => {
const state = createGameState(content);
enterStoryNode(state, content, 'fork_choice');
executeStoryAction(state, content, 'pick_high_road');
expect(state.storyFlags.route_a).toBe(true);
expect(state.currentStoryNodeId).toBe('route_a_beat');
});
it('throws when the choice is not available', () => {
const state = createGameState(content);
enterStoryNode(state, content, 'fork_choice');
executeStoryAction(state, content, 'pick_high_road');
// after taking route A, the current node has no choices, so follow_river (pick_b) is unavailable
expect(() => executeStoryAction(state, content, 'follow_river')).toThrow();
});
});