disable mines
This commit is contained in:
parent
24a656faa1
commit
c7d6c49903
4 changed files with 38 additions and 11 deletions
|
|
@ -105,7 +105,14 @@
|
||||||
async function handleTileClick(index: number) {
|
async function handleTileClick(index: number) {
|
||||||
if (!isPlaying || revealedTiles.includes(index) || !sessionToken) return;
|
if (!isPlaying || revealedTiles.includes(index) || !sessionToken) return;
|
||||||
lastClickedTile = index;
|
lastClickedTile = index;
|
||||||
try {
|
|
||||||
|
// Temporarily disabled - using local simulation
|
||||||
|
toast.error('Mines game temporarily disabled', {
|
||||||
|
description: 'This feature is currently under maintenance'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* try {
|
||||||
const response = await fetch('/api/gambling/mines/reveal', {
|
const response = await fetch('/api/gambling/mines/reveal', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|
@ -142,12 +149,19 @@
|
||||||
toast.error('Failed to reveal tile', {
|
toast.error('Failed to reveal tile', {
|
||||||
description: error instanceof Error ? error.message : 'Unknown error occurred'
|
description: error instanceof Error ? error.message : 'Unknown error occurred'
|
||||||
});
|
});
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cashOut() {
|
async function cashOut() {
|
||||||
if (!isPlaying || !sessionToken) return;
|
if (!isPlaying || !sessionToken) return;
|
||||||
try {
|
|
||||||
|
// Temporarily disabled
|
||||||
|
toast.error('Mines game temporarily disabled', {
|
||||||
|
description: 'This feature is currently under maintenance'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* try {
|
||||||
const response = await fetch('/api/gambling/mines/cashout', {
|
const response = await fetch('/api/gambling/mines/cashout', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|
@ -175,12 +189,19 @@
|
||||||
toast.error('Failed to cash out', {
|
toast.error('Failed to cash out', {
|
||||||
description: error instanceof Error ? error.message : 'Unknown error occurred'
|
description: error instanceof Error ? error.message : 'Unknown error occurred'
|
||||||
});
|
});
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startGame() {
|
async function startGame() {
|
||||||
if (!canBet) return;
|
if (!canBet) return;
|
||||||
balance -= betAmount;
|
|
||||||
|
// Temporarily disabled
|
||||||
|
toast.error('Mines game temporarily disabled', {
|
||||||
|
description: 'This feature is currently under maintenance'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* balance -= betAmount;
|
||||||
onBalanceUpdate?.(balance);
|
onBalanceUpdate?.(balance);
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/gambling/mines/start', {
|
const response = await fetch('/api/gambling/mines/start', {
|
||||||
|
|
@ -207,7 +228,7 @@
|
||||||
toast.error('Failed to start game', {
|
toast.error('Failed to start game', {
|
||||||
description: error instanceof Error ? error.message : 'Unknown error occurred'
|
description: error instanceof Error ? error.message : 'Unknown error occurred'
|
||||||
});
|
});
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import { getSessionKey } from '$lib/server/games/mines';
|
||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
|
|
||||||
export const POST: RequestHandler = async ({ request }) => {
|
export const POST: RequestHandler = async ({ request }) => {
|
||||||
|
throw error(503, 'Service temporarily unavailable');
|
||||||
|
|
||||||
const session = await auth.api.getSession({
|
const session = await auth.api.getSession({
|
||||||
headers: request.headers
|
headers: request.headers
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import { redis, } from '$lib/server/redis';
|
||||||
import { getSessionKey } from '$lib/server/games/mines';
|
import { getSessionKey } from '$lib/server/games/mines';
|
||||||
|
|
||||||
export const POST: RequestHandler = async ({ request }) => {
|
export const POST: RequestHandler = async ({ request }) => {
|
||||||
|
throw error(503, 'Service temporarily unavailable');
|
||||||
|
|
||||||
const session = await auth.api.getSession({
|
const session = await auth.api.getSession({
|
||||||
headers: request.headers
|
headers: request.headers
|
||||||
});
|
});
|
||||||
|
|
@ -40,7 +42,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
if (game.minePositions.includes(tileIndex)) {
|
if (game.minePositions.includes(tileIndex)) {
|
||||||
game.status = 'lost';
|
game.status = 'lost';
|
||||||
const minePositions = game.minePositions;
|
const minePositions = game.minePositions;
|
||||||
|
|
||||||
const userId = Number(session.user.id);
|
const userId = Number(session.user.id);
|
||||||
const [userData] = await db
|
const [userData] = await db
|
||||||
.select({ baseCurrencyBalance: user.baseCurrencyBalance })
|
.select({ baseCurrencyBalance: user.baseCurrencyBalance })
|
||||||
|
|
@ -58,9 +60,9 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
updatedAt: new Date()
|
updatedAt: new Date()
|
||||||
})
|
})
|
||||||
.where(eq(user.id, userId));
|
.where(eq(user.id, userId));
|
||||||
|
|
||||||
await redis.del(getSessionKey(sessionToken));
|
await redis.del(getSessionKey(sessionToken));
|
||||||
|
|
||||||
return json({
|
return json({
|
||||||
hitMine: true,
|
hitMine: true,
|
||||||
minePositions,
|
minePositions,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import { getSessionKey } from '$lib/server/games/mines';
|
||||||
import type { RequestHandler } from './$types';
|
import type { RequestHandler } from './$types';
|
||||||
|
|
||||||
export const POST: RequestHandler = async ({ request }) => {
|
export const POST: RequestHandler = async ({ request }) => {
|
||||||
|
throw error(503, 'Service temporarily unavailable');
|
||||||
|
|
||||||
const session = await auth.api.getSession({
|
const session = await auth.api.getSession({
|
||||||
headers: request.headers
|
headers: request.headers
|
||||||
});
|
});
|
||||||
|
|
@ -51,7 +53,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// transaction token for authentication stuff
|
// transaction token for authentication stuff
|
||||||
const randomBytes = new Uint8Array(8);
|
const randomBytes = new Uint8Array(8);
|
||||||
crypto.getRandomValues(randomBytes);
|
crypto.getRandomValues(randomBytes);
|
||||||
const sessionToken = Array.from(randomBytes)
|
const sessionToken = Array.from(randomBytes)
|
||||||
.map(b => b.toString(16).padStart(2, '0'))
|
.map(b => b.toString(16).padStart(2, '0'))
|
||||||
|
|
@ -85,7 +87,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
})
|
})
|
||||||
.where(eq(user.id, userId));
|
.where(eq(user.id, userId));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sessionToken,
|
sessionToken,
|
||||||
newBalance
|
newBalance
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Reference in a new issue