W1: choose a worldlet (New World and Host Game pages, kept once an island exists), worldlet shown in the Load list; Godot .uid files

This commit is contained in:
Paul Bailey
2026-11-06 16:10:32 +00:00
parent db4a659236
commit 68e6d814d9
96 changed files with 292 additions and 11 deletions

1
tests/net_bot.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://coc65tapbhoan

View File

@@ -0,0 +1 @@
uid://c770mv6jl6dbb

View File

@@ -9,7 +9,7 @@ if [ ! -f .godot/global_script_class_cache.cfg ]; then
echo "Importing the project first (fresh copy)..."
godot --headless --path . --import >/dev/null 2>&1
fi
for t in test_survival_core test_survival_stats test_save_load test_weather_building test_creatures_combat test_wolves test_alpha test_bear test_thieves test_barrow test_boss test_den_sites test_fishing_diet test_food test_hazards test_iron test_stone test_net_lobby test_net_world test_net_shared test_net_life test_net_boss test_net_rules test_host test_tutorial test_tutorial_full test_hints test_updates test_audio test_items_more test_worldlets test_terrain_edges test_boundary; do
for t in test_survival_core test_survival_stats test_save_load test_weather_building test_creatures_combat test_wolves test_alpha test_bear test_thieves test_barrow test_boss test_den_sites test_fishing_diet test_food test_hazards test_iron test_stone test_net_lobby test_net_world test_net_shared test_net_life test_net_boss test_net_rules test_host test_tutorial test_tutorial_full test_hints test_updates test_audio test_items_more test_worldlets test_worldlet_pick test_terrain_edges test_boundary; do
extra=""
[ "$t" = "test_boundary" ] && extra="--fixed-fps 30"
# A suite that waits on a world that failed to load would hang forever,

1
tests/test_alpha.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://ck4x0gw0w6q54

1
tests/test_audio.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://dkwpi1kjp11us

1
tests/test_barrow.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://bveecfelviv2q

1
tests/test_bear.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://bwv2gjno475ns

1
tests/test_boss.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://emp4g3jo3n6u

View File

@@ -0,0 +1 @@
uid://b181ahffmk3oy

View File

@@ -0,0 +1 @@
uid://dpmqwgnwum26x

View File

@@ -0,0 +1 @@
uid://dlm83u70hui08

1
tests/test_food.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://ba0oxbbweqnos

View File

@@ -0,0 +1 @@
uid://b5jjbmkuhcyu2

1
tests/test_hints.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://c2sl304vqgqjm

View File

@@ -46,7 +46,7 @@ func _body() -> void:
var statuses: Array[String] = []
Net.host_status.connect(func(t, _f): statuses.append(t))
print("hosting")
Net.host("Alice's island", "", PORT, "rivals", 4242)
Net.host("Alice's island", "", PORT, "rivals", 4242, "valley")
check(Net.hosting, "Host Game starts a server (%s)" % ", ".join(statuses))
await _until(func(): return Net.state == "connected", 40.0)
check(Net.state == "connected", "and joins it (%s)" % " -> ".join(statuses))
@@ -56,6 +56,7 @@ func _body() -> void:
"with the name and the rules picked (friendly rivals: PvP on)")
check(bool(Net.players.get(Net.local_peer, {}).get("admin", false)), "and Alice is its admin")
check(int(Net.world_info.get("seed", 0)) == 4242, "a new island from the seed given (%d)" % int(Net.world_info.get("seed", 0)))
check(String(Net.world_info.get("worldlet", "")) == "valley", "in the worldlet picked (%s)" % Net.world_info.get("worldlet", "-"))
var addrs: Array[String] = Net.my_addresses()
check(not addrs.is_empty(), "the addresses friends can use: %s" % ", ".join(addrs))
var log_path := ProjectSettings.globalize_path(DIR + "/server.log")
@@ -105,10 +106,12 @@ func _body() -> void:
c.data.backups_kept = 3
c.save()
statuses.clear()
Net.host("Alice's island", "", PORT, "co-op", 999)
Net.host("Alice's island", "", PORT, "co-op", 999, "cove")
await _until(func(): return Net.state == "connected", 40.0)
check(Net.state == "connected", "Host Game again: joined (%s)" % " -> ".join(statuses))
check(int(Net.world_info.get("seed", 0)) == 4242, "the same island (seed %d, not the new one typed)" % int(Net.world_info.get("seed", 0)))
check(String(load("res://scripts/net/server_config.gd").open(DIR + "/server.json").data.worldlet) == "valley",
"and the same worldlet (the Valley, not the new one picked)")
check(not bool(Net.server_info.get("pvp", true)), "with the rules picked this time (co-op: PvP off)")
check(_backups().size() == 3, "start-up made a backup, and only backups_kept (3) are kept (%d)" % _backups().size())
_finished = true

1
tests/test_host.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://ci1cmi2muyyhm

1
tests/test_iron.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://diaexq7aujgcy

View File

@@ -0,0 +1 @@
uid://c14jw5ojloao8

View File

@@ -0,0 +1 @@
uid://clqu3m2ic4h1y

View File

@@ -0,0 +1 @@
uid://dxjnvqs81vu4l

View File

@@ -0,0 +1 @@
uid://bf4kcu6iapdmv

View File

@@ -0,0 +1 @@
uid://cq738mqhslnq6

View File

@@ -0,0 +1 @@
uid://dypssblmpnt01

View File

@@ -0,0 +1 @@
uid://bdcf2xkerrlw1

1
tests/test_stone.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://b2jwpmnhtrv2p

View File

@@ -0,0 +1 @@
uid://rj7p5l0et5vo

View File

@@ -0,0 +1 @@
uid://dlh2tpy6p4cub

View File

@@ -0,0 +1 @@
uid://d0kc40mfvtcnx

View File

@@ -0,0 +1 @@
uid://c2cnl3i4arfv0

View File

@@ -0,0 +1 @@
uid://34ao8ilbht52

View File

@@ -0,0 +1 @@
uid://dy1iyx1vqbbrg

1
tests/test_wolves.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://8mmbdrbtg53y

110
tests/test_worldlet_pick.gd Normal file
View File

@@ -0,0 +1,110 @@
extends SceneTree
## W1 (docs/WORLDLETS_DESIGN.md): choosing a worldlet. The New World and Host
## Game pages have a "Where" picker listing the worldlets a new world can
## start in (only the Valley today, so it sits still); a world made from it
## remembers it; the Load list says where each world is; and a hosted island
## keeps its worldlet, like its seed, once it's made.
## Run: godot --headless --path . --script res://tests/test_worldlet_pick.gd
const DIR := "user://test_worldlet_pick"
var _fails := 0
var _finished := false
func check(cond: bool, what: String) -> void:
print((" ok " if cond else " FAIL ") + what)
if not cond:
_fails += 1
func _initialize() -> void:
_run.call_deferred()
func _run() -> void:
var S: Node = root.get_node("Saves")
var Net: Node = root.get_node("Net")
S.root_dir = DIR + "/worlds"
_rm_tree(DIR)
DirAccess.make_dir_recursive_absolute(DIR)
Net.host_config = DIR + "/server/server.json"
var me = load("res://scripts/net/identity.gd").open(DIR + "/me")
me.name = "Alice"
Net.identity = me
await _body(S, Net)
check(_finished, "test ran to the end (no script errors)")
_rm_tree(DIR)
print("RESULT: %s (%d failures)" % ["PASS" if _fails == 0 else "FAIL", _fails])
quit(1 if _fails > 0 else 0)
func _body(S: Node, Net: Node) -> void:
var T: Script = load("res://scripts/world/terrain.gd")
var TS: Script = load("res://scripts/ui/title_screen.gd")
print("the worldlets to start in")
var starts: Array = T.starting_worldlets()
check(starts.size() == 1 and String(starts[0].id) == "valley", "only the Valley (%s)" % [starts.map(func(w): return w.id)])
check(T.worldlets().all(func(w): return w.has("start")), "every worldlet says whether it's a start")
check(T.worldlet_name("valley") == "Valley", "the Valley's name, for the menus")
check(T.worldlet_name("nowhere") == "nowhere", "(an unknown one: its id)")
check(TS.picked_worldlet(null) == "valley", "nothing picked: the Valley")
print("the New World page")
var title: Node = load("res://scenes/title.tscn").instantiate()
root.add_child(title)
for _i in range(3):
await process_frame
var pick: OptionButton = title._worldlet_pick
check(pick != null and pick.item_count == 1 and pick.get_item_text(0) == "Valley", "a \"Where\" picker with the Valley in it")
check(pick.disabled, "which sits still with only one choice")
check(TS.picked_worldlet(pick) == "valley", "and gives the Valley")
var id: String = S.create_world("Pick test", 4242, {"worldlet": TS.picked_worldlet(pick)})
var meta: Dictionary = S.list_worlds().filter(func(w): return w.id == id)[0] if not id.is_empty() else {}
check(String(meta.get("worldlet", "")) == "valley", "a world made from it remembers the Valley (%s)" % meta.get("worldlet", "-"))
print("the Load list")
title._show("load")
await process_frame
check(_texts(title._list).any(func(t): return t.begins_with("Valley · seed 4242")), "says where each world is (%s)" % [_texts(title._list)])
print("the Host Game page")
var hp: OptionButton = title._host_worldlet
check(hp != null and hp.get_item_text(hp.selected) == "Valley", "a \"Where\" picker too, on the Valley")
title._show("host")
await process_frame
check(hp.disabled and TS.picked_worldlet(hp) == "valley", "a new island: the Valley (the only start)")
# Once the island exists it keeps its worldlet: the picker shows that one.
DirAccess.make_dir_recursive_absolute(DIR + "/server/worlds/server-world")
var f := FileAccess.open(DIR + "/server/worlds/server-world/meta.json", FileAccess.WRITE)
f.store_string(JSON.stringify({"seed": 7, "worldlet": "valley"}))
f.close()
title._show("host")
await process_frame
check(hp.disabled and TS.picked_worldlet(hp) == "valley", "an island already made: shows its worldlet, locked")
check(title._host_seed_label.text == "Seed (kept)", "(like its seed)")
# A worldlet that isn't a start (an island made elsewhere) is still shown.
var extra := OptionButton.new()
extra.add_item("Valley")
extra.set_item_metadata(0, "valley")
check(TS.select_worldlet(extra, "valley") == 0, "select_worldlet finds the Valley")
check(TS.select_worldlet(extra, "nowhere") == -1 and extra.item_count == 1, "and adds nothing for an unknown one")
extra.free()
title.queue_free()
await process_frame
print("hosting records the worldlet")
var C: Script = load("res://scripts/net/server_config.gd")
check(String(C.open(DIR + "/server/server.json").data.worldlet) == "valley", "server.json's worldlet is the Valley by default")
_finished = true
func _texts(n: Node) -> Array:
var out: Array = []
for c in n.find_children("*", "Label", true, false):
out.append(String(c.text))
return out
static func _rm_tree(d: String) -> void:
if not DirAccess.dir_exists_absolute(d):
return
for f in DirAccess.get_files_at(d):
DirAccess.remove_absolute(d.path_join(f))
for s in DirAccess.get_directories_at(d):
_rm_tree(d.path_join(s))
DirAccess.remove_absolute(d)

View File

@@ -0,0 +1 @@
uid://bq1s57q65wp3n

View File

@@ -0,0 +1 @@
uid://s1e6yemcmng2