feat(content): migrate stub actions to kind/group model
This commit is contained in:
@@ -3,21 +3,28 @@ import { createGameState, enqueueAction, tickGame } from '../../engine/game';
|
||||
import { content } from '../index';
|
||||
|
||||
describe('M1 stub content pack', () => {
|
||||
it('defines two resources and four to five actions with costs and unlocks', () => {
|
||||
it('defines two resources and multiple actions with costs, unlocks, and varied kinds', () => {
|
||||
expect(content.resources).toHaveLength(2);
|
||||
expect(content.actions.length).toBeGreaterThanOrEqual(4);
|
||||
expect(content.actions.length).toBeLessThanOrEqual(6);
|
||||
const withCosts = content.actions.filter((a) => a.costs.length > 0);
|
||||
const withUnlocks = content.actions.filter((a) => a.unlock !== undefined);
|
||||
expect(withCosts.length).toBeGreaterThanOrEqual(2);
|
||||
expect(withUnlocks.length).toBeGreaterThanOrEqual(1);
|
||||
// verify the new kinds are present
|
||||
const kinds = new Set(content.actions.map((a) => a.kind));
|
||||
expect(kinds.has('timed')).toBe(true);
|
||||
expect(kinds.has('loop')).toBe(true);
|
||||
expect(kinds.has('story')).toBe(true);
|
||||
});
|
||||
|
||||
it('can simulate a costed action without throwing', () => {
|
||||
it('can simulate a costed timed action without throwing', () => {
|
||||
const state = createGameState(content);
|
||||
const trade = content.actions.find((a) => a.costs.length > 0);
|
||||
const trade = content.actions.find((a) => a.costs.length > 0 && a.kind === 'timed');
|
||||
if (!trade) {
|
||||
throw new Error('expected at least one costed action');
|
||||
throw new Error('expected at least one costed timed action');
|
||||
}
|
||||
if (trade.durationMs === undefined) {
|
||||
throw new Error('expected costed timed action to have durationMs');
|
||||
}
|
||||
enqueueAction(state, content, trade.id);
|
||||
tickGame(state, content, trade.durationMs);
|
||||
|
||||
@@ -9,6 +9,8 @@ const actionsById = {
|
||||
scout_path: {
|
||||
id: 'scout_path',
|
||||
name: 'Scout',
|
||||
kind: 'timed' as const,
|
||||
group: { id: 'travel', label: 'Travel' },
|
||||
durationMs: 1000,
|
||||
costs: [],
|
||||
yields: [{ resourceId: 'coin', amount: 1 }],
|
||||
|
||||
Reference in New Issue
Block a user