From b650634d47899bdf50f7d87bb16e78bf9c4bd95a Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sun, 21 Aug 2022 23:07:43 +0200 Subject: [PATCH] Functionality to print verbose lists --- main.go | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 47ec36f..dd027af 100644 --- a/main.go +++ b/main.go @@ -12,13 +12,13 @@ import ( ) var ( - path, skillString, saveString, statString string - modifier, diceThrows, surfaces int - X, Y int - char Character - skillMap = make(map[string]int) - statMap = make(map[string]int) - advantage, disadvantage, stat_list, skill_list bool + path, skillString, saveString, statString string + modifier, diceThrows, surfaces int + X, Y int + char Character + skillMap = make(map[string]int) + statMap = make(map[string]int) + 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)