N10: Playable network client

The client program now turns a connection into a match someone can play.

- ClientSession: a ClientGame, the keyboard and mouse as commands
  (ClientInput), and a MatchView of the client's own copy of the world.
- ClientMirror writes what the client is showing into that world every
  frame: other players from the recent past, its own player where it was
  predicted, items, the barge, the clock and the sea. The existing views
  draw it unchanged.
- LocalServer: offline play is the same ServerLoop and NetGame in the same
  process, with packets handed across in memory, so there is one path.
- main.gd: --connect=HOST[:PORT] joins a server, otherwise an offline
  match; --autoplay and --client-seconds=N for scripts and checks.
- The camera aboard the barge follows the player's own place on the deck.

Tests drive a scripted client through a whole match on a real server over
loopback UDP, lobby to results, and through an offline match. `make
client-check` does it with two real processes, and `make client-captures`
renders what the client sees.

Closes #77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 14:50:52 -05:00
co-authored by Claude Opus 5.5
parent 6b21e9d4f1
commit 9a36ae8615
25 changed files with 1089 additions and 13 deletions
+74
View File
@@ -0,0 +1,74 @@
## What the client was asked to do on the command line.
##
## tidewall an offline match against bots
## tidewall --connect=HOST[:PORT] join a server
## options: --name=NAME --seed=N --bots=N (offline) --autoplay
## --client-seconds=N quit after N seconds, saying what happened
##
## Menus replace most of this later. Under tools/godot.sh, which has no window, a mode
## has to be asked for: --offline or --connect.
class_name ClientConfig
extends RefCounted
const DEFAULT_NAME: String = "Islander"
const DEFAULT_BOTS: int = Tuning.SOLO_PLAYERS - 1
## Empty to play offline.
var host: String = ""
var port: int = ServerConfig.DEFAULT_PORT
var player_name: String = DEFAULT_NAME
var match_seed: int = 0
var has_seed: bool = false
var bots: int = DEFAULT_BOTS
var autoplay: bool = false
## Quit after this many seconds; 0 runs until the window is closed.
var seconds: float = 0.0
## True when --offline or --connect was given.
var asked: bool = false
var errors: Array[String] = []
static func parse(args: PackedStringArray) -> ClientConfig:
var config: ClientConfig = ClientConfig.new()
for arg: String in args:
var parts: PackedStringArray = arg.split("=", true, 1)
var value: String = parts[1] if parts.size() == 2 else ""
match parts[0]:
"--offline":
config.asked = true
"--autoplay":
config.autoplay = true
"--connect":
config.asked = true
var at: int = value.rfind(":")
config.host = value if at < 0 else value.substr(0, at)
if at >= 0:
var port_text: String = value.substr(at + 1)
config.port = port_text.to_int() if port_text.is_valid_int() else 0
if config.host.is_empty():
config.errors.append("--connect needs a host, as in --connect=192.0.2.7:%d" % ServerConfig.DEFAULT_PORT)
if config.port < 1 or config.port > 65535:
config.errors.append("the port in --connect must be between 1 and 65535")
"--name":
config.player_name = value
"--seed":
config.has_seed = value.is_valid_int()
config.match_seed = value.to_int()
if not config.has_seed:
config.errors.append("--seed must be a whole number, got '%s'" % value)
"--bots":
config.bots = value.to_int()
if not value.is_valid_int() or config.bots < 0 or config.bots > Tuning.SOLO_PLAYERS - 1:
config.errors.append("--bots must be between 0 and %d, got '%s'" % [Tuning.SOLO_PLAYERS - 1, value])
"--client-seconds":
config.seconds = value.to_float()
if not value.is_valid_float() or config.seconds <= 0.0:
config.errors.append("--client-seconds must be a number above 0, got '%s'" % value)
_:
if arg.begins_with("--"):
config.errors.append("unknown option '%s'" % arg)
return config
func is_valid() -> bool:
return errors.is_empty()