forked from rDrama/rDrama
Fix issue with slots not reducing value / center casino games / update user currency without refresh
parent
5e1d98a3bf
commit
cfa4231f7d
|
@ -1,6 +1,7 @@
|
|||
.casino-games {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
// Shared
|
||||
function updatePlayerCoins(updated) {
|
||||
if (updated.coins) {
|
||||
document.getElementById('user-coins-amount').innerText = updated.coins;
|
||||
}
|
||||
|
||||
if (updated.procoins) {
|
||||
document.getElementById('user-bux-amount').innerText = updated.procoins;
|
||||
}
|
||||
}
|
||||
|
||||
// Slots
|
||||
function pullSlots() {
|
||||
const wager = document.getElementById("casinoSlotsBet").value;
|
||||
|
@ -35,7 +46,7 @@ function handleSlotsResponse(xhr) {
|
|||
slotsResult.classList.remove("text-success", "text-danger");
|
||||
|
||||
if (succeeded) {
|
||||
const { game_state } = response;
|
||||
const { game_state, gambler } = response;
|
||||
const state = JSON.parse(game_state);
|
||||
const reels = Array.from(document.querySelectorAll(".reel"));
|
||||
const symbols = state.symbols.split(",");
|
||||
|
@ -56,6 +67,8 @@ function handleSlotsResponse(xhr) {
|
|||
} else if (state.text.includes("Lost")) {
|
||||
slotsResult.classList.add("text-danger");
|
||||
}
|
||||
|
||||
updatePlayerCoins(gambler);
|
||||
} else {
|
||||
slotsResult.style.visibility = "visible";
|
||||
slotsResult.innerText = response.error;
|
||||
|
@ -318,6 +331,10 @@ function handleBlackjackResponse(xhr) {
|
|||
if (response.game_state) {
|
||||
updateBlackjack(response.game_state);
|
||||
}
|
||||
|
||||
if (response.gambler) {
|
||||
updatePlayerCoins(response.gambler);
|
||||
}
|
||||
} else {
|
||||
blackjackResult.style.visibility = "visible";
|
||||
blackjackResult.innerText = response.error;
|
||||
|
|
|
@ -35,6 +35,7 @@ def casino_slot_pull(gambler, wager_value, currency):
|
|||
payout = determine_payout()
|
||||
reward = wager_value * payout
|
||||
|
||||
currency_value = getattr(gambler, currency_prop, 0)
|
||||
setattr(gambler, currency_prop, currency_value + reward)
|
||||
gambler.winnings += reward
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ def pull_slots(v):
|
|||
success, game_state = casino_slot_pull(v, wager, currency)
|
||||
|
||||
if success:
|
||||
return {"game_state": game_state}
|
||||
return {"game_state": game_state, "gambler": { "coins": v.coins, "procoins": v.procoins }}
|
||||
else:
|
||||
return {"error": "Wager must be more than 100 {currency}."}
|
||||
|
||||
|
@ -76,9 +76,9 @@ def deal_blackjack(v):
|
|||
|
||||
if game and game.active:
|
||||
safe_state = get_safe_game_state(v)
|
||||
return {"game_state": safe_state}
|
||||
return {"game_state": safe_state, "gambler": { "coins": v.coins, "procoins": v.procoins }}
|
||||
else:
|
||||
return {"game_state": game_state}
|
||||
return {"game_state": game_state, "gambler": { "coins": v.coins, "procoins": v.procoins }}
|
||||
|
||||
else:
|
||||
return {"error": "Wager must be more than 100 {currency}."}
|
||||
|
@ -113,6 +113,6 @@ def player_took_blackjack_action(v):
|
|||
state = game_state
|
||||
|
||||
if was_successful:
|
||||
return {"active": True, "game_state": state}
|
||||
return {"active": True, "game_state": state, "gambler": { "coins": v.coins, "procoins": v.procoins }}
|
||||
else:
|
||||
return {"active": False, "game_state": None}
|
||||
|
|
|
@ -3,249 +3,251 @@
|
|||
<script src="/assets/js/casino.js?v=2001"></script>
|
||||
|
||||
<!-- New -->
|
||||
<!-- Slots -->
|
||||
<div id="slots-block" class="casino-block">
|
||||
<div class="casino-block-title">
|
||||
Slots
|
||||
<hr style="flex: 1; margin-left: 1rem" />
|
||||
</div>
|
||||
<div class="casino-block-inner">
|
||||
<div class="casino-block-left">
|
||||
<!-- Game -->
|
||||
<div class="casino-block-game">
|
||||
<div>
|
||||
<div class="casino-slots-results" style="flex: 1">
|
||||
<div class="reel">
|
||||
<img src="/i/rDrama/coins.webp?v=3009" alt="coin" />
|
||||
</div>
|
||||
<div class="reel">
|
||||
<img src="/i/rDrama/coins.webp?v=3009" alt="coin" />
|
||||
</div>
|
||||
<div class="reel">
|
||||
<img src="/i/rDrama/coins.webp?v=3009" alt="coin" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="casino-slots-outcome" id="casinoSlotsResult"> </div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bet -->
|
||||
<div class="casino-block-bet">
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys" style="margin-right: 1rem">
|
||||
<div>Enter Bet</div>
|
||||
<div>
|
||||
<input
|
||||
id="casinoSlotsBet"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="100"
|
||||
min="100"
|
||||
step="1"
|
||||
aria-label="Bet"
|
||||
name="casinoSlotsBet"
|
||||
type="number"
|
||||
style="flex: 1; max-width: 200px; text-align: right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lottery-page--stat-values">
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoSlotsCurrency"
|
||||
id="casinoSlotsCurrencyDramacoin"
|
||||
value="dramacoin"
|
||||
checked
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoSlotsCurrencyDramacoin"
|
||||
>
|
||||
<img
|
||||
src="/i/rDrama/coins.webp?v=3009"
|
||||
alt="coin"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Dramacoin"
|
||||
aria-label="Dramacoin"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoSlotsCurrency"
|
||||
id="casinoSlotsCurrencyMarseybux"
|
||||
value="marseybux"
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoSlotsCurrencyMarseybux"
|
||||
>
|
||||
<img
|
||||
src="/i/marseybux.webp?v=2000"
|
||||
alt="marseybux"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Marseybux"
|
||||
aria-label="Marseybux"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success lottery-page--action"
|
||||
id="casinoSlotsPull"
|
||||
style="width: 100%"
|
||||
onclick="pullSlots()"
|
||||
>
|
||||
Pull
|
||||
</button>
|
||||
</div>
|
||||
<div class="casino-games">
|
||||
<!-- Slots -->
|
||||
<div id="slots-block" class="casino-block">
|
||||
<div class="casino-block-title">
|
||||
Slots
|
||||
<hr style="flex: 1; margin-left: 1rem" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Blackjack -->
|
||||
<div id="blackjack-block" class="casino-block">
|
||||
<div class="casino-block-title">
|
||||
Blackjack
|
||||
<hr style="flex: 1; margin-left: 1rem" />
|
||||
</div>
|
||||
<div class="casino-block-inner">
|
||||
<div class="casino-block-left">
|
||||
<!-- Game -->
|
||||
<div class="casino-block-game">
|
||||
<div class="casino-game">
|
||||
<div style="flex: 1">
|
||||
<div class="blackjack-table">
|
||||
<div style="display: flex; align-items: center">
|
||||
<small style="margin-right: 0.5rem">Dealer</small>
|
||||
<hr style="flex: 1" />
|
||||
<div class="casino-block-inner">
|
||||
<div class="casino-block-left">
|
||||
<!-- Game -->
|
||||
<div class="casino-block-game">
|
||||
<div>
|
||||
<div class="casino-slots-results" style="flex: 1">
|
||||
<div class="reel">
|
||||
<img src="/i/rDrama/coins.webp?v=3009" alt="coin" />
|
||||
</div>
|
||||
<div class="hand" id="casinoBlackjackDealerHand">
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="reel">
|
||||
<img src="/i/rDrama/coins.webp?v=3009" alt="coin" />
|
||||
</div>
|
||||
<hr />
|
||||
<div class="hand" id="casinoBlackjackPlayerHand">
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center">
|
||||
<hr style="flex: 1; margin-right: 0.5rem" />
|
||||
<small>Player</small>
|
||||
<div class="reel">
|
||||
<img src="/i/rDrama/coins.webp?v=3009" alt="coin" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
id="casinoBlackjackResult"
|
||||
class="casino-blackjack-outcome"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bet -->
|
||||
<div class="casino-block-bet">
|
||||
<div id="casinoBlackjackWager" class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys" style="margin-right: 1rem">
|
||||
<div>Enter Bet</div>
|
||||
<div>
|
||||
<input
|
||||
id="casinoBlackjackBet"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="100"
|
||||
min="100"
|
||||
step="1"
|
||||
aria-label="Bet"
|
||||
name="casinoBlackjackBet"
|
||||
type="number"
|
||||
style="flex: 1; max-width: 200px; text-align: right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lottery-page--stat-values">
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoBlackjackCurrency"
|
||||
id="casinoBlackjackCurrencyDramacoin"
|
||||
value="dramacoin"
|
||||
checked
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoBlackjackCurrencyDramacoin"
|
||||
>
|
||||
<img
|
||||
src="/i/rDrama/coins.webp?v=3009"
|
||||
alt="coin"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Dramacoin"
|
||||
aria-label="Dramacoin"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoBlackjackCurrency"
|
||||
id="casinoBlackjackCurrencyMarseybux"
|
||||
value="marseybux"
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoBlackjackCurrencyMarseybux"
|
||||
>
|
||||
<img
|
||||
src="/i/marseybux.webp?v=2000"
|
||||
alt="marseybux"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Marseybux"
|
||||
aria-label="Marseybux"
|
||||
/>
|
||||
</label>
|
||||
<div class="casino-slots-outcome" id="casinoSlotsResult">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bet -->
|
||||
<div class="casino-block-bet">
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys" style="margin-right: 1rem">
|
||||
<div>Enter Bet</div>
|
||||
<div>
|
||||
<input
|
||||
id="casinoSlotsBet"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="100"
|
||||
min="100"
|
||||
step="1"
|
||||
aria-label="Bet"
|
||||
name="casinoSlotsBet"
|
||||
type="number"
|
||||
style="flex: 1; max-width: 200px; text-align: right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lottery-page--stat-values">
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoSlotsCurrency"
|
||||
id="casinoSlotsCurrencyDramacoin"
|
||||
value="dramacoin"
|
||||
checked
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoSlotsCurrencyDramacoin"
|
||||
>
|
||||
<img
|
||||
src="/i/rDrama/coins.webp?v=3009"
|
||||
alt="coin"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Dramacoin"
|
||||
aria-label="Dramacoin"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoSlotsCurrency"
|
||||
id="casinoSlotsCurrencyMarseybux"
|
||||
value="marseybux"
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoSlotsCurrencyMarseybux"
|
||||
>
|
||||
<img
|
||||
src="/i/marseybux.webp?v=2000"
|
||||
alt="marseybux"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Marseybux"
|
||||
aria-label="Marseybux"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="casinoBlackjackActions" class="casino-blackjack-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success lottery-page--action"
|
||||
id="casinoBlackjackDeal"
|
||||
id="casinoSlotsPull"
|
||||
style="width: 100%"
|
||||
onclick="dealBlackjack()"
|
||||
onclick="pullSlots()"
|
||||
>
|
||||
Deal
|
||||
Pull
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Blackjack -->
|
||||
<div id="blackjack-block" class="casino-block">
|
||||
<div class="casino-block-title">
|
||||
Blackjack
|
||||
<hr style="flex: 1; margin-left: 1rem" />
|
||||
</div>
|
||||
<div class="casino-block-inner">
|
||||
<div class="casino-block-left">
|
||||
<!-- Game -->
|
||||
<div class="casino-block-game">
|
||||
<div class="casino-game">
|
||||
<div style="flex: 1">
|
||||
<div class="blackjack-table">
|
||||
<div style="display: flex; align-items: center">
|
||||
<small style="margin-right: 0.5rem">Dealer</small>
|
||||
<hr style="flex: 1" />
|
||||
</div>
|
||||
<div class="hand" id="casinoBlackjackDealerHand">
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
<div class="playing-card" data-who="dealer"></div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="hand" id="casinoBlackjackPlayerHand">
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
<div class="playing-card" data-who="player"></div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center">
|
||||
<hr style="flex: 1; margin-right: 0.5rem" />
|
||||
<small>Player</small>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
id="casinoBlackjackResult"
|
||||
class="casino-blackjack-outcome"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Bet -->
|
||||
<div class="casino-block-bet">
|
||||
<div id="casinoBlackjackWager" class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys" style="margin-right: 1rem">
|
||||
<div>Enter Bet</div>
|
||||
<div>
|
||||
<input
|
||||
id="casinoBlackjackBet"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="100"
|
||||
min="100"
|
||||
step="1"
|
||||
aria-label="Bet"
|
||||
name="casinoBlackjackBet"
|
||||
type="number"
|
||||
style="flex: 1; max-width: 200px; text-align: right"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lottery-page--stat-values">
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoBlackjackCurrency"
|
||||
id="casinoBlackjackCurrencyDramacoin"
|
||||
value="dramacoin"
|
||||
checked
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoBlackjackCurrencyDramacoin"
|
||||
>
|
||||
<img
|
||||
src="/i/rDrama/coins.webp?v=3009"
|
||||
alt="coin"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Dramacoin"
|
||||
aria-label="Dramacoin"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input
|
||||
class="form-check-input"
|
||||
type="radio"
|
||||
name="casinoBlackjackCurrency"
|
||||
id="casinoBlackjackCurrencyMarseybux"
|
||||
value="marseybux"
|
||||
/>
|
||||
<label
|
||||
class="form-check-label"
|
||||
for="casinoBlackjackCurrencyMarseybux"
|
||||
>
|
||||
<img
|
||||
src="/i/marseybux.webp?v=2000"
|
||||
alt="marseybux"
|
||||
width="40"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
title="Marseybux"
|
||||
aria-label="Marseybux"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="casinoBlackjackActions" class="casino-blackjack-actions">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success lottery-page--action"
|
||||
id="casinoBlackjackDeal"
|
||||
style="width: 100%"
|
||||
onclick="dealBlackjack()"
|
||||
>
|
||||
Deal
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="casino-lottery">{% include "lottery.html" %}</div>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue