summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/character.rb49
-rw-r--r--app/models/monster.rb8
2 files changed, 44 insertions, 13 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index 52c0959..d1faeb0 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -19,7 +19,10 @@ class Character < ApplicationRecord
attribute :wounds, :integer, default: 0
- after_create :create_skills
+ enum offensive_style: [:balanced, :precise, :brutal]
+ enum defensive_style: [:centered, :elusive, :protective]
+
+ after_create :create_skills, :set_combat_styles
after_create { Hearth.create(character: self) }
def beastslay_level; skill_level("beastslay"); end
@@ -184,20 +187,44 @@ class Character < ApplicationRecord
self.beastslay_level + (equipment_stats["speed"] || 0)
end
- def accuracy
- self.beastslay_level + (equipment_stats["accuracy"] || 0)
+ def accuracy(with_combat_style: false)
+ base = self.beastslay_level + (equipment_stats["accuracy"] || 0)
+ if with_combat_style && self.precise?
+ base = (base * 1.25).floor
+ elsif with_combat_style && self.brutal?
+ base = (base * 0.75).ceil
+ end
+ base
end
- def power
- self.beastslay_level + (equipment_stats["power"] || 0)
+ def power(with_combat_style: false)
+ base = self.beastslay_level + (equipment_stats["power"] || 0)
+ if with_combat_style && self.precise?
+ base = (base * 0.75).ceil
+ elsif with_combat_style && self.brutal?
+ base = (base * 1.25).floor
+ end
+ base
end
- def evasion
- self.beastslay_level + (equipment_stats["evasion"] || 0)
+ def evasion(with_combat_style: false)
+ base = self.beastslay_level + (equipment_stats["evasion"] || 0)
+ if with_combat_style && self.elusive?
+ base = (base * 1.25).floor
+ elsif with_combat_style && self.protective?
+ base = (base * 0.75).ceil
+ end
+ base
end
- def block
- self.beastslay_level + (equipment_stats["block"] || 0)
+ def block(with_combat_style: false)
+ base = self.beastslay_level + (equipment_stats["block"] || 0)
+ 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
@@ -208,4 +235,8 @@ class Character < ApplicationRecord
def create_skills
Skill.all.each { |skill| self.character_skills.create(skill: skill, xp: 0) }
end
+
+ def set_combat_styles
+ self.update(offensive_style: :balanced, defensive_style: :centered)
+ end
end
diff --git a/app/models/monster.rb b/app/models/monster.rb
index 1b521aa..d1e1b99 100644
--- a/app/models/monster.rb
+++ b/app/models/monster.rb
@@ -9,19 +9,19 @@ class Monster < ApplicationRecord
self.whatnot[:speed][:base]
end
- def accuracy
+ def accuracy(with_combat_style: false)
self.whatnot[:accuracy][:base]
end
- def power
+ def power(with_combat_style: false)
self.whatnot[:power][:base]
end
- def evasion
+ def evasion(with_combat_style: false)
self.whatnot[:evasion][:base]
end
- def block
+ def block(with_combat_style: false)
self.whatnot[:block][:base]
end