forked from rDrama/rDrama
[DO NOT MERGE] roulette 0 and 00 bets redux (#470)
* backend support for roulette betting on 0 and 00 * casino: roulette: add 0 and 00 frontend * add spacer * roulette: fix the thing * don't payout where needful not to * sanity check * roulette: validate requests properly * roulette actions from API make more sanemaster
parent
787c89961f
commit
9f51259ee6
|
@ -10,13 +10,13 @@ from files.helpers.alerts import *
|
|||
from files.helpers.get import get_account
|
||||
|
||||
class RouletteAction(str, Enum):
|
||||
STRAIGHT_UP_BET = "STRAIGHT_UP_BET"
|
||||
LINE_BET = "LINE_BET"
|
||||
COLUMN_BET = "COLUMN_BET"
|
||||
DOZEN_BET = "DOZEN_BET"
|
||||
EVEN_ODD_BET = "EVEN_ODD_BET"
|
||||
RED_BLACK_BET = "RED_BLACK_BET"
|
||||
HIGH_LOW_BET = "HIGH_LOW_BET"
|
||||
STRAIGHT_UP_BET = "STRAIGHT_UP_BET", lambda x:x and x >= 0 and x <= 37
|
||||
LINE_BET = "LINE_BET", lambda x:x in LINES
|
||||
COLUMN_BET = "COLUMN_BET", lambda x:x in COLUMNS
|
||||
DOZEN_BET = "DOZEN_BET", lambda x:x in DOZENS
|
||||
EVEN_ODD_BET = "EVEN_ODD_BET", lambda x:x in [y.value for y in RouletteEvenOdd]
|
||||
RED_BLACK_BET = "RED_BLACK_BET", lambda x:x in [y.value for y in RouletteRedBlack]
|
||||
HIGH_LOW_BET = "HIGH_LOW_BET", lambda x:x in [y.value for y in RouletteHighLow]
|
||||
|
||||
|
||||
class RouletteEvenOdd(str, Enum):
|
||||
|
@ -156,12 +156,7 @@ def spin_roulette_wheel():
|
|||
if len(participants) > 0:
|
||||
number = randint(0, 37) # 37 is 00
|
||||
|
||||
if number > 0 and number < 37: # 0 and 00 do not pay anything
|
||||
winners, payouts, rewards_by_game_id = determine_roulette_winners(number, bets)
|
||||
else:
|
||||
winners = []
|
||||
payouts = {}
|
||||
rewards_by_game_id = {}
|
||||
winners, payouts, rewards_by_game_id = determine_roulette_winners(number, bets)
|
||||
|
||||
if number == 37: number = '00'
|
||||
|
||||
|
@ -243,6 +238,13 @@ def determine_roulette_winners(number, bets):
|
|||
if int(bet['which']) == number:
|
||||
add_to_winnings(bet)
|
||||
|
||||
if number == 0 or number == 37:
|
||||
return winners, payouts, rewards_by_game_id
|
||||
|
||||
def is_green(bet):
|
||||
val = int(bet['which'])
|
||||
return val == 0 or val == 37
|
||||
|
||||
# Line Bet
|
||||
line = -1
|
||||
for i in range(1, 7):
|
||||
|
@ -250,6 +252,7 @@ def determine_roulette_winners(number, bets):
|
|||
line = i
|
||||
|
||||
for bet in bets[RouletteAction.LINE_BET]:
|
||||
if is_green(bet): continue
|
||||
if int(bet['which']) == line:
|
||||
add_to_winnings(bet)
|
||||
|
||||
|
@ -260,6 +263,7 @@ def determine_roulette_winners(number, bets):
|
|||
column = i
|
||||
|
||||
for bet in bets[RouletteAction.COLUMN_BET]:
|
||||
if is_green(bet): continue
|
||||
if int(bet['which']) == column:
|
||||
add_to_winnings(bet)
|
||||
|
||||
|
@ -270,6 +274,7 @@ def determine_roulette_winners(number, bets):
|
|||
dozen = i
|
||||
|
||||
for bet in bets[RouletteAction.DOZEN_BET]:
|
||||
if is_green(bet): continue
|
||||
if int(bet['which']) == dozen:
|
||||
add_to_winnings(bet)
|
||||
|
||||
|
@ -277,6 +282,7 @@ def determine_roulette_winners(number, bets):
|
|||
even_odd = RouletteEvenOdd.EVEN if number % 2 == 0 else RouletteEvenOdd.ODD
|
||||
|
||||
for bet in bets[RouletteAction.EVEN_ODD_BET]:
|
||||
if is_green(bet): continue
|
||||
if bet['which'] == even_odd:
|
||||
add_to_winnings(bet)
|
||||
|
||||
|
@ -284,6 +290,7 @@ def determine_roulette_winners(number, bets):
|
|||
red_black = RouletteRedBlack.RED if number in REDS else RouletteRedBlack.BLACK
|
||||
|
||||
for bet in bets[RouletteAction.RED_BLACK_BET]:
|
||||
if is_green(bet): continue
|
||||
if bet['which'] == red_black:
|
||||
add_to_winnings(bet)
|
||||
|
||||
|
@ -291,6 +298,7 @@ def determine_roulette_winners(number, bets):
|
|||
high_low = RouletteHighLow.HIGH if number > 18 else RouletteHighLow.LOW
|
||||
|
||||
for bet in bets[RouletteAction.HIGH_LOW_BET]:
|
||||
if is_green(bet): continue
|
||||
if bet['which'] == high_low:
|
||||
add_to_winnings(bet)
|
||||
|
||||
|
|
|
@ -204,19 +204,26 @@ def roulette_player_placed_bet(v):
|
|||
if v.rehab:
|
||||
abort(403, "You are under Rehab award effect!")
|
||||
|
||||
bet = request.values.get("bet")
|
||||
which = request.values.get("which", None)
|
||||
amount = request.values.get("wager", None, int)
|
||||
currency = request.values.get("currency")
|
||||
|
||||
try: bet_type = RouletteAction(bet)
|
||||
except: abort(400, "Not a valid roulette bet type")
|
||||
|
||||
if not amount or amount < 5: abort(400, f"Minimum bet is 5 {currency}.")
|
||||
if not which: abort(400, "Not a valid roulette bet")
|
||||
|
||||
try: which_int = int(which)
|
||||
except: which_int = None
|
||||
|
||||
if not bet_type.value[1](which_int or which):
|
||||
abort(400, f"Not a valid roulette bet for bet type {bet_type.value[0]}")
|
||||
|
||||
try:
|
||||
bet = request.values.get("bet")
|
||||
which = request.values.get("which")
|
||||
amount = int(request.values.get("wager"))
|
||||
currency = request.values.get("currency")
|
||||
|
||||
if amount < 5:
|
||||
abort(400, f"Minimum bet is 5 {currency}.")
|
||||
|
||||
gambler_placed_roulette_bet(v, bet, which, amount, currency)
|
||||
|
||||
bets = get_roulette_bets()
|
||||
|
||||
return {"success": True, "bets": bets, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
||||
except:
|
||||
abort(400, "Unable to place a bet.")
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
// Lines
|
||||
html += `
|
||||
<div class="roulette-table-row">
|
||||
<div style="flex: 1"></div>
|
||||
<div id="LINE_BET#1" onclick="placeChip('LINE_BET', '1')" class="roulette-table-1to1">Line 1</div>
|
||||
<div id="LINE_BET#2" onclick="placeChip('LINE_BET', '2')" class="roulette-table-1to1">Line 2</div>
|
||||
<div id="LINE_BET#3" onclick="placeChip('LINE_BET', '3')" class="roulette-table-1to1">Line 3</div>
|
||||
|
@ -78,6 +79,7 @@
|
|||
|
||||
// First Column
|
||||
html += "<div class=\"roulette-table-row\">";
|
||||
html += `<div id="STRAIGHT_UP_BET#37" onclick="placeChip('STRAIGHT_UP_BET', '37')" class="roulette-table-number roulette-table-number__green">00</div>`
|
||||
for (let i = 1; i < 13; i++) {
|
||||
const correctNumber = CELL_TO_NUMBER_LOOKUP[i];
|
||||
const isRed = reds.includes(correctNumber);
|
||||
|
@ -95,6 +97,7 @@
|
|||
|
||||
// Second Column
|
||||
html += "<div class=\"roulette-table-row\">";
|
||||
html += `<div id="roulette-spacer-left-middle" class="roulette-table-number roulette-table-number__green"></div>`
|
||||
for (let i = 13; i < 25; i++) {
|
||||
const correctNumber = CELL_TO_NUMBER_LOOKUP[i];
|
||||
const isRed = reds.includes(correctNumber);
|
||||
|
@ -112,6 +115,7 @@
|
|||
|
||||
// Third Column
|
||||
html += "<div class=\"roulette-table-row\">";
|
||||
html += `<div id="STRAIGHT_UP_BET#0" onclick="placeChip('STRAIGHT_UP_BET', '0')" class="roulette-table-number roulette-table-number__green">0</div>`
|
||||
for (let i = 25; i < 37; i++) {
|
||||
const correctNumber = CELL_TO_NUMBER_LOOKUP[i];
|
||||
const isRed = reds.includes(correctNumber);
|
||||
|
@ -130,12 +134,14 @@
|
|||
// Line Bets and 1:1 Bets
|
||||
html += `
|
||||
<div class="roulette-table-row">
|
||||
<div style="flex: 1"></div>
|
||||
<div id="DOZEN_BET#1" class="roulette-table-line" onclick="placeChip('DOZEN_BET', '1')">1st12</div>
|
||||
<div id="DOZEN_BET#2" class="roulette-table-line" onclick="placeChip('DOZEN_BET', '2')">2nd12</div>
|
||||
<div id="DOZEN_BET#3" class="roulette-table-line" onclick="placeChip('DOZEN_BET', '3')">3rd12</div>
|
||||
<div style="flex: 1"></div>
|
||||
</div>
|
||||
<div class="roulette-table-row">
|
||||
<div style="flex: 1"></div>
|
||||
<div id="HIGH_LOW_BET#LOW" class="roulette-table-1to1" onclick="placeChip('HIGH_LOW_BET', 'LOW')">1:18</div>
|
||||
<div id="EVEN_ODD_BET#EVEN" class="roulette-table-1to1" onclick="placeChip('EVEN_ODD_BET', 'EVEN')">EVEN</div>
|
||||
<div id="RED_BLACK_BET#RED" class="roulette-table-1to1" onclick="placeChip('RED_BLACK_BET', 'RED')" style="background-color: red">RED</div>
|
||||
|
@ -309,8 +315,9 @@
|
|||
|
||||
function placeChip(bet, which) {
|
||||
const { amount, currency: safeCurrency, localCurrency: currency } = getWager();
|
||||
const whichNice = which == 37 ? "00" : which;
|
||||
const texts = {
|
||||
STRAIGHT_UP_BET: `Bet ${amount} ${currency} on ${which}?\nYou could win ${amount * 35} ${currency}.`,
|
||||
STRAIGHT_UP_BET: `Bet ${amount} ${currency} on ${whichNice}?\nYou could win ${amount * 35} ${currency}.`,
|
||||
LINE_BET: `Bet ${amount} ${currency} on line ${which}?\nYou could win ${amount * 5} ${currency}.`,
|
||||
COLUMN_BET: `Bet ${amount} ${currency} column ${which}?\nYou could win ${amount * 2} ${currency}.`,
|
||||
DOZEN_BET: `Bet ${amount} ${currency} dozen ${which}?\nYou could win ${amount * 2} ${currency}.`,
|
||||
|
@ -406,6 +413,10 @@
|
|||
background: red;
|
||||
}
|
||||
|
||||
.roulette-table-number__green {
|
||||
background: green;
|
||||
}
|
||||
|
||||
.roulette-table-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
Loading…
Reference in New Issue