personae
Version:
This tool is used to generate a person either NPC or other Edit
44 lines • 1.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const opendnd_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" });
delete common_1.standardQuestions.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(common_1.standardQuestions, (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 !== opendnd_core_1.Genders.Female) {
throw new Error("The mother is not female!");
}
if (fatherPerson.DNA.gender !== opendnd_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, "Would you like to save your child? (y | n)", person, person.name, undefined);
});
};
exports.default = wizardChild;
//# sourceMappingURL=wizard-child.js.map