aboutsummaryrefslogtreecommitdiff
path: root/internal/combat/formulas.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-09 05:59:20 -0400
committerhistoria <[not public]>2026-06-09 05:59:20 -0400
commit9eb5ab1818b6b19501fd7209db1987c9e06cc919 (patch)
tree76e046b0bf611dfe939a8c8f6507467de2e9e20f /internal/combat/formulas.go
downloadthehouseoficarus-9eb5ab1818b6b19501fd7209db1987c9e06cc919.tar.gz
first commit
Diffstat (limited to 'internal/combat/formulas.go')
-rw-r--r--internal/combat/formulas.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/combat/formulas.go b/internal/combat/formulas.go
new file mode 100644
index 0000000..0b3248b
--- /dev/null
+++ b/internal/combat/formulas.go
@@ -0,0 +1,52 @@
+package combat
+
+import "math/rand"
+
+func AttackRoll(attackLevel int, styleBonus int, equipBonus int) int {
+ return (attackLevel + styleBonus + 8) * (equipBonus + 64)
+}
+
+func DefenseRoll(defenseLevel int, styleBonus int, equipBonus int) int {
+ return (defenseLevel + styleBonus + 8) * (equipBonus + 64)
+}
+
+func HitCheck(attackRoll, defenseRoll int) bool {
+ if attackRoll > defenseRoll {
+ return true
+ }
+ if attackRoll < defenseRoll {
+ return false
+ }
+ return rand.Intn(2) == 1
+}
+
+func MaxHit(strengthLevel int, styleBonus int, equipBonus int) int {
+ effective := (strengthLevel + styleBonus + 8) * (equipBonus + 64)
+ hit := effective / 512
+ if hit < 1 {
+ hit = 1
+ }
+ return hit
+}
+
+func RollDamage(maxHit int) int {
+ if maxHit <= 0 {
+ return 0
+ }
+ return 1 + rand.Intn(maxHit)
+}
+
+func AttackStyleBonus(style string) (attack, strength, defense int) {
+ switch style {
+ case "accurate":
+ return 3, 0, 0
+ case "aggressive":
+ return 0, 3, 0
+ case "defensive":
+ return 0, 0, 3
+ case "balanced":
+ return 1, 1, 1
+ default:
+ return 0, 0, 0
+ }
+}