Table of Contents

Class GameReply

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll

What the game and ValheimCLI answered one command: the transport's result, its lines, and whether the game refused it. Execute(string, bool) returns one and, by default, requires it Accepted: the transport completed and no line is a known refusal. A transport result alone is not acceptance: a refused console command still completes. Acceptance supplements a step's semantic check (read the line or state it changed); it never replaces one.

public sealed class GameReply
Inheritance
object
GameReply

Constructors

GameReply(string, CommandResult)

public GameReply(string command, CommandResult result)

Parameters

command string
result CommandResult

Properties

Accepted

The transport completed and no line is a refusal.

public bool Accepted { get; }

Property Value

bool

Command

The command as sent.

public string Command { get; }

Property Value

string

ErrorCode

public string? ErrorCode { get; }

Property Value

string

Message

public string? Message { get; }

Property Value

string

Ok

The transport completed the command (not that the game accepted it: see Accepted).

public bool Ok { get; }

Property Value

bool

Output

public IReadOnlyList<string> Output { get; }

Property Value

IReadOnlyList<string>

Refusal

The first refusal line (IsRefusalLine(string)), or null.

public string? Refusal { get; }

Property Value

string

Result

The transport's result, unchanged.

public CommandResult Result { get; }

Property Value

CommandResult

Methods

Describe()

The reply's lines joined for a message, or "(no output)".

public string Describe()

Returns

string

IsRefusalLine(string)

Whether a line is how Valheim 1.0.16 or ValheimCLI refuses a command: the game's cheat gate ("That command is a cheat"), its "Error executing command" and "Unknown command", and a ValheimCLI ERROR: status line.

public static bool IsRefusalLine(string line)

Parameters

line string

Returns

bool

Line(string)

The first line starting with prefix (ordinal), or null.

public string? Line(string prefix)

Parameters

prefix string

Returns

string

Lines(string)

Every line starting with prefix (ordinal), in order.

public IEnumerable<string> Lines(string prefix)

Parameters

prefix string

Returns

IEnumerable<string>

RequireAccepted()

Throws unless Accepted: a transport failure as {code}: {message} (or the command and its lines when the transport gave neither), a refusal with the command and the reply's lines. Returns this reply.

public GameReply RequireAccepted()

Returns

GameReply

RequireLine(string, string?)

The first line starting with prefix, or a failure naming failure (default: the command and the prefix) with the reply's lines.

public string RequireLine(string prefix, string? failure = null)

Parameters

prefix string
failure string

Returns

string