Ejemplo n.º 1
0
def step_player(player_state, player_next, character_list, character_name):
    my_map = ps.get_map(map_path)
    tile_list = my_map[player_next[0]][player_next[1]].split(',')
    invalid_slots = ['B', 'X']
    current_character = get_current_player(character_list, character_name)
    valid = True
    for tile in tile_list:
        if tile in invalid_slots:
            valid = False
            break
    if valid:
        update_character(character_list, character_name,
                         my_map[player_next[0]][player_next[1]])
        my_map[player_next[0]][player_next[1]] = my_map[player_next[0]][
            player_next[1]].replace('C', 'E')
        my_map[player_next[0]][player_next[1]] = my_map[player_next[0]][
            player_next[1]].replace('S', 'E')
        my_map[player_next[0]][
            player_next[1]] = my_map[player_next[0]][player_next[1]].replace(
                'E', (current_character['user_id'] + player_next[2]))
        for i in range(1, 5):
            my_map[player_state[0]][player_state[1]] = my_map[player_state[0]][
                player_state[1]].replace(
                    str(current_character['user_id']) + str(i), 'E')
        ps.export_map(map_path, my_map)
Ejemplo n.º 2
0
def show_bomb(state, user_id, character_list, character_name):
    my_map = ps.get_map(map_path)
    current_character = get_current_player(character_list, character_name)
    if ('0' not in my_map[state[0]][state[1]]) and (int(
            current_character['bomb_used']) < int(
                current_character['bomb_count'])):
        my_map[state[0]][state[1]] += ',0' + str(user_id)
        ps.export_map(map_path, my_map)
        th1 = threading.Thread(target=bomb_animation,
                               args=[state, user_id, character_name])
        th1.start()
Ejemplo n.º 3
0
def bomb_animation(state, user_id, character_name):
    character_list = ps.get_characters(characters_path)
    current_character = get_current_player(character_list, character_name)
    current_character['bomb_used'] = str(
        int(current_character["bomb_used"]) + 1)
    ps.export_characters(characters_path, character_list)
    time.sleep(2)
    my_map = ps.get_map(map_path)
    my_map[state[0]][state[1]] = my_map[state[0]][state[1]].replace(
        (',0' + str(user_id)), (',M' + str(user_id)), 1)
    explosion_placement(0, 1, current_character, state, user_id, 'R', my_map)
    explosion_placement(0, -1, current_character, state, user_id, 'L', my_map)
    explosion_placement(1, 0, current_character, state, user_id, 'D', my_map)
    explosion_placement(-1, 0, current_character, state, user_id, 'U', my_map)
    ps.export_map(map_path, my_map)
    bomb_delete_animation(state, user_id, character_name)
Ejemplo n.º 4
0
def initialize_my_map():
    ps.export_map(map_path, original_map)