Fix balance change and round

This commit is contained in:
Apologieze
2022-05-23 19:54:45 +02:00
parent 66bcda823c
commit 948ec8f487
3 changed files with 10 additions and 4 deletions

View File

@@ -304,7 +304,10 @@ class GUI():
def change_balance(n):
"""Change the in game balance and the local balance file"""
temp = str(gen.balance+n).split('.')
gen.balance = round(float(temp[0]) + float("0." + temp[1][:min(2, len(temp[1]))]), 2)
gen.balance = round(float(temp[0]) + float(f"0.{temp[1][:min(2, len(temp[1]))]}"), 2)
if len(temp[1])>2:
if temp[1][2]=='9':
gen.balance = round(gen.balance+0.01,2)
gen.gui.display_balance.resize()
with open('value.json', 'w') as json_file:
json.dump({"balance":gen.balance}, json_file)

View File

@@ -452,8 +452,11 @@ def new_round():
def change_balance(n):
"""Change the in game balance and the local balance file"""
temp = str(gen.game_state.balance+n).split('.')
gen.game_state.balance = round(float(temp[0]) + float("0." + temp[1][:min(2, len(temp[1]))]), 2)
temp = str(gen.game_state.balance + n).split('.')
gen.game_state.balance = round(float(temp[0]) + float(f"0.{temp[1][:min(2, len(temp[1]))]}"), 2)
if len(temp[1]) > 2:
if temp[1][2] == '9':
gen.game_state.balance = round(gen.game_state.balance + 0.01, 2)
with open('value.json', 'w') as json_file:
json.dump({"balance":gen.game_state.balance}, json_file)

View File

@@ -1 +1 @@
{"balance": 99.6}
{"balance": 99.0}