aboutsummaryrefslogtreecommitdiff
path: root/internal/player
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-13 23:01:45 -0400
committerhistoria <[not public]>2026-07-13 23:01:45 -0400
commit5a6986a8c539364b7a166abdfb608b3cc00ecb3b (patch)
tree0a8a199fa28173df7f97493a209b5642ef7b4817 /internal/player
parent5ea48c1f91298b42924f6865ffc30810cceec2d3 (diff)
downloadthehouseoficarus-5a6986a8c539364b7a166abdfb608b3cc00ecb3b.tar.gz
feat(admin): convert players page into characters page with basic stats/yaml
Diffstat (limited to 'internal/player')
-rw-r--r--internal/player/player.go8
-rw-r--r--internal/player/store.go20
2 files changed, 28 insertions, 0 deletions
diff --git a/internal/player/player.go b/internal/player/player.go
index 5ffea6d..d78ae9d 100644
--- a/internal/player/player.go
+++ b/internal/player/player.go
@@ -376,6 +376,14 @@ func (p *Player) AddSkillXP(s SkillName, amount int) int {
return 0
}
+func (p *Player) TotalLevel() int {
+ total := 0
+ for _, s := range AllSkills {
+ total += p.Level(s)
+ }
+ return total
+}
+
func (p *Player) CombatLevel() int {
base := 0.25 * float64(p.Level(Defense)+p.Level(Hitpoints)+p.Level(Technology))
att := float64(p.Level(Accuracy))
diff --git a/internal/player/store.go b/internal/player/store.go
index 2691d71..9bfdf40 100644
--- a/internal/player/store.go
+++ b/internal/player/store.go
@@ -154,6 +154,26 @@ func (s *AccountStore) FindCharacter(name string) (string, error) {
// data/players/characters/*.yaml file. Used by room-ID migration to walk and
// rewrite offline characters. Online characters are excluded by the caller
// (their in-memory state is updated directly).
+func (s *AccountStore) ListAccountNames() ([]string, error) {
+ dir := filepath.Join(s.dataDir, "players", "accounts")
+ entries, err := os.ReadDir(dir)
+ if err != nil {
+ return nil, err
+ }
+ var names []string
+ for _, e := range entries {
+ if e.IsDir() {
+ continue
+ }
+ name := strings.TrimSuffix(e.Name(), ".yaml")
+ if name == "" {
+ continue
+ }
+ names = append(names, name)
+ }
+ return names, nil
+}
+
func (s *AccountStore) ListCharacterNames() ([]string, error) {
dir := filepath.Join(s.dataDir, "players", "characters")
entries, err := os.ReadDir(dir)