Implement XP-per-skill tracking with persistence via player.info and event sourcing integration #229
Labels
No labels
Blocked
Duplicate
MoSCoW/Could Have
MoSCoW/Must Have
MoSCoW/Should Have
Points/1
Points/13
Points/2
Points/21
Points/3
Points/5
Points/8
Priority/Backlog
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
State/Completed
State/In progress
State/In review
State/Paused
State/Unverified
State/Verified
State/Wont Do
Type/Bug
Type/Epic
Type/Feature
Type/Legendary
Type/Task
Type/Testing
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
#223 Epic: Skill Tree Data Model & Storage
aethyr/Aethyr
Reference: aethyr/Aethyr#229
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Metadata
feature/m4-skill-xp-tracking-persistencefeat(skills): implement XP-per-skill tracking with persistence and event sourcingBackground and Context
Skill progression requires tracking XP earned toward each individual skill. When a player performs actions relevant to a skill (e.g., attacking for Combat, foraging for Survival), they earn XP in that specific skill. Once enough XP is accumulated, the skill levels up.
XP data is persisted in
player.info["skills"], a hash keyed by skill name. Each entry stores the current level and accumulated XP. Changes to skill XP must be published as Wisper events (:skill_xp_gained) to allow other systems (UI updates, achievements, logging) to react. If event sourcing is enabled in the game configuration,UpdatePlayerSkillXPevents are emitted to the event store.This issue connects the skill data model to the player persistence layer and the event system, completing the data model epic.
Expected Behavior
Player Skill Data Structure in
player.info["skills"]:SkillXPManager class at
lib/aethyr/core/skills/skill_xp_manager.rb:award_xp(player, skill_name, amount)— adds XP to the specified skill. If XP exceeds threshold, levels up. Returns a result hash:{leveled_up: bool, new_level: N, xp_remaining: N}.get_skill(player, skill_name)— returns{level:, xp:}ornil.get_all_skills(player)— returns the entire skills hash.level_up_threshold(skill_name, current_level)— returns XP needed for next level. Default:10000 * (current_level + 1)(scaling formula).reset_skill(player, skill_name)— resets a skill to level 0, xp 0 (for respec).Wisper Event Integration:
:skill_xp_gainedwith payload:{player_id:, skill_name:, amount:, new_xp:, new_level:, leveled_up:}.:skill_level_upwith payload:{player_id:, skill_name:, new_level:, old_level:}.Event Sourcing Integration:
ServerConfig[:event_sourcing]is enabled, emitUpdatePlayerSkillXPevents with full state delta.Persistence:
player.info["skills"]are saved via the existing player save mechanism.player.info["skills"]is restored from storage.Acceptance Criteria
SkillXPManagerclass exists atlib/aethyr/core/skills/skill_xp_manager.rb.award_xpcorrectly accumulates XP and triggers level-ups when threshold is exceeded.award_xphandles overflow (excess XP carries to next level).10000 * (current_level + 1).:skill_xp_gainedWisper event is published on every XP award.:skill_level_upWisper event is published on level-up.UpdatePlayerSkillXPevent sourcing events emitted when event sourcing is enabled.player.info["skills"]persists across player save/load cycles.get_skillandget_all_skillsreturn correct data.reset_skillproperly clears skill data.Subtasks
lib/aethyr/core/skills/skill_xp_manager.rbwith theSkillXPManagerclass.award_xp(player, skill_name, amount)with XP accumulation and level-up logic.get_skill(player, skill_name)andget_all_skills(player).reset_skill(player, skill_name).:skill_xp_gainedand:skill_level_up.UpdatePlayerSkillXPevents when enabled.player.info["skills"]is included in existing player save/load mechanisms.tests/unit/skill_xp_manager.featurecovering XP award, level-up trigger, XP overflow, threshold calculation, Wisper event publishing, event sourcing integration, persistence round-trip, reset skill.tests/integration/for XP tracking with persistence and event publishing end-to-end.bundle exec rake unit_profileand verify no performance regressions.bundle exec rake unit. If coverage is <97% then review the current unit test coverage report atbuild/tests/unit/coverage/and use it to write new Cucumber based unit tests to improve code coverage. Specifically, write Cucumber/Gherkin style unit tests that are descriptively named and specifically improve coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerunbundle exec rake unitto verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.bundle exec rake(default task: unit tests with coverage) andbundle exec rake integration, fix any errors if needed ensuring both pass across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.Definition of Done
This issue is complete when:
master, reviewed, and merged before this issue is marked done.