예제 #1
0
    def on_choose_receiver(self, data):

        try:
            player = loads(data)
        except ValueError:
            emit("error", "Invalid input data when choosing a receiver")
            return

        room_id = player["room_id"]
        receiver = player["receiver"]

        if Database.set_last_receiver(room_id, receiver) is None:
            emit("error", "Invalid input data when choosing receiver.")
            return

        emit("receiver_chosen", {"receiver": receiver},
             json=True,
             broadcast=True)

        Timer(30,
              self._timeout_callback,
              args=[
                  Database.get_current_asker(room_id), player["receiver"],
                  room_id
              ]).start()
예제 #2
0
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))

print("PL: ", Database.get_players(room_id))
print("Del player", Database.delete_player(room_id, 'A'))
print(Database.get())

print("Del room", Database.delete_room(room_id))
print(Database.get())