Merge pull request #45 from cassoule/milo-250827

updagraded solitaire and removed "no" option on timeout votes
This commit is contained in:
Milo Gourvest
2025-08-27 13:22:44 +02:00
committed by GitHub
2 changed files with 16 additions and 5 deletions

View File

@@ -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 },
],
}],
},

View File

@@ -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) {