npc gen : added children

This commit is contained in:
Vlyan
2022-02-25 10:17:28 +01:00
parent a876bfa122
commit 0d3ac2ce83
5 changed files with 49 additions and 6 deletions

View File

@@ -249,6 +249,7 @@
"intrigue": "Intrigue" "intrigue": "Intrigue"
}, },
"age": "Age", "age": "Age",
"children": "Children",
"marital_status": { "marital_status": {
"title": "Marital Status", "title": "Marital Status",
"partner": "Partner", "partner": "Partner",

View File

@@ -249,6 +249,7 @@
"intrigue": "Intriga" "intrigue": "Intriga"
}, },
"age": "Age", "age": "Age",
"children": "Children",
"marital_status": { "marital_status": {
"title": "Marital Status", "title": "Marital Status",
"partner": "Partner", "partner": "Partner",

View File

@@ -249,6 +249,7 @@
"intrigue": "Intrigue" "intrigue": "Intrigue"
}, },
"age": "Age", "age": "Age",
"children": "Enfants",
"marital_status": { "marital_status": {
"title": "État civil", "title": "État civil",
"partner": "Partenaire", "partner": "Partenaire",

View File

@@ -2,6 +2,11 @@
* L5R Character generator base object * L5R Character generator base object
*/ */
export class CharacterGenerator { export class CharacterGenerator {
/**
* Base age (minimal)
*/
static baseAge = 15;
/** /**
* Payload Object * Payload Object
*/ */
@@ -10,7 +15,7 @@ export class CharacterGenerator {
clan: "random", clan: "random",
family: "", family: "",
gender: "male", gender: "male",
age: 15, age: CharacterGenerator.baseAge,
maritalStatus: "", maritalStatus: "",
}; };
@@ -145,7 +150,10 @@ export class CharacterGenerator {
* @return {number} * @return {number}
*/ */
static genAge(avgRingsValue) { static genAge(avgRingsValue) {
return CharacterGenerator._randomInt(15, avgRingsValue * 10 + 15); return CharacterGenerator._randomInt(
CharacterGenerator.baseAge,
avgRingsValue * 10 + CharacterGenerator.baseAge
);
} }
/** /**
@@ -193,6 +201,36 @@ export class CharacterGenerator {
return partner; return partner;
} }
/**
* Generate children
* @param {number} age Current npc age
* @param {string} clan Current npc clan
* @return {Promise<string[]>}
*/
static async genChildren(age, clan) {
const childs = [];
let ageLoop = Math.max(0, age - CharacterGenerator.baseAge - 1);
while (ageLoop > 0) {
const childAge = CharacterGenerator._randomInt(1, ageLoop);
if (Math.random() > 0.66) {
const childIsFemale = Math.random() > 0.5;
const childName = await CharacterGenerator.getRandomizedFirstname(childIsFemale, clan);
childs.push(
`${childName} (${childAge}, ${game.i18n.localize(
"l5r5e.social.gender." + (childIsFemale ? "female" : "male")
)})`
);
}
ageLoop -= childAge + 1;
}
return childs;
}
/** /**
* Generate Honor, Glory and Status values * Generate Honor, Glory and Status values
* @param {number} age * @param {number} age
@@ -615,6 +653,12 @@ export class CharacterGenerator {
"l5r5e.social.gender." + (partner.female ? "female" : "male") "l5r5e.social.gender." + (partner.female ? "female" : "male")
)})` + )})` +
"</p>"; "</p>";
// Childs
const childs = await CharacterGenerator.genChildren(Math.min(this.data.age, partner.age), this.data.clan);
if (childs.length > 0) {
actorDatas.notes += `<p>${game.i18n.localize("l5r5e.social.children")}: ${childs.join(", ")}</p>`;
}
} }
} }

View File

@@ -919,7 +919,6 @@ button {
} }
.autocomplete-wrapper { .autocomplete-wrapper {
/*the container must be positioned relative:*/
position: relative; position: relative;
display: inline-block; display: inline-block;
@@ -929,7 +928,6 @@ button {
border-bottom: none; border-bottom: none;
border-top: none; border-top: none;
z-index: 99; z-index: 99;
/*position the autocomplete items to be the same width as the container:*/
top: 100%; top: 100%;
left: 0; left: 0;
right: 0; right: 0;
@@ -942,11 +940,9 @@ button {
text-align: left; text-align: left;
} }
.autocomplete-items div:hover { .autocomplete-items div:hover {
/*when hovering an item:*/
background-color: #e9e9e9; background-color: #e9e9e9;
} }
.autocomplete-active { .autocomplete-active {
/*when navigating through the items using the arrow keys:*/
background-color: DodgerBlue !important; background-color: DodgerBlue !important;
color: #ffffff; color: #ffffff;
} }