forked from MarseyWorld/MarseyWorld
make roulette cute and valid python syntax
parent
9f51259ee6
commit
4d096a5bb6
|
@ -10,13 +10,24 @@ from files.helpers.alerts import *
|
||||||
from files.helpers.get import get_account
|
from files.helpers.get import get_account
|
||||||
|
|
||||||
class RouletteAction(str, Enum):
|
class RouletteAction(str, Enum):
|
||||||
STRAIGHT_UP_BET = "STRAIGHT_UP_BET", lambda x:x and x >= 0 and x <= 37
|
STRAIGHT_UP_BET = "STRAIGHT_UP_BET",
|
||||||
LINE_BET = "LINE_BET", lambda x:x in LINES
|
LINE_BET = "LINE_BET"
|
||||||
COLUMN_BET = "COLUMN_BET", lambda x:x in COLUMNS
|
COLUMN_BET = "COLUMN_BET"
|
||||||
DOZEN_BET = "DOZEN_BET", lambda x:x in DOZENS
|
DOZEN_BET = "DOZEN_BET"
|
||||||
EVEN_ODD_BET = "EVEN_ODD_BET", lambda x:x in [y.value for y in RouletteEvenOdd]
|
EVEN_ODD_BET = "EVEN_ODD_BET"
|
||||||
RED_BLACK_BET = "RED_BLACK_BET", lambda x:x in [y.value for y in RouletteRedBlack]
|
RED_BLACK_BET = "RED_BLACK_BET"
|
||||||
HIGH_LOW_BET = "HIGH_LOW_BET", lambda x:x in [y.value for y in RouletteHighLow]
|
HIGH_LOW_BET = "HIGH_LOW_BET"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def validation_function(self):
|
||||||
|
if self == self.__class__.STRAIGHT_UP_BET: return lambda x:x and x >= 0 and x <= 37
|
||||||
|
if self == self.__class__.LINE_BET: return lambda x:x in LINES
|
||||||
|
if self == self.__class__.COLUMN_BET: return lambda x:x in COLUMNS
|
||||||
|
if self == self.__class__.DOZEN_BET: return lambda x:x in DOZENS
|
||||||
|
if self == self.__class__.EVEN_ODD_BET: return lambda x:x in [y.value for y in RouletteEvenOdd]
|
||||||
|
if self == self.__class__.RED_BLACK_BET: return lambda x:x in [y.value for y in RouletteRedBlack]
|
||||||
|
if self == self.__class__.HIGH_LOW_BET: return lambda x:x in [y.value for y in RouletteHighLow]
|
||||||
|
raise ValueError("Unhandled validation function for RouletteAction")
|
||||||
|
|
||||||
|
|
||||||
class RouletteEvenOdd(str, Enum):
|
class RouletteEvenOdd(str, Enum):
|
||||||
|
|
|
@ -218,7 +218,7 @@ def roulette_player_placed_bet(v):
|
||||||
try: which_int = int(which)
|
try: which_int = int(which)
|
||||||
except: which_int = None
|
except: which_int = None
|
||||||
|
|
||||||
if not bet_type.value[1](which_int or which):
|
if not bet_type.validation_function(which_int or which):
|
||||||
abort(400, f"Not a valid roulette bet for bet type {bet_type.value[0]}")
|
abort(400, f"Not a valid roulette bet for bet type {bet_type.value[0]}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue