From 0d6ad6267ef6b40b04614b7710bac733c8697b5b Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sat, 31 Dec 2022 00:21:29 +0100 Subject: [PATCH] Feats feature --- example.json | 3 +++ main.go | 26 +++++++++++++++++++------- sheetContent.go | 8 ++++++++ zsh.completion | 19 ++++++++++--------- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/example.json b/example.json index c41b9ee..77a6913 100644 --- a/example.json +++ b/example.json @@ -36,5 +36,8 @@ {"skillName":"intimidation", "proficient":false, "expertise":true, "baseStat":"charisma"}, {"skillName":"performance", "proficient":true, "expertise":false, "baseStat":"charisma"}, {"skillName":"persuasion", "proficient":false, "expertise":false, "baseStat":"charisma"} + ], + "feats":[ + {"featName":"Boring", "featDescription":"Due to being excessivly generic, Bob gains... something"} ] } diff --git a/main.go b/main.go index 0a1a6a4..9d06b00 100644 --- a/main.go +++ b/main.go @@ -16,13 +16,13 @@ import ( const exampleFile string = "/etc/sheet-parser/example.json" var ( - path, pathFlag, 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, trivia bool + path, pathFlag, 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, trivia, feats bool ) func parseFlags() { @@ -43,6 +43,8 @@ func parseFlags() { flag.BoolVar(&trivia, "t", false, "Print character name, level and proficiency") flag.BoolVar(&trivia, "trivia", false, "Print character name, level and proficiency") + flag.BoolVar(&feats, "feats", false, "Print character feats") + flag.Parse() } @@ -109,6 +111,9 @@ func main() { } fmt.Printf("Passive perception: %d\n", passivePerception) + case feats: + listFeats() + case stat_list && skill_list: printStatList(verbose) printSkillList(verbose) @@ -353,3 +358,10 @@ func printSkillList(verbose bool) { } } } + +func listFeats() { + color.Magenta("Listing feats...") + for i := 0; i < len(char.Feats); i++ { + fmt.Printf("%25s\t%s\n", char.Feats[i].FeatName, char.Feats[i].FeatDescription) + } +} diff --git a/sheetContent.go b/sheetContent.go index ce767fd..d80b44c 100644 --- a/sheetContent.go +++ b/sheetContent.go @@ -4,6 +4,7 @@ type Character struct { Misc Misc `json:"misc"` Stats []Stat `json:"stats"` Skills []Skill `json:"skills"` + Feats []Feat `json:"feats"` } type Misc struct { @@ -16,14 +17,21 @@ type Misc struct { JackOfAllTrades bool `json:"jackOfAllTrades"` IsKurthog bool `json:"isKurthog"` } + type Skill struct { SkillName string `json:"skillName"` Proficient bool `json:"proficient"` Expertise bool `json:"expertise"` BaseStat string `json:"baseStat"` } + type Stat struct { StatName string `json:"statName"` Score int `json:"score"` Proficient bool `json:"proficient"` } + +type Feat struct { + FeatName string `json:"featName"` + FeatDescription string `json:"featDescription"` +} diff --git a/zsh.completion b/zsh.completion index 4ed791a..1508dc4 100644 --- a/zsh.completion +++ b/zsh.completion @@ -1,18 +1,19 @@ #compdef sheet-parser arguments=( - '(--advantage --disadvantage --skill --save --stat --skill-list --stat-list -v --verbose --trivia -t)--trivia[Print character trivia]' - '(--advantage --disadvantage --skill --save --stat --skill-list --stat-list -v --verbose --trivia -t)-t[Print character trivia]' + '(--advantage --disadvantage --skill --save --stat --skill-list --stat-list -v --verbose --trivia -t)--feats[Print charater feats]' + '(--advantage --disadvantage --skill --save --stat --skill-list --stat-list -v --verbose --trivia -t --feats)--trivia[Print character trivia]' + '(--advantage --disadvantage --skill --save --stat --skill-list --stat-list -v --verbose --trivia -t --feats)-t[Print character trivia]' '(--file)-f=[Path to character sheet]:character sheet:_files -g "*.(json)(-.)"' '(-f)--file=[Path to character sheet]:character sheet:_files -g "*.(json)(-.)"' - '(--trivia -t --advantage --disadvantage --skill-list --stat-list --skill --save --stat --verbose)-v[To be used in conjuction with list parameters]' - '(--trivia -t --advantage --disadvantage --skill-list --stat-list --skill --save --stat -v)--verbose[To be used in conjuction with list parameters]' - '(--skill --stat --save --advantage --disadvantage --skill-list --stat-list)--stat-list[List stats found in file]' - '(--skill --stat --save --advantage --disadvantage --skill-list --stat-list)--skill-list[List skills found in file]' + '(--trivia -t --advantage --disadvantage --skill-list --stat-list --skill --save --stat --verbose --feats)-v[To be used in conjuction with list parameters]' + '(--trivia -t --advantage --disadvantage --skill-list --stat-list --skill --save --stat -v --feats)--verbose[To be used in conjuction with list parameters]' + '(--skill --stat --save --advantage --disadvantage --skill-list --stat-list --feats)--stat-list[List stats found in file]' + '(--skill --stat --save --advantage --disadvantage --skill-list --stat-list --feats)--skill-list[List skills found in file]' '(--advantage --disadvantage)--advantage[Roll with advantage]' '(--advantage --disadvantage)--disadvantage[Roll with disadvantage]' - '(--skill --save --stat --skill-list --stat-list -v --verbose)--stat[Roll a stat check]:stat to roll:(strength dexterity constitution intelligence wisdom charisma)' - '(--skill --save --stat --skill-list --stat-list -v --verbose)--save[Roll a saving throw]:stat to roll:(strength dexterity constitution intelligence wisdom charisma)' - '(--skill --save --stat --skill-list --stat-list -v --verbose)--skill[Roll a skill check]:stat to roll:(athletics acrobatics sleight_of_hand stealth arcana history investigation nature religion animal_handling insight medicine perception survival deception intimidation performance persuasion)' + '(--skill --save --stat --skill-list --stat-list -v --verbose --feats)--stat[Roll a stat check]:stat to roll:(strength dexterity constitution intelligence wisdom charisma)' + '(--skill --save --stat --skill-list --stat-list -v --verbose --feats)--save[Roll a saving throw]:stat to roll:(strength dexterity constitution intelligence wisdom charisma)' + '(--skill --save --stat --skill-list --stat-list -v --verbose --feats)--skill[Roll a skill check]:stat to roll:(athletics acrobatics sleight_of_hand stealth arcana history investigation nature religion animal_handling insight medicine perception survival deception intimidation performance persuasion)' ) _arguments : $arguments