# Buggy code
def open_technique_menu(self):
    """Open menus to choose a Technique to use

    :return: None
    """

    def choose_technique():
        # open menu to choose technique
        menu = self.game.push_state("Menu")
        menu.shrink_to_items = True

        # add techniques to the menu
        for tech in self.monster.moves:
            image = self.shadow_text(tech.name_trans)
            item = MenuItem(image, None, None, tech)
            menu.add(item)

        # position the new menu
        menu.anchor("bottom", self.rect.top)
        menu.anchor("right", self.game.screen.get_rect().right)

        # set next menu after after selection is made
        menu.on_menu_selection = choose_target

    def choose_target(menu_item):
        # open menu to choose target of technique
        technique = menu_item.game_object
        state = self.game.push_state("CombatTargetMenuState")
        state.on_menu_selection = partial(enqueue_technique, technique)

    def enqueue_technique(technique, menu_item):
        # enqueue the technique
        target = menu_item.game_object
        combat_state = self.game.get_state_name("CombatState")
        combat_state.enqueue_action(self.monster, technique, target)

        # close all the open menus
        self.game.pop_state()  # close target chooser
        self.game.pop_state()  # close technique menu
        self.game.pop_state()  # close the monster action menu

    choose_technique()


# Traceback (KeyError)
Traceback (most recent call last):
File "./tuxemon.py", line 60, in <module>
main()
File "/tmp/Tuxemon/tuxemon/core/main.py", line 109, in main
control.main()
File "/tmp/Tuxemon/tuxemon/core/control.py", line 512, in main
self.main_loop()
File "/tmp/Tuxemon/tuxemon/core/control.py", line 573, in main_loop
self.update(time_delta)
File "/tmp/Tuxemon/tuxemon/core/control.py", line 203, in update
state.update(dt)
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 156, in update
self.update_phase()
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 328, in update_phase
self.handle_action_queue()
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 338, in handle_action_queue
self.check_party_hp()
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 614, in check_party_hp
self.faint_monster(monster)
File "/tmp/Tuxemon/tuxemon/core/states/combat/combat.py", line 581, in faint_monster
awarded_exp = monster.total_experience/monster.level/len(self._damage_map[monster])
KeyError: <core.components.monster.Monster object at 0x7fb24236ddd0>

# Fixed code
def open_technique_menu(self):
    """Open menus to choose a Technique to use

    :return: None
    """

    def choose_technique():
        # open menu to choose technique
        menu = self.game.push_state("Menu")
        menu.shrink_to_items = True

        # add techniques to the menu
        for tech in self.monster.moves:
            image = self.shadow_text(tech.name)
            item = MenuItem(image, None, None, tech)
            menu.add(item)

        # position the new menu
        menu.anchor("bottom", self.rect.top)
        menu.anchor("right", self.game.screen.get_rect().right)

        # set next menu after after selection is made
        menu.on_menu_selection = choose_target

    def choose_target(menu_item):
        # open menu to choose target of technique
        technique = menu_item.game_object
        state = self.game.push_state("CombatTargetMenuState")
        state.on_menu_selection = partial(enqueue_technique, technique)

    def enqueue_technique(technique, menu_item):
        # enqueue the technique
        target = menu_item.game_object
        combat_state = self.game.get_state_name("CombatState")
        combat_state.enqueue_action(self.monster, technique, target)

        # close all the open menus
        self.game.pop_state()  # close target chooser
        self.game.pop_state()  # close technique menu
        self.game.pop_state()  # close the monster action menu

    choose_technique()