<s> from globals import WORLD_INFO , SETTINGS , LIFE , ITEMS <EOL> import life as lfe <EOL> import numbers <EOL> import alife <EOL> import logging <EOL> def get_player_situation ( ) : <EOL> if not SETTINGS [ '<STR_LIT>' ] : <EOL> return False <EOL> _life = LIFE [ SETTINGS [ '<STR_LIT>' ] ] <EOL> _situation = { } <EOL> _situation [ '<STR_LIT>' ] = alife . combat . has_potentially_usable_weapon ( _life ) <EOL> _situation [ '<STR_LIT>' ] = len ( [ l for l in _life [ '<STR_LIT>' ] . values ( ) if l [ '<STR_LIT>' ] in [ '<STR_LIT>' , '<STR_LIT>' ] ] ) <EOL> _situation [ '<STR_LIT>' ] = _life [ '<STR_LIT>' ] <EOL> _situation [ '<STR_LIT>' ] = [ l for l in LIFE . values ( ) if l [ '<STR_LIT>' ] and not l [ '<STR_LIT>' ] and not l [ '<STR_LIT:id>' ] == _life [ '<STR_LIT:id>' ] ] <EOL> _situation [ '<STR_LIT>' ] = [ l for l in _situation [ '<STR_LIT>' ] if alife . judgement . can_trust ( _life , l [ '<STR_LIT:id>' ] ) ] <EOL> _situation [ '<STR_LIT>' ] = len ( lfe . get_all_inventory_items ( _life , matches = [ { '<STR_LIT:type>' : '<STR_LIT>' } ] ) ) > <NUM_LIT:0> <EOL> _situation [ '<STR_LIT>' ] = alife . combat . get_weapons ( _life ) <EOL> _situation [ '<STR_LIT>' ] = lfe . get_all_equipped_items ( _life ) <EOL> return _situation <EOL> def get_group_leader_with_motive ( group_motive , online = False ) : <EOL> for life in LIFE . values ( ) : <EOL> if not ( life [ '<STR_LIT>' ] or not online ) or not life [ '<STR_LIT>' ] or not alife . groups . is_leader ( life , life [ '<STR_LIT>' ] , life [ '<STR_LIT:id>' ] ) or SETTINGS [ '<STR_LIT>' ] == life [ '<STR_LIT:id>' ] : <EOL> continue <EOL> if alife . groups . get_motive ( life , life [ '<STR_LIT>' ] ) == group_motive : <EOL> return life [ '<STR_LIT:id>' ] <EOL> return None <EOL> def handle_tracked_alife ( ) : <EOL> for ai in [ LIFE [ i ] for i in WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] ] : <EOL> if ai [ '<STR_LIT>' ] : <EOL> continue <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] . remove ( ai [ '<STR_LIT:id>' ] ) <EOL> logging . debug ( '<STR_LIT>' % '<STR_LIT:U+0020>' . join ( ai [ '<STR_LIT:name>' ] ) ) <EOL> def get_overwatch_hardship ( no_mod = True ) : <EOL> _stats = WORLD_INFO [ '<STR_LIT>' ] <EOL> _situation = get_player_situation ( ) <EOL> if not _situation : <EOL> return <NUM_LIT:0> <EOL> if no_mod : <EOL> _mod = <NUM_LIT:1> <EOL> else : <EOL> if len ( _situation [ '<STR_LIT>' ] ) == len ( _situation [ '<STR_LIT>' ] ) : <EOL> _mod = _stats [ '<STR_LIT>' ] / float ( WORLD_INFO [ '<STR_LIT>' ] ) <EOL> else : <EOL> _mod = numbers . clip ( ( _stats [ '<STR_LIT>' ] * <NUM_LIT> ) / float ( WORLD_INFO [ '<STR_LIT>' ] ) , <NUM_LIT:0> , <NUM_LIT:1.0> ) <EOL> _hardship = _stats [ '<STR_LIT>' ] <EOL> _hardship += _stats [ '<STR_LIT>' ] <EOL> _hardship += _stats [ '<STR_LIT>' ] <EOL> _hardship += _stats [ '<STR_LIT>' ] * <NUM_LIT:4> <EOL> _hardship *= _mod <EOL> return numbers . clip ( float ( _hardship ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def get_overwatch_success ( ) : <EOL> _stats = WORLD_INFO [ '<STR_LIT>' ] <EOL> _situation = get_player_situation ( ) <EOL> if not _situation : <EOL> return <NUM_LIT:0> <EOL> _success = len ( _situation [ '<STR_LIT>' ] ) <EOL> _success += _stats [ '<STR_LIT>' ] <EOL> return numbers . clip ( float ( _success ) , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def evaluate_overwatch_mood ( ) : <EOL> _stats = WORLD_INFO [ '<STR_LIT>' ] <EOL> _hardship = get_overwatch_hardship ( no_mod = True ) <EOL> _success = get_overwatch_success ( ) <EOL> _hardship_rate = _hardship / <NUM_LIT> <EOL> _success_rate = _success / <NUM_LIT> <EOL> _activity = _stats [ '<STR_LIT>' ] / float ( WORLD_INFO [ '<STR_LIT>' ] ) <EOL> _difficulty = numbers . clip ( _hardship_rate - _success_rate , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> if _activity > numbers . clip ( _success_rate , <NUM_LIT> , <NUM_LIT> ) : <EOL> _stats [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> elif _success_rate < <NUM_LIT> : <EOL> _stats [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> elif _success_rate > _hardship_rate : <EOL> _stats [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> _stats [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def record_intervention ( amount ) : <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] += amount <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] = WORLD_INFO [ '<STR_LIT>' ] <EOL> logging . debug ( '<STR_LIT>' % amount ) <EOL> def record_encounter ( amount , life_ids = None ) : <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] += amount <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] = WORLD_INFO [ '<STR_LIT>' ] <EOL> if life_ids : <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] . extend ( life_ids ) <EOL> logging . debug ( '<STR_LIT>' % amount ) <EOL> def record_dangerous_event ( amount ) : <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] += amount <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] = WORLD_INFO [ '<STR_LIT>' ] <EOL> logging . debug ( '<STR_LIT>' % amount ) <EOL> def record_loss ( amount ) : <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] += amount <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] = WORLD_INFO [ '<STR_LIT>' ] <EOL> logging . debug ( '<STR_LIT>' % amount ) <EOL> def record_injury ( amount ) : <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] += amount <EOL> WORLD_INFO [ '<STR_LIT>' ] [ '<STR_LIT>' ] = WORLD_INFO [ '<STR_LIT>' ] <EOL> logging . debug ( '<STR_LIT>' % amount ) </s>
