package combat import "math/rand" func EffectiveRoll(level int, styleBonus int, equipBonus int) int { effective := level + styleBonus + 8 return effective * (equipBonus + 64) } func HitChance(attackRoll, defenseRoll int) float64 { a := float64(attackRoll) d := float64(defenseRoll) if a > d { return 1.0 - (d+2.0)/(2.0*(a+1.0)) } return a / (2.0 * (d + 1.0)) } func HitCheck(attackRoll, defenseRoll int) bool { chance := HitChance(attackRoll, defenseRoll) return rand.Float64() < chance } func MaxHit(level int, styleBonus int, equipBonus int) int { effective := level + styleBonus + 8 hit := (effective * (equipBonus + 64)) / 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 } } func RangedStyleBonus(style string) (ranged, defense int) { switch style { case "accurate": return 3, 0 case "aggressive": return 3, 0 case "defensive": return 0, 3 case "balanced": return 1, 1 default: return 0, 0 } } func SelectBonus(attackType string, stab, slash, crush, science, ranged int) int { switch attackType { case "stab": return stab case "slash": return slash case "crush": return crush case "science": return science case "ranged": return ranged default: return crush } }