def post(self, request, join_id):
try:
game = Game.objects.get(join_id=join_id)
except Game.DoesNotExist:
raise NotFound("Invalid join_id",404)
if game.game_state != 'starting':
raise ValidationError("You can no longer join this game")
data = request.data
enforce_required_params(['name'],data)
player = Player.objects.create(name=data['name'], game=game)
if game.num_players == game.players.count():
game.game_state = 'pick_wc'
game.save()
game.start_new_round()
return Response({
'player':player.get_dict(show_private=True),
'game':game.get_dict()})
评论列表
文章目录