mirror of
https://gitlab.com/EternalWanderer/sheet-parser.git
synced 2024-11-29 05:23:49 +01:00
Got rid of explicit modifier
This commit is contained in:
parent
6910c1bf65
commit
811dbf8581
14
main.go
14
main.go
|
@ -72,14 +72,14 @@ func GetSkill(skillName string) Skill {
|
||||||
return char.Skills[skillMap[skillName]]
|
return char.Skills[skillMap[skillName]]
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSkillModifier(skill Skill) int {
|
|
||||||
return GetStat(skill.BaseStat).Modifier
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetStat(statName string) Stat {
|
func GetStat(statName string) Stat {
|
||||||
return char.Stats[statMap[statName]]
|
return char.Stats[statMap[statName]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetModifier(stat Stat) int {
|
||||||
|
return (stat.Score - 10) / 2
|
||||||
|
}
|
||||||
|
|
||||||
func SkillCheck(skill Skill) int {
|
func SkillCheck(skill Skill) int {
|
||||||
var die, x, y int
|
var die, x, y int
|
||||||
switch {
|
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)
|
fmt.Printf("%s%d%s\tx: %d\ty: %d\n", Colors.ColorGreen, die, Colors.ColorReset, x, y)
|
||||||
switch {
|
switch {
|
||||||
case skill.Expertise:
|
case skill.Expertise:
|
||||||
return die + GetSkillModifier(skill) + char.Misc.Proficiency*2
|
return die + GetModifier(GetStat(skill.BaseStat)) + char.Misc.Proficiency*2
|
||||||
case skill.Proficient:
|
case skill.Proficient:
|
||||||
return die + GetSkillModifier(skill) + char.Misc.Proficiency
|
return die + GetModifier(GetStat(skill.BaseStat)) + char.Misc.Proficiency
|
||||||
default:
|
default:
|
||||||
return die + GetSkillModifier(skill)
|
return die + GetModifier(GetStat(skill.BaseStat))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,5 @@ type Skill struct {
|
||||||
type Stat struct {
|
type Stat struct {
|
||||||
StatName string `json:"statName"`
|
StatName string `json:"statName"`
|
||||||
Score int `json:"score"`
|
Score int `json:"score"`
|
||||||
Modifier int `json:"modifier"`
|
|
||||||
Proficient bool `json:"proficient"`
|
Proficient bool `json:"proficient"`
|
||||||
}
|
}
|
||||||
|
|
12
stats.json
12
stats.json
|
@ -6,12 +6,12 @@
|
||||||
"name": "Bob"
|
"name": "Bob"
|
||||||
},
|
},
|
||||||
"stats":[
|
"stats":[
|
||||||
{"statName":"strength", "score":20, "modifier":5, "proficient":false },
|
{"statName":"strength", "score":20, "proficient":false },
|
||||||
{"statName":"dexterity", "score":10, "modifier":3, "proficient":false },
|
{"statName":"dexterity", "score":10, "proficient":false },
|
||||||
{"statName":"constitution", "score":10, "modifier":0, "proficient":false },
|
{"statName":"constitution", "score":15, "proficient":false },
|
||||||
{"statName":"intelligence", "score":10, "modifier":0, "proficient":false },
|
{"statName":"intelligence", "score":10, "proficient":false },
|
||||||
{"statName":"wisdom", "score":10, "modifier":0, "proficient":false },
|
{"statName":"wisdom", "score":10, "proficient":false },
|
||||||
{"statName":"charisma", "score":10, "modifier":0, "proficient":false }
|
{"statName":"charisma", "score":10, "proficient":false }
|
||||||
],
|
],
|
||||||
"skills":[
|
"skills":[
|
||||||
{"skillName":"athletics", "proficient":false, "expertise":false, "baseStat":"strength"},
|
{"skillName":"athletics", "proficient":false, "expertise":false, "baseStat":"strength"},
|
||||||
|
|
Loading…
Reference in a new issue