<s> """<STR_LIT>""" <EOL> from herculeum . ui . controllers import InventoryController <EOL> from pyherc . aspects import log_debug , log_info <EOL> class InventoryScreen ( ) : <EOL> """<STR_LIT>""" <EOL> @ log_debug <EOL> def __init__ ( self , character , config , screen , action_factory , <EOL> parent ) : <EOL> """<STR_LIT>""" <EOL> super ( InventoryScreen , self ) . __init__ ( ) <EOL> self . character = character <EOL> self . config = config <EOL> self . screen = screen . subwin ( <NUM_LIT:20> , <NUM_LIT> , <NUM_LIT:2> , <NUM_LIT:2> ) <EOL> self . inventory_controller = InventoryController ( character , <EOL> action_factory ) <EOL> self . parent = parent <EOL> self . keys = [ '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' , '<STR_LIT:d>' , '<STR_LIT:e>' , '<STR_LIT:f>' , '<STR_LIT:g>' , '<STR_LIT:h>' , '<STR_LIT:i>' , '<STR_LIT>' , <EOL> '<STR_LIT:k>' , '<STR_LIT:l>' , '<STR_LIT:m>' , '<STR_LIT:n>' , '<STR_LIT:o>' , '<STR_LIT:p>' , '<STR_LIT:q>' , '<STR_LIT:r>' , '<STR_LIT:s>' , '<STR_LIT:t>' , <EOL> '<STR_LIT:u>' , '<STR_LIT:v>' , '<STR_LIT:w>' , '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' , '<STR_LIT:A>' , '<STR_LIT:B>' , '<STR_LIT:C>' , '<STR_LIT:D>' ] <EOL> @ log_debug <EOL> def _draw_screen ( self ) : <EOL> """<STR_LIT>""" <EOL> self . screen . clear ( ) <EOL> self . screen . border ( ) <EOL> for index , item in enumerate ( self . character . inventory ) : <EOL> if index < <NUM_LIT:15> : <EOL> column = <NUM_LIT:1> <EOL> row = <NUM_LIT:1> + index <EOL> else : <EOL> column = <NUM_LIT> <EOL> row = <NUM_LIT:1> + index - <NUM_LIT:15> <EOL> self . screen . addstr ( row , column , <EOL> '<STR_LIT>' . format ( self . keys [ index ] , <EOL> item . get_name ( self . character , <EOL> True ) ) ) <EOL> self . screen . refresh ( ) <EOL> @ log_info <EOL> def show ( self ) : <EOL> """<STR_LIT>""" <EOL> running = <NUM_LIT:1> <EOL> self . _draw_screen ( ) <EOL> while running == <NUM_LIT:1> : <EOL> item = None <EOL> key = chr ( self . screen . getch ( ) ) <EOL> if key in [ '<STR_LIT:u>' , '<STR_LIT:r>' , '<STR_LIT:d>' , '<STR_LIT:i>' ] : <EOL> self . screen . addstr ( <NUM_LIT:0> , <NUM_LIT:2> , '<STR_LIT>' ) <EOL> item_key = chr ( self . screen . getch ( ) ) <EOL> if item_key in self . keys : <EOL> index = self . keys . index ( item_key ) <EOL> if index < len ( self . character . inventory ) : <EOL> item = self . character . inventory [ index ] <EOL> if item is not None : <EOL> if key == '<STR_LIT:u>' : <EOL> self . inventory_controller . use_item ( item ) <EOL> elif key == '<STR_LIT:r>' : <EOL> self . inventory_controller . unequip_item ( item ) <EOL> elif key == '<STR_LIT:d>' : <EOL> self . inventory_controller . drop_item ( item ) <EOL> elif key == '<STR_LIT:i>' : <EOL> self . screen . border ( ) <EOL> self . screen . addstr ( <NUM_LIT:0> , <NUM_LIT:2> , '<STR_LIT>' ) <EOL> self . screen . refresh ( ) <EOL> self . _show_detailed_info ( item , self . character ) <EOL> elif key == '<STR_LIT:U+0020>' : <EOL> running = <NUM_LIT:0> <EOL> self . _draw_screen ( ) <EOL> self . parent . refresh ( ) <EOL> @ log_debug <EOL> def _show_detailed_info ( self , item , character ) : <EOL> """<STR_LIT>""" <EOL> new_screen = self . screen . derwin ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> new_screen . clear ( ) <EOL> new_screen . addstr ( <NUM_LIT:0> , <NUM_LIT:0> , self . inventory_controller . item_description ( item ) ) <EOL> new_screen . refresh ( ) <EOL> chr ( new_screen . getch ( ) ) </s>
