mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
updagraded solitaire and removed "no" option on timeout votes
This commit is contained in:
@@ -164,7 +164,6 @@ export async function handleTimeoutCommand(req, res, client) {
|
||||
type: MessageComponentTypes.ACTION_ROW,
|
||||
components: [
|
||||
{ type: MessageComponentTypes.BUTTON, custom_id: `vote_for_${pollId}`, label: 'Oui ✅', style: ButtonStyleTypes.SUCCESS },
|
||||
{ type: MessageComponentTypes.BUTTON, custom_id: `vote_against_${pollId}`, label: 'Non ❌', style: ButtonStyleTypes.DANGER },
|
||||
],
|
||||
}],
|
||||
},
|
||||
@@ -204,7 +203,6 @@ export async function handleTimeoutCommand(req, res, client) {
|
||||
type: MessageComponentTypes.ACTION_ROW,
|
||||
components: [
|
||||
{ type: MessageComponentTypes.BUTTON, custom_id: `vote_for_${pollId}`, label: 'Oui ✅', style: ButtonStyleTypes.SUCCESS },
|
||||
{ type: MessageComponentTypes.BUTTON, custom_id: `vote_against_${pollId}`, label: 'Non ❌', style: ButtonStyleTypes.DANGER },
|
||||
],
|
||||
}],
|
||||
},
|
||||
|
||||
@@ -206,13 +206,26 @@ function updateGameStats(gameState, actionType, moveData = {}) {
|
||||
|
||||
/** Handles the logic when a game is won. */
|
||||
async function handleWin(userId, gameState, io) {
|
||||
if (!gameState.isSOTD) return;
|
||||
const currentUser = getUser.get(userId);
|
||||
if (!currentUser) return;
|
||||
|
||||
if (gameState.hardMode) {
|
||||
const bonus = 100;
|
||||
const newCoins = currentUser.coins + bonus;
|
||||
updateUserCoins.run({ id: userId, coins: newCoins });
|
||||
insertLog.run({
|
||||
id: `${userId}-hardmode-solitaire-${Date.now()}`, user_id: userId,
|
||||
action: 'HARDMODE_SOLITAIRE_WIN', target_user_id: null,
|
||||
coins_amount: bonus, user_new_amount: newCoins,
|
||||
});
|
||||
await socketEmit('data-updated', { table: 'users' });
|
||||
}
|
||||
|
||||
if (!gameState.isSOTD) return; // Only process SOTD wins here
|
||||
|
||||
gameState.endTime = Date.now();
|
||||
const timeTaken = gameState.endTime - gameState.startTime;
|
||||
|
||||
const currentUser = getUser.get(userId);
|
||||
if (!currentUser) return;
|
||||
const existingStats = getUserSOTDStats.get(userId);
|
||||
|
||||
if (!existingStats) {
|
||||
|
||||
Reference in New Issue
Block a user