diff options
author | David Gay <david@davidgay.org> | 2021-05-28 15:33:13 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-28 15:33:13 -0400 |
commit | c913f1d50c428aedef57faa46e8ab0e9cb24741c (patch) | |
tree | f656eb5aaee281dc7072e0ab01929c46d0d7e6b5 | |
parent | 1a27db1925501902b4a122b6b76e8e20075adb85 (diff) |
Implement trophies
-rw-r--r-- | app/controllers/game_controller.rb | 8 | ||||
-rw-r--r-- | app/models/character.rb | 5 | ||||
-rw-r--r-- | data/items.yml | 12 |
3 files changed, 25 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) diff --git a/data/items.yml b/data/items.yml index 93f9ebb..627e396 100644 --- a/data/items.yml +++ b/data/items.yml @@ -199,15 +199,27 @@ warped_eyestalk: pit_leech_trophy: name: "pit leech trophy" description: "A trophy from a pit leech." + whatnot: + equip_slots: + - "curio" stalk_beast_trophy: name: "stalk beast trophy" description: "A trophy from a stalk beast." + whatnot: + equip_slots: + - "curio" grinpad_trophy: name: "grinpad trophy" description: "A trophy from a grinpad." + whatnot: + equip_slots: + - "curio" lesser_trodgeathomp_trophy: name: "lesser trodgeathomp trophy" description: "A trophy from a lesser trodgeathomp." + whatnot: + equip_slots: + - "curio" slate_ring: name: "slate ring" description: "A brittle ring made of slate. It's flat, inside and out." |