Files
hypercross 77ed233f8c feat(games): add the generic d6 oracle game package
Serves as the reference implementation of the game package contract:
rules, spark tables, character backgrounds, and an example command.
2026-09-13 16:41:20 +08:00

32 lines
1000 B
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseTable, rollTable } from '@solo/oracle';
const HERE = path.dirname(fileURLToPath(import.meta.url));
/** Roll a starting background from characters/backgrounds.csv. */
function background() {
const file = path.join(HERE, 'characters', 'backgrounds.csv');
const entries = parseTable(fs.readFileSync(file, 'utf8'));
const { roll, entry } = rollTable(entries);
const tags = entry.tags.length ? ` [${entry.tags.join(', ')}]` : '';
console.log(`background roll ${roll} → "${entry.text}"${tags}`);
}
/**
* A game package's default export is its manifest. See docs/games.md.
*/
export default {
id: 'generic',
title: 'Generic d6 Oracle',
description: 'System-agnostic solo play driven by the d6 oracle and spark tables.',
rules: 'game.md',
commands: {
background: {
description: 'Roll a starting character background.',
run: background,
},
},
};