Exemplo n.º 1
0
    def choose_new_question_and_asker(self, room_id, asker=None):
        if asker is None:
            next_asker = Database.get_next_asker(room_id)
        else:
            next_asker = asker

        emit("asker_chosen", {"asker": next_asker}, json=True, broadcast=True)
        generated_question = Database.get_question(room_id)

        if generated_question is None:
            emit("game_over", "", broadcast=True)
        else:
            potential_receivers = Database.get_potential_receivers(room_id)
            emit("generated_question", {
                "question": generated_question,
                "potential_receivers": potential_receivers
            },
                 json=True,
                 room=Database.get_session_id(room_id, next_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))