Files

50 lines
2.0 KiB
C#
Raw Permalink Normal View History

using Theriapolis.Core.Data;
using Theriapolis.Core.Entities;
using Theriapolis.Core.Rules.Reputation;
namespace Theriapolis.Core.Rules.Dialogue;
/// <summary>
/// Phase 6 M3 — read/write window into player + npc state used by
/// <see cref="DialogueRunner"/> to evaluate conditions and apply effects.
/// Keeps the runner free of direct PlayScreen / ActorManager references
/// so the runner can be unit-tested with a synthetic context.
/// </summary>
public sealed class DialogueContext
{
public NpcActor Npc { get; }
public Rules.Character.Character Pc { get; }
public PlayerReputation Reputation { get; }
public Dictionary<string, int> Flags { get; }
public ContentResolver Content { get; }
/// <summary>Player position for tagging RepEvent origins. Optional; defaults to (0, 0) in tests.</summary>
public int PlayerWorldTileX { get; set; }
public int PlayerWorldTileY { get; set; }
public long WorldClockSeconds { get; set; }
/// <summary>Set true by <see cref="DialogueRunner"/> when an option fires the open_shop effect.</summary>
public bool ShopRequested { get; set; }
/// <summary>
/// Phase 6 M3 — quest hook stub. set_flag-only for M3; the real quest
/// engine wires in M4 and consumes <see cref="StartQuestRequests"/>.
/// </summary>
public List<string> StartQuestRequests { get; } = new();
public DialogueContext(NpcActor npc, Rules.Character.Character pc,
PlayerReputation rep, Dictionary<string, int> flags,
ContentResolver content)
{
Npc = npc;
Pc = pc;
Reputation = rep;
Flags = flags;
Content = content;
}
/// <summary>Effective disposition for the current NPC vs the player. Cached per dialogue turn — recomputed on demand.</summary>
public int EffectiveDispositionScore()
=> EffectiveDisposition.For(Npc, Pc, Reputation, Content);
}