-
Notifications
You must be signed in to change notification settings - Fork 38
DRAFT: Use accessors for mob/player stats #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR centralizes stat field access by introducing accessor methods and updating all references to use these generic getters.
- Added
GetStatInfoNames
andGet(name)
for dynamic stat handling - Refactored the status command and templates to use the new accessors
- Replaced direct
Stats.X
references withStats.Get("X")
across character logic
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/usercommands/status.go | Use GetStatInfoNames for prompts and replace the manual switch with Stats.Get |
internal/templates/templatesfunctions.go | Added template helper funcs (charStat* ) for stat fields |
internal/stats/stats.go | Introduced GetStatInfoNames and Get ; added strings import |
internal/characters/character.go | Swapped all Stats.X field accesses for Stats.Get("X") calls |
_datafiles/world/default/templates/character/status.template | Updated template to use charStatValue instead of direct .Stats.X access |
Comments suppressed due to low confidence (7)
_datafiles/world/default/templates/character/status.template:9
- [nitpick] The stat literals use mixed casing ("Vitality" vs lowercase "vitality"); consider normalizing to a consistent case for clarity.
│ <ansi fg="yellow">Area: </ansi>{{ printf "%-22s" .Character.Zone }}│ │ <ansi fg="yellow">Strength: </ansi>{{ printf "<ansi fg=\"stat\">%-4d</ansi><ansi fg=\"statmod\">(%-3d)</ansi>" (charStatValue .Character "strength") (.Character.StatMod "strength") }} <ansi fg="yellow">Vitality: </ansi>{{ printf "<ansi fg=\"stat\">%-4d</ansi><ansi fg=\"statmod\">(%-3d)</ansi>" (charStatValue .Character "Vitality") (.Character.StatMod "vitality") }} │
internal/stats/stats.go:24
- Add unit tests for
GetStatInfoNames
andGet
to verify correct ordering, casing, and behavior on invalid inputs.
func (s *Statistics) GetStatInfoNames() []string {
internal/stats/stats.go:4
- The import "math" is unused in this file and will cause a compilation error; consider removing it.
"math"
internal/usercommands/status.go:64
- The variable 'selection' is undefined; you likely meant to use the 'match' value returned from FindMatchIn.
before = user.Character.Stats.Get(selection).Value - user.Character.Stats.Get(selection).Mods
internal/usercommands/status.go:64
- This code always increments Training and spends a point regardless of whether the selection was valid; add validation to ensure 'match' is non-empty and the stat can actually be trained.
before = user.Character.Stats.Get(selection).Value - user.Character.Stats.Get(selection).Mods
internal/usercommands/status.go:65
- [nitpick] To avoid repeated lookups on the same stat, cache the result of
Stats.Get(match)
in a local variable before updating it.
user.Character.Stats.Get(selection).Training += 1
internal/characters/character.go:1393
- [nitpick] Consider removing these commented-out assignments to eliminate dead code and improve readability.
// c.Stats.Get("Strength").Base = raceInfo.Stats.Get("Strength").Base
What's the state of this draft PR currently? Does it need testing or anything? |
I’m still planning on continuing it but like others life has been getting in the way. |
NP, just wanted to make sure you weren't waiting on me. |
Description
#210
This PR centralizes stat field access by introducing accessor methods and replacing direct struct field references.
Changes