J3b: chat, the player list (with each player's land) and admin commands across lands; sleep needs everyone in every land, with a 'waiting for everyone else' message
This commit is contained in:
@@ -118,6 +118,13 @@ func _body() -> void:
|
||||
check(world.all_pieces().any(func(p): return p.item_id == "torch_stand" and world.underground_at(p.global_position)),
|
||||
"a torch stand set down there, for everyone")
|
||||
|
||||
# (A hut with beds in the Valley, for Bob, later.)
|
||||
var vsite: Vector3 = world.build.debug_find_site(world._spawn + Vector3(0, 0, 14), 3.0)
|
||||
PN.ask("debug_hut", [vsite])
|
||||
await _until(func(): return _beds().size() >= 1, 8.0)
|
||||
var bob_bed: int = WN.nid(_beds()[0]) if not _beds().is_empty() else 0
|
||||
var bob_bed_at: Vector3 = _beds()[0].global_position if not _beds().is_empty() else Vector3.ZERO
|
||||
|
||||
print("out to the Cove")
|
||||
var day0: int = world.day_night.day
|
||||
var stone0: int = player.inventory.count("stone")
|
||||
@@ -138,6 +145,7 @@ func _body() -> void:
|
||||
check(world.sea_cave.open(), "the sea cave leads back up (the hub says the tunnel's through)")
|
||||
var bob := await _bob({"do": "report"})
|
||||
check(not bob.has("error") and not bob.is_empty(), "Bob carries on in the Valley, on the hub (%s)" % bob.get("error", "ok"))
|
||||
await _across_lands(bob_bed, bob_bed_at)
|
||||
|
||||
print("back up to the Valley")
|
||||
_arrived = ""
|
||||
@@ -173,8 +181,82 @@ func _body() -> void:
|
||||
await _load_world()
|
||||
check(world.worldlet_id() == "cove" and player.global_position.distance_to(spot) < 1.5,
|
||||
"where she left off (%.1f m off)" % player.global_position.distance_to(spot))
|
||||
print("an admin in the Cove kicks someone in the Valley")
|
||||
await _until(func(): return Net.roster.any(func(e): return String(e.name) == "Bob"), 4.0)
|
||||
root.get_node("Chat").say("/kick Bob")
|
||||
await _until(func(): return not Net.roster.any(func(e): return String(e.name) == "Bob"), 6.0)
|
||||
check(not Net.roster.any(func(e): return String(e.name) == "Bob"), "Bob's gone from the server (%s)" % [Net.roster.map(func(e): return e.name)])
|
||||
_finished = true
|
||||
|
||||
# --- J3b: chat, the player list, commands and sleep across lands --------------------------
|
||||
|
||||
func _across_lands(bob_bed: int, bob_bed_at: Vector3) -> void:
|
||||
var C: Node = root.get_node("Chat")
|
||||
print("chat across lands")
|
||||
await _bob({"do": "say", "text": "hello from the Valley"})
|
||||
await _until(func(): return C.heard.has("Bob: hello from the Valley"), 4.0)
|
||||
check(C.heard.has("Bob: hello from the Valley"), "Bob in the Valley says hello; Alice hears it in the Cove")
|
||||
await _sleep(1.2) # (chat's flood gap)
|
||||
C.say("hi from the Cove")
|
||||
var heard := false
|
||||
for _i in range(15):
|
||||
var h := await _bob({"do": "heard"})
|
||||
if (h.get("heard", []) as Array).has("Alice: hi from the Cove"):
|
||||
heard = true
|
||||
break
|
||||
await _sleep(0.2)
|
||||
check(heard, "and Bob hears her back")
|
||||
|
||||
print("the player list")
|
||||
await _until(func(): return Net.roster.size() >= 2, 4.0)
|
||||
var where := {}
|
||||
for e in Net.roster:
|
||||
where[String(e.name)] = String(e.land)
|
||||
check(where.get("Alice", "") == "cove" and where.get("Bob", "") == "valley", "everyone, and where they are (%s)" % [where])
|
||||
C.say("/players")
|
||||
await _until(func(): return C.heard.any(func(l): return String(l).begins_with("2 online")), 4.0)
|
||||
var line: String = ""
|
||||
for l in C.heard:
|
||||
if String(l).begins_with("2 online"):
|
||||
line = String(l)
|
||||
check(line.contains("Bob in the Valley") and line.contains("Alice (admin) in the Cove"), "/players from the Cove: %s" % line)
|
||||
C.say("/set wolf_grace_days 5")
|
||||
await _until(func(): return int(Net.server_info.get("wolf_grace_days", 0)) == 5, 4.0)
|
||||
check(int(Net.server_info.get("wolf_grace_days", 0)) == 5, "an admin's /set from the Cove: the hub keeps server.json, and the Cove's rules follow")
|
||||
|
||||
print("sleep needs everyone, in every land")
|
||||
await _bob({"do": "ask", "what": "debug_time", "args": [world.day_night.day, 21.0]})
|
||||
await _until(func(): return world.day_night.hours() > 20.5, 15.0)
|
||||
check(world.day_night.hours() > 20.5, "night in the Valley is night in the Cove (%s)" % world.day_night.clock_text())
|
||||
var day_n: int = world.day_night.day
|
||||
var site: Vector3 = world.build.debug_find_site(player.global_position + Vector3(0, 0, 14), 3.0)
|
||||
PN.ask("debug_hut", [site])
|
||||
await _until(func(): return _beds().size() >= 1, 8.0)
|
||||
check(not _beds().is_empty() and bob_bed != 0, "beds in the Cove and the Valley")
|
||||
if _beds().is_empty() or bob_bed == 0:
|
||||
return
|
||||
await _bob({"do": "tp", "to": [bob_bed_at.x, bob_bed_at.y + 0.1, bob_bed_at.z + 0.9]})
|
||||
await _bob({"do": "bed", "nid": bob_bed})
|
||||
await _bob({"do": "bed", "nid": bob_bed})
|
||||
await _until(func(): return C.heard.any(func(l): return String(l).begins_with("Bob is in bed")), 4.0)
|
||||
check(C.heard.has("Bob is in bed (1 of 2 asleep)"), "Bob gets into bed in the Valley; Alice hears it in the Cove (%s)" % [C.heard.slice(-2)])
|
||||
await _sleep(1.0)
|
||||
check(world.day_night.hours() > 20.5, "and the night goes on: Alice is still up, in another land")
|
||||
var mine: Node3D = _beds()[0]
|
||||
await _tp(mine.global_position + Vector3(0, 0.1, 0.9))
|
||||
_toasts.clear()
|
||||
A.use_bed(player, mine)
|
||||
await _sleep(0.5)
|
||||
A.use_bed(player, mine)
|
||||
await _until(func(): return world.day_night.hours() < 7.0, 5.0)
|
||||
check(world.day_night.hours() >= 5.9 and world.day_night.hours() < 7.0 and world.day_night.day == day_n + 1,
|
||||
"Alice gets into bed in the Cove, and the night passes for both (%s, day %d)" % [world.day_night.clock_text(), world.day_night.day])
|
||||
var life := await _bob({"do": "life"})
|
||||
check(float(life.get("hours", 0)) >= 5.9 and float(life.get("hours", 0)) < 7.0, "Bob wakes to morning in the Valley too (%.1f h)" % float(life.get("hours", 0)))
|
||||
|
||||
func _beds() -> Array:
|
||||
return WN.pieces.values().filter(func(p): return is_instance_valid(p) and p.item_id == "bed")
|
||||
|
||||
# --- helpers -------------------------------------------------------------------------
|
||||
|
||||
## (Re)loads the world for whichever server we're on now.
|
||||
|
||||
@@ -269,7 +269,8 @@ func _sleeping() -> void:
|
||||
await _sleep(0.5)
|
||||
A.use_bed(player, beds[0])
|
||||
await _sleep(1.0)
|
||||
check(_toasts.any(func(t): return t.begins_with("You're in bed (1 of 2")), "Alice gets into bed: 1 of 2 asleep (%s)" % [_toasts])
|
||||
check(_toasts.any(func(t): return t == "You're in bed: waiting for everyone else to go to bed (1 of 2 asleep)"),
|
||||
"Alice gets into bed: waiting for the others, 1 of 2 asleep (%s)" % [_toasts])
|
||||
check(world.day_night.hours() > 20.5, "and the night goes on, because Bob's still up")
|
||||
await _bob({"do": "bed", "nid": WN.nid(beds[1])})
|
||||
await _bob({"do": "bed", "nid": WN.nid(beds[1])})
|
||||
|
||||
Reference in New Issue
Block a user