Functionality to print verbose lists

This commit is contained in:
Nox Sluijtman 2022-08-21 23:07:43 +02:00
parent e09604a832
commit b650634d47

41
main.go
View file

@ -18,7 +18,7 @@ var (
char Character
skillMap = make(map[string]int)
statMap = make(map[string]int)
advantage, disadvantage, stat_list, skill_list bool
advantage, disadvantage, stat_list, skill_list, verbose bool
)
func parseFlags() {
@ -33,6 +33,8 @@ func parseFlags() {
flag.BoolVar(&stat_list, "stat-list", false, "Print list of stats, can also be used with -save flag")
flag.BoolVar(&skill_list, "skill-list", false, "Print list of skills to be used in combination with the -skill flag")
flag.BoolVar(&verbose, "verbose", false, "Print stat numbers, to be used in combination with -stat-list or -skill-list")
flag.BoolVar(&verbose, "v", false, "Print stat numbers, to be used in combination with -stat-list or -skill-list")
flag.Parse()
}
@ -72,6 +74,42 @@ func main() {
initMaps()
switch {
case stat_list && verbose:
var proficiency string
for i := 0; i < len(char.Stats); i++ {
name := char.Stats[i].StatName
isProficient := char.Stats[i].Proficient
if isProficient {
proficiency = "Proficient"
} else {
proficiency = "Not proficient"
}
score := char.Stats[i].Score
fmt.Printf("Stat: %s\t%s\tStat score: %d\tStat modifier: %d\n", name, proficiency, score, getModifier(char.Stats[i]))
}
case skill_list && verbose:
var proficiency string
var expertise string
for i := 0; i < len(char.Skills); i++ {
name := char.Skills[i].SkillName
localModifier := getModifier(getStat(char.Skills[i].BaseStat))
if char.Skills[i].Proficient {
proficiency = "Proficient"
localModifier += getProficiency()
} else {
proficiency = "Not proficient"
}
if char.Skills[i].Expertise {
expertise = "Has expertise"
localModifier += getProficiency()
} else {
expertise = "Doesn't have expertise"
}
fmt.Printf("Skill: %s\t%s\t%s\tSkill modifier: %d\n", name, proficiency, expertise, localModifier)
}
case stat_list:
for i := 0; i < len(char.Stats); i++ {
fmt.Println(char.Stats[i].StatName)
@ -80,6 +118,7 @@ func main() {
for i := 0; i < len(char.Skills); i++ {
fmt.Println(char.Skills[i].SkillName)
}
case advantage && disadvantage:
fmt.Println("You can't roll with both advantage and disadvantage")
os.Exit(1)