[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: millionaire_game.js
// Millionaire Game JavaScript $(document).ready(function() { console.log('Millionaire Game initialized'); }); function startGame() { playSound('gameStart'); gameData.current_level = 1; updateMoneyLadder(); loadQuestion(); $('#questionArea').html(''); $('#answersArea').show(); $('#actionButtons').show(); } function loadQuestion() { // Get random question from current level const levelQuestions = gameData.questions[gameData.current_level]; console.log('Loading question for level:', gameData.current_level); console.log('Available questions:', levelQuestions); if (!levelQuestions || levelQuestions.length === 0) { endGame(false, 'لا توجد أسئلة لهذا المستوى'); return; } const randomIndex = Math.floor(Math.random() * levelQuestions.length); gameData.current_question = levelQuestions[randomIndex]; console.log('Selected question:', gameData.current_question); // Display question let questionHtml = ` <div class="text-center mb-3"> <h4>السؤال رقم ${gameData.current_level}</h4> <h5 class="text-warning">للفوز بـ ${gameData.money_ladder[gameData.current_level]}</h5> </div> `; if (gameData.current_question.question_image) { questionHtml += ` <div class="text-center mb-3"> <img src="../${gameData.current_question.question_image}" class="img-fluid rounded" style="max-height: 200px;"> </div> `; } questionHtml += `<h5 class="text-center">${gameData.current_question.question_text}</h5>`; $('#questionArea').html(questionHtml); // Display answers $('#answer1 .answer-text').text(gameData.current_question.answer1); $('#answer2 .answer-text').text(gameData.current_question.answer2); $('#answer3 .answer-text').text(gameData.current_question.answer3); $('#answer4 .answer-text').text(gameData.current_question.answer4); // Reset answer buttons $('.millionaire-answer').removeClass('selected correct incorrect disabled').prop('disabled', false); $('#finalAnswer').prop('disabled', true); gameData.selected_answer = 0; // Update current prize updateCurrentPrize(); console.log('Question loaded successfully'); } function selectAnswer(answerNumber) { if ($(`#answer${answerNumber}`).hasClass('disabled')) { return; } // Remove previous selection $('.millionaire-answer').removeClass('selected'); // Select new answer $(`#answer${answerNumber}`).addClass('selected'); gameData.selected_answer = answerNumber; // Enable final answer button $('#finalAnswer').prop('disabled', false); } function confirmAnswer() { if (gameData.selected_answer === 0) { return; } // Disable all buttons $('.millionaire-answer').prop('disabled', true); $('#finalAnswer').prop('disabled', true); // Check if answer is correct const isCorrect = parseInt(gameData.selected_answer) === parseInt(gameData.current_question.correct_answer); // Show correct answer $(`.millionaire-answer`).removeClass('selected'); $(`#answer${gameData.current_question.correct_answer}`).addClass('correct'); if (!isCorrect) { $(`#answer${gameData.selected_answer}`).addClass('incorrect'); playSound('millionaireWrong'); setTimeout(() => { endGame(false, 'إجابة خاطئة!'); }, 3000); } else { playSound('millionaireCorrect'); // Update ladder $(`.ladder-item`).removeClass('active completed'); $(`#ladder-${gameData.current_level}`).addClass('completed'); if (gameData.current_level === 15) { // Won the million! setTimeout(() => { endGame(true, 'مبروك! لقد ربحت المليون ريال!'); }, 3000); } else { // Move to next level setTimeout(() => { gameData.current_level++; updateMoneyLadder(); loadQuestion(); }, 3000); } } } function walkAway() { const currentPrize = gameData.current_level > 1 ? gameData.money_ladder[gameData.current_level - 1] : '0 ريال'; if (confirm(`هل أنت متأكد من الانسحاب بمبلغ ${currentPrize}؟`)) { endGame(true, `لقد انسحبت بمبلغ ${currentPrize}`); } } function useFiftyFifty() { if (gameData.lifelines_used.fifty_fifty) { return; } gameData.lifelines_used.fifty_fifty = true; $('#fiftyFifty').addClass('used'); playSound('lifeline'); // Remove two wrong answers const correctAnswer = gameData.current_question.correct_answer; const wrongAnswers = [1, 2, 3, 4].filter(num => num !== correctAnswer); // Randomly select 2 wrong answers to remove const toRemove = wrongAnswers.sort(() => 0.5 - Math.random()).slice(0, 2); toRemove.forEach(answerNum => { $(`#answer${answerNum}`).addClass('disabled').prop('disabled', true); $(`#answer${answerNum} .answer-text`).text(''); }); showAlert('تم حذف إجابتين خاطئتين', 'info'); } function askAudience() { if (gameData.lifelines_used.ask_audience) { return; } gameData.lifelines_used.ask_audience = true; $('#askAudience').addClass('used'); playSound('lifeline'); // Generate audience poll results const correctAnswer = gameData.current_question.correct_answer; const results = [0, 0, 0, 0]; // Give correct answer higher probability results[correctAnswer - 1] = Math.floor(Math.random() * 30) + 40; // 40-70% // Distribute remaining percentage among other answers let remaining = 100 - results[correctAnswer - 1]; for (let i = 0; i < 4; i++) { if (i !== correctAnswer - 1) { if (remaining > 0) { const portion = Math.floor(Math.random() * remaining); results[i] = portion; remaining -= portion; } } } // Add any remaining to a random wrong answer if (remaining > 0) { const wrongAnswers = [0, 1, 2, 3].filter(i => i !== correctAnswer - 1); const randomWrong = wrongAnswers[Math.floor(Math.random() * wrongAnswers.length)]; results[randomWrong] += remaining; } // Display results let resultsHtml = '<div class="audience-poll">'; const labels = ['أ', 'ب', 'ج', 'د']; results.forEach((percentage, index) => { resultsHtml += ` <div class="poll-result mb-2"> <div class="d-flex justify-content-between"> <span>${labels[index]}: ${percentage}%</span> </div> <div class="progress"> <div class="progress-bar bg-primary" style="width: ${percentage}%"></div> </div> </div> `; }); resultsHtml += '</div>'; $('#audienceResults').html(resultsHtml); $('#audienceModal').modal('show'); } function callFriend() { if (gameData.lifelines_used.call_friend) { return; } gameData.lifelines_used.call_friend = true; $('#callFriend').addClass('used'); playSound('lifeline'); // Generate friend's advice const correctAnswer = gameData.current_question.correct_answer; const labels = ['أ', 'ب', 'ج', 'د']; let advice = ''; const confidence = Math.random(); if (confidence > 0.7) { // Friend is confident about correct answer advice = `أعتقد أن الإجابة الصحيحة هي ${labels[correctAnswer - 1]}. أنا متأكد بنسبة 80%.`; } else if (confidence > 0.4) { // Friend is unsure but leans toward correct answer const wrongAnswer = Math.floor(Math.random() * 4) + 1; advice = `أعتقد أن الإجابة إما ${labels[correctAnswer - 1]} أو ${labels[wrongAnswer - 1]}، لكنني أميل أكثر لـ ${labels[correctAnswer - 1]}.`; } else { // Friend is not sure advice = `آسف، هذا السؤال صعب جداً. لست متأكداً من الإجابة. أنصحك بالاعتماد على معرفتك.`; } $('#friendAdvice').text(advice); $('#friendModal').modal('show'); } function updateMoneyLadder() { $('.ladder-item').removeClass('active completed'); // Mark completed levels for (let i = 1; i < gameData.current_level; i++) { $(`#ladder-${i}`).addClass('completed'); } // Mark current level $(`#ladder-${gameData.current_level}`).addClass('active'); } function updateCurrentPrize() { const currentPrize = gameData.current_level > 1 ? gameData.money_ladder[gameData.current_level - 1] : '0 ريال'; $('#currentPrize').text(currentPrize); } function endGame(won, message) { playSound('gameEnd'); let finalPrize = '0 ريال'; let finalScore = 0; if (won && gameData.current_level > 1) { finalPrize = gameData.money_ladder[gameData.current_level === 15 && won ? 15 : gameData.current_level - 1]; // Convert prize to score (1000 currency = 1 point) const prizeNumber = parseInt(finalPrize.replace(/[^\d]/g, '')); finalScore = Math.floor(prizeNumber / 1000); } let resultsHtml = ` <div class="text-center"> <h2>${won ? '🎉' : '😔'} ${message}</h2> <h3 class="text-warning">المبلغ النهائي: ${finalPrize}</h3> <h4 class="text-info">النقاط المكتسبة: ${finalScore} نقطة</h4> <div class="mt-4"> <button class="btn btn-primary me-2" onclick="location.reload()"> <i class="fas fa-redo me-1"></i> لعب مرة أخرى </button> <button class="btn btn-secondary" onclick="window.location.href='../index.php'"> <i class="fas fa-home me-1"></i> العودة للرئيسية </button> </div> </div> `; $('#questionArea').html(resultsHtml); $('#answersArea').hide(); $('#actionButtons').hide(); // Save results if not public game if (!gameData.is_public) { saveGameResults(finalPrize, finalScore); } } function saveGameResults(finalPrize, finalScore) { $.ajax({ url: '../ajax/save_millionaire_results.php', type: 'POST', data: { competition_id: gameData.competition_id, player_name: gameData.player_name, final_level: gameData.current_level - 1, final_prize: finalPrize, final_score: finalScore }, success: function(response) { console.log('Results saved successfully'); }, error: function() { console.log('Failed to save results'); } }); }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.86 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285