From 811dbf85811803f9746aa9b438f168cdb94509df Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sat, 20 Aug 2022 16:44:47 +0200 Subject: [PATCH] Got rid of explicit modifier --- main.go | 14 +++++++------- sheetContent.go | 1 - stats.json | 12 ++++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/main.go b/main.go index 26ff767..dfbbc1d 100644 --- a/main.go +++ b/main.go @@ -72,14 +72,14 @@ func GetSkill(skillName string) Skill { return char.Skills[skillMap[skillName]] } -func GetSkillModifier(skill Skill) int { - return GetStat(skill.BaseStat).Modifier -} - func GetStat(statName string) Stat { return char.Stats[statMap[statName]] } +func GetModifier(stat Stat) int { + return (stat.Score - 10) / 2 +} + func SkillCheck(skill Skill) int { var die, x, y int switch { @@ -93,10 +93,10 @@ func SkillCheck(skill Skill) int { fmt.Printf("%s%d%s\tx: %d\ty: %d\n", Colors.ColorGreen, die, Colors.ColorReset, x, y) switch { case skill.Expertise: - return die + GetSkillModifier(skill) + char.Misc.Proficiency*2 + return die + GetModifier(GetStat(skill.BaseStat)) + char.Misc.Proficiency*2 case skill.Proficient: - return die + GetSkillModifier(skill) + char.Misc.Proficiency + return die + GetModifier(GetStat(skill.BaseStat)) + char.Misc.Proficiency default: - return die + GetSkillModifier(skill) + return die + GetModifier(GetStat(skill.BaseStat)) } } diff --git a/sheetContent.go b/sheetContent.go index b72b32d..005604a 100644 --- a/sheetContent.go +++ b/sheetContent.go @@ -21,6 +21,5 @@ type Skill struct { type Stat struct { StatName string `json:"statName"` Score int `json:"score"` - Modifier int `json:"modifier"` Proficient bool `json:"proficient"` } diff --git a/stats.json b/stats.json index d7761f7..abd3124 100644 --- a/stats.json +++ b/stats.json @@ -6,12 +6,12 @@ "name": "Bob" }, "stats":[ - {"statName":"strength", "score":20, "modifier":5, "proficient":false }, - {"statName":"dexterity", "score":10, "modifier":3, "proficient":false }, - {"statName":"constitution", "score":10, "modifier":0, "proficient":false }, - {"statName":"intelligence", "score":10, "modifier":0, "proficient":false }, - {"statName":"wisdom", "score":10, "modifier":0, "proficient":false }, - {"statName":"charisma", "score":10, "modifier":0, "proficient":false } + {"statName":"strength", "score":20, "proficient":false }, + {"statName":"dexterity", "score":10, "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 } ], "skills":[ {"skillName":"athletics", "proficient":false, "expertise":false, "baseStat":"strength"},