def testSupermanSkill1(self): self.game.units[25] = unit.UnitObject(25, 0, "superman", (100, 100), self.game.buff) self.game.units[26] = unit.UnitObject(26, 1, "bolt_tank", (101, 100), self.game.buff) order = ["superman_skill1", 25, 26] self.testOrders.clear() self.testOrders.append(order) ehn = 500 - calculateInjure(15, 100) self.assertEqual(self.game.units[26].health_now, ehn) # superman attack bolt tank through skill1
def setUp(self): self.test_obj = gamemain.GameMain() # __init__()写好后加入参数 self.test_obj.units[0] = unit.UnitObject(0, 0, 'meat', (1, 2), test_buff) # 加入一个编号为0的单位 self.test_obj.units[1] = unit.UnitObject(1, 1, 'meat', (1, 2), test_buff) self.test_obj.units[2] = unit.UnitObject(2, 1, 'meat', (1, 2), test_buff) self.test_obj.units[3] = unit.UnitObject(3, 0, 'superman', (1, 2), test_buff) self.test_obj.buildings[0] = unit.UnitObject(99, 2, 'hack_lab', (1, 1), test_buff)
def test_move_to_building(self): # 非法移动测试 for building in self.test_obj.buildings: if building.Get_type_name() == 'base': building.position = (50, 50) if building.Get_unit_type() == 4: building.position = (48, 50) self.test_obj.units[101] = unit.UnitObject(100, 0, 'meat', (49, 50), test_buff) self.test_obj.units[102] = unit.UnitObject(101, 0, 'meat', (49, 50), test_buff) self.test_obj.move_instr_0.append([101, 50, 50]) self.test_obj.move_instr_0.append([102, 49, 50]) self.test_obj.move_phase() self.assertTrue(self.test_obj.units[101].position != (50, 50)) self.assertTrue(self.test_obj.units[102].position != (48, 50))
def setUp(self): self.test_obj = gamemain.GameMain() # __init__()写好后加入参数 self.test_obj.units[100] = unit.UnitObject(100, 0, 'meat', (1, 1), test_buff) # 加入一个编号为0的单位 self.test_obj.units[101] = unit.UnitObject(101, 0, 'eagle', (1, 1), test_buff)
def setUp(self): self.orders = [["bolt_tank_skill1", 1, 12], #0 ["bolt_tank_skill1", 1, 8], #1 ["bolt_tank_skill1", 1, 10], #2 ["hacker_skill1", 2, 12], #3 ["uav", 5, 10], #4 ["battle_tank_skill1", 3, 10], #5 ["nuke_tank_skill1", 16, 8], #6 ["nuke_tank_skill2", 16, 2], #7 ["eagle_skill1", 4, 1], #8 ["eagle_skill2", 0, 1], #9 ["superman_skill1", 1, 0], #10 ["superman_skill2", 1, 0], #11 #先存好所有需要测试的指令 ["uav", 5, 8], #12 ["battle_tank_skill1", 3, 15] ] #13 self.testOrders = list() #将测试的指令 self.game = gamemain.GameMain() #初始化游戏 testBuff = self.game.buff # 设置属性加成 self.units = [ unit.UnitObject(1, 0, "bolt_tank", (3, 4), testBuff), #0 unit.UnitObject(2, 0, "hacker", (6, 8), testBuff), #1 unit.UnitObject(3, 0, "battle_tank", (10, 10), testBuff),#2 unit.UnitObject(4, 0, "eagle", (20, 20), testBuff), #3 unit.UnitObject(5, 0, "uav", (3, 3),testBuff), #4 unit.UnitObject(6, 0, "superman", (35, 35), testBuff), #5 unit.UnitObject(7, 0, "eagle", (50, 50), testBuff), #6 unit.UnitObject(8, 1, "bolt_tank", (3, 5), testBuff), #7 unit.UnitObject(9, 1, "hacker", (6, 8), testBuff), #8 unit.UnitObject(10, 1, "battle_tank", (13, 13), testBuff),#9 unit.UnitObject(11, 1, "eagle", (20, 20), testBuff), #10 unit.UnitObject(12, 1, "uav", (3, 3), testBuff), #11 unit.UnitObject(13, 1, "superman", (35, 35), testBuff), #12 unit.UnitObject(14, 1, "eagle", (50, 50), testBuff), #13 unit.UnitObject(15, 1, "meat", (8, 8), testBuff),# 14 unit.UnitObject(16, 0, "nuke_tank", (10, 11), testBuff) ] # 15 #生成测试需要的单位 for i in range(len(self.units)): self.game.units[i+1] = self.units[i]