From f4dd5073c6d946a38d1f57c952af23eabaae1e1f Mon Sep 17 00:00:00 2001 From: linhara Date: Sun, 4 Oct 2020 13:02:32 +0200 Subject: [PATCH] =?UTF-8?q?linus=20n=C3=A4stan=20bra=20adjustEnergy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/main.py b/main.py index ada3548..eb627f9 100644 --- a/main.py +++ b/main.py @@ -189,5 +189,24 @@ def chartMap(): if state.map[x][y] == 0: availableTiles.append((x, y)) +def adjustEnergy(currentBuilding, newTemp): + blueprint = game_layer.get_residence_blueprint(currentBuilding.building_name) + outDoorTemp = game_layer.game_state.current_temp + + effectiveEnergyIn = ((newTemp - currentBuilding.temperature - 0.04 * currentBuilding.current_pop + (currentBuilding.temperature - outDoorTemp)* 2 * blueprint.emissivity) / 0.75) + blueprint.base_energy_need + effectiveEnergyIn /= 1.7 + + if effectiveEnergyIn > blueprint.base_energy_need: + game_layer.adjust_energy_level((currentBuilding.X, currentBuilding.Y), effectiveEnergyIn) + elif effectiveEnergyIn < blueprint.base_energy_need: + game_layer.adjust_energy_level((currentBuilding.X, currentBuilding.Y), blueprint.base_energy_need + 0.01) + else: + print("you did it!") + game_layer.wait() + + + + + if __name__ == "__main__": main()