Extract cast context policy

This commit is contained in:
2026-06-27 03:43:07 +02:00
parent 972c8f14b6
commit 9884b6f6e7
6 changed files with 143 additions and 81 deletions
+11 -73
View File
@@ -24,6 +24,7 @@ try:
template_list as _template_list,
)
from . import camera_config as camera_policy
from . import cast_context as cast_context_policy
from . import category_template_metadata as item_template_policy
from . import character_config as character_policy
from . import character_profile as character_profile_policy
@@ -67,6 +68,7 @@ except ImportError: # Allows local smoke tests with `python -c`.
template_list as _template_list,
)
import camera_config as camera_policy
import cast_context as cast_context_policy
import category_template_metadata as item_template_policy
import character_config as character_policy
import character_profile as character_profile_policy
@@ -2831,67 +2833,11 @@ def _appearance_for_subject(
def _count_phrase(count: int, singular: str, plural: str) -> str:
words = {
0: "no",
1: "one",
2: "two",
3: "three",
4: "four",
5: "five",
6: "six",
7: "seven",
8: "eight",
9: "nine",
10: "ten",
11: "eleven",
12: "twelve",
}
label = singular if count == 1 else plural
return f"{words.get(count, str(count))} {label}"
return cast_context_policy.count_phrase(count, singular, plural)
def _configured_cast_context(women_count: int, men_count: int) -> dict[str, str]:
women_count = max(0, int(women_count))
men_count = max(0, int(men_count))
if women_count + men_count == 0:
women_count = 1
parts = []
if women_count:
parts.append(_count_phrase(women_count, "adult woman", "adult women"))
if men_count:
parts.append(_count_phrase(men_count, "adult man", "adult men"))
if len(parts) == 1:
subject_phrase = parts[0]
else:
subject_phrase = f"{parts[0]} and {parts[1]}"
person_count = women_count + men_count
if person_count == 1:
scene_kind = "solo adult sexual pose"
elif person_count == 2:
scene_kind = "adult couple sex scene"
elif person_count == 3:
scene_kind = "adult threesome sex scene"
else:
scene_kind = "adult group sex scene"
women_label = "woman" if women_count == 1 else "women"
men_label = "man" if men_count == 1 else "men"
cast_summary = f"{women_count} {women_label}, {men_count} {men_label}, {person_count} total adults"
return {
"subject_type": "configured_cast",
"subject": f"{women_count}w_{men_count}m_sex_scene",
"subject_phrase": subject_phrase,
"age": "21+ adults",
"body": "varied",
"skin": "",
"hair": "",
"eyes": "",
"body_phrase": "varied adult bodies",
"women_count": str(women_count),
"men_count": str(men_count),
"person_count": str(person_count),
"cast_summary": cast_summary,
"scene_kind": scene_kind,
}
return cast_context_policy.configured_cast_context(women_count, men_count)
def _couple_type_from_counts(
@@ -2899,21 +2845,13 @@ def _couple_type_from_counts(
women_count: int,
men_count: int,
) -> tuple[str, str, str, int, int]:
women_count = max(0, int(women_count))
men_count = max(0, int(men_count))
if women_count >= 2 and men_count == 0:
return "two women", "two women", "close affectionate couple pose", 2, 0
if men_count >= 2 and women_count == 0:
return "two men", "two men", "relaxed romantic couple pose", 0, 2
if women_count >= 1 and men_count >= 1:
return "woman and man", "a woman and a man", "playful date-night pose", 1, 1
primary_subject, subject_phrase, pose = g.choose(rng, g.COUPLE_TYPES)
if primary_subject == "two women":
return primary_subject, subject_phrase, pose, 2, 0
if primary_subject == "two men":
return primary_subject, subject_phrase, pose, 0, 2
return primary_subject, subject_phrase, pose, 1, 1
return cast_context_policy.couple_type_from_counts(
rng,
women_count,
men_count,
choose=g.choose,
couple_types=g.COUPLE_TYPES,
)
def _subject_context(