summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-16 19:20:17 -0400
committerDavid Gay <david@davidgay.org>2021-06-16 19:20:17 -0400
commit361acfad2162e08a962c63c4443641fbbd812089 (patch)
tree5ad983e464ef6ef04d7eb9b2b8873efcc5aff384
parentc626f5ec23449e0c62a6c026012ecedc29a6bab8 (diff)
Learn spells from spellpages
-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
-rw-r--r--data/activities.yml16
-rw-r--r--data/items.yml8
5 files changed, 21 insertions, 16 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>
diff --git a/data/activities.yml b/data/activities.yml
index 66b7765..3202e7f 100644
--- a/data/activities.yml
+++ b/data/activities.yml
@@ -2904,9 +2904,9 @@ havencast_dazzle:
- type: "xp"
gid: "havencast"
base: 5
-havencast_decipher_magicscript:
- name: "Cast Decipher Magicscript"
- description: "Cast the Decipher Magicscript cantrip."
+havencast_decipher_simple_magicscript:
+ name: "Cast Decipher Simple Magicscript"
+ description: "Cast the Decipher Simple Magicscript cantrip."
whatnot:
tags:
- "spell"
@@ -2927,13 +2927,17 @@ havencast_decipher_magicscript:
value: 1
cost:
- type: "item"
- gid: "spellpage"
+ gid: "simple_spellpage"
quantity: 1
results:
- type: "xp"
gid: "havencast"
- base: 7
- - type: "decipher_magicscript"
+ base: 10
+ - type: "activity"
+ chance: 1
+ table:
+ - gid: "havencast_stinging_rays"
+ score: 0
havencast_enchant_apprentice_wand:
name: "Cast Enchant Apprentice Wand"
description: "Cast the Enchant Apprentice Wand spell."
diff --git a/data/items.yml b/data/items.yml
index b20ab34..a89591e 100644
--- a/data/items.yml
+++ b/data/items.yml
@@ -1134,9 +1134,9 @@ faint_mana:
- type: "stat_change"
gid: "mana"
modifier: 1
-spellpage:
- name: "spellpage"
- description: "A piece of parchment covered in magical script. Deciphering it can yield knowledge of a spell."
+simple_spellpage:
+ name: "simple spellpage"
+ description: "An old piece of parchment covered in magical script. Deciphering it can yield knowledge of a spell."
whatnot:
tags:
- - "materials"
+ - "material"