diff options
author | David Gay <david@davidgay.org> | 2021-06-06 14:15:59 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-06-06 14:15:59 -0400 |
commit | d2afb75b2cf512158d82ea2513ee4fb6662362a7 (patch) | |
tree | 8a939fc049446372440ba030cf2843db5c80ed35 /app/models | |
parent | bce9b7729ec148d0b728602309fea6787802468b (diff) |
Switch from power-based damage to damage types, replace block with resistance, and make natural 20 accuracy rolls always hit (and crit)
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/character.rb | 22 | ||||
-rw-r--r-- | app/models/monster.rb | 8 |
2 files changed, 10 insertions, 20 deletions
diff --git a/app/models/character.rb b/app/models/character.rb index 0f434cf..15169a4 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -312,6 +312,10 @@ class Character < ApplicationRecord effects.filter_map { |e| e[:modifier] if e[:type] == "stat_change" && e[:gid] == gid }.sum end + def damage_ranges + effects.filter_map { |e| { gid: e[:gid], min: e[:min], max: e[:max] } if e[:type] == "damage" } + end + def planting_spots [total_stat_change("planting_spots"), 0].max end @@ -325,12 +329,16 @@ class Character < ApplicationRecord bleed physical energy].include?(damage_type) raise "Invalid damage type" end + res = total_stat_change("#{damage_type}_resistance") if %w[slash pierce bash].include?(damage_type) res += resistance("physical") elsif %w[arcane fire frost lightning acid thunder radiant necrotic].include?(damage_type) res += resistance("energy") end + + res = (res * 0.75).ceil if elusive? + res = (res * 1.25).floor if protective? [res, 0].max end @@ -376,20 +384,6 @@ class Character < ApplicationRecord base end - def block(with_combat_style: false) - base = [self.beastslay_level + total_stat_change("block"), 0].max - if with_combat_style && self.elusive? - base = (base * 0.75).ceil - elsif with_combat_style && self.protective? - base = (base * 1.25).floor - end - base - end - - def block_value - [total_stat_change("block_value"), 0].max - end - private def create_skills Skill.all.each { |skill| self.character_skills.create(skill: skill, xp: 0) } diff --git a/app/models/monster.rb b/app/models/monster.rb index f4ae7a7..40018fd 100644 --- a/app/models/monster.rb +++ b/app/models/monster.rb @@ -21,12 +21,8 @@ class Monster < ApplicationRecord self.whatnot[:evasion][:base] end - def block(with_combat_style: false) - self.whatnot[:block][:base] - end - - def block_value - self.whatnot[:block_value][:base] + def damage_ranges + self.whatnot[:hit_effects].filter_map { |e| { gid: e[:gid], min: e[:min], max: e[:max] } if e[:type] == "damage" } end def resistance(damage_type) |