diff --git a/example.json b/example.json index 77a6913..47bd49d 100644 --- a/example.json +++ b/example.json @@ -10,12 +10,12 @@ "isKurthog": false }, "stats":[ - {"statName":"strength", "score":20, "proficient":false }, - {"statName":"dexterity", "score":1, "proficient":false }, - {"statName":"constitution", "score":15, "proficient":false }, - {"statName":"intelligence", "score":10, "proficient":false }, - {"statName":"wisdom", "score":10, "proficient":false }, - {"statName":"charisma", "score":10, "proficient":false } + {"statName":"strength", "score":20, "proficient":false, "saveProficient":false }, + {"statName":"dexterity", "score":1, "proficient":false, "saveProficient":false }, + {"statName":"constitution", "score":15, "proficient":false, "saveProficient":false }, + {"statName":"intelligence", "score":10, "proficient":false, "saveProficient":false }, + {"statName":"wisdom", "score":10, "proficient":false, "saveProficient":false }, + {"statName":"charisma", "score":10, "proficient":false, "saveProficient":false } ], "skills":[ {"skillName":"athletics", "proficient":true, "expertise":false, "baseStat":"strength"}, diff --git a/main.go b/main.go index 9d06b00..4d4938f 100644 --- a/main.go +++ b/main.go @@ -99,17 +99,8 @@ 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) - // passive perception - var passivePerception int - switch { - case GetSkill("perception").Proficient && GetSkill("perception").Expertise: - passivePerception = 10 + GetModifier(GetStat("wisdom")) + GetProficiency()*2 - case GetSkill("perception").Proficient: - passivePerception = 10 + GetModifier(GetStat("wisdom")) + GetProficiency() - default: - passivePerception = 10 + GetModifier(GetStat("wisdom")) - } - fmt.Printf("Passive perception: %d\n", passivePerception) + fmt.Printf("Passive perception: %d\n", passiveSkillCheck(GetSkill("perception"))) + fmt.Printf("Passive investigation: %d\n", passiveSkillCheck(GetSkill("investigation"))) case feats: listFeats() @@ -275,19 +266,40 @@ func skillErrorCheck() error { func statCheck(stat Stat) (int, int, error) { die := rollDice() return die + GetModifier(stat), die, statErrorCheck() - } func savingThrow(stat Stat) (int, int, error) { die := rollDice() plainDie := die - if stat.Proficient { + if stat.SaveProficient { die += GetProficiency() } return die + GetModifier(stat), plainDie, statErrorCheck() } +func passiveSkillCheck(skill Skill) int { + die := 10 + + die += GetModifier(GetStat(skill.BaseStat)) + + switch { + case skill.Expertise: + die += GetProficiency() * 2 + case skill.Proficient: + die += GetProficiency() + case !skill.Proficient && char.Misc.JackOfAllTrades: + die += (GetProficiency() / 2) + } + switch { + case advantage: + die += 5 + case disadvantage: + die -= 5 + } + return die +} + func skillCheck(skill Skill) (int, int, error) { die := rollDice() if char.Misc.ReliableTalent && skill.Proficient && die < 10 { diff --git a/sheetContent.go b/sheetContent.go index d80b44c..afc6a43 100644 --- a/sheetContent.go +++ b/sheetContent.go @@ -26,9 +26,10 @@ type Skill struct { } type Stat struct { - StatName string `json:"statName"` - Score int `json:"score"` - Proficient bool `json:"proficient"` + StatName string `json:"statName"` + Score int `json:"score"` + Proficient bool `json:"proficient"` + SaveProficient bool `json:"saveProficient"` } type Feat struct {