summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-07-11 17:27:38 -0400
committerDavid Gay <david@davidgay.org>2021-07-11 17:27:38 -0400
commit0fba923dda9440a7817e4dfa191bc242e5e0eb76 (patch)
tree5c666d25ea26b23ac026cd0fedbea5021f8b8e83
parent362b92dbebf1ccc529794890153f8c1bfc43637d (diff)
First worldcall spell: Hearth Passage
-rw-r--r--app/controllers/characters/spells_controller.rb4
-rw-r--r--app/lib/activity_processor.rb4
-rw-r--r--app/views/application/_results.html.erb6
-rw-r--r--data/activities/worldcall.yml33
4 files changed, 46 insertions, 1 deletions
diff --git a/app/controllers/characters/spells_controller.rb b/app/controllers/characters/spells_controller.rb
index a0e6913..b98c1c3 100644
--- a/app/controllers/characters/spells_controller.rb
+++ b/app/controllers/characters/spells_controller.rb
@@ -1,6 +1,8 @@
class Characters::SpellsController < ApplicationController
def index
- @spell_activities = Activity.where("gid like ?", "havencast_%").where(innate: true).order(:name)
+ @spell_activities = Activity.where("gid like ?", "havencast_%")
+ .or(Activity.where("gid like ?", "worldcall_%"))
+ .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 }
diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb
index 72aa85d..3f62d28 100644
--- a/app/lib/activity_processor.rb
+++ b/app/lib/activity_processor.rb
@@ -111,6 +111,10 @@ class ActivityProcessor
end
end
end
+ when "hearth_location"
+ location = @character.hearth&.location || Location.find_by_gid("floret")
+ @character.update(location: location)
+ @results.push({ type: type, location: location })
else
raise "Invalid result type (#{type})" # TODO: Improve this.
end
diff --git a/app/views/application/_results.html.erb b/app/views/application/_results.html.erb
index a7dc002..d1ec927 100644
--- a/app/views/application/_results.html.erb
+++ b/app/views/application/_results.html.erb
@@ -12,6 +12,12 @@
<% when "hearth_planting" %>
<p>You planted <%= link_to result[:hearth_planting].item.name,
item_path(result[:hearth_planting].item) %> in the loam.</p>
+ <% when "hearth_location" %>
+ <% if current_char.hearth&.location %>
+ <p>You appear in <%= result[:location].name %>.</p>
+ <% else %>
+ <p>Lacking a hearth to return to, you appear in an empty patch of land in <%= result[:location].name %>.</p>
+ <% end %>
<% when "activity" %>
<p>You learned how to <%= result[:activity].name %>!</p>
<% when "monster" %>
diff --git a/data/activities/worldcall.yml b/data/activities/worldcall.yml
new file mode 100644
index 0000000..c5ea3e4
--- /dev/null
+++ b/data/activities/worldcall.yml
@@ -0,0 +1,33 @@
+worldcall_hearth_passage:
+ name: "Cast Hearth Passage"
+ description: "Teleport to the location of your hearth."
+ whatnot:
+ tags:
+ - "spell"
+ - "worldcall"
+ requirements:
+ - type: "skill"
+ gid: "worldcall"
+ level: 1
+ cost:
+ - type: "item"
+ gid: "stone"
+ quantity: 5
+ - type: "item"
+ gid: "wood"
+ quantity: 5
+ duration:
+ base: 60
+ minimum: 35
+ scaling:
+ - type: "skill"
+ gid: "worldcall"
+ scale_value: 0.5
+ - type: "stat"
+ gid: "worldcall_speed"
+ scale_value: 1
+ results:
+ - type: "hearth_location"
+ - type: "xp"
+ gid: "worldcall"
+ base: 4