From ca9d189e51b7467f539d906a6e891fa4a7caa2fc Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 25 May 2021 20:31:22 -0400 Subject: Queued actions, allowing for non-infinite activity repeat and one-time activities --- app/models/character.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app/models') 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 -- cgit v1.2.3