Ejemplo n.º 1
0
 def test_division_kill(self):
     """Обрабатывается уничтожение дивизии"""
     controller = processing.GroundController(IOC)
     IOC.campaign_controller._mission = TEST_MISSION
     IOC.campaign_controller._campaign_map = model.CampaignMap(
         1, TEST_DATE, TEST_DATE, TEST_MISSION.tvd_name, list(), list(),
         TEST_MISSION)
     target_name = 'static_il2'
     aircraft_name = 'I-16 type 24'
     attacker = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(2, aircraft_name, 201, 'Test attacker',
                                   -1))
     target = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(3, target_name, 101,
                                   'Test ground target', -1))
     IOC.storage.divisions.update(
         model.Division(TEST_MISSION.tvd_name, 'BTD1', 10,
                        TEST_TARGET_POS_BTD1_UNITS[0]))
     controller.start_mission(IOC.campaign_controller.mission)
     # Act
     for pos in TEST_TARGET_POS_BTD1_UNITS:
         for i in range(20):
             IOC.objects_controller.kill(
                 atypes.Atype3(4444, attacker.obj_id, target.obj_id, pos))
             controller.kill(atypes.Atype3(123, -1, target.obj_id, pos))
     # Assert
     self.assertSequenceEqual(['BTD1'],
                              IOC.console_mock.received_server_inputs)
Ejemplo n.º 2
0
 def test_do_not_give_for_friendly(self):
     """Не даётся модификация за вылет со стрельбой по своим"""
     _create(FILTER, TEST_PLAYER)
     controller = processing.PlayersController(IOC)
     aircraft_name = 'I-16 type 24'
     bot_name = 'BotPilot'
     target_name = 'static_il2'
     atype12_aircraft = tests.mocks.atype_12_stub(1, aircraft_name, 201,
                                                  'test_aircraft', -1)
     atype12_bot = tests.mocks.atype_12_stub(2, bot_name, 201, 'test_bot',
                                             1)
     atype12_static = tests.mocks.atype_12_stub(3, target_name, 201,
                                                'test_target', -1)
     atype10 = _atype_10_stub(1, 2, {
         'x': 100,
         'z': 100
     }, aircraft_name, 201, 3)
     aircraft = IOC.objects_controller.create_object(atype12_aircraft)
     bot = IOC.objects_controller.create_object(atype12_bot)
     target = IOC.objects_controller.create_object(atype12_static)
     IOC.objects_controller.spawn(atype10)
     pos = {'x': 100.0, 'y': 100.0, 'z': 100.0}
     expect = TEST_PLAYER[constants.Player.UNLOCKS]
     # Act
     controller.start_mission()
     controller.spawn(atype10)
     IOC.objects_controller.kill(
         atypes.Atype3(7888, aircraft.obj_id, target.obj_id, pos))
     controller.finish(atypes.Atype16(9222, bot.obj_id, pos))
     controller.disconnect(TEST_ACCOUNT_ID)
     # Assert
     document = IOC.storage.players.collection.find_one(FILTER)
     self.assertEqual(expect, document[constants.Player.UNLOCKS])
Ejemplo n.º 3
0
 def test_kill_aircraft(self):
     """Учитываются только уничтоженные наземные цели"""
     controller = processing.GroundController(IOC)
     aircraft_name = 'I-16 type 24'
     aircraft = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(2, aircraft_name, 101, 'Test aircraft',
                                   -1))
     pos_aircraft = {'x': 200.0, 'y': 100.0, 'z': 100.0}
     # Act
     controller.kill(atypes.Atype3(123, -1, aircraft.obj_id, pos_aircraft))
     # Assert
     self.assertSequenceEqual([], controller.ground_kills)
Ejemplo n.º 4
0
 def test_kill(self):
     """Учитываются уничтоженные наземные цели"""
     controller = processing.GroundController(IOC)
     target_name = 'static_il2'
     aircraft_name = 'I-16 type 24'
     pos_target = {'x': 300.0, 'y': 100.0, 'z': 100.0}
     attacker = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(2, aircraft_name, 201, 'Test attacker',
                                   -1))
     target = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(3, target_name, 101,
                                   'Test ground target', -1))
     # Act
     IOC.objects_controller.kill(
         atypes.Atype3(4444, attacker.obj_id, target.obj_id, pos_target))
     controller.kill(atypes.Atype3(123, -1, 3, pos_target))
     # Assert
     self.assertTrue(target.killed)
     self.assertSequenceEqual(
         [geometry.Point(x=pos_target['x'], z=pos_target['z'])],
         controller.ground_kills)
Ejemplo n.º 5
0
 def test_division_unit_kill(self):
     """Обрабатывается уничтожение подразделения дивизии"""
     controller = processing.GroundController(IOC)
     IOC.campaign_controller._mission = TEST_MISSION
     IOC._divisions_controller = DIVISIONS_CONTROLLER_MOCK
     target_name = 'static_il2'
     aircraft_name = 'I-16 type 24'
     attacker = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(2, aircraft_name, 201, 'Test attacker',
                                   -1))
     target = IOC.objects_controller.create_object(
         tests.mocks.atype_12_stub(3, target_name, 101,
                                   'Test ground target', -1))
     controller.start_mission(IOC.campaign_controller.mission)
     # Act
     IOC.objects_controller.kill(
         atypes.Atype3(4444, attacker.obj_id, target.obj_id,
                       TEST_TARGET_POS_BTD1_UNITS[0]))
     controller.kill(
         atypes.Atype3(123, -1, target.obj_id,
                       TEST_TARGET_POS_BTD1_UNITS[0]))
     IOC.objects_controller.kill(
         atypes.Atype3(4444, attacker.obj_id, target.obj_id,
                       TEST_TARGET_POS_BTD1_UNITS[0]))
     controller.kill(
         atypes.Atype3(123, -1, target.obj_id,
                       TEST_TARGET_POS_BTD1_UNITS[0]))
     IOC.objects_controller.kill(
         atypes.Atype3(4444, attacker.obj_id, target.obj_id,
                       TEST_TARGET_POS_BTD1_UNITS[0]))
     controller.kill(
         atypes.Atype3(123, -1, target.obj_id,
                       TEST_TARGET_POS_BTD1_UNITS[0]))
     # Assert
     self.assertSequenceEqual([], IOC.console_mock.received_server_inputs)
     self.assertIn('BTD1', DIVISIONS_CONTROLLER_MOCK.damaged_divisions)
Ejemplo n.º 6
0
 def event_kill(self, tik: int, attacker_id: int, target_id: int, pos: dict) -> None:
     """AType 3 handler"""
     atype = atypes.Atype3(tik, attacker_id, target_id, pos)
     self.objects_controller.kill(atype)
     self.ground_controller.kill(atype)