1
0
GameServerSupervisor/gameserver/models.py
Pratyush Desai 1c097640a7
Add base models for testing
Attempt to figure out the necessary data models
and applicable fields.

Signed-off-by: Pratyush Desai <pratyush.desai@liberta.casa>
2024-12-20 15:01:01 +05:30

55 lines
1.9 KiB
Python

from django.db import models
class Game(models.Model):
name = models.CharField(max_length=255)
friendly_name = models.CharField(max_length=255)
# command_line = models.CharField(max_length=255)
def __str__(self):
return self.friendly_name
class Server(models.Model):
game = models.ForeignKey(Game, on_delete=models.CASCADE)
port = models.IntegerField()
game_type = models.CharField(max_length=255)
mod = models.ForeignKey('Mod', on_delete=models.CASCADE)
players = models.ManyToManyField('Player')
# spawned_at_utc = models.DateTimeField(auto_now_add=True)
# last_collection_utc = models.DateTimeField(null=True, blank=True)
# last_heartbeat_utc = models.DateTimeField()
# process_id = models.IntegerField()
# port = models.IntegerField()
# is_started = models.BooleanField()
# is_private = models.BooleanField()
# current_players = models.IntegerField()
# maximum_players = models.IntegerField()
class Player(models.Model):
name = models.CharField(max_length=255)
score = models.IntegerField()
class Mod(models.Model):
name = models.CharField(max_length=255)
friendly_name = models.CharField(max_length=255)
# command_line = models.CharField(max_length=255)
# class SpawnedServerInfo(models.Model):
# process_id = models.IntegerField()
# port = models.IntegerField()
# mod = models.ForeignKey('Mod', on_delete=models.CASCADE)
# class StateResponse(models.Model):
# servers = models.ManyToManyField('Server')
# man_minutes_played = models.IntegerField()
# running_since_utc = models.DateTimeField()
# class State(models.Model):
# servers = models.ManyToManyField('Server')
# created_at_utc = models.DateTimeField(auto_now_add=True)
# playtime = models.DurationField(default='00:00:00')
# def increase_playtime(self, time_to_add):
# self.playtime += time_to_add