Пример #1
0
def async_board_message(room_id, message, color, number_of_moves):
    app = current_app._get_current_object()
    message_list = [{color: message}]
    with app.app_context():
        room_manager = game_objects.RoomManager(room_id)
        if room_manager.get_number_of_moves() == number_of_moves:
            socketio.emit('inf_board_message', message_list, room=room_id)
Пример #2
0
def roll_dice_handler():
    # dice_rolled
    room_id = session['room_id']
    pm = game_objects.PlayerManager(session['pers_id'], room_id)
    rm = game_objects.RoomManager(room_id)
    number_of_moves = rm.get_number_of_moves()
    width, height = pm.roll_dice()
    color = pm.player.order_of_turn

    message = (session['username'] + ' has figure with sides: ' +
               str(width) + ' and ' + str(height))

    async_board_message.apply_async((room_id, message, color,
                                     number_of_moves,),
                                    countdown=2)

    emit('dice_rolled', (width, height,))
Пример #3
0
def change_ready_status_handler():
    message_list = []
    room_id = session['room_id']

    pm = game_objects.PlayerManager(session['pers_id'], room_id)
    room_manager = game_objects.RoomManager(room_id)

    if room_manager.is_playing():
        message_list.append({-1: 'You cant do this'})
        emit('inf_board_message', message_list)
        raise InappropriateActionError('You can`t do this')

    all_ready = pm.change_ready_status()

    color = pm.player.order_of_turn
    if pm.player.ready is True:
        message_list.append({color: session['username'] + ' is ready'})
    else:
        message_list.append({color: session['username'] + ' is not ready'})

    if all_ready:
        message_list = start_game_event(room_manager, message_list)

    send_board_message_and_refresh_score_table(room_manager, message_list)
Пример #4
0
def room_manager(get_id, db):
    game_objects.RoomManager.create_room(get_id, 'test', 'public', 4)
    return game_objects.RoomManager(get_id)
Пример #5
0
def game_clock(room_id, current_player_id, number_of_moves):
    app = current_app._get_current_object()
    with app.app_context():
        room_manager = game_objects.RoomManager(room_id)
        if room_manager.get_number_of_moves() == number_of_moves:
            socketio.emit('stop_game_clock', current_player_id, room=room_id)