diff options
author | David Gay <david@davidgay.org> | 2021-05-27 19:24:12 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-05-27 19:24:12 -0400 |
commit | 09dbf09b5fa6d106a57cdb601c6ed6c23e00f7dd (patch) | |
tree | 26ff703ba99ef0821f0f74539378e40e18dd85af /app/controllers | |
parent | d9f829e7a723ae36367280950dcbb7edf394e9a2 (diff) |
Make timer more robust, and `stop_activity` if you can't do it
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/game_controller.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index 40d8991..886b37a 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -9,7 +9,14 @@ class GameController < ApplicationController return unless current_char.activity_time_remaining <= 0 activity = current_char.activity - return unless current_char.can_do_activity?(activity) # TODO: Add error message + unless current_char.can_do_activity?(activity) + message = "You can't do this right now." + message += " (requires #{activity.requirements&.join(", ")})" if activity.requirements.any? + message += " (costs #{activity.costs&.join(", ")})" if activity.costs.any? + @results.replace([{ type: "error", message: message }]) + current_char.stop_activity + return + end Character.transaction do current_char.pay_cost_for(activity) |