<s> """<STR_LIT>""" <EOL> from pyherc . ports import is_move_legal , move , attack <EOL> from pyherc . data import get_character <EOL> class MoveController ( ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , action_factory , rng ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . __init__ ( ) <EOL> self . action_factory = action_factory <EOL> self . rng = rng <EOL> def move_or_attack ( self , character , direction ) : <EOL> """<STR_LIT>""" <EOL> level = character . level <EOL> if is_move_legal ( character , <EOL> direction ) : <EOL> move ( character , direction ) <EOL> elif direction != <NUM_LIT:9> : <EOL> loc = character . get_location_at_direction ( direction ) <EOL> if get_character ( level , loc ) is not None : <EOL> attack ( character , <EOL> direction , <EOL> self . rng ) </s>
