check if structures are available before building

This commit is contained in:
Thefeli73 2020-10-04 17:54:41 +02:00
parent 0a8934c974
commit 0833b843a3

37
main.py
View File

@ -287,22 +287,27 @@ def build(structure):
for i in range(len(availableTiles)): for i in range(len(availableTiles)):
if isinstance(availableTiles[i], tuple): if isinstance(availableTiles[i], tuple):
game_layer.place_foundation(availableTiles[i], structure) game_layer.place_foundation(availableTiles[i], structure)
for j in range(len(state.residences)): for building in state.available_residence_buildings:
building = state.residences[j] if structure in building.building_name:
coords_to_check = (building.X, building.Y) for j in range(len(state.residences)):
if coords_to_check == availableTiles[i]: building = state.residences[j]
availableTiles[i] = building coords_to_check = (building.X, building.Y)
building_under_construction = (building.X, building.Y, j) if coords_to_check == availableTiles[i]:
rounds_between_energy = len(state.residences)+5 availableTiles[i] = building
return True building_under_construction = (building.X, building.Y, j)
for j in range(len(state.utilities)): rounds_between_energy = len(state.residences)+2
building = state.utilities[j] return True
coords_to_check = (building.X, building.Y) for building in state.available_utility_buildings:
if coords_to_check == availableTiles[i]: if structure in building.building_name:
availableTiles[i] = building for j in range(len(state.utilities)):
building_under_construction = (building.X, building.Y, j) building = state.utilities[j]
rounds_between_energy = len(state.residences)+5 coords_to_check = (building.X, building.Y)
return True if coords_to_check == availableTiles[i]:
availableTiles[i] = building
building_under_construction = (building.X, building.Y, j)
rounds_between_energy = len(state.residences)+2
return True
return False
if __name__ == "__main__": if __name__ == "__main__":