diff options
author | David Gay <david@davidgay.org> | 2021-05-05 18:39:27 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-05 18:39:27 -0400 |
commit | 82fa2b72be613713d42b451e0d1801904b4580e8 (patch) | |
tree | 350b45ed1be179d67ce9cdd776a72fcbce4609a5 /app/controllers | |
parent | a32e05fea88fa4d9b9072f5a7e25189c99b16b9d (diff) |
Symbolize whatnot keys
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/game_controller.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index f5fd4a9..4e55924 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -4,21 +4,21 @@ class GameController < ApplicationController return unless current_char.activity_time_remaining <= 0 current_char.update(activity_started_at: Time.now) - current_char.activity.whatnot["results"].each do |result| - type = result["type"] + current_char.activity.whatnot[:results].each do |result| + type = result[:type] case type when "item" - next if rand > result["chance"] + next if rand > result[:chance] table_roll = rand - result["table"].sort_by { |_, v| -v["score"] }.each do |item_gid, item_data| - quantity = item_data["quantity"] || 1 - if table_roll >= item_data["score"] + result[:table].sort_by { |_, v| -v[:score] }.each do |item_gid, item_data| + quantity = item_data[:quantity] || 1 + if table_roll >= item_data[:score] item = Item.find_by_gid(item_gid) xp_awards = {} - if item.whatnot && item.whatnot.key?("xp_value") - xp_awards = item.whatnot["xp_value"] - .map { |gid, amount| { skill: Skill.find_by_gid(gid), amount: amount } } + if item.whatnot && item.whatnot.key?(:xp_value) + xp_awards = item.whatnot[:xp_value] + .map { |gid, amount| { skill: Skill.find_by_gid(gid.to_s), amount: amount } } xp_awards.each do |award| current_char.add_skill_xp(award[:skill], award[:amount]) end |