From f452aab82505174af8b12a19dcb022cc91ac7390 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Tue, 7 May 2024 08:42:48 -0500 Subject: [PATCH] don't penalize character inside the log_out method part, quit, kick are all going to have their own need to log out the character without a penalty (because they apply their own), so to avoid double penalties, the log out penalty should be moved into the bot command and managed that way. this was the only place where an action method was also applying a penalty, so hopefully this remains consistent too Signed-off-by: Brian S. Stephan --- idlerpg/models.py | 2 -- tests/test_idlerpg_character.py | 4 ---- 2 files changed, 6 deletions(-) diff --git a/idlerpg/models.py b/idlerpg/models.py index ce746d2..b4bad4c 100644 --- a/idlerpg/models.py +++ b/idlerpg/models.py @@ -189,8 +189,6 @@ class Character(models.Model): if self.status != self.CHARACTER_STATUS_ONLINE: raise ValueError(f"character '{self.name}' can't be logged out, isn't logged in!") - seconds = self.penalize(self.LOGOUT_P, "logging out") - self.time_penalized_logout += seconds self.status = self.CHARACTER_STATUS_OFFLINE self.last_login = timezone.now() logger.info("%s::%s: logged out", self.game.name, self.name) diff --git a/tests/test_idlerpg_character.py b/tests/test_idlerpg_character.py index 1469c09..d775e8e 100644 --- a/tests/test_idlerpg_character.py +++ b/tests/test_idlerpg_character.py @@ -29,17 +29,13 @@ class CharacterTest(TestCase): def test_log_out(self): """Test basic log out functionality and end result.""" char = Character.objects.get(pk=1) - # retain some data for comparison after logging out - old_next_level = char.next_level logout_time = timezone.now() with patch('django.utils.timezone.now', return_value=logout_time): char.log_out() - assert char.next_level == old_next_level + timedelta(seconds=20) assert char.status == Character.CHARACTER_STATUS_OFFLINE assert char.last_login == logout_time - assert char.time_penalized_logout == 20 def test_cant_log_out_offline(self): """Test that we error if trying to log out a character already offline."""