From d25f6f2ac132c4c95dfc23d6b7c9142851f48ff1 Mon Sep 17 00:00:00 2001 From: Thefeli73 Date: Wed, 7 Oct 2020 20:02:47 +0200 Subject: [PATCH] fix for building functions --- main.py | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/main.py b/main.py index 7bd0a4f..2de8f1e 100644 --- a/main.py +++ b/main.py @@ -418,6 +418,13 @@ def build_place(structure, i): global building_under_construction, rounds_between_energy, state if isinstance(available_tiles[i], tuple): 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)): building = state.utilities[j] coords_to_check = (building.X, building.Y) @@ -433,25 +440,22 @@ def build(structure): for i in range(len(available_tiles)): if isinstance(available_tiles[i], tuple): game_layer.place_foundation(available_tiles[i], structure) - for building in state.available_residence_buildings: - if structure in building.building_name: - 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) - rounds_between_energy = len(state.residences)+2 - return True - for building in state.available_utility_buildings: - if structure in building.building_name: - for j in range(len(state.utilities)): - building = state.utilities[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.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) + rounds_between_energy = len(state.residences)+2 + return True + for j in range(len(state.utilities)): + building = state.utilities[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 + return False return False