mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 05:54:07 +01:00
Add Level in UserStats
This commit is contained in:
parent
a34f2f0a7f
commit
661b178715
@ -110,6 +110,17 @@ class Task(models.Model):
|
||||
else:
|
||||
return 4
|
||||
|
||||
def get_exp(self):
|
||||
return self.user.level * (0.2*self.difficulty) * (0.3*self.user.userstats.luck)
|
||||
|
||||
def get_reward(self):
|
||||
pass
|
||||
|
||||
def get_penalty(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.priority = self.calculate_eisenhower_matrix_category()
|
||||
super(Task, self).save(*args, **kwargs)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import random
|
||||
import math
|
||||
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
@ -30,6 +31,10 @@ class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||||
USERNAME_FIELD = 'email'
|
||||
REQUIRED_FIELDS = ['username', 'first_name']
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
UserStats.objects.get_or_create(user=self)
|
||||
super(CustomUser, self).save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
# String representation of the user
|
||||
return self.username
|
||||
@ -62,3 +67,6 @@ class UserStats(models.Model):
|
||||
luck = models.IntegerField(default=random_luck, validators=[MinValueValidator(1),
|
||||
MaxValueValidator(50)],)
|
||||
|
||||
@property
|
||||
def level(self):
|
||||
return (math.pow(self.experience, 2) // 225) + 1
|
||||
Loading…
Reference in New Issue
Block a user