summaryrefslogtreecommitdiff
path: root/app/controllers/game_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/game_controller.rb')
-rw-r--r--app/controllers/game_controller.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb
index 39bb940..f1387e0 100644
--- a/app/controllers/game_controller.rb
+++ b/app/controllers/game_controller.rb
@@ -5,7 +5,6 @@ class GameController < ApplicationController
activity = current_char.activity
return unless current_char.can_do_activity?(activity) # TODO: Add error message
- current_char.update(activity_started_at: Time.now)
Character.transaction do
current_char.pay_cost_for(activity)
@@ -88,6 +87,17 @@ class GameController < ApplicationController
raise "Invalid result type (#{type})" # TODO: Improve this.
end
end
+
+ if current_char.queued_actions
+ if current_char.queued_actions > 0
+ current_char.queued_actions -= 1
+ current_char.activity_started_at = Time.now
+ current_char.save
+ else
+ current_char.stop_activity
+ @results.push({ type: "message", body: "You have finished your work." })
+ end
+ end
end
rescue ItemQuantityError
@results.replace([{ type: "error", message: "You don't have enough items to complete this activity." }])