summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/models/character.rb11
-rw-r--r--app/models/monster.rb17
-rw-r--r--app/views/characters/show.html.erb20
3 files changed, 32 insertions, 16 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index 74dbe9f..0f434cf 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -321,10 +321,17 @@ class Character < ApplicationRecord
end
def resistance(damage_type)
- unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison bleed].include?(damage_type)
+ unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison
+ bleed physical energy].include?(damage_type)
raise "Invalid damage type"
end
- [total_stat_change("#{damage_type}_resistance"), 0].max
+ 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, 0].max
end
def max_wounds
diff --git a/app/models/monster.rb b/app/models/monster.rb
index 523afa7..f4ae7a7 100644
--- a/app/models/monster.rb
+++ b/app/models/monster.rb
@@ -30,12 +30,21 @@ class Monster < ApplicationRecord
end
def resistance(damage_type)
- unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison bleed].include?(damage_type)
+ unless %w[slash pierce bash arcane fire frost lightning acid thunder radiant necrotic poison bleed
+ physical energy].include?(damage_type)
raise "Invalid damage type"
end
- self.whatnot&.each do |resistance|
- return resistance[:base] if resistance[:gid] == damage_type
+ res = 0
+ whatnot[:resistances]&.each do |data|
+ if data[:gid] == damage_type
+ res += data[:base]
+ end
end
- 0
+ 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
end
end
diff --git a/app/views/characters/show.html.erb b/app/views/characters/show.html.erb
index 09e2400..7875a24 100644
--- a/app/views/characters/show.html.erb
+++ b/app/views/characters/show.html.erb
@@ -103,19 +103,19 @@
<th class="table-cell-padded text-right">Bash</th>
<td class="table-cell-padded"><%= @character.resistance("bash") %></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Arcane</th>
<td class="table-cell-padded"><%= @character.resistance("arcane") %></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Fire</th>
<td class="table-cell-padded"><%= @character.resistance("fire") %></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Frost</th>
<td class="table-cell-padded"><%= @character.resistance("frost") %></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Lightning</th>
<td class="table-cell-padded"><%= @character.resistance("lightning") %></td>
</tr>
@@ -125,27 +125,27 @@
<div class="my-2">
<table class="table-auto">
<tbody>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Acid</th>
<td class="table-cell-padded"><%= @character.resistance("acid") %></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Thunder</th>
<td class="table-cell-padded"><%= @character.resistance("thunder")%></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Radiant</th>
<td class="table-cell-padded"><%= @character.resistance("radiant") %></td>
</tr>
- <tr>
+ <tr class="text-blue-500">
<th class="table-cell-padded text-right">Necrotic</th>
<td class="table-cell-padded"><%= @character.resistance("necrotic") %></td>
</tr>
- <tr>
+ <tr class="text-purple-500">
<th class="table-cell-padded text-right">Poison</th>
<td class="table-cell-padded"><%= @character.resistance("poison") %></td>
</tr>
- <tr>
+ <tr class="text-red-500">
<th class="table-cell-padded text-right">Bleed</th>
<td class="table-cell-padded"><%= @character.resistance("bleed") %></td>
</tr>