feat(content): add M1 stub resource and action pack

This commit is contained in:
ginnoir
2026-06-11 18:20:26 -05:00
parent 964e9260fa
commit 7625e081fd
2 changed files with 33 additions and 14 deletions
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from 'vitest';
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', () => {
expect(content.resources).toHaveLength(2);
expect(content.actions.length).toBeGreaterThanOrEqual(4);
expect(content.actions.length).toBeLessThanOrEqual(5);
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);
});
it('can simulate a costed action without throwing', () => {
const state = createGameState(content);
const trade = content.actions.find((a) => a.costs.length > 0);
expect(trade).toBeDefined();
enqueueAction(state, content, trade!.id);
tickGame(state, content, trade!.durationMs);
expect(state.activeActionId).toBeNull();
});
});
+9 -14
View File
@@ -1,17 +1,12 @@
/** export const resourceDefs = [
* Walking-skeleton content: one resource, one timed action. { id: 'supplies', name: 'Supplies', startAmount: 10 },
* { id: 'coin', name: 'Coin', startAmount: 0 },
* M1 expands this into the real resource/action set and the story graph. Kept as ];
* plain data so it stays diffable and authorable without touching engine code.
*/
export const resourceDefs = [{ id: 'gold', name: 'Gold', startAmount: 0 }];
export const actionDefs = [ export const actionDefs = [
{ { id: 'gather_supplies', name: 'Gather supplies', durationMs: 3000, yields: [{ resourceId: 'supplies', amount: 2 }] },
id: 'forage', { id: 'scout_path', name: 'Scout the path', durationMs: 5000, costs: [{ resourceId: 'supplies', amount: 2 }], yields: [{ resourceId: 'coin', amount: 1 }] },
name: 'Forage for coin', { id: 'trade_supplies', name: 'Trade at camp', durationMs: 4000, costs: [{ resourceId: 'supplies', amount: 3 }], yields: [{ resourceId: 'coin', amount: 2 }], unlock: { minResources: { coin: 1 } } },
durationMs: 3000, { id: 'fortify_camp', name: 'Fortify camp', durationMs: 8000, costs: [{ resourceId: 'supplies', amount: 5 }, { resourceId: 'coin', amount: 2 }], yields: [{ resourceId: 'supplies', amount: 4 }], unlock: { minResources: { supplies: 8 } } },
yields: [{ resourceId: 'gold', amount: 1 }], { id: 'rest', name: 'Rest briefly', durationMs: 2000, yields: [{ resourceId: 'supplies', amount: 1 }] },
},
]; ];