-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelements.py
70 lines (58 loc) · 1.39 KB
/
elements.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class Player:
name = "None"
def __init__(self, name):
self.name = name
class Unit:
owner = "None"
territory = None
utype = "Army"
def __init__(self, player, territory, utype="Army"):
self.owner = player
self.territory = territory
self.utype = utype
def __repr__(self):
return "<{} at {}>".format(self.utype, self.territory)
class Territory:
name = "None"
short = "shrt"
terrain = "coastal"
x = 0.0
y = 0.0
def __init__(self, name, short, x=0.0, y=0.0):
self.name = name
self.short = short
self.x = x
self.y = y
def __repr__(self):
return "<%s (%s)>" % (self.name, self.short)
class Border:
A = "None"
B = "None"
modA = []
modB = []
typ = "all"
def __init__(self, A, B, typ="all", modA=[], modB=[]):
self.A = A
self.B = B
self.modA = modA
self.modB = modB
self.type = typ
def __repr__(self):
modAstring = "" if self.modA == [] else self.modA
modBstring = "" if self.modB == [] else self.modB
return "< {} -{}- {} -{}- {} >".format(self.A, modAstring, self.type, modBstring, self.B)
class GameState:
territories = []
units = []
borders = []
occupations = []
def __init__(self, territories, units, borders, occupations):
self.territories = territories
self.units = units
self.borders = borders
self.occupations = occupations
def getUnitAt(self, territory):
for unit in self.units:
if unit.territory == territory:
return unit
return None