From 0fba923dda9440a7817e4dfa191bc242e5e0eb76 Mon Sep 17 00:00:00 2001 From: David Gay Date: Sun, 11 Jul 2021 17:27:38 -0400 Subject: First worldcall spell: Hearth Passage --- app/controllers/characters/spells_controller.rb | 4 ++- app/lib/activity_processor.rb | 4 +++ app/views/application/_results.html.erb | 6 +++++ data/activities/worldcall.yml | 33 +++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 data/activities/worldcall.yml 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" %>

You planted <%= link_to result[:hearth_planting].item.name, item_path(result[:hearth_planting].item) %> in the loam.

+ <% when "hearth_location" %> + <% if current_char.hearth&.location %> +

You appear in <%= result[:location].name %>.

+ <% else %> +

Lacking a hearth to return to, you appear in an empty patch of land in <%= result[:location].name %>.

+ <% end %> <% when "activity" %>

You learned how to <%= result[:activity].name %>!

<% 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 -- cgit v1.2.3