Move cast descriptor entry policy
This commit is contained in:
+117
-14
@@ -14,9 +14,15 @@ except ImportError: # Allows local smoke tests with top-level imports.
|
||||
import pair_options
|
||||
|
||||
|
||||
CastDescriptors = Callable[..., list[str]]
|
||||
AxisRng = Callable[[dict[str, int], str, int, int], Any]
|
||||
Choose = Callable[[Any, list[str]], str]
|
||||
CharacterContextForLabel = Callable[
|
||||
[str, dict[str, dict[str, Any]], Any, str, str, bool, bool],
|
||||
tuple[dict[str, Any], dict[str, Any] | None],
|
||||
]
|
||||
CharacterSlotLabelMap = Callable[[list[dict[str, Any]]], dict[str, dict[str, Any]]]
|
||||
ParseCharacterCast = Callable[[str | dict[str, Any] | list[Any] | None], list[dict[str, Any]]]
|
||||
SlotIsPov = Callable[[dict[str, Any] | None], bool]
|
||||
SlotSoftcoreOutfit = Callable[[dict[str, Any] | None, Any], str]
|
||||
|
||||
|
||||
@@ -53,6 +59,98 @@ def prompt_cast_descriptors(text: str) -> str:
|
||||
return str(text or "").replace("Woman A / primary creator:", "Woman A:")
|
||||
|
||||
|
||||
def cast_descriptor_entries_from_slots(
|
||||
*,
|
||||
seed_config: dict[str, int],
|
||||
seed: int,
|
||||
row_number: int,
|
||||
ethnicity: str,
|
||||
figure: str,
|
||||
no_plus_women: bool,
|
||||
no_black: bool,
|
||||
women_count: int,
|
||||
men_count: int,
|
||||
character_slots: list[dict[str, Any]],
|
||||
character_slot_map: dict[str, dict[str, Any]],
|
||||
primary_descriptor: str = "",
|
||||
axis_rng: AxisRng,
|
||||
character_context_for_label: CharacterContextForLabel,
|
||||
slot_is_pov: SlotIsPov,
|
||||
) -> tuple[list[str], list[dict[str, Any]]]:
|
||||
rng = axis_rng(seed_config, "person", seed, row_number + 997)
|
||||
descriptors: list[str] = []
|
||||
for index in range(max(0, women_count)):
|
||||
label = f"Woman {chr(ord('A') + index)}"
|
||||
if index == 0 and primary_descriptor:
|
||||
descriptors.append(f"Woman A / primary creator: {primary_descriptor}")
|
||||
continue
|
||||
context, _slot = character_context_for_label(
|
||||
label,
|
||||
character_slot_map,
|
||||
rng,
|
||||
ethnicity,
|
||||
figure,
|
||||
no_plus_women,
|
||||
no_black,
|
||||
)
|
||||
descriptors.append(f"{label}: {insta_descriptor_from_context(context)}")
|
||||
for index in range(max(0, men_count)):
|
||||
label = f"Man {chr(ord('A') + index)}"
|
||||
if slot_is_pov(character_slot_map.get(label)):
|
||||
continue
|
||||
context, _slot = character_context_for_label(
|
||||
label,
|
||||
character_slot_map,
|
||||
rng,
|
||||
ethnicity,
|
||||
figure,
|
||||
no_plus_women,
|
||||
no_black,
|
||||
)
|
||||
descriptors.append(f"{label}: {insta_descriptor_from_context(context)}")
|
||||
return descriptors, character_slots
|
||||
|
||||
|
||||
def cast_descriptor_entries(
|
||||
*,
|
||||
seed_config: dict[str, int],
|
||||
seed: int,
|
||||
row_number: int,
|
||||
ethnicity: str,
|
||||
figure: str,
|
||||
no_plus_women: bool,
|
||||
no_black: bool,
|
||||
women_count: int,
|
||||
men_count: int,
|
||||
character_cast: str | dict[str, Any] | list[Any] | None = "",
|
||||
primary_descriptor: str = "",
|
||||
parse_character_cast: ParseCharacterCast,
|
||||
character_slot_label_map: CharacterSlotLabelMap,
|
||||
axis_rng: AxisRng,
|
||||
character_context_for_label: CharacterContextForLabel,
|
||||
slot_is_pov: SlotIsPov,
|
||||
) -> tuple[list[str], list[dict[str, Any]]]:
|
||||
slots = parse_character_cast(character_cast)
|
||||
label_map = character_slot_label_map(slots)
|
||||
return cast_descriptor_entries_from_slots(
|
||||
seed_config=seed_config,
|
||||
seed=seed,
|
||||
row_number=row_number,
|
||||
ethnicity=ethnicity,
|
||||
figure=figure,
|
||||
no_plus_women=no_plus_women,
|
||||
no_black=no_black,
|
||||
women_count=women_count,
|
||||
men_count=men_count,
|
||||
character_slots=slots,
|
||||
character_slot_map=label_map,
|
||||
primary_descriptor=primary_descriptor,
|
||||
axis_rng=axis_rng,
|
||||
character_context_for_label=character_context_for_label,
|
||||
slot_is_pov=slot_is_pov,
|
||||
)
|
||||
|
||||
|
||||
def softcore_partner_styling(
|
||||
*,
|
||||
seed_config: dict[str, int],
|
||||
@@ -117,24 +215,29 @@ def resolve_insta_pair_cast_context(
|
||||
platform_styles: dict[str, str],
|
||||
soft_levels: dict[str, str],
|
||||
hardcore_levels: dict[str, str],
|
||||
build_cast_descriptors: CastDescriptors,
|
||||
axis_rng: AxisRng,
|
||||
character_context_for_label: CharacterContextForLabel,
|
||||
slot_is_pov: SlotIsPov,
|
||||
choose: Choose,
|
||||
slot_softcore_outfit: SlotSoftcoreOutfit,
|
||||
) -> dict[str, Any]:
|
||||
descriptor = insta_descriptor_from_row(soft_row)
|
||||
cast_descriptors = build_cast_descriptors(
|
||||
descriptor,
|
||||
parsed_seed_config,
|
||||
seed,
|
||||
row_number,
|
||||
ethnicity,
|
||||
figure,
|
||||
no_plus_women,
|
||||
no_black,
|
||||
hard_women_count,
|
||||
hard_men_count,
|
||||
character_slots,
|
||||
cast_descriptors, _descriptor_slots = cast_descriptor_entries_from_slots(
|
||||
seed_config=parsed_seed_config,
|
||||
seed=seed,
|
||||
row_number=row_number,
|
||||
ethnicity=ethnicity,
|
||||
figure=figure,
|
||||
no_plus_women=no_plus_women,
|
||||
no_black=no_black,
|
||||
women_count=hard_women_count,
|
||||
men_count=hard_men_count,
|
||||
character_slots=character_slots,
|
||||
character_slot_map=character_slot_map,
|
||||
primary_descriptor=descriptor,
|
||||
axis_rng=axis_rng,
|
||||
character_context_for_label=character_context_for_label,
|
||||
slot_is_pov=slot_is_pov,
|
||||
)
|
||||
cast_descriptor_text = prompt_cast_descriptors("; ".join(cast_descriptors))
|
||||
same_softcore_cast = options["softcore_cast"] == "same_as_hardcore"
|
||||
|
||||
Reference in New Issue
Block a user