<s> import graphics as gfx <EOL> import life as lfe <EOL> import scripting <EOL> import numbers <EOL> import items <EOL> def get_items_for_crafting ( life ) : <EOL> return [ i for i in life [ '<STR_LIT>' ] if '<STR_LIT>' in items . get_item_from_uid ( i ) ] <EOL> def get_recipe_difficulty ( life , item , recipe ) : <EOL> _difficulty = <NUM_LIT:0> <EOL> for skill in recipe [ '<STR_LIT>' ] : <EOL> if skill in life [ '<STR_LIT>' ] : <EOL> _difficulty += recipe [ '<STR_LIT>' ] [ skill ] - life [ '<STR_LIT>' ] [ skill ] <EOL> return _difficulty <EOL> def meets_requirements ( life , requirements ) : <EOL> return True <EOL> def perform_recipe ( life , item , recipe ) : <EOL> lfe . add_action ( life , { '<STR_LIT:action>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : item [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : item [ '<STR_LIT>' ] . index ( recipe ) } , <EOL> <NUM_LIT> , <EOL> delay = recipe [ '<STR_LIT:time>' ] ) <EOL> def execute_recipe ( life , item , recipe ) : <EOL> _difficulty = get_recipe_difficulty ( life , item , recipe ) <EOL> _dice_percentage = numbers . roll ( <NUM_LIT:2> , <NUM_LIT:5> ) / ( <NUM_LIT> + _difficulty ) <EOL> if _dice_percentage >= <NUM_LIT> : <EOL> _recipe_quality = '<STR_LIT:success>' <EOL> elif _dice_percentage >= <NUM_LIT> : <EOL> _recipe_quality = '<STR_LIT>' <EOL> else : <EOL> _recipe_quality = '<STR_LIT>' <EOL> if recipe [ '<STR_LIT:type>' ] == '<STR_LIT>' : <EOL> for create_item in recipe [ '<STR_LIT>' ] : <EOL> if not _recipe_quality in recipe [ '<STR_LIT>' ] [ create_item ] : <EOL> continue <EOL> for i in range ( recipe [ '<STR_LIT>' ] [ create_item ] [ _recipe_quality ] [ '<STR_LIT>' ] ) : <EOL> _created_item = items . create_item ( create_item ) <EOL> lfe . add_item_to_inventory ( life , _created_item ) <EOL> if _recipe_quality in recipe [ '<STR_LIT>' ] : <EOL> gfx . message ( recipe [ '<STR_LIT>' ] [ _recipe_quality ] ) <EOL> else : <EOL> gfx . message ( '<STR_LIT>' ) </s>
