Expand character helper fact fields

This commit is contained in:
2026-08-14 13:14:59 +00:00
parent 23d2c20a50
commit 21a4d788ed
3 changed files with 118 additions and 6 deletions
+98 -1
View File
@@ -290,11 +290,36 @@ def _ensure_sentence(value):
return text
def _parse_positive_int(value):
text = str(value or "").strip()
if not text:
return None
try:
parsed = int(text)
except (TypeError, ValueError):
return None
if parsed <= 0:
return None
return parsed
def _indefinite_article(value):
text = _normalize_free_text(value).lower()
if not text:
return "a"
return "an" if text[0] in "aeiou" else "a"
def _build_character_helper_text(
primary_picture_id,
secondary_picture_id,
character_id,
name,
alias,
pronouns,
age,
nationality,
occupation,
height_feet,
height_inches,
accent,
@@ -304,8 +329,13 @@ def _build_character_helper_text(
secondary_picture = int(secondary_picture_id)
character_name = _normalize_free_text(name)
character_id = _normalize_free_text(character_id)
alias = _normalize_free_text(alias)
pronouns = _normalize_free_text(pronouns)
nationality = _normalize_free_text(nationality)
occupation = _normalize_free_text(occupation)
accent = _normalize_free_text(accent)
general = _ensure_sentence(general)
age_value = _parse_positive_int(age)
character_label = _label_for_character(character_name, character_id)
if character_name:
@@ -333,12 +363,29 @@ def _build_character_helper_text(
if character_id:
lines.append(f'The character ID string is "{character_id}".')
if alias:
lines.append(f"{character_label} is also known as {alias}.")
if pronouns:
lines.append(f"{character_label} uses {pronouns} pronouns.")
if age_value is not None:
lines.append(f"{character_label} is {age_value} years old.")
if nationality:
lines.append(f"{character_label} is {nationality}.")
if occupation:
lines.append(f"{character_label} works as {occupation}.")
height_text = _format_height_text(height_feet, height_inches)
if height_text:
lines.append(f"{character_label} is {height_text} tall.")
if accent:
lines.append(f"{character_label} has a {accent} accent.")
lines.append(
f"{character_label} speaks in {_indefinite_article(accent)} {accent} accent."
)
if general:
lines.append(general)
@@ -798,6 +845,46 @@ class DumasCharacterHelperNode:
"tooltip": "Character name used in the main reference sentences.",
},
),
"alias": (
"STRING",
{
"default": "",
"multiline": False,
"tooltip": "Optional alternate name, codename, or nickname.",
},
),
"pronouns": (
"STRING",
{
"default": "",
"multiline": False,
"tooltip": "Optional pronouns such as he/him or she/her.",
},
),
"age": (
"STRING",
{
"default": "",
"multiline": False,
"tooltip": "Optional numeric age. Invalid values are omitted.",
},
),
"nationality": (
"STRING",
{
"default": "",
"multiline": False,
"tooltip": "Optional nationality, origin, or cultural background.",
},
),
"occupation": (
"STRING",
{
"default": "",
"multiline": False,
"tooltip": "Optional job, role, or function that is not visually obvious.",
},
),
"height_feet": (
["", "3", "4", "5", "6", "7", "8"],
{
@@ -839,6 +926,11 @@ class DumasCharacterHelperNode:
image2_picture_id,
character_id,
name,
alias,
pronouns,
age,
nationality,
occupation,
height_feet,
height_inches,
accent,
@@ -849,6 +941,11 @@ class DumasCharacterHelperNode:
image2_picture_id,
character_id,
name,
alias,
pronouns,
age,
nationality,
occupation,
height_feet,
height_inches,
accent,