feat(client): NpcResult model
This commit is contained in:
27
client/scripts/net/npc_result.gd
Normal file
27
client/scripts/net/npc_result.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
# client/scripts/net/npc_result.gd
|
||||
class_name NpcResult
|
||||
extends RefCounted
|
||||
## The game-meaningful result of one /npc/speak call. The caller applies
|
||||
## valid_moves (via MoveApplier) and harvests facts — state writes stay explicit
|
||||
## (§2). dropped_moves are kept only so the caller can log the §6 drops.
|
||||
|
||||
var display_text: String
|
||||
var facts: Array
|
||||
var valid_moves: Array
|
||||
var dropped_moves: Array
|
||||
var ends_conversation: bool
|
||||
var degraded: bool
|
||||
|
||||
|
||||
func _init(p_display_text := "", p_facts := [], p_valid := [], p_dropped := [],
|
||||
p_ends := false, p_degraded := false) -> void:
|
||||
display_text = p_display_text
|
||||
facts = p_facts
|
||||
valid_moves = p_valid
|
||||
dropped_moves = p_dropped
|
||||
ends_conversation = p_ends
|
||||
degraded = p_degraded
|
||||
|
||||
|
||||
static func fallback(line: String) -> NpcResult:
|
||||
return NpcResult.new(line, [], [], [], false, true)
|
||||
@@ -2,6 +2,7 @@ extends "res://addons/gut/test.gd"
|
||||
|
||||
const DmResponse = preload("res://scripts/net/dm_response.gd")
|
||||
const NarrateResult = preload("res://scripts/net/narrate_result.gd")
|
||||
const NpcResult = preload("res://scripts/net/npc_result.gd")
|
||||
const DmTransport = preload("res://scripts/net/dm_transport.gd")
|
||||
const ProxyConfig = preload("res://scripts/net/proxy_config.gd")
|
||||
|
||||
@@ -52,3 +53,12 @@ func test_proxy_config_override():
|
||||
ProjectSettings.set_setting(ProxyConfig.SETTING, "http://example.test:9000")
|
||||
assert_eq(ProxyConfig.base_url(), "http://example.test:9000")
|
||||
ProjectSettings.set_setting(ProxyConfig.SETTING, null)
|
||||
|
||||
|
||||
func test_npc_result_fallback_is_degraded_with_no_moves():
|
||||
var r = NpcResult.fallback("The figure says nothing.")
|
||||
assert_true(r.degraded)
|
||||
assert_eq(r.display_text, "The figure says nothing.")
|
||||
assert_eq(r.valid_moves, [])
|
||||
assert_eq(r.facts, [])
|
||||
assert_false(r.ends_conversation)
|
||||
|
||||
Reference in New Issue
Block a user