1
|
|
|
# coding: utf-8 |
2
|
1 |
|
""" |
3
|
|
|
Primitive actor data structures. |
4
|
|
|
|
5
|
|
|
""" |
6
|
|
|
|
7
|
1 |
|
from il2fb.commons.structures import BaseStructure |
8
|
|
|
|
9
|
|
|
|
10
|
1 |
|
class Actor(BaseStructure): |
11
|
|
|
|
12
|
|
|
def __repr__(self): |
13
|
|
|
return "<Actor>" |
14
|
|
|
|
15
|
|
|
|
16
|
1 |
|
class Human(Actor): |
17
|
1 |
|
__slots__ = ['callsign', ] |
18
|
|
|
|
19
|
1 |
|
def __init__(self, callsign): |
20
|
|
|
self.callsign = callsign |
21
|
|
|
|
22
|
|
|
def __repr__(self): |
23
|
|
|
return "<Human '{0}'>".format(self.callsign) |
24
|
|
|
|
25
|
|
|
|
26
|
1 |
|
class HumanAircraft(Human): |
27
|
1 |
|
__slots__ = Human.__slots__ + ['aircraft', ] |
28
|
|
|
|
29
|
1 |
|
def __init__(self, callsign, aircraft): |
30
|
|
|
super(HumanAircraft, self).__init__(callsign) |
31
|
|
|
self.aircraft = aircraft |
32
|
|
|
|
33
|
|
|
def __repr__(self): |
34
|
|
|
return "<Human aircraft '{0}:{1}'>".format(self.callsign, self.aircraft) |
35
|
|
|
|
36
|
|
|
|
37
|
1 |
|
class HumanAircraftCrewMember(HumanAircraft): |
38
|
1 |
|
__slots__ = HumanAircraft.__slots__ + ['index', ] |
39
|
|
|
|
40
|
1 |
|
def __init__(self, callsign, aircraft, index): |
41
|
|
|
super(HumanAircraftCrewMember, self).__init__(callsign, aircraft) |
42
|
|
|
self.index = index |
43
|
|
|
|
44
|
|
|
def __repr__(self): |
45
|
|
|
return ( |
46
|
|
|
"<Human aircraft crew member #{0} in '{1}:{2}'>" |
47
|
|
|
.format(self.index, self.callsign, self.aircraft) |
48
|
|
|
) |
49
|
|
|
|
50
|
|
|
|
51
|
1 |
|
class AIAircraft(Actor): |
52
|
1 |
|
__slots__ = ['flight', 'aircraft', ] |
53
|
|
|
|
54
|
1 |
|
def __init__(self, flight, aircraft): |
55
|
|
|
self.flight = flight |
56
|
|
|
self.aircraft = aircraft |
57
|
|
|
|
58
|
|
|
def __repr__(self): |
59
|
|
|
return "<AI aircraft '{0}:{1}'>".format(self.flight, self.aircraft) |
60
|
|
|
|
61
|
|
|
|
62
|
1 |
|
class AIAircraftCrewMember(AIAircraft): |
63
|
1 |
|
__slots__ = AIAircraft.__slots__ + ['index', ] |
64
|
|
|
|
65
|
1 |
|
def __init__(self, flight, aircraft, index): |
66
|
|
|
super(AIAircraftCrewMember, self).__init__(flight, aircraft) |
67
|
|
|
self.index = index |
68
|
|
|
|
69
|
|
|
def __repr__(self): |
70
|
|
|
return ( |
71
|
|
|
"<AI aircraft crew member #{0} in '{1}:{2}'>" |
72
|
|
|
.format(self.index, self.flight, self.aircraft) |
73
|
|
|
) |
74
|
|
|
|
75
|
|
|
|
76
|
1 |
|
class Unit(Actor): |
77
|
1 |
|
__slots__ = ['id', ] |
78
|
|
|
|
79
|
1 |
|
def __init__(self, id): |
80
|
|
|
self.id = id |
81
|
|
|
|
82
|
|
|
def __repr__(self): |
83
|
|
|
return "<Unit '{0}'>".format(self.id) |
84
|
|
|
|
85
|
|
|
|
86
|
1 |
|
class StationaryUnit(Unit): |
87
|
|
|
|
88
|
|
|
def __repr__(self): |
89
|
|
|
return "<Stationary unit '{0}'>".format(self.id) |
90
|
|
|
|
91
|
|
|
|
92
|
1 |
|
class MovingUnit(Unit): |
93
|
|
|
|
94
|
|
|
def __repr__(self): |
95
|
|
|
return "<Moving unit '{0}'>".format(self.id) |
96
|
|
|
|
97
|
|
|
|
98
|
1 |
|
class MovingUnitMember(MovingUnit): |
99
|
1 |
|
__slots__ = MovingUnit.__slots__ + ['index', ] |
100
|
|
|
|
101
|
1 |
|
def __init__(self, id, index): |
102
|
|
|
super(MovingUnitMember, self).__init__(id) |
103
|
|
|
self.index = index |
104
|
|
|
|
105
|
|
|
def __repr__(self): |
106
|
|
|
return "<Moving unit member #{0} in '{1}'>".format(self.index, self.id) |
107
|
|
|
|
108
|
|
|
|
109
|
1 |
|
class Building(Actor): |
110
|
1 |
|
__slots__ = ['name', ] |
111
|
|
|
|
112
|
1 |
|
def __init__(self, name): |
113
|
|
|
self.name = name |
114
|
|
|
|
115
|
|
|
def __repr__(self): |
116
|
|
|
return "<Building '{0}'>".format(self.name) |
117
|
|
|
|
118
|
|
|
|
119
|
1 |
|
class Bridge(Actor): |
120
|
1 |
|
__slots__ = ['id', ] |
121
|
|
|
|
122
|
1 |
|
def __init__(self, id): |
123
|
|
|
self.id = id |
124
|
|
|
|
125
|
|
|
def __repr__(self): |
126
|
|
|
return "<Bridge '{0}'>".format(self.id) |
127
|
|
|
|