package client import ( "io/fs" "path/filepath" "github.com/chompy/roguelike_rpg/internal/util" ) type Role struct { Name string `yaml:"name"` Stats map[string][]int `yaml:"stats"` Actions []string `yaml:"actions"` } type RoleList []Role func (l RoleList) Get(name string) Role { for _, role := range l { if role.Name == name { return role } } return Role{} } func LoadRoles(assetFS fs.FS) (RoleList, error) { roles := make(RoleList, 0) return roles, util.ReadYAML(assetFS, filepath.Join("combat", "roles.yaml"), &roles) } func (r *Role) GetStatsForLevel(level int) map[string]int { stats := make(map[string]int) for statName, statValues := range r.Stats { stats[statName] = 0 if len(statValues) > 0 { index := max(0, min(len(statValues)-1, level-1)) stats[statName] = statValues[index] } } return stats }