92 lines
3.3 KiB
GDScript
92 lines
3.3 KiB
GDScript
extends "res://addons/gut/test.gd"
|
|
|
|
const NewGame = preload("res://scripts/newgame/new_game.gd")
|
|
const ContentDB = preload("res://scripts/content/content_db.gd")
|
|
|
|
|
|
func _built():
|
|
var world = ContentDB.new()
|
|
world.load_from(ContentDB.default_content_root())
|
|
var origin = ContentDB.load_json(ContentDB.origin_path("deserter"))
|
|
var creation := {
|
|
"name": "Aldric", "race_id": "human", "calling_id": "sellsword",
|
|
"seed": 8675309, "spend": {},
|
|
"skills": ["athletics", "endurance"], "bonus_skill": "perception",
|
|
}
|
|
return NewGame.construct(origin, world, creation)
|
|
|
|
|
|
func test_for_character_derives_vitals_and_location_from_the_real_character():
|
|
var res = _built()
|
|
assert_true(res["ok"], str(res["errors"]))
|
|
var state = res["state"]
|
|
var log = res["log"]
|
|
var s := ShellState.for_character(state, log)
|
|
assert_eq(s.vitals["hp"], state.sheet.hp, "hp from the sheet")
|
|
assert_eq(s.vitals["hp_max"], state.sheet.max_hp(), "hp_max from the sheet")
|
|
assert_eq(s.vitals["mp"], state.sheet.mp, "mp from the sheet")
|
|
assert_eq(s.vitals["mp_max"], state.sheet.max_mp(), "mp_max from the sheet")
|
|
assert_eq(s.vitals["purse_copper"], state.purse_copper, "purse from origin grants (47c)")
|
|
assert_eq(s.location_label, log.location.name, "location from the canon log")
|
|
assert_ne(s.vitals["hp_max"], 60, "NOT the seed's hardcoded 60 — this is a real L1 sheet")
|
|
|
|
|
|
func test_for_character_keeps_the_seed_placeholders_for_combat_and_inventory():
|
|
# turn_order/consumables/round_label have no real source yet (M5/M7 own them);
|
|
# for_character must reuse seed()'s placeholders, not invent its own.
|
|
var res = _built()
|
|
var s := ShellState.for_character(res["state"], res["log"])
|
|
var seed := ShellState.seed()
|
|
assert_eq(s.turn_order.size(), seed.turn_order.size(), "turn rail is still the placeholder")
|
|
assert_eq(s.consumables, seed.consumables, "consumables are still the placeholder")
|
|
assert_eq(s.round_label, seed.round_label, "round label is still the placeholder")
|
|
|
|
|
|
func test_turn_entry_holds_fields():
|
|
var e := TurnEntry.new("DW", 12, &"ally")
|
|
assert_eq(e.initials, "DW")
|
|
assert_eq(e.initiative, 12)
|
|
assert_eq(e.side, &"ally")
|
|
assert_false(e.is_active)
|
|
assert_false(e.is_downed)
|
|
|
|
|
|
func test_seed_vitals():
|
|
var s := ShellState.seed()
|
|
assert_eq(s.vitals["hp"], 42)
|
|
assert_eq(s.vitals["hp_max"], 60)
|
|
assert_eq(s.vitals["mp"], 18)
|
|
assert_eq(s.vitals["mp_max"], 30)
|
|
assert_eq(s.vitals["purse_copper"], 347)
|
|
assert_false("gold" in s.vitals, "the flat gold placeholder is gone")
|
|
|
|
|
|
func test_seed_purse_renders_as_denominations():
|
|
var s := ShellState.seed()
|
|
assert_eq(Currency.format(s.vitals["purse_copper"]), "3s 47c")
|
|
|
|
|
|
func test_seed_turn_order():
|
|
var s := ShellState.seed()
|
|
assert_eq(s.turn_order.size(), 4)
|
|
assert_eq(s.turn_order[0].initials, "EL")
|
|
assert_true(s.turn_order[0].is_active, "first combatant is the active turn")
|
|
assert_true(s.turn_order[3].is_downed, "last combatant is downed")
|
|
|
|
|
|
func test_seed_consumables():
|
|
var s := ShellState.seed()
|
|
assert_eq(s.consumables.size(), 8)
|
|
assert_eq(s.consumables[0]["label"], "Salve")
|
|
assert_eq(s.consumables[0]["hotkey"], 1)
|
|
assert_eq(s.consumables[6]["label"], "", "slot 7 is empty")
|
|
|
|
|
|
func test_toggle_dock_flips():
|
|
var s := ShellState.seed()
|
|
assert_true(s.dock_open, "seed opens with the dock out")
|
|
assert_false(s.toggle_dock())
|
|
assert_false(s.dock_open)
|
|
assert_true(s.toggle_dock())
|
|
assert_true(s.dock_open)
|