namespace MultiversalDiplomacy.Script;
///
/// The result of an processing a line of input.
///
/// Whether processing was successful.
/// The handler to continue script processing with.
/// If processing failed, the error message.
public class ScriptResult(bool success, IScriptHandler? next, string message)
{
///
/// Whether processing was successful.
///
public bool Success { get; } = success;
///
/// The handler to continue script processing with.
///
public IScriptHandler? NextHandler { get; } = next;
///
/// If processing failed, the error message.
///
public string Message { get; } = message;
///
/// Mark the processing as successful and continue processing with the next handler.
///
public static ScriptResult Succeed(IScriptHandler next) => new(true, next, "");
///
/// Mark the processing as a failure and optionally continue with the next handler.
///
/// The reason for the processing failure.
public static ScriptResult Fail(string message, IScriptHandler? next = null) => new(false, next, message);
}