Files
Christopher Wiebe b451f83174 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>
2026-04-30 20:40:51 -07:00

45 lines
1.6 KiB
C#

using Theriapolis.Core.Data;
namespace Theriapolis.Core.Rules.Reputation;
/// <summary>
/// Phase 6 M2 — top-level aggregate of every reputation track owned by
/// the player. Hangs off PlayScreen as a parallel-to-Character record
/// (deliberate separation: <c>Character</c> is what the player is,
/// <c>PlayerReputation</c> is what the world thinks of them).
///
/// Round-trips through <see cref="Persistence.ReputationSnapshot"/>.
/// </summary>
public sealed class PlayerReputation
{
public FactionStanding Factions { get; } = new();
public Dictionary<string, PersonalDisposition> Personal { get; } = new(System.StringComparer.OrdinalIgnoreCase);
public RepLedger Ledger { get; } = new();
/// <summary>Get-or-create the per-NPC personal disposition record for <paramref name="roleTag"/>.</summary>
public PersonalDisposition PersonalFor(string roleTag)
{
if (!Personal.TryGetValue(roleTag, out var p))
{
p = new PersonalDisposition { RoleTag = roleTag };
Personal[roleTag] = p;
}
return p;
}
/// <summary>
/// Submit a reputation event. Updates faction standing (with opposition
/// cascade), the addressed NPC's personal disposition, and the ledger.
/// </summary>
public void Submit(RepEvent ev, IReadOnlyDictionary<string, FactionDef> factions)
{
if (!string.IsNullOrEmpty(ev.FactionId) && ev.Magnitude != 0)
Factions.Apply(ev.FactionId, ev.Magnitude, factions);
if (!string.IsNullOrEmpty(ev.RoleTag))
PersonalFor(ev.RoleTag).Apply(ev);
Ledger.Append(ev);
}
}