UNPKG

@opendnd/personae

Version:

This tool is used to generate a person either NPC or other Edit

45 lines 1.97 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 personae_1 = require("./personae"); const saver_1 = require("./saver"); const questions = require("questions"); const colors = require("colors/safe"); const rootDir = path.join(__dirname, ".."); const logo = fs.readFileSync(path.join(rootDir, "logo.txt"), { encoding: "utf-8" }); const parsedQuestions = Object.assign({}, common_1.standardQuestions); delete parsedQuestions.race; const wizardChild = (outputDir, mother = "", father = "") => { if (outputDir === undefined) { outputDir = "."; } // output welcome process.stdout.write(`\n${colors.yellow(logo)}\n`); // ask a few questions questions.askMany(parsedQuestions, (opts) => { const motherPerson = saver_1.default.load(mother); const fatherPerson = saver_1.default.load(father); // check for proper inputs if (motherPerson.DNA.race.uuid !== fatherPerson.DNA.race.uuid) { throw new Error("Cross-breeding between races is not yet supported!"); } if (motherPerson.DNA.gender !== core_1.Genders.Female) { throw new Error("The mother is not female!"); } if (fatherPerson.DNA.gender !== core_1.Genders.Male) { throw new Error("The father is not male!"); } // add mother's race opts.race = motherPerson.race; opts = common_1.sanitizeWizardOpts(opts); const personae = new personae_1.default(opts); const person = personae.generateChild(opts, motherPerson, fatherPerson); process.stdout.write(personae_1.default.output(person)); saver_1.default.finish(outputDir, common_1.saveMsg("child"), person, person.name, undefined); }); }; exports.default = wizardChild; //# sourceMappingURL=wizard-child.js.map