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 <bss@incorporeal.org>
This commit is contained in:
parent
180d3f8b6f
commit
f452aab825
|
@ -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)
|
||||
|
|
|
@ -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."""
|
||||
|
|
Loading…
Reference in New Issue