NEO-142: satisfy pre-push gdlint for faction HUD wiring
Wrap faction standing HUD deps in a setup dictionary to stay under the function-argument limit, shorten the faction client doc comment for max line length, and add a GdUnit test for setup wiring.pull/182/head
parent
3308fa564f
commit
4022a1c220
|
|
@ -1,6 +1,7 @@
|
|||
extends Node
|
||||
|
||||
## NEO-142: prototype HTTP client for [code]GET /game/players/{id}/faction-standing[/code] (NEO-139).
|
||||
## NEO-142: prototype HTTP client for faction-standing GET (NEO-139).
|
||||
## Route: [code]GET /game/players/{id}/faction-standing[/code].
|
||||
|
||||
signal faction_standing_received(snapshot: Dictionary)
|
||||
signal faction_standing_sync_failed(reason: String)
|
||||
|
|
|
|||
|
|
@ -870,8 +870,7 @@ func _setup_quest_progress_sync() -> void:
|
|||
_item_defs_client,
|
||||
_inventory_client,
|
||||
_skill_progression_client,
|
||||
_faction_standing_client,
|
||||
_faction_standing_label
|
||||
{"client": _faction_standing_client, "label": _faction_standing_label}
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,16 +48,15 @@ func setup(
|
|||
item_defs_client: Node = null,
|
||||
inventory_client: Node = null,
|
||||
skill_progression_client: Node = null,
|
||||
faction_standing_client: Node = null,
|
||||
faction_standing_label: Label = null
|
||||
faction_standing_hud: Dictionary = {}
|
||||
) -> void:
|
||||
_progress_client = progress_client
|
||||
_defs_client = defs_client
|
||||
_item_defs_client = item_defs_client
|
||||
_inventory_client = inventory_client
|
||||
_skill_progression_client = skill_progression_client
|
||||
_faction_standing_client = faction_standing_client
|
||||
_faction_standing_label = faction_standing_label
|
||||
_faction_standing_client = faction_standing_hud.get("client")
|
||||
_faction_standing_label = faction_standing_hud.get("label")
|
||||
_progress_label = progress_label
|
||||
_accept_label = accept_label
|
||||
_reward_label = reward_label
|
||||
|
|
@ -283,21 +282,15 @@ func _render_faction_standing_label() -> void:
|
|||
func _format_faction_gate_blocked_deny(quest_id: String) -> String:
|
||||
var rules: Array = _faction_gate_rules_for(quest_id)
|
||||
if rules.is_empty():
|
||||
return (
|
||||
"Quest accept: denied — faction standing too low (%s)" % FACTION_GATE_BLOCKED_REASON
|
||||
)
|
||||
return "Quest accept: denied — faction standing too low (%s)" % FACTION_GATE_BLOCKED_REASON
|
||||
var first_rule: Variant = rules[0]
|
||||
if not first_rule is Dictionary:
|
||||
return (
|
||||
"Quest accept: denied — faction standing too low (%s)" % FACTION_GATE_BLOCKED_REASON
|
||||
)
|
||||
return "Quest accept: denied — faction standing too low (%s)" % FACTION_GATE_BLOCKED_REASON
|
||||
var rule: Dictionary = first_rule
|
||||
var faction_id := str(rule.get("factionId", "")).strip_edges()
|
||||
var min_standing: int = int(rule.get("minStanding", 0))
|
||||
if faction_id.is_empty():
|
||||
return (
|
||||
"Quest accept: denied — faction standing too low (%s)" % FACTION_GATE_BLOCKED_REASON
|
||||
)
|
||||
return "Quest accept: denied — faction standing too low (%s)" % FACTION_GATE_BLOCKED_REASON
|
||||
var faction_label := _faction_display_name(faction_id)
|
||||
var current_standing: int = FactionStandingClient.standing_for(
|
||||
faction_id, _last_faction_snapshot
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ func test_faction_gate_blocked_deny_uses_readable_gate_copy() -> void:
|
|||
controller.set("_defs_client", defs_client)
|
||||
controller.set("_accept_label", accept_label)
|
||||
controller.call(
|
||||
"_on_faction_standing_received", {"schemaVersion": 1, "playerId": "dev-local-1", "factions": []}
|
||||
"_on_faction_standing_received",
|
||||
{"schemaVersion": 1, "playerId": "dev-local-1", "factions": []}
|
||||
)
|
||||
# Act
|
||||
var deny_text: String = str(
|
||||
|
|
@ -156,7 +157,8 @@ func test_accept_result_received_paints_readable_faction_gate_blocked() -> void:
|
|||
controller.set("_accept_label", accept_label)
|
||||
controller.set("_progress_client", progress_client)
|
||||
controller.call(
|
||||
"_on_faction_standing_received", {"schemaVersion": 1, "playerId": "dev-local-1", "factions": []}
|
||||
"_on_faction_standing_received",
|
||||
{"schemaVersion": 1, "playerId": "dev-local-1", "factions": []}
|
||||
)
|
||||
# Act
|
||||
controller.call(
|
||||
|
|
@ -216,3 +218,43 @@ func test_completion_transition_requests_faction_standing_refresh() -> void:
|
|||
controller.call("_on_progress_received", completed_snapshot)
|
||||
# Assert
|
||||
assert_int(faction_client.sync_count).is_equal(1)
|
||||
|
||||
|
||||
func test_setup_wires_faction_standing_hud_dictionary() -> void:
|
||||
# Arrange
|
||||
var controller: Node = QuestHudController.new()
|
||||
var progress_label := Label.new()
|
||||
var accept_label := Label.new()
|
||||
var standing_label := Label.new()
|
||||
var progress := Node.new()
|
||||
var defs := Node.new()
|
||||
var faction_client := MockFactionSyncClient.new()
|
||||
auto_free(controller)
|
||||
auto_free(progress_label)
|
||||
auto_free(accept_label)
|
||||
auto_free(standing_label)
|
||||
auto_free(progress)
|
||||
auto_free(defs)
|
||||
auto_free(faction_client)
|
||||
add_child(controller)
|
||||
# Act
|
||||
controller.call(
|
||||
"setup",
|
||||
progress,
|
||||
defs,
|
||||
progress_label,
|
||||
accept_label,
|
||||
Callable(self, "_noop_http_config"),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
{"client": faction_client, "label": standing_label}
|
||||
)
|
||||
# Assert
|
||||
assert_object(controller.get("_faction_standing_client")).is_same(faction_client)
|
||||
assert_object(controller.get("_faction_standing_label")).is_same(standing_label)
|
||||
|
||||
|
||||
func _noop_http_config(_client: Node) -> void:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Reference in New Issue