<s> """<STR_LIT>""" <EOL> from pyherc . aspects import log_debug <EOL> from pyherc . data . level import get_characters <EOL> from pyherc . events import e_level <EOL> ESCAPED_DUNGEON = <NUM_LIT:1> <EOL> DIED_IN_DUNGEON = <NUM_LIT:2> <EOL> class Model ( ) : <EOL> """<STR_LIT>""" <EOL> @ log_debug <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . __init__ ( ) <EOL> self . dungeon = None <EOL> self . player = None <EOL> self . config = None <EOL> self . tables = None <EOL> self . __event_listeners = [ ] <EOL> self . end_condition = <NUM_LIT:0> <EOL> @ log_debug <EOL> def register_event_listener ( self , listener ) : <EOL> """<STR_LIT>""" <EOL> assert listener is not None <EOL> self . __event_listeners . append ( listener ) <EOL> @ log_debug <EOL> def get_event_listeners ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . __event_listeners [ : ] <EOL> @ log_debug <EOL> def raise_event ( self , event ) : <EOL> """<STR_LIT>""" <EOL> level = e_level ( event ) <EOL> if self . player : <EOL> self . player . receive_event ( event ) <EOL> for listener in self . __event_listeners : <EOL> listener . receive_event ( event ) <EOL> def get_next_creature ( self , rules_engine ) : <EOL> """<STR_LIT>""" <EOL> level = self . player . level <EOL> if level is None : <EOL> return None <EOL> creatures = list ( get_characters ( level ) ) <EOL> while <NUM_LIT:1> : <EOL> for creature in creatures : <EOL> if creature . tick <= <NUM_LIT:0> : <EOL> return creature <EOL> for creature in creatures : <EOL> creature . tick = creature . tick - <NUM_LIT:1> <EOL> for effect in creature . get_effects ( ) : <EOL> if effect . tick is not None : <EOL> effect . tick = effect . tick - <NUM_LIT:1> <EOL> if effect . tick <= <NUM_LIT:0> : <EOL> effect . trigger ( rules_engine . dying_rules ) <EOL> creature . remove_expired_effects ( ) <EOL> for skill , limit in creature . cooldowns . items ( ) : <EOL> if limit > <NUM_LIT:0> : <EOL> creature . cooldowns [ skill ] = limit - <NUM_LIT:1> <EOL> class Damage ( ) : <EOL> """<STR_LIT>""" <EOL> @ log_debug <EOL> def __init__ ( self , amount = <NUM_LIT:0> , damage_type = '<STR_LIT>' , magic_bonus = <NUM_LIT:0> ) : <EOL> super ( ) . __init__ ( ) <EOL> self . amount = amount <EOL> self . damage_type = damage_type <EOL> self . magic_bonus = magic_bonus <EOL> class MimicData ( ) : <EOL> """<STR_LIT>""" <EOL> @ log_debug <EOL> def __init__ ( self , character ) : <EOL> super ( ) . __init__ ( ) <EOL> self . fov_matrix = [ ] <EOL> self . character = character <EOL> @ log_debug <EOL> def get_character ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . character <EOL> @ log_debug <EOL> def set_character ( self , character ) : <EOL> """<STR_LIT>""" <EOL> self . character = character </s>
