Exemplo n.º 1
0
    def on_create_question(self, data):

        try:
            question = loads(data)
        except ValueError:
            emit("error", "Invalid input data when creating a question.")
            return

        room_id = question["room_id"]

        questions_left = Database.player_enters_question(
            room_id, question["user_id"], question["question"])
        if questions_left == -1:
            emit("error", "Player has already submitted enough questions.")

        emit("question_created", {"questions_left": questions_left}, json=True)

        if Database.questions_ready(room_id):
            asker = Database.set_askers_order(room_id)
            self.choose_new_question_and_asker(room_id, asker=asker)
Exemplo n.º 2
0
from bluetato_server.database import Database

room_id = '1'
print("CREATE ", Database.create_room(3))

user_id = 'id1'
session_id = 's1'
name = 'A'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))
print("Adding questions")
print(Database.player_enters_question(room_id, user_id, 'Qa'))
print(Database.player_enters_question(room_id, user_id, 'Qb'))
print(Database.player_enters_question(room_id, user_id, 'Qc'))
print("Ending questions")
print("SessionId ", Database.get_session_id(room_id, '1'))

user_id = 'id2'
session_id = 's2'
name = 'B'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))
print("Adding questions")
print(Database.player_enters_question(room_id, user_id, 'Qd'))
print(Database.player_enters_question(room_id, user_id, 'Qe'))
print(Database.player_enters_question(room_id, user_id, 'Qf'))
print("Ending questions")

user_id = 'id3'
session_id = 's3'
name = 'C'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))