-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpreter.py
More file actions
152 lines (130 loc) · 4.92 KB
/
Copy pathinterpreter.py
File metadata and controls
152 lines (130 loc) · 4.92 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
class Interpreter(object):
def __init__(self):
return
def write(self, grid):
'''
#get from grid and write all the info about each tile
self.mapFile = open("testMap","w")
for self.x in range(game.grid.x):
for self.y in range(game.grid.y):
mapFile.write(self.x + " " + self.y + " " + ) #add grid features like terrain and stuff
self.mapFile.close()
#--------------------------------------------------------------
#get from Civs and write all info about each civ
self.civFile = open("testCiv","w")
for self.civNum in game.civs:
civsFile.write(self.civNum + " ")
self.civFile.close()
#-------------------------------------------------------
#get from Cities and write all info about each cities
self.cityFile = open("testCities","w")
for self.city in grid.cities:
citiesFile.write(self.city.x + " " + self.city.y + " " + self.city.civ + "" \
+ self.city.pop + " " + self.city.food + " " + self.city.production + " " \
+ self.city.health + " " + self.city.strength + " ")
for self.building in self.city.building_list:
citiesFile.write(self.building + "$")
citiesFile.write("EOL")
self.cityFile.close()
#--------------------------------------------------------
#get from Units and write all info about each units
self.unitFile = open("testUnits", "w")
for self.unit in grid.units:
unitFile.write(self.unit.name + " " + )
self.unitFile.close()
#--------------------------------------------------------
'''
return
#get from grid and write all the info about each tile
def writeMap(self, grid):
self.mapFile = open("testMap","w")
for x in range(grid.x):
for y in range(grid.y):
tile = grid.tiles[y][x]
mapFile.write(
x + " " +
y + " " +
tile.elevation + " " +
tile.biome + " " +
tile.terrain + " " +
tile.improvement + " " +
tile.unit + " " +
tile.city + " " +
tile.owner + " " +
tile.food_yield + " " +
tile.prod_yield + " " +
tile.science_yield + " " +
tile.gold_yield + " " +
tile.road + "\n") #add grid features like terrain and stuff
self.mapFile.close()
return
#--------------------------------------------------------------
#get from Civs and write all info about each civ
def writeCiv(self, grid):
self.civFile = open("testCiv","w")
for self.civNum in game.civs:
civsFile.write(self.civNum + " ")
self.civFile.close()
return
#-------------------------------------------------------
#get from Cities and write all info about each cities
def writeCities(self, grid):
self.cityFile = open("testCities","w")
for self.city in grid.cities:
citiesFile.write(
self.city.x + " " +
self.city.y + " " +
self.city.civ + " " +
self.city.pop + " " +
self.city.food + " " +
self.city.production + " " +
self.city.health + " " +
self.city.strength + " " +)
for self.building in self.city.building_list:
citiesFile.write(self.building + "$")
citiesFile.write("EOL\n")
self.cityFile.close()
return
#------------------------------------------------------
#get from Units and write all info about each units
def writeUnits(self, grid):
self.unitFile = open("testUnits", "w")
for unit in grid.units:
unitFile.write(
unit.x + " " +
unit.y + " " +
unit.name + " " +
unit.health + " " +
unit.speed + " " +
unit.atype + " " +
unit.prod_cost + " " +
unit.strength + " " +
unit.civ + " " +
unit.airdrop)
self.unitFile.close()
return
#--------------------------------------------------------
def read(self, game):
#varify that variables is indeed what they should be
#if(game)
#varify that gameNum is resonable
if(type(game.gameNumber) is int):
if(game.gameNumber > 0):
gameNum = gameNumber
else:
pass
#Exception
else:
pass
#Exception
#varify that turnNum is reasoable
if(type(turnNumber) is int):
if(turnNumber > 0 and turnNumber <= 500):
turnNum = turnNumber
else:
pass
#Exception
else:
pass
#Exception
return