From d2afb75b2cf512158d82ea2513ee4fb6662362a7 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 6 Jun 2021 14:15:59 -0400 Subject: Switch from power-based damage to damage types, replace block with resistance, and make natural 20 accuracy rolls always hit (and crit) --- app/models/character.rb | 22 ++++++++-------------- app/models/monster.rb | 8 ++------ 2 files changed, 10 insertions(+), 20 deletions(-) (limited to 'app/models') 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) -- cgit v1.2.3