4765bbce28
ci / verify (push) Successful in 47s
Identity is shaped like Steamworks so swapping to it is one subclass and no schema change: the client presents an opaque ticket, the server validates it into a stable 64-bit account id, and nothing downstream sees anything else. LocalAuthProvider takes any ticket at face value -- insecure on purpose, and labelled as such everywhere, because the point is the shape rather than the security. Do not ship it. Characters persist as JSON keyed by account. Account ids are written as decimal strings because they are 64-bit and JSON numbers are doubles, which would silently round them. A corrupt store aborts the server rather than starting empty: starting empty looks like it worked and then saves over every character on the first level-up. Levels 1-15, +10 max health each, level DERIVED from lifetime experience rather than stored beside it, so a hand-edited save cannot produce a level 12 character with a level 3's experience. Experience is shared undivided across everyone alive in the instance -- splitting it would make bringing a friend cost you progress. A level-up heals by what it added, so gaining one mid-fight is relief rather than a bar that moved further from full. Death is permanent and unbinds the character entirely: no "return to the hub as the character who just died", because the run is over. The record is retired, never deleted. The five-character cap counts LIVING characters only -- counting the dead would lock a player out of their own account after five deaths. Verified by tools/diag_progression.tscn, which drives the real server through kill -> xp -> level -> health and death -> retire -> roster. The bot smoke test cannot cover that: bots are poor shots and rarely kill anything. Writing it caught two real ordering bugs -- the death event was dispatched before the payload that tells the player they died, and the dead character stayed bound to the peer. Also added --account and --store so several clients and test runs can coexist on one machine. The smoke test now uses a scratch store; without it a rerun resumed the previous run's characters and "a character was created" quietly stopped being true. 193 tests. check.sh, test.sh, smoke.sh, diag_progression and diag_prediction all pass.
79 lines
3.4 KiB
GDScript
79 lines
3.4 KiB
GDScript
extends GutTest
|
|
## The XP curve and what a level is worth. Pure arithmetic, so the shape of
|
|
## progression can be argued about without running a server.
|
|
|
|
|
|
func test_level_one_is_the_base_health() -> void:
|
|
assert_eq(Progression.max_hp_for_level(1), SimConfig.PLAYER_MAX_HP)
|
|
|
|
|
|
func test_each_level_adds_ten_health() -> void:
|
|
for level in range(1, Progression.MAX_LEVEL):
|
|
assert_eq(Progression.max_hp_for_level(level + 1)
|
|
- Progression.max_hp_for_level(level), Progression.HP_PER_LEVEL)
|
|
|
|
|
|
func test_the_cap_is_reachable_and_final() -> void:
|
|
assert_eq(Progression.max_hp_for_level(Progression.MAX_LEVEL),
|
|
SimConfig.PLAYER_MAX_HP + (Progression.MAX_LEVEL - 1) * Progression.HP_PER_LEVEL)
|
|
# Past the cap nothing further is gained, however much xp arrives.
|
|
assert_eq(Progression.max_hp_for_level(999),
|
|
Progression.max_hp_for_level(Progression.MAX_LEVEL))
|
|
assert_eq(Progression.xp_to_next(Progression.MAX_LEVEL), 0)
|
|
|
|
|
|
func test_level_is_derived_consistently_from_experience() -> void:
|
|
# The two directions must agree exactly, or a character's level could
|
|
# disagree with the experience that earned it.
|
|
for level in range(1, Progression.MAX_LEVEL + 1):
|
|
var at := Progression.total_xp_for_level(level)
|
|
assert_eq(Progression.level_for_xp(at), level,
|
|
"exactly enough xp for level %d should be level %d" % [level, level])
|
|
# Skipped at level 1: there is no level 0 to fall short into, and
|
|
# negative lifetime xp is not a state a character can be in.
|
|
if level > Progression.START_LEVEL:
|
|
assert_eq(Progression.level_for_xp(at - 1), level - 1,
|
|
"one short of level %d should still be level %d" % [level, level - 1])
|
|
|
|
|
|
func test_experience_never_exceeds_the_cap() -> void:
|
|
assert_eq(Progression.level_for_xp(99999999), Progression.MAX_LEVEL)
|
|
assert_eq(Progression.level_progress(99999999), 1.0,
|
|
"a capped character's bar should read full, not empty")
|
|
|
|
|
|
func test_progress_runs_from_zero_to_one_within_a_level() -> void:
|
|
var at := Progression.total_xp_for_level(3)
|
|
assert_almost_eq(Progression.level_progress(at), 0.0, 0.001)
|
|
assert_almost_eq(Progression.level_progress(at + Progression.xp_to_next(3) / 2), 0.5, 0.05)
|
|
|
|
|
|
func test_the_requirement_grows_with_level() -> void:
|
|
for level in range(1, Progression.MAX_LEVEL - 1):
|
|
assert_gt(Progression.xp_to_next(level + 1), Progression.xp_to_next(level),
|
|
"later levels must cost more, or the curve is flat at the end")
|
|
|
|
|
|
## The brief's one concrete pacing requirement: a first full clear should be a
|
|
## bit more than the first level-up needs.
|
|
func test_a_first_full_dungeon_clear_slightly_exceeds_the_first_level() -> void:
|
|
# A depth-1 dungeon holds roughly a dozen enemies plus the boss.
|
|
var trash := 12 * Progression.xp_for_enemy(Content.ENEMY_DRIFTER)
|
|
var clear := trash + Progression.xp_for_boss(Content.BOSS_WARDEN)
|
|
var needed := Progression.xp_to_next(1)
|
|
assert_gt(clear, needed, "a full clear should get you the first level")
|
|
assert_lt(clear, needed * 2,
|
|
"but not two levels, or the first run outpaces the curve")
|
|
|
|
|
|
func test_unknown_enemies_award_nothing_rather_than_a_default() -> void:
|
|
assert_eq(Progression.xp_for_enemy(&"no_such_enemy"), 0)
|
|
assert_eq(Progression.xp_for_enemy(Content.ENEMY_DUMMY), 0,
|
|
"the practice target must not be an xp farm")
|
|
|
|
|
|
func test_experience_below_the_first_level_is_still_level_one() -> void:
|
|
assert_eq(Progression.level_for_xp(0), Progression.START_LEVEL)
|
|
assert_eq(Progression.level_for_xp(-500), Progression.START_LEVEL,
|
|
"a nonsensical total must clamp rather than produce a level 0 character")
|