مسابقات رمضانية

let questions=[
{q:“شخص فقد الوعي، ما أول خطوة؟”,
options:[“رش ماء”,“التأكد من التنفس”,“إعطاء عصير”],
answer:1},

{q:“عند الحروق؟”,
options:[“وضع زيت”,“تبريد بالماء”,“تغطية بقطن”],
answer:1},

{q:“نزيف شديد؟”,
options:[“الضغط على الجرح”,“تركه”,“غسله فقط”],
answer:0},

{q:“كسر في الساق؟”,
options:[“تحريكها بقوة”,“تثبيت وعدم تحريك”,“تدليكها”],
answer:1},

{q:“اختناق؟”,
options:[“إعطاؤه ماء”,“مناورة هيمليك”,“ضرب الرأس”],
answer:1}
];

let score=0;
let currentIndex=0;
let dailyQuestions=;
let current;

function startGame(){
let name=document.getElementById(“playerName”).value;
if(name===“”){alert(“اكتب اسمك”);return;}

document.getElementById(“game”).style.display=“block”;

generateDailyQuestions();
loadQuestion();
}

function generateDailyQuestions(){
let shuffled=[…questions].sort(()=>0.5-Math.random());
dailyQuestions=shuffled.slice(0,3);
currentIndex=0;
}

function loadQuestion(){
current=dailyQuestions[currentIndex];
document.getElementById(“question”).innerText=current.q;

let optionsDiv=document.getElementById(“options”);
optionsDiv.innerHTML=“”;
current.options.forEach((opt,i)=>{
let btn=document.createElement(“button”);
btn.innerText=opt;
btn.onclick=function(){checkAnswer(i)};
optionsDiv.appendChild(btn);
});

document.getElementById(“result”).innerHTML=“”;
}

function checkAnswer(i){

if(i===current.answer){
score+=10;
document.getElementById(“result”).innerHTML=“:tada: أحسنت!”;
}else{
document.getElementById(“result”).innerHTML=“:sweat_smile: خطأ!”;
}

document.getElementById(“score”).innerText=score;

setTimeout(()=>{
currentIndex++;

if(currentIndex<3){
loadQuestion();
}else{
endGame();
}

},1500);
}

function endGame(){

document.getElementById(“question”).innerHTML=
:trophy: انتهى تحدي اليوم!

نتيجتك: “+score+” نقطة”;

document.getElementById(“options”).innerHTML=“”;
document.getElementById(“result”).innerHTML=

:dove: غدًا نكمل المستوى – المرحلة الثانية”;
}

function speak(){
let speech=new SpeechSynthesisUtterance(current.q);
speech.lang=“ar-SA”;
window.speechSynthesis.speak(speech);
}