Added save profciency and passive check function

This commit is contained in:
Nox Sluijtman 2023-01-03 15:21:08 +01:00
parent 85eb9d3470
commit bbd5f100cd
3 changed files with 35 additions and 22 deletions

View file

@ -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"},

38
main.go
View file

@ -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 {

View file

@ -29,6 +29,7 @@ type Stat struct {
StatName string `json:"statName"`
Score int `json:"score"`
Proficient bool `json:"proficient"`
SaveProficient bool `json:"saveProficient"`
}
type Feat struct {