Added percpetion skill and some more cleanup

This commit is contained in:
Nox Sluijtman 2022-08-20 18:56:23 +02:00
parent 67d8e210f8
commit 417762a74d
2 changed files with 10 additions and 15 deletions

18
main.go
View file

@ -76,6 +76,7 @@ func main() {
} }
func getProficiency() int { func getProficiency() int {
// https://worldbuildersjunction.com/what-is-proficiency-bonus-in-dd-5e-how-it-works-calculated/
return (char.Misc.Level-1)/4 + 2 return (char.Misc.Level-1)/4 + 2
} }
@ -88,6 +89,7 @@ func getStat(statName string) Stat {
} }
func getModifier(stat Stat) int { func getModifier(stat Stat) int {
// https://worldbuildersjunction.com/dungeon-and-dragons-ability-scores-explained-for-beginners/
return (stat.Score - 10) / 2 return (stat.Score - 10) / 2
} }
@ -114,22 +116,14 @@ func savingThrow(stat Stat) int {
die := rollDice() die := rollDice()
if stat.Proficient { if stat.Proficient {
die += getModifier(stat) die += getProficiency()
} }
return die return die + getModifier(stat)
} }
func skillCheck(skill Skill) int { func skillCheck(skill Skill) int {
var die, x, y int var die int
switch { die = rollDice()
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)
die += getModifier(getStat(skill.BaseStat)) die += getModifier(getStat(skill.BaseStat))

View file

@ -1,18 +1,18 @@
{ {
"misc":{ "misc":{
"level": 13, "level": 1,
"name": "Bob" "name": "Bob"
}, },
"stats":[ "stats":[
{"statName":"strength", "score":20, "proficient":false }, {"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":"constitution", "score":15, "proficient":false },
{"statName":"intelligence", "score":10, "proficient":false }, {"statName":"intelligence", "score":10, "proficient":false },
{"statName":"wisdom", "score":10, "proficient":false }, {"statName":"wisdom", "score":10, "proficient":false },
{"statName":"charisma", "score":10, "proficient":false } {"statName":"charisma", "score":10, "proficient":false }
], ],
"skills":[ "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":"acrobatics", "proficient":false, "expertise":false, "baseStat":"dexterity"},
{"skillName":"sleight_of_hand", "proficient":false, "expertise":false, "baseStat":"dexterity"}, {"skillName":"sleight_of_hand", "proficient":false, "expertise":false, "baseStat":"dexterity"},
{"skillName":"stealth", "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":"animal_handling", "proficient":false, "expertise":false, "baseStat":"wisdom"},
{"skillName":"insight", "proficient":false, "expertise":false, "baseStat":"wisdom"}, {"skillName":"insight", "proficient":false, "expertise":false, "baseStat":"wisdom"},
{"skillName":"medicine", "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":"survival", "proficient":false, "expertise":false, "baseStat":"wisdom"},
{"skillName":"deception", "proficient":false, "expertise":false, "baseStat":"charisma"}, {"skillName":"deception", "proficient":false, "expertise":false, "baseStat":"charisma"},
{"skillName":"intimidation", "proficient":false, "expertise":true, "baseStat":"charisma"}, {"skillName":"intimidation", "proficient":false, "expertise":true, "baseStat":"charisma"},