1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
1 |
|
from il2fb.commons.spatial import Point2D |
4
|
|
|
|
5
|
1 |
|
from ..converters import to_bool, to_belligerent |
6
|
1 |
|
from . import CollectingParser |
7
|
|
|
|
8
|
|
|
|
9
|
1 |
|
class BornPlaceParser(CollectingParser): |
10
|
|
|
""" |
11
|
|
|
Parses ``BornPlace`` section. |
12
|
|
|
View :ref:`detailed description <bornplace-section>`. |
13
|
|
|
""" |
14
|
|
|
|
15
|
1 |
|
def check_section_name(self, section_name): |
16
|
1 |
|
return section_name == "BornPlace" |
17
|
|
|
|
18
|
1 |
|
def parse_line(self, line): |
19
|
1 |
|
( |
20
|
|
|
belligerent, the_range, pos_x, pos_y, has_parachutes, |
21
|
|
|
air_spawn_height, air_spawn_speed, air_spawn_heading, max_pilots, |
22
|
|
|
radar_min_height, radar_max_height, radar_range, air_spawn_always, |
23
|
|
|
enable_aircraft_limits, aircraft_limits_consider_lost, |
24
|
|
|
disable_spawning, friction_enabled, friction_value, |
25
|
|
|
aircraft_limits_consider_stationary, show_default_icon, |
26
|
|
|
air_spawn_if_deck_is_full, spawn_in_stationary, |
27
|
|
|
return_to_start_position |
28
|
|
|
) = line.split() |
29
|
|
|
|
30
|
1 |
|
self.data.append({ |
31
|
|
|
'range': int(the_range), |
32
|
|
|
'belligerent': to_belligerent(belligerent), |
33
|
|
|
'show_default_icon': to_bool(show_default_icon), |
34
|
|
|
'friction': { |
35
|
|
|
'enabled': to_bool(friction_enabled), |
36
|
|
|
'value': float(friction_value), |
37
|
|
|
}, |
38
|
|
|
'spawning': { |
39
|
|
|
'enabled': not to_bool(disable_spawning), |
40
|
|
|
'with_parachutes': to_bool(has_parachutes), |
41
|
|
|
'max_pilots': int(max_pilots), |
42
|
|
|
'in_stationary': { |
43
|
|
|
'enabled': to_bool(spawn_in_stationary), |
44
|
|
|
'return_to_start_position': to_bool(return_to_start_position), |
45
|
|
|
}, |
46
|
|
|
'in_air': { |
47
|
|
|
'height': int(air_spawn_height), |
48
|
|
|
'speed': int(air_spawn_speed), |
49
|
|
|
'heading': int(air_spawn_heading), |
50
|
|
|
'conditions': { |
51
|
|
|
'always': to_bool(air_spawn_always), |
52
|
|
|
'if_deck_is_full': to_bool(air_spawn_if_deck_is_full), |
53
|
|
|
}, |
54
|
|
|
}, |
55
|
|
|
'aircraft_limitations': { |
56
|
|
|
'enabled': to_bool(enable_aircraft_limits), |
57
|
|
|
'consider_lost': to_bool(aircraft_limits_consider_lost), |
58
|
|
|
'consider_stationary': to_bool(aircraft_limits_consider_stationary), |
59
|
|
|
}, |
60
|
|
|
}, |
61
|
|
|
'radar': { |
62
|
|
|
'range': int(radar_range), |
63
|
|
|
'min_height': int(radar_min_height), |
64
|
|
|
'max_height': int(radar_max_height), |
65
|
|
|
}, |
66
|
|
|
'pos': Point2D(pos_x, pos_y), |
67
|
|
|
}) |
68
|
|
|
|
69
|
1 |
|
def clean(self): |
70
|
|
|
return {'home_bases': self.data, } |
71
|
|
|
|