56 lines
1.8 KiB
GDScript
56 lines
1.8 KiB
GDScript
# client/tests/unit/test_move_applier.gd
|
|
extends "res://addons/gut/test.gd"
|
|
|
|
const MoveApplier = preload("res://scripts/npc/move_applier.gd")
|
|
const ContentDB = preload("res://scripts/content/content_db.gd")
|
|
|
|
|
|
func _m(name, args := []) -> Dictionary:
|
|
return {"name": name, "args": args}
|
|
|
|
|
|
func _content() -> ContentDB:
|
|
var c = ContentDB.new()
|
|
c.quests = {"find_the_ledger": {"id": "find_the_ledger",
|
|
"name": "The Missing Ledger", "objective": "Find who took it"}}
|
|
return c
|
|
|
|
|
|
func test_offer_quest_adds_active_quest():
|
|
var log = CanonLog.new()
|
|
MoveApplier.apply([_m("offer_quest", ["find_the_ledger"])],
|
|
GameState.new(), log, _content(), "fenn")
|
|
assert_true(log.has_quest("find_the_ledger"))
|
|
assert_eq(log.active_quests[0].name, "The Missing Ledger")
|
|
|
|
|
|
func test_reveal_marks_topic():
|
|
var gs = GameState.new()
|
|
MoveApplier.apply([_m("reveal", ["varrell_twins"])], gs, CanonLog.new(), _content(), "fenn")
|
|
assert_true(gs.is_revealed("varrell_twins"))
|
|
|
|
|
|
func test_adjust_disposition_clamps_to_max_delta():
|
|
var gs = GameState.new()
|
|
MoveApplier.apply([_m("adjust_disposition", ["+50"])], gs, CanonLog.new(), _content(), "fenn")
|
|
assert_eq(gs.npc_dispositions.get("fenn", 0), MoveApplier.MAX_DELTA)
|
|
|
|
|
|
func test_become_hostile_sets_floor():
|
|
var gs = GameState.new()
|
|
MoveApplier.apply([_m("become_hostile")], gs, CanonLog.new(), _content(), "fenn")
|
|
assert_eq(gs.npc_dispositions.get("fenn", 0), MoveApplier.HOSTILE_FLOOR)
|
|
|
|
|
|
func test_accept_item_removes_from_inventory():
|
|
var gs = GameState.new()
|
|
gs.add_item("coin", 2)
|
|
MoveApplier.apply([_m("accept_item", ["coin"])], gs, CanonLog.new(), _content(), "fenn")
|
|
assert_eq(gs.inventory.get("coin", 0), 1)
|
|
|
|
|
|
func test_refuse_and_end_are_noops():
|
|
var gs = GameState.new()
|
|
MoveApplier.apply([_m("refuse"), _m("end_conversation")], gs, CanonLog.new(), _content(), "fenn")
|
|
assert_eq(gs.npc_dispositions.size(), 0)
|