UNPKG

@opendnd/genetica

Version:

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

46 lines 2 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 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" }); delete common_1.standardQuestions.race; const wizardChild = (outputDir, mother = "", father = "") => { 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 motherDNA = saver_1.default.load(mother); const fatherDNA = saver_1.default.load(father); // check for proper inputs if (motherDNA.race.uuid !== fatherDNA.race.uuid) { throw new Error("Cross-breeding between races is not yet supported!"); } if (motherDNA.gender !== core_1.Genders.Female) { throw new Error("The mother is not female!"); } if (fatherDNA.gender !== core_1.Genders.Male) { throw new Error("The father is not male!"); } // add mother's race opts.race = motherDNA.race.uuid; // convert the text gender to a enum const genOpts = common_1.sanitizeWizardOpts(opts); const genetica = new genetica_1.default(genOpts); const result = genetica.generateChild(genOpts, motherDNA, fatherDNA); renderer_1.default.output(result); saver_1.default.finish(outputDir, common_1.saveMsg("child"), result, result.uuid, undefined); }); }; exports.default = wizardChild; //# sourceMappingURL=wizard-child.js.map