diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/game_controller.rb | 8 | ||||
-rw-r--r-- | app/models/character.rb | 5 |
2 files changed, 13 insertions, 0 deletions
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index b0fdaea..dcfc3a3 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -32,6 +32,14 @@ class GameController < ApplicationController when "monster" raise TooManyWoundsError unless current_char.can_fight? next if rand > (result[:chance] || 1) + + if result[:table].pluck(:gid).include?(current_char.trophy_monster_gid) + monster = Monster.find_by_gid(current_char.trophy_monster_gid) + @results.push({ type: type, monster: monster }) + resolve_combat_with(monster) + break + end + table_roll = rand result[:table].sort_by { |t| -t[:score] }.each do |table_entry| score = table_entry[:score] diff --git a/app/models/character.rb b/app/models/character.rb index fda6868..f0705f9 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -82,6 +82,11 @@ class Character < ApplicationRecord item.equip_slots.reject { |slot| full_slots.include?(slot) } end + def trophy_monster_gid + equipment = self.equipment.joins(:item).where("items.gid like ?", "%_trophy").first + equipment.item.gid.split("_trophy").first + end + def equip(item) Character.transaction do open_slots = self.open_slots_for(item) |