def main(): with open('sample_map.yaml') as f: data = yaml.load(f) map = Map(data) input_object = Input(read_line=input, put_line=print) game = Game(data = map) input_object.put_line(game.start()) while True: read = input_object.next_move() if read: move, args = read response = getattr(game, move)(*args) input_object.put_line(response)
def test_look(self): result = [] input = Input(self.__make_input(['look']), self.__make_output(result)) self.assertEqual(input.next_move(), ("look", []))
def test_move(self): result = [] input = Input(self.__make_input(['move north']), self.__make_output(result)) self.assertEqual(input.next_move(), ("move", ['north']))
def test_wrong_input(self): result = [] input = Input(self.__make_input(['dupa']), self.__make_output(result)) self.assertEqual(input.next_move(), None) self.assertEqual(result, ['Wrong move. Try: look.'])