This commit is contained in:
confestim 2023-05-09 05:00:00 +02:00
parent 489a06504f
commit e784ea0f4d
2 changed files with 11 additions and 2 deletions

View File

@ -156,15 +156,18 @@ class Scraper:
created = game.create()
# TODO: This doesn't work, because we need to serve stuff separately(as in private keys)
# Fix
requests.put(f"{self.URL}/current/1", data={
r = requests.put(f"{self.URL}/current/{name}", data={
"lobby_name": created,
"players": 1,
})
print(r)
# Wait until there are 10 players(confirmed) in the lobby
#while requests.get(f"{self.URL}/current").json()[0].get("lobby_name") != 10:
#time.sleep(5)
# Start the game
print("starting")
time.sleep(2)
game.start()
else:

View File

@ -30,6 +30,12 @@ class CurrentSerializer(serializers.ModelSerializer):
model = Current
fields = ("lobby_name", "creator", "players", "teams")
def create(self, validated_data):
"""
Create and return a new `Current` instance, given the validated data.
"""
return Current.objects.create(**validated_data)
def update(self, instance, validated_data):
instance.players = validated_data.get('players', instance.players)
instance.lobby_name = validated_data.get('lobby_name', instance.lobby_name)