Esempio n. 1
0
    def test_should_initialize_game_with_light_of_power_and_thor(self):
        thor = Thor(10, 20)
        light_of_power = LightOfPower(15, 2)

        self.game = Game(thor, light_of_power)

        self.assertEqual(thor, self.game.thor)
        self.assertEqual(light_of_power, self.game.light_of_power)
Esempio n. 2
0
    def test_should_pick_south_east_when_light_of_power_is_below_and_diagonally_aligned_to_the_right_with_thor(self):
        pos_x, pos_y, expected_direction = 5, 1, "SE"
        light_of_power = LightOfPower(13, 5)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Esempio n. 3
0
    def test_should_pick_south_when_light_of_power_is_below_and_aligned_vertically_with_thor(self):
        pos_x, pos_y, expected_direction = 6, 30, "S"
        light_of_power = LightOfPower(6, 40)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Esempio n. 4
0
    def test_should_pick_west_when_light_of_power_is_behind_and_aligned_horizontally_with_thor(self):
        pos_x, pos_y, expected_direction = 10, 0, "W"
        light_of_power = LightOfPower(6, 0)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Esempio n. 5
0
    def test_should_decrease_thors_position_in_y_when_heading_south(self):
        pos_x, pos_y, expected_pos_y = 4, 10, 11
        light_of_power = LightOfPower(15, 2)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        self.game.move("S")

        self.assertEqual(expected_pos_y, self.game.thor.pos_y)
Esempio n. 6
0
    def test_should_increase_thors_position_in_x_when_heading_east(self):
        pos_x, pos_y, expected_pos_x = 4, 10, 5
        light_of_power = LightOfPower(15, 2)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        self.game.move("E")

        self.assertEqual(expected_pos_x, self.game.thor.pos_x)
Esempio n. 7
0
    def test_should_pick_north_west_when_light_of_power_is_above_and_diagonally_aligned_to_the_left_with_thor(self):
        pos_x, pos_y, expected_direction = 15, 15, "NW"
        light_of_power = LightOfPower(7, 7)
        self.thor = Thor(pos_x, pos_y)
        self.game = Game(self.thor, light_of_power)

        computed_move = self.game.compute_move()

        self.assertEqual(expected_direction, computed_move)
Esempio n. 8
0
def main():
    light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()]
    light_of_power = LightOfPower(light_x, light_y)
    thor = Thor(initial_tx, initial_ty)
    game = Game(thor, light_of_power)

    while True:
        remaining_turns = int(input())
        if remaining_turns >= 0:
            direction = game.compute_move()

            print(direction)
            game.move(direction)
Esempio n. 9
0
def hero_sprites():

    global heroes
    global widow
    global cap
    global tony
    global thor
    global hawkeye
    global hulk
    widow = Widow()
    cap = Cap()
    tony = Tony()
    thor = Thor()
    hawkeye = Hawkeye()
    hulk = Hulk()
    heroes = pygame.sprite.Group()
    heroes.add(cap)
    heroes.add(widow)
    heroes.add(tony)
    heroes.add(thor)
    heroes.add(hawkeye)
    heroes.add(hulk)
Esempio n. 10
0
	def run(self):
		while True:
			server=Thor(SERVER,PORT,HOST)
			server.run()