예제 #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)
예제 #2
0
def _make_campaign_map(tvd_name: str) -> model.CampaignMap:
    """Упрощение конструктора карт кампании"""
    return model.CampaignMap(order=1,
                             date='01.09.1941',
                             mission_date='01.09.1941',
                             tvd_name=tvd_name,
                             months=list(),
                             actions=list())
예제 #3
0
 def test_get_month_supply(self):
     """Формируется месячная поставка самолётов"""
     campaign_map = model.CampaignMap(1, CAMPAIGN_DATE, CAMPAIGN_DATE,
                                      TEST_TVD_NAME, list(), list())
     vendor = processing.AircraftVendor(PLANES, GAMEPLAY)
     # Act
     supply = vendor.get_month_supply(TEST_MONTH, campaign_map)
     # Assert
     self.assertNotEqual(supply, None)
예제 #4
0
 def test_initial_front_supply(self):
     """Выполняется начальная поставка на фронтовые аэродромы"""
     airfields = {
         101: [
             model.ManagedAirfield('test_red_af1', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af2', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af3', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af4', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af5', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af6', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af7', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af8', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af9', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af10', TEST_TVD_NAME, 123, 321,
                                   dict())
         ],
         201: [
             model.ManagedAirfield('test_blue_af1', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af2', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af3', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af4', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af5', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af6', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af7', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af8', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af9', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af10', TEST_TVD_NAME, 123,
                                   321, dict())
         ]
     }
     campaign_map = model.CampaignMap(1, CAMPAIGN_DATE, CAMPAIGN_DATE,
                                      TEST_TVD_NAME, list(), list())
     vendor = processing.AircraftVendor(PLANES, GAMEPLAY)
     # Act
     vendor.initial_front_supply(campaign_map, airfields)
     # Assert
     for country in airfields:
         for managed_airfield in airfields[country]:
             self.assertEqual(managed_airfield.planes_count, 100)
예제 #5
0
 def _convert_from_document(document) -> model.CampaignMap:
     """Конвертировать документ из БД в объект класса карты кампании"""
     return model.CampaignMap(
         order=document[constants.CampaignMap.ORDER],
         date=document[constants.CampaignMap.DATE],
         mission_date=document[constants.CampaignMap.MISSION_DATE],
         tvd_name=document[constants.TVD_NAME],
         months=document[constants.CampaignMap.MONTHS],
         actions=CampaignMaps._convert_actions(
             document[constants.CampaignMap.ACTIONS]),
         mission=CampaignMissions.convert_from_document(
             document[constants.CampaignMap.MISSION]))
예제 #6
0
 def initialize_map(self, tvd_name: str):
     """Инициализировать карту кампании"""
     self.grid_controller.initialize(tvd_name)
     self.warehouses_controller.initialize_warehouses(tvd_name)
     start = self.config.mgen.cfg[tvd_name][START_DATE]
     order = list(self.config.mgen.maps).index(tvd_name) + 1
     campaign_map = model.CampaignMap(order=order,
                                      date=start,
                                      mission_date=start,
                                      tvd_name=tvd_name,
                                      months=list(),
                                      actions=list())
     tvd = self.tvd_builders[campaign_map.tvd_name].get_tvd(
         campaign_map.date.strftime(constants.DATE_FORMAT))
     self.airfields_controller.initialize_tvd(tvd, campaign_map)
     self.storage.campaign_maps.update(campaign_map)
     self.divisions_controller.initialize_divisions(tvd_name)
예제 #7
0
 def test_deliver_month_supply(self):
     """Начисляются самолёты ежемесячной поставки"""
     campaign_map = model.CampaignMap(1, CAMPAIGN_DATE, CAMPAIGN_DATE,
                                      TEST_TVD_NAME, list(), list())
     vendor = processing.AircraftVendor(PLANES, GAMEPLAY)
     supply = vendor.get_month_supply(CAMPAIGN_DATE, campaign_map)
     test_red_af1 = model.ManagedAirfield('test_red_af1', TEST_TVD_NAME,
                                          123, 321, dict())
     test_red_af2 = model.ManagedAirfield('test_red_af2', TEST_TVD_NAME,
                                          123, 321, dict())
     test_red_af3 = model.ManagedAirfield('test_red_af3', TEST_TVD_NAME,
                                          123, 321, dict())
     test_blue_af1 = model.ManagedAirfield('test_blue_af1', TEST_TVD_NAME,
                                           123, 321, dict())
     test_blue_af2 = model.ManagedAirfield('test_blue_af2', TEST_TVD_NAME,
                                           123, 321, dict())
     test_blue_af3 = model.ManagedAirfield('test_blue_af3', TEST_TVD_NAME,
                                           123, 321, dict())
     airfields = {
         101: [
             test_red_af1, test_red_af2, test_red_af3,
             model.ManagedAirfield('test_red_af4', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af5', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af6', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af7', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af8', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af9', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af10', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af11', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af12', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af13', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af14', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af15', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af16', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af17', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af18', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af19', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_red_af20', TEST_TVD_NAME, 123, 321,
                                   dict())
         ],
         201: [
             test_blue_af1, test_blue_af2, test_blue_af3,
             model.ManagedAirfield('test_blue_af4', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af5', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af6', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af7', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af8', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af9', TEST_TVD_NAME, 123, 321,
                                   dict()),
             model.ManagedAirfield('test_blue_af10', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af11', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af12', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af13', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af14', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af15', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af16', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af17', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af18', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af19', TEST_TVD_NAME, 123,
                                   321, dict()),
             model.ManagedAirfield('test_blue_af20', TEST_TVD_NAME, 123,
                                   321, dict())
         ]
     }
     GAMEPLAY.initial_priority[TEST_TVD_NAME] = list(
         x.name for x in (test_red_af1, test_red_af2, test_red_af3,
                          test_blue_af1, test_blue_af2, test_blue_af3))
     # Act
     vendor.deliver_month_supply(campaign_map, airfields, supply)
     # Assert
     self.assertFalse(supply.has_aircrafts)
     self.assertIn(CAMPAIGN_DATE, campaign_map.months)
     self.assertSequenceEqual(supply.amounts, len(supply.amounts) * [0])
     for country in airfields:
         for airfield in airfields[country]:
             for key in airfield.planes:
                 for name in PLANES.cfg['uncommon']:
                     if PLANES.name_to_key(name) == key:
                         self.assertEqual(
                             country,
                             PLANES.cfg['uncommon'][name]['country'])
     for airfield in test_red_af1, test_red_af2, test_red_af3, test_blue_af1, test_blue_af2, test_blue_af3:
         self.assertTrue(
             airfield.planes_count >= GAMEPLAY.rear_max_power * 2)
예제 #8
0
def _load_all_campaign_maps():
    """Фальшивый метод загрузки карт кампании"""
    return [
        model.CampaignMap(1, TEST_TVD_DATE, TEST_TVD_DATE, TEST_TVD_NAME,
                          list(), list())
    ]