mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 22:14:07 +01:00
Add UserProfile
This commit is contained in:
parent
eb22d30a24
commit
cb2b235e20
30
backend/users/migrations/0004_userstats.py
Normal file
30
backend/users/migrations/0004_userstats.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Generated by Django 4.2.6 on 2023-11-06 05:30
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('users', '0003_customuser_profile_pic'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UserStats',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('health', models.IntegerField(default=100)),
|
||||
('gold', models.FloatField(default=0.0)),
|
||||
('experience', models.FloatField(default=0)),
|
||||
('strength', models.IntegerField(default=1)),
|
||||
('intelligence', models.IntegerField(default=1)),
|
||||
('endurance', models.IntegerField(default=1)),
|
||||
('perception', models.IntegerField(default=1)),
|
||||
('luck', models.IntegerField(default=1)),
|
||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@ -1,7 +1,10 @@
|
||||
import random
|
||||
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
|
||||
from .managers import CustomAccountManager
|
||||
|
||||
@ -32,15 +35,30 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||||
return self.username
|
||||
|
||||
|
||||
# class UserStats(models.Model):
|
||||
# """
|
||||
# Represents User Profiles and Attributes.
|
||||
# Fields:
|
||||
# - health: health points of the user.
|
||||
# - gold: gold points of the user.
|
||||
# - experience: experience points of the user.
|
||||
# """
|
||||
# user = models.OneToOneField(CustomUser, on_delete=models.CASCADE)
|
||||
# health = models.IntegerField(default=100)
|
||||
# gold = models.IntegerField(default=0)
|
||||
# experience = models.FloatField(default=0)
|
||||
def random_luck():
|
||||
return random.randint(1, 50)
|
||||
|
||||
class UserStats(models.Model):
|
||||
"""
|
||||
Represents User Profiles and Attributes.
|
||||
Fields:
|
||||
- health: health points of the user.
|
||||
- gold: gold points of the user.
|
||||
- experience: experience points of the user.
|
||||
"""
|
||||
user = models.OneToOneField(CustomUser, on_delete=models.CASCADE)
|
||||
health = models.IntegerField(default=100)
|
||||
gold = models.FloatField(default=0.0)
|
||||
experience = models.FloatField(default=0)
|
||||
strength = models.IntegerField(default=1,
|
||||
validators=[MinValueValidator(1),
|
||||
MaxValueValidator(100)])
|
||||
intelligence = models.IntegerField(default=1, validators=[MinValueValidator(1),
|
||||
MaxValueValidator(100)])
|
||||
endurance = models.IntegerField(default=1, validators=[MinValueValidator(1),
|
||||
MaxValueValidator(100)])
|
||||
perception = models.IntegerField(default=1, validators=[MinValueValidator(1),
|
||||
MaxValueValidator(100)])
|
||||
luck = models.IntegerField(default=random_luck, validators=[MinValueValidator(1),
|
||||
MaxValueValidator(50)],)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user