Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Bet size and chances widget values fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Apr 5, 2018
1 parent 488bde3 commit 6555c7f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/etheroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def value(self):
Returns normalized bet size value.
"""
try:
return self.cast_to(self.ids.bet_size_input_id.text)
return round(float(self.ids.bet_size_input_id.text), ROUND_DIGITS)
except ValueError:
return 0

Expand All @@ -265,7 +265,10 @@ def value(self):
Returns normalized chances value.
"""
try:
return int(self.ids.chances_input_id.text)
# `input_filter: 'int'` only verifies that we have a number
# but doesn't convert to int
chances = float(self.ids.chances_input_id.text)
return int(chances)
except ValueError:
return 0

Expand All @@ -276,17 +279,11 @@ def get_roll_input(self):
"""
Returns bet size and chance of winning user input values.
"""
# bet size
bet_size = self.ids.bet_size_id
bet_size_input = bet_size.ids.bet_size_input_id
bet_size_value = float(bet_size_input.text)
# chance of winning
chance_of_winning = self.ids.chance_of_winning_id
chances_input = chance_of_winning.ids.chances_input_id
chances_value = int(chances_input.text)
return {
"bet_size": bet_size_value,
"chances": chances_value,
"bet_size": bet_size.value,
"chances": chance_of_winning.value,
}


Expand Down

0 comments on commit 6555c7f

Please sign in to comment.