aurinn-train-content-generator
Version:
A custom fork of the fantasy-name-content-generator specifically for Aurinn Train, a custom D&D campaign format.
134 lines (124 loc) • 5.07 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseSkillProficiencyList = exports.randomPersonalityTrait = exports.randomFlaw = exports.randomBond = exports.randomIdeal = exports.random = exports.getAllBackgrounds = exports.getBackgroundData = void 0;
var Utils = __importStar(require("../utils/"));
var backgrounds_json_1 = __importDefault(require("./backgrounds.json"));
/** Template for backgrounds:
"background template": {
"name": "",
"description": "",
"skill proficiencies": [
],
"tool proficiencies": [
],
"languages": [
],
"equipment": [
],
"additional rolls": {
},
"feature": {
"name": "",
"description": ""
},
"characteristics": "",
"personality traits": [
],
"ideals": {
},
"bonds": [
],
"flaws": [
]
},
*/
exports.getBackgroundData = function (name) {
return backgrounds_json_1.default[name];
};
exports.getAllBackgrounds = function () {
return backgrounds_json_1.default;
};
exports.random = function () {
return Utils.pick(Object.keys(backgrounds_json_1.default));
};
exports.randomIdeal = function (props) {
var background = props.background, morality = props.morality, adherence = props.adherence, seed = props.seed;
seed = seed || Utils.FantasyContentGeneratorSeed || Utils.generateUUID();
return Utils.withSeed(seed, function () {
var ideals = background["ideals"];
var choices = [];
var neutralFlag = false;
if (Object.keys(ideals).includes("any"))
choices.push.apply(choices, ideals["any"]);
if (morality != undefined && Object.keys(ideals).includes(morality)) {
choices.push.apply(choices, ideals[morality]);
if (morality == "neutral")
neutralFlag = true;
}
if (adherence != undefined && Object.keys(ideals).includes(adherence)) {
if (adherence != "neutral" || !neutralFlag)
choices.push.apply(choices, ideals[adherence]);
}
Utils.pick(choices);
});
};
exports.randomBond = function (background, seed) {
var _a;
if (seed === void 0) { seed = undefined; }
seed = (_a = seed !== null && seed !== void 0 ? seed : Utils.FantasyContentGeneratorSeed) !== null && _a !== void 0 ? _a : Utils.generateUUID();
return Utils.withSeed(seed, function () {
return Utils.pick(background["bonds"]);
});
};
exports.randomFlaw = function (background, seed) {
var _a;
if (seed === void 0) { seed = undefined; }
seed = (_a = seed !== null && seed !== void 0 ? seed : Utils.FantasyContentGeneratorSeed) !== null && _a !== void 0 ? _a : Utils.generateUUID();
return Utils.withSeed(seed, function () {
return Utils.pick(background["flaws"]);
});
};
exports.randomPersonalityTrait = function (background, seed) {
var _a;
if (seed === void 0) { seed = undefined; }
seed = (_a = seed !== null && seed !== void 0 ? seed : Utils.FantasyContentGeneratorSeed) !== null && _a !== void 0 ? _a : Utils.generateUUID();
return Utils.withSeed(seed, function () {
return Utils.pick(background["personality traits"]);
});
};
exports.parseSkillProficiencyList = function (proficiency) {
proficiency.split("|");
};
var functions = {
getBackgroundData: exports.getBackgroundData,
getAllBackgrounds: exports.getAllBackgrounds,
random: exports.random,
randomIdeal: exports.randomIdeal,
randomBond: exports.randomBond,
randomFlaw: exports.randomFlaw,
randomPersonalityTrait: exports.randomPersonalityTrait,
parseSkillProficiencyList: exports.parseSkillProficiencyList
};
exports.default = functions;