Profile, Startoptionen und vorsichtiges Lesen
Die Befehlszeile wählt ein Profil, einen Namen und einen Direktstart. Zwei Fenster auf einem Rechner sind so zwei Spieler. Ein Schlüssel oder Spielstand, der sich gerade nicht lesen lässt, wird nicht mehr ersetzt. Name und zuletzt genutzte Adresse bleiben gespeichert. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
extends TestCase
|
||||
|
||||
|
||||
func test_without_arguments_the_menu_shows_and_the_default_profile_is_used() -> void:
|
||||
var options := LaunchOptions.parse(PackedStringArray())
|
||||
check_eq(options.start, "", "no direct start")
|
||||
check_eq(options.storage_dir(), "user://", "the user folder itself")
|
||||
check_eq(options.port, NetLink.DEFAULT_PORT, "the default port")
|
||||
|
||||
|
||||
func test_every_argument_is_read() -> void:
|
||||
var options := LaunchOptions.parse(PackedStringArray(["--profile=second", "--name=Grace", "--host", "--port=25000"]))
|
||||
check_eq(options.storage_dir(), "user://profiles/second", "a folder of its own")
|
||||
check_eq(options.player_name, "Grace", "name")
|
||||
check_eq(options.start, "host", "opens the world")
|
||||
check_eq(options.port, 25000, "port")
|
||||
var joining := LaunchOptions.parse(PackedStringArray(["--join=192.168.1.20:25000"]))
|
||||
check_eq(joining.start, "join", "joins")
|
||||
check_eq(joining.address, "192.168.1.20:25000", "address")
|
||||
check_eq(LaunchOptions.parse(PackedStringArray(["--solo"])).start, "solo", "plays alone")
|
||||
|
||||
|
||||
func test_profile_names_cannot_leave_the_profile_folder() -> void:
|
||||
check(LaunchOptions.is_valid_profile("Zweiter_2-b"), "letters, digits, - and _")
|
||||
for name in ["", "../save", "a/b", "a b", "x".repeat(33)]:
|
||||
check(not LaunchOptions.is_valid_profile(name), "refused: '%s'" % name)
|
||||
var options := LaunchOptions.parse(PackedStringArray(["--profile=../oops", "--port=70000", "--fly"]))
|
||||
check_eq(options.storage_dir(), "user://", "a bad profile is ignored")
|
||||
check_eq(options.port, NetLink.DEFAULT_PORT, "a bad port is ignored")
|
||||
check_eq(options.ignored, PackedStringArray(["--profile=../oops", "--port=70000", "--fly"]), "everything ignored is listed")
|
||||
Reference in New Issue
Block a user