From 417762a74d46019fdf9741a67c14b95475b71f6b Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Sat, 20 Aug 2022 18:56:23 +0200 Subject: [PATCH] Added percpetion skill and some more cleanup --- main.go | 18 ++++++------------ stats.json | 7 ++++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index dafc5de..65986cf 100644 --- a/main.go +++ b/main.go @@ -76,6 +76,7 @@ func main() { } func getProficiency() int { + // https://worldbuildersjunction.com/what-is-proficiency-bonus-in-dd-5e-how-it-works-calculated/ return (char.Misc.Level-1)/4 + 2 } @@ -88,6 +89,7 @@ func getStat(statName string) Stat { } func getModifier(stat Stat) int { + // https://worldbuildersjunction.com/dungeon-and-dragons-ability-scores-explained-for-beginners/ return (stat.Score - 10) / 2 } @@ -114,22 +116,14 @@ func savingThrow(stat Stat) int { die := rollDice() if stat.Proficient { - die += getModifier(stat) + die += getProficiency() } - return die + return die + getModifier(stat) } func skillCheck(skill Skill) int { - var die, x, y int - switch { - case advantage: - die, x, y = Dice.Advantage() - case disadvantage: - die, x, y = Dice.Disadvantage() - default: - die = Dice.SimpleCast() - } - fmt.Printf("%s%d%s\tx: %d\ty: %d\n", Colors.ColorGreen, die, Colors.ColorReset, x, y) + var die int + die = rollDice() die += getModifier(getStat(skill.BaseStat)) diff --git a/stats.json b/stats.json index 2339dd7..4ae5b0b 100644 --- a/stats.json +++ b/stats.json @@ -1,18 +1,18 @@ { "misc":{ - "level": 13, + "level": 1, "name": "Bob" }, "stats":[ {"statName":"strength", "score":20, "proficient":false }, - {"statName":"dexterity", "score":10, "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 } ], "skills":[ - {"skillName":"athletics", "proficient":false, "expertise":false, "baseStat":"strength"}, + {"skillName":"athletics", "proficient":true, "expertise":false, "baseStat":"strength"}, {"skillName":"acrobatics", "proficient":false, "expertise":false, "baseStat":"dexterity"}, {"skillName":"sleight_of_hand", "proficient":false, "expertise":false, "baseStat":"dexterity"}, {"skillName":"stealth", "proficient":false, "expertise":false, "baseStat":"dexterity"}, @@ -24,6 +24,7 @@ {"skillName":"animal_handling", "proficient":false, "expertise":false, "baseStat":"wisdom"}, {"skillName":"insight", "proficient":false, "expertise":false, "baseStat":"wisdom"}, {"skillName":"medicine", "proficient":false, "expertise":false, "baseStat":"wisdom"}, + {"skillName":"perception", "proficient":false, "expertise":false, "baseStat":"wisdom"}, {"skillName":"survival", "proficient":false, "expertise":false, "baseStat":"wisdom"}, {"skillName":"deception", "proficient":false, "expertise":false, "baseStat":"charisma"}, {"skillName":"intimidation", "proficient":false, "expertise":true, "baseStat":"charisma"},