Website/users/models.py

23 lines
1019 B
Python

from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class UserData(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.CharField(max_length=40)
xp = models.IntegerField()
money = models.IntegerField()
equipment = models.CharField(max_length=1024, default='0;')
inventory = models.CharField(max_length=1024, default='0;')
def __str__(self):
return f"{self.user.username}'s data"
# So this is my beutiful brainchild to keep user data in about 1KB per user, I'm not too sure but still
# it's worth the try, so the main payload is the inventory along the soliers an their weapons and vehicles
# along with the mods for everything which I have separated by `;`, `.` and `,` for soldier, equipment
# class and each equipment. I'll try a bit of bit-hacking to pack as much info of 20 bytes in 2 of the mods.
# ammo|--|sights|---|internals|---|, trigger|--|barrel|--|skins|----|, number|--------|