def test_move_on_friendly_far(self): m = Map(3, 10) m.generate_from_ascii("models/maps/corridor.txt") g = GreaserUnit(0, 0, m, CONST.jets) g1 = GreaserUnit(0, 5, m, CONST.jets) assert (not g.move(0, 5)) assert (g.move(0, 4))
def test_bruiser_special_collide(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") s = GreaserUnit(8, 3, m, CONST.sharks) g = GreaserUnit(8, 4, m, CONST.sharks) b = BruiserUnit(8, 5, m, CONST.jets) assert (b.special_attack(8, 4)) assert (m.unit_at(8, 3) is s)
def test_recreate_astar_no_path_bug(self): m = Map(32, 18) m.generate_from_ascii("models/maps/TheBlock.txt") g1 = GreaserUnit(12, 11, m, CONST.jets) g3 = GreaserUnit(15, 11, m, CONST.sharks) g4 = GreaserUnit(14, 12, m, CONST.sharks) b1 = BruiserUnit(16, 12, m, CONST.sharks) s3 = SquabblerUnit(15, 13, m, CONST.sharks) g1.valid_moves()
def quick_board_32_18(self): unit4 = GreaserUnit(12, 6, self, CONST.jets) unit5 = SquabblerUnit(14, 4, self, CONST.jets) unit6 = GreaserUnit(13, 5, self, CONST.jets) unit7 = SquabblerUnit(17,6, self, CONST.jets) unit8 = BruiserUnit(18,6,self,CONST.jets) unit1 = GreaserUnit(12, 15, self, CONST.sharks) unit2 = BruiserUnit(13, 16, self, CONST.sharks) unit3 = SquabblerUnit(16, 16, self, CONST.sharks) unit9 = BruiserUnit(17, 14,self,CONST.sharks) uni10 = GreaserUnit(14, 14, self, CONST.sharks)
def test_simple_move(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") g = GreaserUnit(4, 4, m, CONST.jets) assert (g.move(5, 4)) assert (g.x == 5 and g.y == 4) assert (m.unit_at(5, 4) is g)
def testMoveAroundEnemy(self): m = Map(3, 10) m.generate_from_ascii("models/maps/corridor.txt") g = GreaserUnit(1, 2, m, CONST.jets) b1 = BruiserUnit(2, 3, m, CONST.sharks) ##blocked by teammate b2 = BruiserUnit(1, 3, m, CONST.sharks) ##blocked by teammate assert (g.move(1, 4))
def test_piece_at(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") g = GreaserUnit(2, 2, m, CONST.jets) assert (m.unit_at(2, 2) == g) m.delete_unit(g) assert (m.unit_at(2, 2) == None)
def test_squabbler_special(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") s = SquabblerUnit(8, 3, m, CONST.jets) g = GreaserUnit(8, 4, m, CONST.sharks) gw = g.wit s.special_attack(8, 4) assert (g.demoralize)
def testAttackSimple(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") g = GreaserUnit(8, 3, m, CONST.jets) b = BruiserUnit(8, 4, m, CONST.sharks) ##blocked by teammate s = b.hp assert (g.attack(8, 4)) assert (b.hp < s)
def test_a_star_long_blocked_by_enemy(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10funnel.txt") start = m.tile_matrix[4][1] end = m.tile_matrix[4][7] g = GreaserUnit(4, 4, m, CONST.sharks) #shark blocking the path path = m.a_star(start, end, CONST.jets, limit=20) assert (len(path) == 0)
def testMoveThroughFriendly(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10funnel.txt") g = GreaserUnit(4, 3, m, CONST.jets) b = BruiserUnit(4, 4, m, CONST.jets) ##blocked by teammate assert (g.move(4, 6)) assert (g.x == 4 and g.y == 6) assert (m.unit_at(4, 6) is g)
def test_greaser_special(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") s = SquabblerUnit(8, 3, m, CONST.jets) g = GreaserUnit(8, 4, m, CONST.sharks) b = BruiserUnit(8, 5, m, CONST.jets) bh = b.hp sh = s.hp assert (g.special_attack(8, 5)) assert (bh > b.hp and sh > s.hp)
def test_greaser(self): n = Map(6, 4) n.generate_from_ascii("models/maps/6by4.txt") g = GreaserUnit(2, 2, n, CONST.jets) assert (g.max_hp >= CONST.greaser_min_hp & g.max_hp <= CONST.greaser_max_hp) assert (g.finesse >= CONST.greaser_min_finesse & g.finesse <= CONST.greaser_max_finesse) assert (g.x == 2 & g.y == 2) assert (g.team == CONST.jets)
def test_a_star_long_blocked_by_friendly(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10funnel.txt") start = m.tile_matrix[4][1] end = m.tile_matrix[4][7] g = GreaserUnit(4, 4, m, CONST.jets) path = m.a_star(start, end, CONST.jets, limit=20) for tile in path: assert (m.can_go_through(tile.x, tile.y, CONST.jets)) assert (path[0] == start) assert (path[len(path) - 1] == end)
def test_add_remove_unit(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") g = GreaserUnit(2, 2, m, CONST.jets) assert (m.tile_matrix[2][2].is_occupied) assert (not m.tile_matrix[3][3].is_occupied) b = BruiserUnit(3, 3, m, CONST.jets) assert (m.tile_matrix[3][3].is_occupied) s = SquabblerUnit(4, 4, m, CONST.jets) assert (m.tile_matrix[4][4].is_occupied) m.delete_unit(g) assert (not m.tile_matrix[2][2].is_occupied) m.delete_unit(b) assert (not m.tile_matrix[3][3].is_occupied) m.delete_unit(s) assert (not m.tile_matrix[4][4].is_occupied)
def test_can_go_through_unit(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") g = GreaserUnit(4, 5, m, CONST.jets) assert (m.can_go_through(4, 5, CONST.jets)) assert (not m.can_go_through(4, 5, CONST.sharks))
def test_is_enemy_occupied(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10.txt") g = GreaserUnit(2, 2, m, CONST.jets) assert (m.is_enemy_occupied(2, 2, CONST.sharks)) assert (not m.is_enemy_occupied(2, 2, CONST.jets))
def test_a_star_issue(self): m = Map(32, 18) m.generate_from_ascii("models/maps/32by18.txt") g = GreaserUnit(4, 10, m, CONST.jets) g.move(0, 10)
def test_rout(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10funnel.txt") g = GreaserUnit(8, 4, m, CONST.jets) assert (not m.jets_routed()) assert (m.sharks_routed())
def test_valid_moves(self): m = Map(32, 18) m.generate_from_ascii("models/maps/32by18.txt") g = GreaserUnit(4, 10, m, CONST.jets) g.valid_moves()
def testMoveTooFar(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10funnel.txt") g = GreaserUnit(8, 1, m, CONST.jets) assert (not g.move(1, 6)) assert (g.move(6, 3))
def testMoveThroughEnemy(self): m = Map(10, 10) m.generate_from_ascii("models/maps/10by10funnel.txt") g = GreaserUnit(8, 3, m, CONST.jets) b = BruiserUnit(8, 4, m, CONST.sharks) ##blocked by teammate assert (not g.move(8, 5))