get rid of the online character status, it's not necessary
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
54e944b74b
commit
f941762f26
18
idlerpg/migrations/0005_alter_character_status.py
Normal file
18
idlerpg/migrations/0005_alter_character_status.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.5 on 2024-05-13 04:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('idlerpg', '0004_remove_character_no_characters_with_same_name_per_game_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='character',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('DISABLED', 'Disabled'), ('LOGGEDIN', 'Logged in'), ('OFFLINE', 'Offline')], default='OFFLINE', max_length=8),
|
||||
),
|
||||
]
|
@ -79,12 +79,10 @@ class Character(models.Model):
|
||||
CHARACTER_STATUS_DISABLED = 'DISABLED'
|
||||
CHARACTER_STATUS_LOGGED_IN = 'LOGGEDIN'
|
||||
CHARACTER_STATUS_OFFLINE = 'OFFLINE'
|
||||
CHARACTER_STATUS_ONLINE = 'ONLINE'
|
||||
CHARACTER_STATUSES = {
|
||||
CHARACTER_STATUS_DISABLED: "Disabled",
|
||||
CHARACTER_STATUS_LOGGED_IN: "Logged in",
|
||||
CHARACTER_STATUS_OFFLINE: "Offline",
|
||||
CHARACTER_STATUS_ONLINE: "Online",
|
||||
}
|
||||
|
||||
NICK_CHANGE_P = 30
|
||||
@ -169,8 +167,8 @@ class Character(models.Model):
|
||||
Raises:
|
||||
ValueError: if the provided password was incorrect, or the character isn't logged out
|
||||
"""
|
||||
if self.status != self.CHARACTER_STATUS_ONLINE:
|
||||
raise ValueError(f"character '{self.name}' can't be logged in, isn't online!")
|
||||
if self.status != self.CHARACTER_STATUS_OFFLINE:
|
||||
raise ValueError(f"character '{self.name}' can't be logged in, isn't offline!")
|
||||
if not check_password(password, self.password):
|
||||
raise ValueError(f"incorrect password for character '{self.name}'!")
|
||||
|
||||
|
@ -56,7 +56,6 @@ class CharacterTest(TestCase):
|
||||
char.log_out()
|
||||
# logout has a penalty of its own, so this post-logout value is what will be altered
|
||||
old_next_level = char.next_level
|
||||
char.status = Character.CHARACTER_STATUS_ONLINE
|
||||
with patch('django.utils.timezone.now', return_value=login_time):
|
||||
char.log_in('bss', 'bss!bss@test_log_in')
|
||||
|
||||
@ -74,7 +73,6 @@ class CharacterTest(TestCase):
|
||||
"""Test that we can't log in the character if we don't have the right password."""
|
||||
char = Character.objects.get(pk=1)
|
||||
char.log_out()
|
||||
char.status = Character.CHARACTER_STATUS_ONLINE
|
||||
with self.assertRaises(ValueError):
|
||||
char.log_in('bad pass', 'bss!bss@test_bad_password')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user