Beispiel #1
0
def game(game_id):
    if request.method == 'GET':
        data = DataRepository.read_game_by_id(game_id)
        if data is not None:
            return jsonify(game=data), 200
        else:
            return jsonify(message=f'ERROR: there is no game with this id: {game_id}'), 404
    elif request.method == 'PUT':
        gegevens = DataRepository.json_or_formdata(request)

        data = DataRepository.update_game_by_id(
            game_id, gegevens['name'], gegevens['description'], gegevens['cardDecks'], gegevens['rulesetID'])
        if data is not None:
            if data > 0:
                return jsonify(gameID=data), 200
            elif data == 0:
                return jsonify(message='There wasn\'t anything to update.'), 200
        else:
            return jsonify(message='ERROR: there went something wrong with updating the game.'), 404
    elif request.method == 'DELETE':
        data = DataRepository.delete_game(game_id)
        if data is not None:
            if data > 0:
                return jsonify(message='The game has been deleted.'), 200
            elif data == 0:
                return jsonify(message='No game has been deleted.'), 200
        else:
            return jsonify(message='ERROR: there went something wrong with deleting the game'), 404
Beispiel #2
0
def delete_game(game_id):
    data = DataRepository.delete_game(game_id['ID'])
    socketio.emit('B2F_game_deleted')