2022-09-04 20:53:34 +00:00
|
|
|
from files.__main__ import app
|
|
|
|
from files.helpers.wrappers import *
|
|
|
|
from files.helpers.alerts import *
|
|
|
|
from files.helpers.get import *
|
|
|
|
from files.helpers.const import *
|
|
|
|
from files.helpers.wrappers import *
|
|
|
|
from files.helpers.slots import *
|
|
|
|
from files.helpers.lottery import *
|
2022-09-10 21:01:34 +00:00
|
|
|
from files.helpers.casino import *
|
|
|
|
from files.helpers.twentyone import *
|
2022-09-13 01:07:39 +00:00
|
|
|
from files.helpers.roulette import *
|
2022-09-04 20:53:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.get("/casino")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-04 20:53:34 +00:00
|
|
|
def casino(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return render_template("casino/rehab.html", v=v)
|
2022-09-10 21:01:34 +00:00
|
|
|
|
2022-09-13 01:07:39 +00:00
|
|
|
return render_template("casino.html", v=v)
|
2022-09-09 23:55:13 +00:00
|
|
|
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-05 20:59:42 +00:00
|
|
|
@app.get("/casino/<game>")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-05 20:59:42 +00:00
|
|
|
def casino_game_page(v, game):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return render_template("casino/rehab.html", v=v)
|
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
feed = json.dumps(get_game_feed(game))
|
|
|
|
leaderboard = json.dumps(get_game_leaderboard(game))
|
|
|
|
|
|
|
|
return render_template(
|
|
|
|
f"casino/{game}_screen.html",
|
|
|
|
v=v,
|
|
|
|
game=game,
|
|
|
|
feed=feed,
|
|
|
|
leaderboard=leaderboard
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/casino/<game>/feed")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-10 21:01:34 +00:00
|
|
|
def casino_game_feed(v, game):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
feed = get_game_feed(game)
|
|
|
|
return {"feed": feed}
|
2022-09-05 20:59:42 +00:00
|
|
|
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-13 01:07:39 +00:00
|
|
|
# Lottershe
|
|
|
|
@app.get("/lottershe")
|
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-13 01:07:39 +00:00
|
|
|
def lottershe(v):
|
|
|
|
if v.rehab:
|
|
|
|
return render_template("casino/rehab.html", v=v)
|
|
|
|
|
|
|
|
participants = get_users_participating_in_lottery()
|
|
|
|
return render_template("lottery.html", v=v, participants=participants)
|
|
|
|
|
|
|
|
# Slots
|
2022-09-04 20:53:34 +00:00
|
|
|
@app.post("/casino/slots")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-04 20:53:34 +00:00
|
|
|
def pull_slots(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
2022-09-09 23:55:13 +00:00
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
try:
|
|
|
|
wager = int(request.values.get("wager"))
|
|
|
|
except:
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": "Invalid wager."}, 400
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
try:
|
|
|
|
currency = request.values.get("currency")
|
|
|
|
except:
|
2022-09-13 20:46:08 +00:00
|
|
|
return {"error": "Invalid currency (expected 'coin' or 'marseybux')."}, 400
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-13 20:46:08 +00:00
|
|
|
if (currency == "coin" and wager > v.coins) or (currency == "marseybux" and wager > v.procoins):
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": f"Not enough {currency} to make that bet."}, 400
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
success, game_state = casino_slot_pull(v, wager, currency)
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
if success:
|
|
|
|
return {"game_state": game_state, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
|
|
|
else:
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": f"Wager must be more than 5 {currency}."}, 400
|
2022-09-04 20:53:34 +00:00
|
|
|
|
|
|
|
|
2022-09-13 01:07:39 +00:00
|
|
|
# 21
|
2022-09-10 21:01:34 +00:00
|
|
|
@app.post("/casino/twentyone/deal")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-10 21:01:34 +00:00
|
|
|
def blackjack_deal_to_player(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
2022-09-09 23:55:13 +00:00
|
|
|
|
2022-09-11 02:27:27 +00:00
|
|
|
try:
|
|
|
|
wager = int(request.values.get("wager"))
|
|
|
|
currency = request.values.get("currency")
|
|
|
|
create_new_game(v, wager, currency)
|
|
|
|
state = dispatch_action(v, BlackjackAction.DEAL)
|
|
|
|
feed = get_game_feed('blackjack')
|
2022-09-04 20:53:34 +00:00
|
|
|
|
2022-09-13 01:07:39 +00:00
|
|
|
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
2022-09-11 02:29:22 +00:00
|
|
|
except Exception as e:
|
2022-09-13 01:07:39 +00:00
|
|
|
return {"error": str(e)}, 400
|
2022-09-04 20:53:34 +00:00
|
|
|
|
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
@app.post("/casino/twentyone/hit")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-10 21:01:34 +00:00
|
|
|
def blackjack_player_hit(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
|
|
|
|
2022-09-10 21:01:34 +00:00
|
|
|
try:
|
|
|
|
state = dispatch_action(v, BlackjackAction.HIT)
|
|
|
|
feed = get_game_feed('blackjack')
|
|
|
|
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
|
|
|
except:
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": "Unable to hit."}, 400
|
2022-09-10 21:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.post("/casino/twentyone/stay")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-10 21:01:34 +00:00
|
|
|
def blackjack_player_stay(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
2022-09-10 21:01:34 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
state = dispatch_action(v, BlackjackAction.STAY)
|
|
|
|
feed = get_game_feed('blackjack')
|
|
|
|
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
|
|
|
except:
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": "Unable to stay."}, 400
|
2022-09-10 21:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.post("/casino/twentyone/double-down")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-10 21:01:34 +00:00
|
|
|
def blackjack_player_doubled_down(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
2022-09-10 21:01:34 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
state = dispatch_action(v, BlackjackAction.DOUBLE_DOWN)
|
|
|
|
feed = get_game_feed('blackjack')
|
|
|
|
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
|
|
|
except:
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": "Unable to double down."}, 400
|
2022-09-10 21:01:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
@app.post("/casino/twentyone/buy-insurance")
|
2022-09-11 02:05:50 +00:00
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-10 21:01:34 +00:00
|
|
|
def blackjack_player_bought_insurance(v):
|
2022-09-13 01:07:39 +00:00
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
2022-09-10 21:01:34 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
state = dispatch_action(v, BlackjackAction.BUY_INSURANCE)
|
|
|
|
feed = get_game_feed('blackjack')
|
|
|
|
return {"success": True, "state": state, "feed": feed, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
|
|
|
except:
|
2022-09-12 09:52:07 +00:00
|
|
|
return {"error": "Unable to buy insurance."}, 400
|
2022-09-13 01:07:39 +00:00
|
|
|
|
|
|
|
# Roulette
|
|
|
|
@app.get("/casino/roulette/bets")
|
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-13 01:07:39 +00:00
|
|
|
def roulette_get_bets(v):
|
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
|
|
|
|
|
|
|
bets = get_roulette_bets()
|
|
|
|
|
|
|
|
return {"success": True, "bets": bets, "gambler": {"coins": v.coins, "procoins": v.procoins}}
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/casino/roulette/place-bet")
|
|
|
|
@limiter.limit("100/minute;2000/hour;12000/day")
|
2022-09-15 08:00:03 +00:00
|
|
|
@admin_level_required(3)
|
2022-09-13 01:07:39 +00:00
|
|
|
def roulette_player_placed_bet(v):
|
|
|
|
if v.rehab:
|
|
|
|
return {"error": "You are under Rehab award effect!"}, 400
|
|
|
|
|
|
|
|
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:
|
|
|
|
return {"error": 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:
|
2022-09-15 08:00:03 +00:00
|
|
|
return {"error": "Unable to place a bet."}, 400
|