From 4c96893a114059dc4e748307c6d046ec1faa778f Mon Sep 17 00:00:00 2001 From: David Gay Date: Wed, 2 Jun 2021 22:15:02 -0400 Subject: Magiculture --- app/controllers/game_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/controllers/game_controller.rb') diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 2de342a..04d743c 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -129,6 +129,15 @@ class GameController < ApplicationController .find_or_initialize_by(hearth_amenity: HearthAmenity.find_by_gid(result[:gid])) bhi.update(level: result[:level]) @results.push({ type: type, hearth_amenity: bhi.hearth_amenity }) + when "hearth_planting" + unless current_char.hearth.available_planting_spots > 0 + @results.replace([{ type: "error", message: "You're out of space to plant seeds." }]) + current_char.stop_activity + return + end + item = Item.find_by_gid(result[:gid]) + hp = current_char.hearth.hearth_plantings.create(item: item) + @results.push({ type: type, hearth_planting: hp }) when "activity" next if rand > (result[:chance] || 1) table_roll = rand @@ -174,6 +183,9 @@ class GameController < ApplicationController rescue ItemQuantityError current_char.stop_activity @results.replace([{ type: "error", message: "You don't have enough items to complete this activity." }]) + rescue HearthPlantingError + current_char.stop_activity + @results.replace([{ type: "error", message: "You don't have that crop planted." }]) rescue TooManyWoundsError current_char.stop_activity @results.replace([{ type: "error", -- cgit v1.2.3