summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/characters/spells_controller.rb6
-rw-r--r--app/lib/activity_processor.rb5
-rw-r--r--app/views/application/_results.html.erb2
3 files changed, 7 insertions, 6 deletions
diff --git a/app/controllers/characters/spells_controller.rb b/app/controllers/characters/spells_controller.rb
index 9694856..a0e6913 100644
--- a/app/controllers/characters/spells_controller.rb
+++ b/app/controllers/characters/spells_controller.rb
@@ -1,5 +1,9 @@
class Characters::SpellsController < ApplicationController
def index
- @spell_activities = Activity.where("gid like ?", "havencast_%").order(:name)
+ @spell_activities = Activity.where("gid like ?", "havencast_%").where(innate: true).order(:name)
+ # TODO: Don't load into memory
+ @spell_activities = @spell_activities.to_a + current_char.learned_activities
+ .map { |la| la.activity }
+ .select { |a| a.gid.start_with?("havencast_") }
end
end
diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb
index fb0b13d..18fdece 100644
--- a/app/lib/activity_processor.rb
+++ b/app/lib/activity_processor.rb
@@ -97,10 +97,6 @@ class ActivityProcessor
@results.push({ type: "message", body: result[:message] })
@results.push({ type: type, condition: condition })
end
- when "decipher_magicscript"
- Character.transaction do
- # TODO: Add functionality
- end
when "activity"
next if rand > (result[:chance] || 1)
table_roll = rand
@@ -108,6 +104,7 @@ class ActivityProcessor
score = table_entry[:score]
if table_roll >= score
new_activity = Activity.find_by_gid(table_entry[:gid])
+ raise "Invalid activity gid (#{table_entry[:gid]})" unless new_activity
unless @character.learned_activities.exists?(activity: new_activity)
@character.learned_activities.create(activity: new_activity)
@results.push({ type: type, activity: new_activity })
diff --git a/app/views/application/_results.html.erb b/app/views/application/_results.html.erb
index 691f1d5..a7dc002 100644
--- a/app/views/application/_results.html.erb
+++ b/app/views/application/_results.html.erb
@@ -13,7 +13,7 @@
<p>You planted <%= link_to result[:hearth_planting].item.name,
item_path(result[:hearth_planting].item) %> in the loam.</p>
<% when "activity" %>
- <p>You realized how to <%= result[:activity].name %>!</p>
+ <p>You learned how to <%= result[:activity].name %>!</p>
<% when "monster" %>
<p>You encountered a <%= result[:monster].name %>.</p>
<p class="text-xs italic"><%= result[:monster].description %></p>