|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
1 |
|
from il2fb.commons.organization import Belligerents |
|
5
|
|
|
|
|
6
|
1 |
|
from ..converters import to_bool |
|
7
|
1 |
|
from . import CollectingParser, ValuesParser |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
1 |
|
class MDSSectionParser(ValuesParser): |
|
11
|
|
|
""" |
|
12
|
|
|
Parses ``MDS`` section. |
|
13
|
|
|
View :ref:`detailed description <mds-section>`. |
|
14
|
|
|
""" |
|
15
|
|
|
|
|
16
|
1 |
|
def check_section_name(self, section_name): |
|
17
|
1 |
|
return section_name == "MDS" |
|
18
|
|
|
|
|
19
|
1 |
|
def parse_line(self, line): |
|
20
|
1 |
|
super(MDSSectionParser, self).parse_line(line.replace('MDS_', '')) |
|
21
|
|
|
|
|
22
|
1 |
|
def clean(self): |
|
23
|
1 |
|
return { |
|
24
|
|
|
'conditions': { |
|
25
|
|
|
'radar': { |
|
26
|
|
|
'advanced_mode': to_bool(self.data['Radar_SetRadarToAdvanceMode']), |
|
27
|
|
|
'refresh_interval': int(self.data['Radar_RefreshInterval']), |
|
28
|
|
|
'ships': { |
|
29
|
|
|
'big': { |
|
30
|
|
|
'max_range': int(self.data['Radar_ShipRadar_MaxRange']), |
|
31
|
|
|
'min_height': int(self.data['Radar_ShipRadar_MinHeight']), |
|
32
|
|
|
'max_height': int(self.data['Radar_ShipRadar_MaxHeight']), |
|
33
|
|
|
}, |
|
34
|
|
|
'small': { |
|
35
|
|
|
'max_range': int(self.data['Radar_ShipSmallRadar_MaxRange']), |
|
36
|
|
|
'min_height': int(self.data['Radar_ShipSmallRadar_MinHeight']), |
|
37
|
|
|
'max_height': int(self.data['Radar_ShipSmallRadar_MaxHeight']), |
|
38
|
|
|
}, |
|
39
|
|
|
}, |
|
40
|
|
|
'scouts': { |
|
41
|
|
|
'max_range': int(self.data['Radar_ScoutRadar_MaxRange']), |
|
42
|
|
|
'max_height': int(self.data['Radar_ScoutRadar_DeltaHeight']), |
|
43
|
|
|
'alpha': int(self.data['Radar_ScoutGroundObjects_Alpha']), |
|
44
|
|
|
}, |
|
45
|
|
|
}, |
|
46
|
|
|
'scouting': { |
|
47
|
|
|
'ships_affect_radar': to_bool(self.data['Radar_ShipsAsRadar']), |
|
48
|
|
|
'scouts_affect_radar': to_bool(self.data['Radar_ScoutsAsRadar']), |
|
49
|
|
|
'only_scouts_complete_targets': to_bool(self.data['Radar_ScoutCompleteRecon']), |
|
50
|
|
|
}, |
|
51
|
|
|
'communication': { |
|
52
|
|
|
'tower_communication': to_bool(self.data['Radar_EnableTowerCommunications']), |
|
53
|
|
|
'vectoring': not to_bool(self.data['Radar_DisableVectoring']), |
|
54
|
|
|
'ai_radio_silence': to_bool(self.data['Misc_DisableAIRadioChatter']), |
|
55
|
|
|
}, |
|
56
|
|
|
'home_bases': { |
|
57
|
|
|
'hide_ai_aircrafts_after_landing': to_bool(self.data['Misc_DespawnAIPlanesAfterLanding']), |
|
58
|
|
|
'hide_unpopulated': to_bool(self.data['Radar_HideUnpopulatedAirstripsFromMinimap']), |
|
59
|
|
|
'hide_players_count': to_bool(self.data['Misc_HidePlayersCountOnHomeBase']), |
|
60
|
|
|
}, |
|
61
|
|
|
'crater_visibility_muptipliers': { |
|
62
|
|
|
'le_100kg': float(self.data['Misc_BombsCat1_CratersVisibilityMultiplier']), |
|
63
|
|
|
'le_1000kg': float(self.data['Misc_BombsCat2_CratersVisibilityMultiplier']), |
|
64
|
|
|
'gt_1000kg': float(self.data['Misc_BombsCat3_CratersVisibilityMultiplier']), |
|
65
|
|
|
}, |
|
66
|
|
|
}, |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
1 |
|
class MDSScoutsSectionParser(CollectingParser): |
|
71
|
|
|
""" |
|
72
|
|
|
Parses ``MDS_Scouts`` section. |
|
73
|
|
|
View :ref:`detailed description <mds-scouts-section>`. |
|
74
|
|
|
""" |
|
75
|
1 |
|
input_prefix = "MDS_Scouts_" |
|
76
|
1 |
|
output_prefix = "scouts_" |
|
77
|
|
|
|
|
78
|
1 |
|
def check_section_name(self, section_name): |
|
79
|
1 |
|
if not section_name.startswith(self.input_prefix): |
|
80
|
1 |
|
return False |
|
81
|
1 |
|
belligerent_name = self._get_belligerent_name(section_name) |
|
82
|
1 |
|
return bool(belligerent_name) |
|
83
|
|
|
|
|
84
|
1 |
|
def init_parser(self, section_name): |
|
85
|
1 |
|
super(MDSScoutsSectionParser, self).init_parser(section_name) |
|
86
|
1 |
|
belligerent_name = self._get_belligerent_name(section_name) |
|
87
|
1 |
|
self.belligerent = Belligerents[belligerent_name] |
|
88
|
1 |
|
self.output_key = "{0}{1}".format(self.output_prefix, belligerent_name) |
|
89
|
|
|
|
|
90
|
1 |
|
def _get_belligerent_name(self, section_name): |
|
91
|
1 |
|
return section_name[len(self.input_prefix):].lower() |
|
92
|
|
|
|
|
93
|
1 |
|
def clean(self): |
|
94
|
1 |
|
return { |
|
95
|
|
|
self.output_key: { |
|
96
|
|
|
'belligerent': self.belligerent, |
|
97
|
|
|
'aircrafts': self.data, |
|
98
|
|
|
}, |
|
99
|
|
|
} |
|
100
|
|
|
|