2025-05-29 14:12:27 +03:00
< script lang = "ts" >
import Coinflip from '$lib/components/self/games/Coinflip.svelte';
import Slots from '$lib/components/self/games/Slots.svelte';
import { USER_DATA } from '$lib/stores/user-data';
2025-06-11 11:06:05 +03:00
import { PORTFOLIO_SUMMARY , fetchPortfolioSummary } from '$lib/stores/portfolio-data';
2025-05-29 14:12:27 +03:00
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
import SignInConfirmDialog from '$lib/components/self/SignInConfirmDialog.svelte';
import { Button } from '$lib/components/ui/button';
2025-05-30 13:15:00 +03:00
import SEO from '$lib/components/self/SEO.svelte';
2025-05-29 14:12:27 +03:00
let shouldSignIn = $state(false);
let balance = $state(0);
let loading = $state(true);
let activeGame = $state('coinflip');
function handleBalanceUpdate(newBalance: number) {
balance = newBalance;
2025-06-11 11:06:05 +03:00
if ($PORTFOLIO_SUMMARY) {
PORTFOLIO_SUMMARY.update((data) =>
2025-05-29 14:12:27 +03:00
data
? {
...data,
baseCurrencyBalance: newBalance,
totalValue: newBalance + data.totalCoinValue
}
: null
);
}
}
$effect(() => {
2025-06-11 11:06:05 +03:00
if ($USER_DATA && $PORTFOLIO_SUMMARY) {
balance = $PORTFOLIO_SUMMARY.baseCurrencyBalance;
2025-05-29 14:12:27 +03:00
}
});
< / script >
2025-05-30 13:15:00 +03:00
< SEO
title="Gambling - Rugplay"
description="Play virtual gambling games with simulated currency in Rugplay. Try coinflip and slots games using virtual money with no real-world value - purely for entertainment."
keywords="virtual gambling simulation, coinflip game, slots game, virtual casino, simulated gambling, entertainment games"
/>
2025-05-29 14:12:27 +03:00
< SignInConfirmDialog bind:open = { shouldSignIn } / >
2025-05-30 13:15:00 +03:00
2025-05-29 14:12:27 +03:00
< div class = "container mx-auto max-w-4xl p-6" >
< h1 class = "mb-6 text-center text-3xl font-bold" > Gambling< / h1 >
{ #if ! $USER_DATA }
< div class = "flex h-96 items-center justify-center" >
< div class = "text-center" >
< div class = "text-muted-foreground mb-4 text-xl" > Sign in to start gambling< / div >
< p class = "text-muted-foreground mb-4 text-sm" > You need an account to place bets< / p >
2025-06-10 20:20:50 +02:00
< Button onclick = {() => ( shouldSignIn = true )} > Sign In </ Button >
2025-05-29 14:12:27 +03:00
< / div >
< / div >
{ : else }
<!-- Game Selection -->
< div class = "mb-6 flex justify-center gap-4" >
< Button
variant={ activeGame === 'coinflip' ? 'default' : 'outline' }
onclick={() => ( activeGame = 'coinflip' )}
>
Coinflip
< / Button >
< Button
variant={ activeGame === 'slots' ? 'default' : 'outline' }
onclick={() => ( activeGame = 'slots' )}
>
Slots
< / Button >
< / div >
<!-- Game Content -->
{ #if activeGame === 'coinflip' }
< Coinflip bind:balance onBalanceUpdate = { handleBalanceUpdate } / >
{ :else if activeGame === 'slots' }
< Slots bind:balance onBalanceUpdate = { handleBalanceUpdate } / >
{ /if }
{ /if }
< / div >