Serves as the reference implementation of the game package contract: rules, spark tables, character backgrounds, and an example command.
32 lines
1000 B
JavaScript
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,
|
|
},
|
|
},
|
|
};
|