31 lines
1.2 KiB
Python
31 lines
1.2 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()
|
|
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 beautiful 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 soldiers and 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 info of as much as 20 bytes
|
|
# in 2 for the mods. ammo|--|sights|---|internals|---|, trigger|--|barrel|--|skins|----|, number|--------|
|
|
|
|
|
|
class UserAction(models.Model):
|
|
user = models.OneToOneField(User, on_delete=models.CASCADE)
|
|
action = models.CharField(max_length=200)
|
|
|
|
def __str__(self):
|
|
return f"{self.user.username}'s action"
|