summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/concerns/has_whatnot.rb12
-rw-r--r--app/models/monster.rb2
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/concerns/has_whatnot.rb b/app/models/concerns/has_whatnot.rb
index 22322c0..987c969 100644
--- a/app/models/concerns/has_whatnot.rb
+++ b/app/models/concerns/has_whatnot.rb
@@ -18,5 +18,17 @@ module HasWhatnot
def where_has_tag(tag)
where("whatnot->'tags' ? :tag", tag: tag)
end
+
+ def conditions_met?(data)
+ data[:conditions]&.each do |conditions_data|
+ case conditions_data[:type]
+ when "time_of_day"
+ return false unless conditions_data[:times].include? World.time_of_day.to_s
+ else
+ raise "Invalid condition type GID (#{conditions_data[:type]})"
+ end
+ end
+ true
+ end
end
end
diff --git a/app/models/monster.rb b/app/models/monster.rb
index 40018fd..9e3060f 100644
--- a/app/models/monster.rb
+++ b/app/models/monster.rb
@@ -22,7 +22,7 @@ class Monster < ApplicationRecord
end
def damage_ranges
- self.whatnot[:hit_effects].filter_map { |e| { gid: e[:gid], min: e[:min], max: e[:max] } if e[:type] == "damage" }
+ self.whatnot[:hit_effects].filter_map { |e| { gid: e[:gid], min: e[:min], max: e[:max] } if e[:type] == "damage" && conditions_met?(e) }
end
def resistance(damage_type)