// Provenance: own design — shared run scripts (spec §6; one hook shape for §4.2 capabilities, see Actions) namespace Godosa.Core.Runs.Scripts; /// A game's run-script adapter. holds the lib's game-hooked verbs by their lib name /// (talk, walk-to, cheat, …) and the game's own verbs. Player-kind actions return input plans only; /// the lib injects them. public interface IRunGame { string Name { get; } string ContentVersion { get; } IInputRouter Input { get; } IReadOnlyDictionary Probes { get; } IReadOnlyDictionary Constants { get; } IReadOnlyDictionary Locators { get; } IReadOnlyDictionary Actions { get; } IRunRng? Rng { get; } bool SupportsSnapshot { get; } byte[] SnapshotSave(); /// Why the current state can't be checkpointed faithfully (e.g. state the snapshot doesn't hold), or null. /// A refused checkpoint is not cached (warning); failure snapshots are still taken. string? SnapshotRefusal() => null; void SnapshotRestore(byte[] data); /// The restore completes after this frame (a window rebuilds its game view): the runner pauses one frame /// (), in which the host advances no game frame. bool RestoreDeferred => false; ulong Digest(); string Dump(); void Advance(); } public interface IProbe { int MinArgs { get; } int MaxArgs { get; } RunValue Eval(IReadOnlyList args); } public readonly record struct LocatorResult(int X, int Y, string? Error) { public static LocatorResult Ok(int x, int y) => new(x, y, null); public static LocatorResult Fail(string message) => new(0, 0, message); public bool IsOk => Error == null; } /// Finds where to aim (virtual-screen position) from game state, as a player reads the screen. public interface ILocator { LocatorResult Locate(IReadOnlyList args); } /// Begin returns an input plan to inject (player) and/or an immediate status (debug: usually Done); after the /// plan is sent, Poll runs each frame until Done or Fault. public interface IRunAction { VerbKind Kind { get; } int MinArgs { get; } int MaxArgs { get; } ActionStart Begin(IReadOnlyList args); StepStatus Poll(); } public sealed record ActionStart(InputPlan? Plan = null, StepStatus? Status = null); public interface IRunRng { void Seed(long seed); void ForceNext(string kind, long value); }