def player_steal_resource(player,robber_tile,app):
    """Prompts player for which player they would like to steal from"""
    from catan_logic import get_stealable_players

    clear_resource_panel(app)
    draw_resource_panel(player,app)

    # Skip this step if there is nobody to steal from
    stealable_players = get_stealable_players(player,robber_tile,app)
    if len(stealable_players)==0:
        return

    app.button_chosen.set(-1)
    while app.button_chosen.get()!=0 or \
        app.displays.steal_choice.get()=="Choose a player to steal from":
        app.board_canvas.wait_variable(app.button_chosen)
    app.button_chosen.set(-1)

    target_player_name = app.displays.steal_choice.get()
    for guy in app.pieces.players:
        if guy.name==target_player_name:
            target_player = guy
            break
    target_resources = []
    for i in range(target_player.wood):
        target_resources.append("wood")
    for i in range(target_player.brick):
        target_resources.append("brick")
    for i in range(target_player.sheep):
        target_resources.append("sheep")
    for i in range(target_player.wheat):
        target_resources.append("wheat")
    for i in range(target_player.stone):
        target_resources.append("stone")
    stolen_resource = choice(target_resources)
    if stolen_resource=="wood":
        target_player.wood -= 1
        player.wood += 1
    if stolen_resource=="brick":
        target_player.brick -= 1
        player.brick += 1
    if stolen_resource=="sheep":
        target_player.sheep -= 1
        player.sheep += 1
    if stolen_resource=="wheat":
        target_player.wheat -= 1
        player.wheat += 1
    if stolen_resource=="stone":
        target_player.stone -= 1
        player.stone += 1

    write_log(app,player.name,"stole a resource from",target_player.name)
def draw_steal_screen(player,app):
    from catan_logic import get_stealable_players

    draw_resources(player,app)

    for tile in app.pieces.tiles:
        if tile.has_robber:
            robber_tile = tile
            break
    stealable_players = get_stealable_players(player,robber_tile,app)
    if len(stealable_players)==0:
        return
    player_options = []
    for guy in stealable_players:
        player_options.append(guy.name)

    app.board_canvas.create_text(
        int((app.style.hex_x_off-app.style.water_width)*5/10),
        int(app.style.win_height*.4+4*app.style.txt_size),
        text="Take a resource from:",
        font=(app.style.txt_font,int(.8*app.style.txt_size)), tags="steal")
    app.displays.steal_choice.set("Choose a player to steal from")
    player_choice_menu = OptionMenu(app.board_canvas, app.displays.steal_choice,
        *player_options)
    app.displays.add_object(player_choice_menu)
    app.board_canvas.create_window(
        int((app.style.hex_x_off-app.style.water_width)*5/10),
        int(app.style.win_height*.4+6*app.style.txt_size),
        window=player_choice_menu, tags="steal")
    steal_button = Button(app.board_canvas,
        font=(app.style.txt_font,int(.8*app.style.txt_size)), text="Steal",
        command=lambda : app.set_button_chosen(0))
    steal_button.configure(width=10, height=1, padx=0, pady=0)
        #background=inactive_button_color, activebackground=active_button_color)
    app.displays.add_object(steal_button)
    app.board_canvas.create_window(
        int((app.style.hex_x_off-app.style.water_width)*5/10),
        int(app.style.win_height*.4+9*app.style.txt_size),
        window=steal_button, tags="steal")