UNPKG

@opendnd/genetica

Version:

This is a tool for using a simplified genetics system to generate inheritable traits for DnD characters.

49 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs"); const path = require("path"); const core_1 = require("@opendnd/core"); const common_1 = require("./common"); const defaults_1 = require("./defaults"); const genetica_1 = require("./genetica"); const renderer_1 = require("./renderer"); const saver_1 = require("./saver"); const questions = require("questions"); // tslint:disable-line const colors = require("colors/safe"); // tslint:disable-line const rootDir = path.join(__dirname, ".."); const logo = fs.readFileSync(path.join(rootDir, "logo.txt"), { encoding: "utf-8" }); const wizardManual = (outputDir) => { if (outputDir === undefined) { outputDir = "."; } // output welcome process.stdout.write(`\n${colors.blue(logo)}\n`); // ask a few questions questions.askMany(common_1.standardQuestions, (opts) => { const tplOpts = common_1.sanitizeWizardOpts(opts); const template = defaults_1.default.racesDict[tplOpts.race.uuid]; const Xdice = template.sex.x; const Ydice = template.sex.y; const geneQuestions = {}; Object.keys(template.chromosomes).forEach((c) => { const dice = template.chromosomes[c]; if (dice === core_1.Categories.Sex) { geneQuestions["chromosome-sex"] = common_1.makeQuestion(`What rolls do you want for the sex Chromosome ${c}?`, `ex: X1=Y1 (dice are X: ${Xdice}, Y: ${Ydice})`, true); return geneQuestions; } geneQuestions[`chromosome-${c}`] = common_1.makeQuestion(`What rolls do you want for Chromosome ${c}?`, `ex: 1=1 (dice is ${dice})`, true); return geneQuestions; }); // ask questions about the genes questions.askMany(geneQuestions, (geneOpts) => { let genOpts = common_1.sanitizeWizardOpts(geneOpts); genOpts = Object.assign(tplOpts, genOpts); const genetica = new genetica_1.default(genOpts); const result = genetica.generate(); renderer_1.default.output(result); saver_1.default.finish(outputDir, common_1.saveMsg("genes"), result, result.uuid, undefined); }); }); }; exports.default = wizardManual; //# sourceMappingURL=wizard-manual.js.map