mirror of
https://gitlab.com/EternalWanderer/sheet-parser.git
synced 2024-11-29 05:23:49 +01:00
Added save profciency and passive check function
This commit is contained in:
parent
85eb9d3470
commit
bbd5f100cd
12
example.json
12
example.json
|
@ -10,12 +10,12 @@
|
||||||
"isKurthog": false
|
"isKurthog": false
|
||||||
},
|
},
|
||||||
"stats":[
|
"stats":[
|
||||||
{"statName":"strength", "score":20, "proficient":false },
|
{"statName":"strength", "score":20, "proficient":false, "saveProficient":false },
|
||||||
{"statName":"dexterity", "score":1, "proficient":false },
|
{"statName":"dexterity", "score":1, "proficient":false, "saveProficient":false },
|
||||||
{"statName":"constitution", "score":15, "proficient":false },
|
{"statName":"constitution", "score":15, "proficient":false, "saveProficient":false },
|
||||||
{"statName":"intelligence", "score":10, "proficient":false },
|
{"statName":"intelligence", "score":10, "proficient":false, "saveProficient":false },
|
||||||
{"statName":"wisdom", "score":10, "proficient":false },
|
{"statName":"wisdom", "score":10, "proficient":false, "saveProficient":false },
|
||||||
{"statName":"charisma", "score":10, "proficient":false }
|
{"statName":"charisma", "score":10, "proficient":false, "saveProficient":false }
|
||||||
],
|
],
|
||||||
"skills":[
|
"skills":[
|
||||||
{"skillName":"athletics", "proficient":true, "expertise":false, "baseStat":"strength"},
|
{"skillName":"athletics", "proficient":true, "expertise":false, "baseStat":"strength"},
|
||||||
|
|
38
main.go
38
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("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)
|
fmt.Printf("Race: %s\tClass: %s\tBackground: %s\n", char.Misc.Race, char.Misc.Class, char.Misc.Background)
|
||||||
|
|
||||||
// passive perception
|
fmt.Printf("Passive perception: %d\n", passiveSkillCheck(GetSkill("perception")))
|
||||||
var passivePerception int
|
fmt.Printf("Passive investigation: %d\n", passiveSkillCheck(GetSkill("investigation")))
|
||||||
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)
|
|
||||||
|
|
||||||
case feats:
|
case feats:
|
||||||
listFeats()
|
listFeats()
|
||||||
|
@ -275,19 +266,40 @@ func skillErrorCheck() error {
|
||||||
func statCheck(stat Stat) (int, int, error) {
|
func statCheck(stat Stat) (int, int, error) {
|
||||||
die := rollDice()
|
die := rollDice()
|
||||||
return die + GetModifier(stat), die, statErrorCheck()
|
return die + GetModifier(stat), die, statErrorCheck()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func savingThrow(stat Stat) (int, int, error) {
|
func savingThrow(stat Stat) (int, int, error) {
|
||||||
die := rollDice()
|
die := rollDice()
|
||||||
plainDie := die
|
plainDie := die
|
||||||
|
|
||||||
if stat.Proficient {
|
if stat.SaveProficient {
|
||||||
die += GetProficiency()
|
die += GetProficiency()
|
||||||
}
|
}
|
||||||
return die + GetModifier(stat), plainDie, statErrorCheck()
|
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) {
|
func skillCheck(skill Skill) (int, int, error) {
|
||||||
die := rollDice()
|
die := rollDice()
|
||||||
if char.Misc.ReliableTalent && skill.Proficient && die < 10 {
|
if char.Misc.ReliableTalent && skill.Proficient && die < 10 {
|
||||||
|
|
|
@ -29,6 +29,7 @@ type Stat struct {
|
||||||
StatName string `json:"statName"`
|
StatName string `json:"statName"`
|
||||||
Score int `json:"score"`
|
Score int `json:"score"`
|
||||||
Proficient bool `json:"proficient"`
|
Proficient bool `json:"proficient"`
|
||||||
|
SaveProficient bool `json:"saveProficient"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Feat struct {
|
type Feat struct {
|
||||||
|
|
Loading…
Reference in a new issue