22 lines
1.0 KiB
Python
22 lines
1.0 KiB
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(default=0)
|
|
money = models.IntegerField(default=10000)
|
|
equipment = models.CharField(max_length=1024, default='0;', blank=True)
|
|
inventory = models.CharField(max_length=1024, default='0;', blank=True)
|
|
|
|
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|--------| |