fix for building functions

This commit is contained in:
Thefeli73 2020-10-07 20:02:47 +02:00
parent 17fc759321
commit d25f6f2ac1

42
main.py
View File

@ -418,6 +418,13 @@ def build_place(structure, i):
global building_under_construction, rounds_between_energy, state global building_under_construction, rounds_between_energy, state
if isinstance(available_tiles[i], tuple): if isinstance(available_tiles[i], tuple):
game_layer.place_foundation(available_tiles[i], structure) game_layer.place_foundation(available_tiles[i], structure)
for j in range(len(state.residences)):
building = state.residences[j]
coords_to_check = (building.X, building.Y)
if coords_to_check == available_tiles[i]:
available_tiles[i] = building
building_under_construction = (building.X, building.Y, j)
return True
for j in range(len(state.utilities)): for j in range(len(state.utilities)):
building = state.utilities[j] building = state.utilities[j]
coords_to_check = (building.X, building.Y) coords_to_check = (building.X, building.Y)
@ -433,25 +440,22 @@ def build(structure):
for i in range(len(available_tiles)): for i in range(len(available_tiles)):
if isinstance(available_tiles[i], tuple): if isinstance(available_tiles[i], tuple):
game_layer.place_foundation(available_tiles[i], structure) game_layer.place_foundation(available_tiles[i], structure)
for building in state.available_residence_buildings: for j in range(len(state.residences)):
if structure in building.building_name: building = state.residences[j]
for j in range(len(state.residences)): coords_to_check = (building.X, building.Y)
building = state.residences[j] if coords_to_check == available_tiles[i]:
coords_to_check = (building.X, building.Y) available_tiles[i] = building
if coords_to_check == available_tiles[i]: building_under_construction = (building.X, building.Y, j)
available_tiles[i] = building rounds_between_energy = len(state.residences)+2
building_under_construction = (building.X, building.Y, j) return True
rounds_between_energy = len(state.residences)+2 for j in range(len(state.utilities)):
return True building = state.utilities[j]
for building in state.available_utility_buildings: coords_to_check = (building.X, building.Y)
if structure in building.building_name: if coords_to_check == available_tiles[i]:
for j in range(len(state.utilities)): available_tiles[i] = building
building = state.utilities[j] building_under_construction = (building.X, building.Y, j)
coords_to_check = (building.X, building.Y) return True
if coords_to_check == available_tiles[i]: return False
available_tiles[i] = building
building_under_construction = (building.X, building.Y, j)
return True
return False return False