Initial commit: Theriapolis baseline at port/godot branch point

Captures the pre-Godot-port state of the codebase. This is the rollback
anchor for the Godot port (M0 of theriapolis-rpg-implementation-plan-godot-port.md).
All Phase 0 through Phase 6.5 work is included; Phase 7 is in flight.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Christopher Wiebe
2026-04-30 20:40:51 -07:00
commit b451f83174
525 changed files with 75786 additions and 0 deletions
@@ -0,0 +1,45 @@
using Theriapolis.Core.Rules.Combat;
namespace Theriapolis.Core.Entities.Ai;
/// <summary>
/// One NPC behavior — what does this NPC do on its turn? Behaviors are
/// dispatched by id (the template's <c>behavior</c> field) via
/// <see cref="BehaviorRegistry"/>. Each behavior must produce its turn's
/// actions within bounded time — no recursion, no while-true loops; if no
/// valid action is available, end the turn.
/// </summary>
public interface INpcBehavior
{
/// <summary>
/// Take one turn for <paramref name="self"/>. Behaviors call into
/// <see cref="Resolver"/> to mutate the encounter, then return — the
/// caller (typically <see cref="Encounter"/>'s turn pump) calls
/// <see cref="Encounter.EndTurn"/> after this returns.
/// </summary>
void TakeTurn(Combatant self, AiContext ctx);
}
/// <summary>
/// Maps behavior ids (the strings in <c>npc_templates.json</c>'s
/// <c>behavior</c> field) to their <see cref="INpcBehavior"/>
/// implementation. Phase 5 M5 ships three: <c>brigand</c>,
/// <c>wild_animal</c>, <c>poi_guard</c>. Unknown ids fall back to
/// <c>brigand</c> with a debug log.
/// </summary>
public static class BehaviorRegistry
{
private static readonly System.Collections.Generic.Dictionary<string, INpcBehavior> _impls
= new(System.StringComparer.OrdinalIgnoreCase)
{
["brigand"] = new BrigandBehavior(),
["wild_animal"] = new WildAnimalBehavior(),
["poi_guard"] = new PoiGuardBehavior(),
["patrol"] = new BrigandBehavior(), // patrol shares brigand combat behavior
};
public static INpcBehavior For(string id)
{
return _impls.TryGetValue(id, out var b) ? b : _impls["brigand"];
}
}