def setNextAction(self, key_event=None, logic_event=None): ''' Interface with logic module to get next course of action. ''' print 'key event: {}, logic event: {}'.format(key_event, logic_event) if key_event is not None: logic_event = logic.execute(self, key_event.keysym) if logic_event in ['Up', 'Down', 'Left', 'Right']: self.setDestination(self.getDestination(logic_event)) elif logic_event == 'E' or logic_event == 'R': self.game_ended = True
def move(self): ''' Update XY coordinates base on set velocity ''' self.XY_coord[0] += self.x_vel self.XY_coord[1] += self.y_vel # sets destination to None when it has reached # then resets velocity and finally interfaces with the logic # module (to update the logic module with its new location) if self.isAtDestination(): self.grid_coord = self.dest_grid_coord # update grid coordinate self.resetDestination() self.setVel() self.setNextAction(logic_event=logic.execute(self))
def restartLevel(self): ''' Reset all the coordinates ''' self.grid_coord = self.starting_grid_coord self.XY_coord = self.starting_XY_coord[:] self.game_ended = False self.setNextAction(logic_event=logic.execute(self))
def execute_action(self): val = logic.execute(self.command.get()) if val: self.v.set(val) else: self.v.set("")
def test_it_shold_return_None_with_None_input(self): self.assertFalse(logic.execute(""))
def test_it_should_return_None_with_empty_input_string(self): self.assertFalse(logic.execute(""))
def execute(container_uuid, command): logic.execute(container_uuid=container_uuid, command=command, output_handler=click.echo)