Example #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)
Example #2
0
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))

user_id = 'id4'
session_id = 's4'
name = 'D'
print("+-> ", Database.create_player(room_id, name, session_id, user_id))

print("Setting askers order")
print(Database.set_askers_order(room_id))
print("Current asker - " + Database.get_current_asker(room_id))
print("Current asker - " + Database.get_current_asker(room_id))

print("Next asker set - " + Database.get_next_asker(room_id))
print("Current asker - " + Database.get_current_asker(room_id))
print("Next asker set - " + Database.get_next_asker(room_id))
print("Next asker set - " + Database.get_next_asker(room_id))
print("Next asker set - " + Database.get_next_asker(room_id))

print("Set last receiver", Database.set_last_receiver(room_id, 'B'))
print("Poten receiv", Database.get_potential_receivers(room_id))

print("Set last receiver", Database.set_last_receiver(room_id, 'X'))
print("Set last receiver", Database.set_last_receiver(-1, 'B'))
print("Poten receiv", Database.get_potential_receivers(-1))