summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-06-09 21:27:36 -0400
committerDavid Gay <david@davidgay.org>2021-06-09 21:27:36 -0400
commit6fbb3db6f1dda597cc997fa07ab6545ef99f717d (patch)
tree72a266f1157889a461340d788cdbdab3d325d476
parenta068f2a59cd7070ec7a59b32908bde5ede4a1fb7 (diff)
Extra guards to prevent running activity duration check code when important related values are nil (hopefully fixes #3 and fixes #2)
-rw-r--r--CHANGELOG.md2
-rw-r--r--app/lib/activity_processor.rb2
-rw-r--r--app/models/character.rb1
3 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e721dd8..e832c89 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,8 @@ All notable changes to this project will be documented in this file.
- Leviathans that had item drops with a less than 100% chance could fail to check all their items due to the awarding
code returning early. This wouldn't have happened in the game yet because prior to this patch there were no item
drops on leviathans with less than 100% drop chance.
+- Hopefully fix two bugs with activity completion / timer code (seems like the same bug manifested in two different
+ ways).
- Spelling of laboratory
## [0.1.9.1] - 2021-06-07
diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb
index 72c7ddd..b5dd11c 100644
--- a/app/lib/activity_processor.rb
+++ b/app/lib/activity_processor.rb
@@ -9,7 +9,7 @@ class ActivityProcessor
end
def process
- return unless @character.activity_time_remaining <= 0
+ return unless @character.activity && @character.activity_time_remaining <= 0
if @character.resting?
@results.replace([{ type: "error", message: "You can't do anything while you're resting." }])
@character.stop_activity
diff --git a/app/models/character.rb b/app/models/character.rb
index ce2b0db..d386002 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -197,6 +197,7 @@ class Character < ApplicationRecord
end
def activity_time_remaining
+ return nil unless self.activity
time = activity_duration - (Time.now - self.activity_started_at)
time -= rested_duration_to_spend_on_activity if self.rested_duration > 0
time