M6.13: Sex picker + species variant schema

Adds character Sex (male/female) as a top-level CharacterDraft field
required for every character, and species variants as a layer on top
of the base species record. Two variant axes:

  - "sex": auto-resolves from CharacterDraft.Sex for purebreds; for
           hybrids, pinned by parent role (sire = male, dam = female)
           by definition. No picker needed beyond Step 0.
  - "lineage": explicit per-species pick (Ram-Folk's sheep/goat). Has
               its own picker on Step 1 (purebred path under the grid;
               hybrid path embedded into the per-parent pick column).

Schema (Theriapolis.Core/Data):
  - SpeciesDef gains VariantAxis (string) and Variants (array of
    SpeciesVariantDef { Id, Name, Traits, Detriments }).
  - JSON content not yet populated — that's M6.14.

CharacterDraft adds:
  - Sex (required by Step 0 validation)
  - SpeciesVariant / SireSpeciesVariant / DamSpeciesVariant
  - ResolveVariantId(species, role) that returns the active variant
    id for a given context — used by Aside to layer variant traits
    onto the base species traits.

Step 0 (StepClade): sex picker row above the hybrid toggle. Two
toggle buttons radio-style.

Step 1 (StepSpecies): purebred path renders a lineage picker below
the grid when the picked species has VariantAxis == "lineage";
hybrid path embeds a lineage picker at the top of each parent's
pick column. Hover popovers summarise each variant's contents.

Validation: Sex is required at Step 0. Lineage variant required at
Step 1 for any picked species (purebred or per-hybrid-parent) with
VariantAxis == "lineage".

Aside: AddVariantContent layers the resolved variant's extra
traits/detriments onto the base species rendering, for both purebred
and hybrid paths.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Christopher Wiebe
2026-05-04 21:03:56 -07:00
parent 44b2ec111f
commit e1fb988969
6 changed files with 301 additions and 9 deletions
+51
View File
@@ -28,6 +28,23 @@ public partial class CharacterDraft : Resource
[Export] public string SubclassId { get; set; } = "";
[Export] public string BackgroundId { get; set; } = "";
/// <summary>"male" or "female". Required for every character. For
/// purebreds with sex-axis variants (Elk, Lion), drives variant
/// resolution. For hybrids, sire variant always resolves to "male"
/// and dam variant to "female" by parent-role definition — the
/// character's own Sex remains an identity field.</summary>
[Export] public string Sex { get; set; } = "";
/// <summary>Lineage-axis variant id picked for the purebred species
/// (e.g. "sheep" or "goat" for Ram-Folk). Empty if the picked species
/// has no lineage variant.</summary>
[Export] public string SpeciesVariant { get; set; } = "";
/// <summary>Hybrid: lineage-axis variant for sire's species.</summary>
[Export] public string SireSpeciesVariant { get; set; } = "";
/// <summary>Hybrid: lineage-axis variant for dam's species.</summary>
[Export] public string DamSpeciesVariant { get; set; } = "";
// ── Phase 6.5 hybrid origin ────────────────────────────────────────
/// <summary>True when the PC is a hybrid (two parent lineages).</summary>
[Export] public bool IsHybrid { get; set; }
@@ -67,6 +84,36 @@ public partial class CharacterDraft : Resource
public int CladeTraitLimit(string lineage) =>
lineage == DominantParent ? 2 : 1;
/// <summary>
/// Resolves the active variant id for a species. <paramref name="role"/>
/// is "" for purebred, "sire" or "dam" for hybrid lineages. Returns
/// empty when the species has no variants or the relevant pick/sex is
/// missing.
/// </summary>
public string ResolveVariantId(Theriapolis.Core.Data.SpeciesDef? species, string role)
{
if (species is null || string.IsNullOrEmpty(species.VariantAxis)) return "";
return species.VariantAxis switch
{
// Sex-axis: purebred uses character Sex; hybrid lineages are
// pinned by parent role (sire = male, dam = female).
"sex" => role switch
{
"sire" => "male",
"dam" => "female",
_ => Sex,
},
// Lineage-axis: explicit per-species pick.
"lineage" => role switch
{
"sire" => SireSpeciesVariant,
"dam" => DamSpeciesVariant,
_ => SpeciesVariant,
},
_ => "",
};
}
/// <summary>
/// Resolves the "active" clade for downstream steps (Class / Subclass
/// / Background). Purebred uses <see cref="CladeId"/>; hybrids use
@@ -149,6 +196,10 @@ public partial class CharacterDraft : Resource
case "dam_chosen_species_trait": DamChosenSpeciesTrait = (string)patch[key]; break;
case "sire_chosen_species_detriment":SireChosenSpeciesDetriment = (string)patch[key]; break;
case "dam_chosen_species_detriment": DamChosenSpeciesDetriment = (string)patch[key]; break;
case "sex": Sex = (string)patch[key]; break;
case "species_variant": SpeciesVariant = (string)patch[key]; break;
case "sire_species_variant": SireSpeciesVariant = (string)patch[key]; break;
case "dam_species_variant": DamSpeciesVariant = (string)patch[key]; break;
default:
GD.PushWarning($"[CharacterDraft] unknown patch key: {k}");
break;
+16 -1
View File
@@ -33,6 +33,7 @@ public static class WizardValidation
private static string? ValidateClade(CharacterDraft draft)
{
if (string.IsNullOrEmpty(draft.Sex)) return "Pick a sex.";
if (draft.IsHybrid)
{
if (string.IsNullOrEmpty(draft.SireCladeId)) return "Pick a sire clade.";
@@ -85,9 +86,23 @@ public static class WizardValidation
&& string.IsNullOrEmpty(draft.DamChosenSpeciesDetriment))
return "Pick a dam species detriment.";
// Lineage-axis variants: each parent species needs an
// explicit lineage pick when applicable.
if (sireSp is not null && sireSp.VariantAxis == "lineage"
&& string.IsNullOrEmpty(draft.SireSpeciesVariant))
return "Pick a sire species lineage.";
if (damSp is not null && damSp.VariantAxis == "lineage"
&& string.IsNullOrEmpty(draft.DamSpeciesVariant))
return "Pick a dam species lineage.";
return null;
}
return string.IsNullOrEmpty(draft.SpeciesId) ? "Pick a species." : null;
if (string.IsNullOrEmpty(draft.SpeciesId)) return "Pick a species.";
var purebredSp = CodexContent.SpeciesById(draft.SpeciesId);
if (purebredSp is not null && purebredSp.VariantAxis == "lineage"
&& string.IsNullOrEmpty(draft.SpeciesVariant))
return "Pick a species lineage.";
return null;
}
private static string? ValidateSkills(CharacterDraft draft)