summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-05-25 20:31:22 -0400
committerDavid Gay <david@davidgay.org>2021-05-25 20:31:22 -0400
commitca9d189e51b7467f539d906a6e891fa4a7caa2fc (patch)
tree2904645ffce5290ef2aa8303a14f4683e30197b3 /app/models
parent0dd10a2297cc9b3d2a0fe991c1d597b8a1d5fcc2 (diff)
Queued actions, allowing for non-infinite activity repeat and one-time activities
Diffstat (limited to 'app/models')
-rw-r--r--app/models/character.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/character.rb b/app/models/character.rb
index 040c89b..970ede1 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -138,8 +138,16 @@ class Character < ApplicationRecord
true
end
- def start_activity(activity)
- self.update(activity: activity, activity_started_at: Time.now) if self.can_do_activity?(activity)
+ def start_activity(activity, queued_actions: nil)
+ if self.can_do_activity?(activity)
+ self.update(activity: activity, activity_started_at: Time.now, queued_actions: queued_actions)
+ else
+ false
+ end
+ end
+
+ def stop_activity
+ self.update(activity: nil, activity_started_at: nil, queued_actions: nil)
end
def equipment_stats