generate the uuid on the model
This commit is contained in:
parent
ad70870d8e
commit
7577e3afee
@ -9,6 +9,7 @@
|
||||
"""
|
||||
|
||||
import os
|
||||
import uuid
|
||||
import datetime
|
||||
|
||||
from peewee import (
|
||||
@ -55,7 +56,7 @@ class PlayerModel(BaseModel):
|
||||
class GameModel(BaseModel):
|
||||
"""Games that are ran"""
|
||||
|
||||
game_id = UUIDField(primary_key=True)
|
||||
game_id = UUIDField(primary_key=True, default=uuid.uuid4)
|
||||
server_id = IntegerField()
|
||||
|
||||
pitch_value = IntegerField(null=True)
|
||||
@ -66,7 +67,7 @@ class GameModel(BaseModel):
|
||||
class GuessModel(BaseModel):
|
||||
"""Guesses for a particular game"""
|
||||
|
||||
guess_id = UUIDField(primary_key=True)
|
||||
guess_id = UUIDField(primary_key=True, default=uuid.uuid4)
|
||||
|
||||
player = ForeignKeyField(PlayerModel, backref="guesses")
|
||||
game = ForeignKeyField(GameModel, backref="guesses")
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
# pylint: disable=missing-module-docstring
|
||||
|
||||
import uuid
|
||||
|
||||
from database.models import GameModel as Game
|
||||
from game.base import BaseGameManager
|
||||
|
||||
@ -28,6 +26,6 @@ class NewGameManager(BaseGameManager):
|
||||
self.is_running = True
|
||||
|
||||
# game.pitch_value is unknown at the start of the game
|
||||
self.game = Game.create(game_id=uuid.uuid4(), server_id=self.message.channel.id)
|
||||
self.game = Game.create(server_id=self.message.channel.id)
|
||||
|
||||
await self.message.channel.send("Send me your guesses with !guess <number>")
|
||||
|
Loading…
Reference in New Issue
Block a user