Skip to content

Commit

Permalink
types/skills: update skills to accomodate themes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmillerv committed Apr 13, 2021
1 parent 21aef18 commit 009ec60
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions src/types/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,42 @@ import (

//Skills contains a string array of all possible skills
type Skills struct {
Names []string `json:"skills"`
Fantasy []string `json:"fantasy"`
Future []string `json:"future"`
Heroics []string `json:"heroics"`
Horror []string `json:"horror"`
Magic []string `json:"magic"`
Standard []string `json:"standard"`
Superpowers []string `json:"superpowers"`
}

//GetSkills returns a random selection of three skills in the form of a CharacterSkills struct
func (s *Skills) GetSkills() CharacterSkills {
var skills CharacterSkills
rand.Seed(time.Now().Unix())
key := rand.Intn(len(s.Names))
skills.First = s.Names[key]
key2 := rand.Intn(len(s.Names))
skills.Second = s.Names[key2]
key3 := rand.Intn(len(s.Names))
skills.Third = s.Names[key3]
key := rand.Intn(len(s.Standard))
skills.First = s.Standard[key]
key2 := rand.Intn(len(s.Standard))
skills.Second = s.Standard[key2]
key3 := rand.Intn(len(s.Standard))
skills.Third = s.Standard[key3]
return skills
}

//LoadSkills returns embedded json of skills into a struct
func LoadSkills(b []byte) Skills {
s := new(Skills)
s := struct {
Skills `json:"skills"`
}{}
_ = json.Unmarshal(b, &s)
return *s
skills := &Skills{
Fantasy: s.Fantasy,
Future: s.Future,
Heroics: s.Heroics,
Horror: s.Horror,
Magic: s.Magic,
Standard: s.Standard,
Superpowers: s.Superpowers,
}
return *skills
}

0 comments on commit 009ec60

Please sign in to comment.