feat: add XP levels and progression points
This commit is contained in:
@@ -61,3 +61,20 @@ func test_player_kill_with_companion_uses_one_neutral_xp_allocation_and_one_jour
|
||||
assert_eq(state.companion.actor.xp, 4)
|
||||
assert_eq(xp_descriptors.size(), 1)
|
||||
assert_eq(xp_descriptors[0].payload, {"xp": 5, "companion_xp": 4})
|
||||
|
||||
func test_shared_xp_reports_a_level_gain_when_the_player_share_crosses_a_threshold() -> void:
|
||||
var map := GridMapState.new(Vector2i(4, 3), GridMapState.CellKind.FLOOR)
|
||||
var player := _actor(&"player", Vector2i(1, 1), 12)
|
||||
player.xp = 99
|
||||
player.progression.set_total_xp(99)
|
||||
player.weapon_damage = 12
|
||||
var enemy := _actor(&"goblin", Vector2i(2, 1), 1)
|
||||
enemy.xp_reward = 1
|
||||
var state := GameState.new(map, player, {enemy.id: enemy})
|
||||
state.companion = CompanionState.from_choice(&"moth", Vector2i(0, 1))
|
||||
|
||||
var results := state.try_player_action(Vector2i.RIGHT)
|
||||
var xp_descriptors: Array = results[0].payload.domain_events.filter(func(event: Dictionary) -> bool: return event.kind == &"xp_granted")
|
||||
|
||||
assert_eq(player.progression.level, 2)
|
||||
assert_eq(xp_descriptors[0].payload, {"xp": 1, "companion_xp": 0, "levels_gained": 1})
|
||||
|
||||
Reference in New Issue
Block a user