Add naming scheme support for genlockes with lineage-aware suggestions (#20)
All checks were successful
CI / backend-lint (push) Successful in 8s
CI / frontend-lint (push) Successful in 33s

Genlockes can now select a naming scheme at creation time, which is
automatically applied to every leg's run. When catching a pokemon whose
evolution family appeared in a previous leg, the system suggests the
original nickname with a roman numeral suffix (e.g., "Heracles II").

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Reviewed-on: TheFurya/nuzlocke-tracker#20
Co-authored-by: Julian Tabel <juliantabel.jt@gmail.com>
Co-committed-by: Julian Tabel <juliantabel.jt@gmail.com>
This commit was merged in pull request #20.
This commit is contained in:
2026-02-14 10:00:36 +01:00
committed by TheFurya
parent c01c504519
commit 3412d6c6fd
13 changed files with 293 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
import json
import random
import re
from functools import lru_cache
from pathlib import Path
@@ -26,6 +27,42 @@ def get_words_for_category(category: str) -> list[str]:
return _load_dictionary().get(category, [])
_ROMAN_NUMERALS = [
(1000, "M"),
(900, "CM"),
(500, "D"),
(400, "CD"),
(100, "C"),
(90, "XC"),
(50, "L"),
(40, "XL"),
(10, "X"),
(9, "IX"),
(5, "V"),
(4, "IV"),
(1, "I"),
]
_ROMAN_SUFFIX_RE = re.compile(
r"\s+(M{0,3}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3}))$"
)
def to_roman(n: int) -> str:
"""Convert a positive integer to a roman numeral string."""
parts: list[str] = []
for value, numeral in _ROMAN_NUMERALS:
while n >= value:
parts.append(numeral)
n -= value
return "".join(parts)
def strip_roman_suffix(name: str) -> str:
"""Remove a trailing roman numeral suffix from a name (e.g., 'Heracles II' -> 'Heracles')."""
return _ROMAN_SUFFIX_RE.sub("", name).strip()
def suggest_names(
category: str,
used_names: set[str],