diff --git a/main.go b/main.go index 8557eba..9683385 100644 --- a/main.go +++ b/main.go @@ -83,49 +83,13 @@ func main() { fmt.Printf("Name: %s\tLevel: %d\tProficiency: %d\n", char.Misc.Name, char.Misc.Level, getProficiency()) fmt.Printf("Race: %s\tClass: %s\tBackground: %s\n", char.Misc.Race, char.Misc.Class, char.Misc.Background) - 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\tSkill modifier: %d\t%s\t%s\n", name, localModifier, proficiency, expertise) - } - + case stat_list && skill_list: + printStatList(verbose) + printSkillList(verbose) case stat_list: - for i := 0; i < len(char.Stats); i++ { - fmt.Println(char.Stats[i].StatName) - } + printStatList(verbose) case skill_list: - for i := 0; i < len(char.Skills); i++ { - fmt.Println(char.Skills[i].SkillName) - } + printSkillList(verbose) case advantage && disadvantage: fmt.Println("You can't roll with both advantage and disadvantage") @@ -244,3 +208,53 @@ func skillCheck(skill Skill) int { } return die } +func printStatList(verbose bool) { + color.Magenta("Listing stats...") + if 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])) + } + } else { + for i := 0; i < len(char.Stats); i++ { + fmt.Println(char.Stats[i].StatName) + } + } +} + +func printSkillList(verbose bool) { + color.Magenta("Listing skills...") + var proficiency string + var expertise string + if verbose { + 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\tSkill modifier: %d\t%s\t%s\n", name, localModifier, proficiency, expertise) + } + } else { + for i := 0; i < len(char.Skills); i++ { + fmt.Println(char.Skills[i].SkillName) + } + } +}