๐Ÿค– AI LOGIC LABS

โ•โ• Recruit ยท Solve ยท Rank Up โ•โ•
๐Ÿ† Rank: Prompt Rookie Rookie
โญ XP: 0
๐Ÿช™ Coins: 0
๐ŸŽฏ Score: 0
โ† Back to AI Universe
',bug:'Missing DOCTYPE declaration',fix:'\n\n\n

Hello World

\n\n',type:'html',hint:'Kya aapne HTML5 ka doctype add kiya?'}, {code:'const x = [1,2,3]\nx.forEach(item => {\n console.log(item)\n})\nx.push(4)\nconsole.log(x)',bug:'No bug โ€” code is correct!',fix:'const x = [1,2,3]\nx.forEach(item => {\n console.log(item)\n})\nx.push(4)\nconsole.log(x)',type:'none',hint:'Is code mein koi bug nahi hai!'} ]; var vaultSymbols=['๐ŸŒŸ','๐Ÿ”ฅ','๐Ÿ’Ž','โšก','๐ŸŒ™','โ˜€๏ธ','๐ŸŒ€','โ„๏ธ']; /* โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• ๐Ÿ™๏ธ CODER CITY โ€” Real 2D Canvas City with Guns & Code โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ• */ var coderMissions=[ { scene:'๐Ÿ›‘ THIEF ALERT!', target:{type:'thief',label:'๐Ÿ‘ค THIEF',x:220,y:230,color:'#FF4444',size:12}, bgColor:'#FF4444', task:"Use gun.shoot() to stop the thief. gun.shoot('thief')", answer:"gun.shoot('thief')", ansDisplay:"gun.shoot('thief')", hint:"gun.shoot() function mein 'thief' parameter pass karo" }, { scene:'๐Ÿš— RUNAWAY CAR!', target:{type:'car',label:'๐Ÿš— CAR',x:400,y:300,color:'#FF8800',size:20}, bgColor:'#FF8800', task:"Use stop() to halt the car. stop('car')", answer:"stop('car')", ansDisplay:"stop('car')", hint:"stop() function mein 'car' parameter pass karo" }, { scene:'๐Ÿ’€ GANG ATTACK!', target:{type:'gang',label:'๐Ÿ‘ฅ GANG',x:160,y:240,color:'#FF0066',size:18}, bgColor:'#FF0066', task:"Use eliminate() to take down the gang. eliminate('gang')", answer:"eliminate('gang')", ansDisplay:"eliminate('gang')", hint:"eliminate() function mein 'gang' parameter pass karo" }, { scene:'๐ŸŽฏ SNIPER ON ROOF!', target:{type:'sniper',label:'๐Ÿ”ญ SNIPER',x:380,y:95,color:'#FF00FF',size:14}, bgColor:'#FF00FF', task:"Use aim().fire() chain. aim('roof').fire()", answer:"aim('roof').fire()", ansDisplay:"aim('roof').fire() (method chaining!)", hint:"pehle aim() se target lo, phir .fire() se fire karo" }, { scene:'๐Ÿค– GIANT BOT!', target:{type:'boss',label:'๐Ÿค– BOSS',x:300,y:110,color:'#FF0000',size:40}, bgColor:'#FF0000', task:"Use ultimate.destroy() on the boss. ultimate.destroy('boss')", answer:"ultimate.destroy('boss')", ansDisplay:"ultimate.destroy('boss')", hint:"ultimate.destroy() mein 'boss' parameter bhejo" } ]; var cityCV=null, cityCX=null, cityAnim=null; var cityNPCs=[], cityFX=[], cityTarget=null, cityHit=false, cityStop=false, cityKillTimer=0; /* city coordinate system: logical 700x400, canvas scales to fit */ function cityInitCanvas(){ cityCV=document.getElementById('cityCanvas'); if(!cityCV)return; cityCV.width=700; cityCV.height=400; cityCX=cityCV.getContext('2d'); if(!cityCX){console.warn('Canvas 2D context unavailable');return;} } function citySpawnNPCs(){ cityNPCs=[ {type:'car',x:50,y:295,w:44,h:16,speed:1.8,color:'#4488FF'}, {type:'car',x:330,y:295,w:44,h:16,speed:-1.2,color:'#FF6644'}, {type:'car',x:580,y:300,w:40,h:14,speed:1.5,color:'#44FF88'}, {type:'bike',x:120,y:288,w:14,h:10,speed:2.2,color:'#FFDD44'}, {type:'bike',x:460,y:288,w:14,h:10,speed:-1.8,color:'#FF88FF'}, {type:'person',x:180,y:340,w:10,h:18,speed:0.6,color:'#FFD700'}, {type:'person',x:400,y:345,w:10,h:18,speed:-0.4,color:'#FF99CC'}, {type:'person',x:280,y:342,w:10,h:18,speed:0.5,color:'#88FF88'}, ]; } function cityDrawScene(){ var c=cityCX; if(!c)return; var w=700, h=400; var groundY=280, roadY=groundY, roadH=55, swY=roadY+roadH; // Sky var g=c.createLinearGradient(0,0,0,groundY); g.addColorStop(0,'#1a1a3e');g.addColorStop(0.4,'#2d4a7a');g.addColorStop(0.7,'#5b8fc9');g.addColorStop(1,'#87CEEB'); c.fillStyle=g;c.fillRect(0,0,w,groundY); // Sun c.fillStyle='#FFD700';c.shadowColor='#FFD700';c.shadowBlur=40; c.beginPath();c.arc(620,45,28,0,Math.PI*2);c.fill();c.shadowBlur=0; c.fillStyle='rgba(255,215,0,0.08)';c.beginPath();c.arc(620,45,80,0,Math.PI*2);c.fill(); // Clouds function cloud(cx,cy,s){c.fillStyle='rgba(255,255,255,0.35)';c.beginPath();c.arc(cx,cy,s*0.5,0,Math.PI*2);c.arc(cx+s*0.4,cy-s*0.2,s*0.4,0,Math.PI*2);c.arc(cx+s*0.8,cy,s*0.5,0,Math.PI*2);c.arc(cx+s*0.4,cy+s*0.1,s*0.45,0,Math.PI*2);c.fill();} cloud(100,55,45);cloud(340,80,35);cloud(530,45,40); // Buildings var bld=[ {x:20,w:65,h:170,color:'#4a5a6a'},{x:100,w:55,h:210,color:'#3a4a5a'},{x:170,w:75,h:150,color:'#5a6a7a'}, {x:260,w:50,h:230,color:'#3d5a6a'},{x:325,w:70,h:185,color:'#4a6a7a'},{x:410,w:60,h:205,color:'#5a7a8a'}, {x:485,w:70,h:165,color:'#4a5a6a'},{x:570,w:55,h:220,color:'#3a5a6a'},{x:640,w:50,h:175,color:'#5a6a7a'} ]; bld.forEach(function(b){ var bh=Math.min(b.h,groundY-25), by=groundY-bh; c.fillStyle=b.color;c.fillRect(b.x,by,b.w,bh); c.strokeStyle='rgba(0,0,0,0.25)';c.lineWidth=1;c.strokeRect(b.x,by,b.w,bh); for(var r=0;r0.25?'#FFE4B5':'rgba(0,0,0,0.35)'; c.fillRect(b.x+5+cl*14,by+5+r*18,9,12); } }); // Ground c.fillStyle='#4a6a3a';c.fillRect(0,groundY,w,h-groundY); // Road c.fillStyle='#2a2a2a';c.fillRect(0,roadY,w,roadH); c.fillStyle='#555';c.fillRect(0,roadY,w,2);c.fillRect(0,roadY+roadH-2,w,2); c.strokeStyle='#FFD700';c.lineWidth=2;c.setLineDash([12,12]); c.beginPath();c.moveTo(0,roadY+roadH/2);c.lineTo(w,roadY+roadH/2);c.stroke();c.setLineDash([]); // Sidewalk c.fillStyle='#666';c.fillRect(0,swY,w,h-swY);c.fillStyle='#777';c.fillRect(0,swY,w,2); // NPCs cityNPCs.forEach(function(n){ if(n.type==='car'){ c.fillStyle=n.color;c.fillRect(n.x,n.y,n.w,n.h); c.fillStyle='#222';c.fillRect(n.x+3,n.y-3,10,3);c.fillRect(n.x+n.w-13,n.y-3,10,3); c.fillStyle='#111';c.fillRect(n.x+3,n.y+n.h,8,3);c.fillRect(n.x+n.w-11,n.y+n.h,8,3); c.fillStyle='rgba(200,230,255,0.3)';c.fillRect(n.x+5,n.y+2,20,12); }else if(n.type==='bike'){ c.fillStyle=n.color;c.fillRect(n.x,n.y,n.w,n.h); c.fillStyle='#222';c.beginPath();c.arc(n.x+2,n.y+n.h+2,3,0,Math.PI*2);c.fill(); c.beginPath();c.arc(n.x+n.w-2,n.y+n.h+2,3,0,Math.PI*2);c.fill(); }else if(n.type==='person'){ c.fillStyle=n.color;c.fillRect(n.x+2,n.y-8,6,8);c.fillRect(n.x,n.y,n.w,n.h); } }); // Player var px=610, py=230; c.fillStyle='#00FF88';c.fillRect(px,py,16,30);c.fillRect(px+4,py-10,8,10); c.fillStyle='#333';c.fillRect(px-14,py+6,16,4);c.fillStyle='#888';c.fillRect(px-18,py+5,6,6); c.fillStyle='#FFD700';c.fillRect(px-22,py+7,22,3);c.fillStyle='#FFF';c.fillRect(px-22,py+5,3,7); c.fillStyle='rgba(0,255,136,0.6)';c.font='9px monospace';c.fillText('YOU',px-2,py-14); // Target (only show alive and not hit) if(cityTarget&&!cityHit&&!cityStop){ var t=cityTarget; var shakeX=cityKillTimer>0&&cityKillTimer<10?(Math.random()-0.5)*6:0; var shakeY=cityKillTimer>0&&cityKillTimer<10?(Math.random()-0.5)*6:0; var alpha=cityKillTimer>0&&cityKillTimer<15?0.3+0.7*Math.sin(Date.now()/50):1; c.save();c.globalAlpha=alpha; c.shadowColor=t.color;c.shadowBlur=20; c.strokeStyle=t.color;c.lineWidth=2;c.setLineDash([4,4]); c.beginPath(); if(t.type==='boss'){c.arc(t.x+20+shakeX,t.y+20+shakeY,28,0,Math.PI*2);} else if(t.type==='sniper'){c.arc(t.x+7+shakeX,t.y+7+shakeY,18,0,Math.PI*2);} else if(t.type==='gang'){c.arc(t.x+12+shakeX,t.y+12+shakeY,20,0,Math.PI*2);} else if(t.type==='car'){c.arc(t.x+20+shakeX,t.y+8+shakeY,24,0,Math.PI*2);} else{c.arc(t.x+6+shakeX,t.y+6+shakeY,16,0,Math.PI*2);} c.stroke();c.setLineDash([]);c.shadowBlur=0; // Draw target sprite with shake var tx=t.x+shakeX, ty=t.y+shakeY; if(t.type==='boss'){ c.fillStyle='#8B0000';c.fillRect(tx,ty,40,40); c.fillStyle='#FF0000';c.fillRect(tx+4,ty+4,32,12); c.fillStyle='#FFD700';c.font='8px monospace';c.fillText('๐Ÿ‘๏ธ',tx+14,ty+22); }else if(t.type==='sniper'){ c.fillStyle='#4a003a';c.fillRect(tx,ty,14,14); c.fillStyle='#FF00FF';c.fillRect(tx+5,ty-3,4,10); }else if(t.type==='gang'){ c.fillStyle='#660033';c.fillRect(tx,ty,24,18); c.fillStyle='#333';c.fillRect(tx+3,ty-5,6,5);c.fillRect(tx+14,ty-5,6,5); }else if(t.type==='car'){ c.fillStyle='#883300';c.fillRect(tx,ty,40,16); c.fillStyle='#FF8800';c.fillRect(tx+4,ty+2,30,8); c.fillStyle='#111';c.fillRect(tx+5,ty-3,8,3);c.fillRect(tx+27,ty-3,8,3); }else{ c.fillStyle='#660000';c.fillRect(tx,ty,12,18); c.fillRect(tx+2,ty-8,8,8); } c.fillStyle='#FFF';c.font='8px monospace';c.fillText(t.label,tx-5,ty-12); c.restore(); // Warning pulse c.fillStyle='rgba(255,0,0,'+(0.15+0.1*Math.sin(Date.now()/200))+')'; c.fillRect(0,0,w,h); } // Hit effect if(cityHit){ c.fillStyle='rgba(255,255,0,0.25)';c.fillRect(0,0,w,h); c.fillStyle='#FFF';c.font='bold 30px monospace';c.textAlign='center'; c.shadowColor='#FFD700';c.shadowBlur=20; c.fillText('๐Ÿ’ฅ ELIMINATED!',350,80); c.shadowBlur=0;c.textAlign='left'; // Blood/debris splatter if(cityTarget){ var ct=cityTarget;var cx=ct.x+(ct.size||12),cy=ct.y+(ct.size||12); c.fillStyle='rgba(255,0,0,0.3)';c.beginPath(); for(var i=0;i<8;i++){var a=i*Math.PI/4;c.arc(cx+Math.cos(a)*25,cy+Math.sin(a)*25,4+Math.random()*6,0,Math.PI*2);} c.fill(); } } // Stop effect if(cityStop){ c.fillStyle='rgba(255,100,0,0.12)';c.fillRect(0,0,w,h); c.fillStyle='#FF8800';c.font='bold 24px monospace';c.textAlign='center'; c.shadowColor='#FF8800';c.shadowBlur=15;c.fillText('๐Ÿ›‘ CAR STOPPED! ๐Ÿš—๐Ÿ’จ',350,80); c.shadowBlur=0;c.textAlign='left'; c.fillStyle='rgba(200,200,200,0.4)'; c.beginPath();c.arc(380,300,20+10*Math.sin(Date.now()/100),0,Math.PI*2);c.fill(); } // FX (bullets, explosions) cityFX.forEach(function(fx){ if(fx.type==='bullet'){ c.strokeStyle='#FFD700';c.lineWidth=3; c.shadowColor='#FFD700';c.shadowBlur=10; c.beginPath();c.moveTo(fx.x,fx.y);c.lineTo(fx.x-fx.vx*0.5,fx.y-fx.vy*0.5);c.stroke(); c.fillStyle='#FFF';c.beginPath();c.arc(fx.x,fx.y,4,0,Math.PI*2);c.fill(); c.shadowBlur=0; }else if(fx.type==='explode'){ c.fillStyle='rgba(255,200,0,'+Math.max(0,1-fx.life)+')'; c.beginPath();c.arc(fx.x,fx.y,10+fx.life*25,0,Math.PI*2);c.fill(); c.fillStyle='rgba(255,50,0,'+Math.max(0,1-fx.life*0.7)+')'; c.beginPath();c.arc(fx.x,fx.y,6+fx.life*20,0,Math.PI*2);c.fill(); c.fillStyle='rgba(255,255,200,'+Math.max(0,1-fx.life*0.5)+')'; c.beginPath();c.arc(fx.x,fx.y,3+fx.life*15,0,Math.PI*2);c.fill(); }else if(fx.type==='particle'){ c.fillStyle=fx.color; c.globalAlpha=Math.max(0,1-fx.life); c.beginPath();c.arc(fx.x+fx.vx*fx.life*20,fx.y+fx.vy*fx.life*20,3,0,Math.PI*2);c.fill(); c.globalAlpha=1; } }); } function cityAnimate(){ if(!cityStop&&!cityHit){ cityNPCs.forEach(function(n){ n.x+=n.speed;if(n.x>750)n.x=-60;if(n.x<-60)n.x=750; }); } // Kill timer โ€” bullet impact if(cityKillTimer>0){ cityKillTimer--; if(cityKillTimer===0){ cityHit=true; var t=cityTarget; if(t){ var cx=t.x+(t.size||12)/2, cy=t.y+(t.size||12)/2; cityFX.push({type:'explode',x:cx,y:cy,life:0}); for(var i=0;i<8;i++){ var a=i*Math.PI/4; cityFX.push({type:'particle',x:cx,y:cy,vx:Math.cos(a),vy:Math.sin(a),life:0,color:['#FFD700','#FF4400','#FF8800','#FFF'][i%4]}); } } } } // Update FX cityFX=cityFX.filter(function(fx){ if(fx.type==='bullet'){fx.x+=fx.vx;fx.y+=fx.vy;return fx.life++=5; var locked=!r.unlock&&state.xp<50; html+='
'+ '
'+r.icon+'
'+ '
'+r.name+'
'+ '
'+r.desc+'
'+ '
'+ (completed?'โœ… Completed '+(state.rooms[r.id])+'/5':'๐Ÿ“ '+(state.rooms[r.id]||0)+'/5')+'
'+ (locked?'
๐Ÿ”’ Need 50 XP
':'')+ '
'; }); document.getElementById('roomGrid').innerHTML=html; } /* ===== ENTER ROOM ===== */ function enterRoom(id){ state.currentRoom=id; state.missionIdx=state.rooms[id]||0; state.hintsUsed=0; if(state.missionIdx>=5)state.missionIdx=0; renderGame(id); } function backToRooms(){cityStopAnim();state.currentRoom=null;document.getElementById('gameArea').classList.remove('active');document.getElementById('gameArea').innerHTML='';renderRooms()} /* ===== RENDER GAME ===== */ function renderGame(id){ cityStopAnim(); var ga=document.getElementById('gameArea'); ga.classList.add('active'); if(id==='cyber')renderCyber(); else if(id==='arena')renderArena(); else if(id==='logic')renderLogic(); else if(id==='virus')renderVirus(); else if(id==='vault')renderVault(); else if(id==='coder')renderCoder(); } /* ===== CYBER LAB ===== */ function renderCyber(){ var m=cyberMissions[state.missionIdx]; if(!m){backToRooms();return} var completed=state.rooms.cyber>=5; var ga=document.getElementById('gameArea'); ga.innerHTML='

๐Ÿ’ป Cyber Lab

'+ '
๐ŸŽฏ Seekho: '+rooms.find(function(r){return r.id==='cyber'}).learning+'
'+ '
'+[0,1,2,3,4].map(function(i){return '
'}).join('')+'
'+ (completed?'':'')+ (!completed?'
'+m.code.replace(/funtion|consol|functoin/g,'$&')+'
'+ '
'+ '
'+ ''+ ''+ '
'+ ''+ ''+ ''+ '
':''); } function checkCyber(){ var m=cyberMissions[state.missionIdx]; var input=document.getElementById('cyberInput'); var fb=document.getElementById('cyberFb'); var ans=input.value.trim().replace(/\s+/g,' ').toLowerCase(); var correct=m.fix.replace(/\s+/g,' ').toLowerCase(); if(ans===correct||input.value.trim().toLowerCase().includes(m.fix.replace(/\n/g,'').trim().toLowerCase().substring(0,20))){ state.xp+=20;state.coins+=15;state.score+=50;state.rooms.cyber++; if(window.addGlobalXP)window.addGlobalXP(25); var bonus=state.hintsUsed===0?' +10 bonus!':''; if(state.hintsUsed===0){state.xp+=10} save();updateStats(); fb.className='feedback-box success show'; fb.innerHTML='โœ… Correct! +20 XP +15 coins'+bonus; if(state.rooms.cyber>=5){setTimeout(function(){renderCyber()},1200)} else{state.missionIdx++;setTimeout(function(){renderCyber()},1200)} }else{ var m2=cyberMissions[state.missionIdx]; fb.className='feedback-box error show'; fb.innerHTML='โŒ Not quite. Error: '+m2.err+'
๐Ÿ’ก Tip: '+m2.hint; } } function cyberHint(){ if(state.hintsUsed>=3){toast('No hints left!');return} state.hintsUsed++; var m=cyberMissions[state.missionIdx]; var h=document.getElementById('cyberHint'); h.className='hint-box show'; h.textContent='๐Ÿ’ก Hint '+state.hintsUsed+'/3: '+m.hint; save(); } function showCyberAnswer(){ var m=cyberMissions[state.missionIdx]; var a=document.getElementById('cyberAns'); a.className='answer-box show'; a.innerHTML='๐Ÿ“– Correct Answer:\n\n'+m.fix+'\n\n๐Ÿ“ Error: '+m.err+' | ๐Ÿ’ก Tip: '+m.hint+''; } /* ===== ARENA ===== */ function renderArena(){ var m=arenaMissions[state.missionIdx]; if(!m){backToRooms();return} var completed=state.rooms.arena>=5; var ga=document.getElementById('gameArea'); ga.innerHTML='

๐Ÿค– AI Prompt Arena

'+ '
๐ŸŽฏ Seekho: '+rooms.find(function(r){return r.id==='arena'}).learning+'
'+ '
'+[0,1,2,3,4].map(function(i){return '
'}).join('')+'
'+ (completed?'':'')+ (!completed?'
๐Ÿงช Weak Prompt:
"'+m.prompt+'"
'+ '
'+ ''+ ''+ '
'+ ''+ ''+ '
'+ '

๐Ÿ’ก Add: style, colors, details, features, output format

':''); } function checkArena(){ var input=document.getElementById('arenaInput'); var fb=document.getElementById('arenaFb'); var txt=input.value; var score=0; if(txt.length>20)score+=15; if(txt.length>50)score+=10; if(/modern|futuristic|cyberpunk|dark|neon|clean/i.test(txt))score+=15; if(/color|blue|red|gold|purple|gradient|lighting/i.test(txt))score+=15; if(/animation|hover|smooth|transition|glow|effect/i.test(txt))score+=15; if(/responsive|mobile|grid|flex|layout/i.test(txt))score+=10; if(/html|css|javascript|react|js/i.test(txt))score+=10; if(/detail|high|quality|professional|cinematic/i.test(txt))score+=10; score=Math.min(100,score); var earnedXP=Math.floor(score/5); var earnedCoins=Math.floor(score/8); if(score>=50){ state.xp+=earnedXP;state.coins+=earnedCoins;state.score+=score;state.rooms.arena++; if(window.addGlobalXP)window.addGlobalXP(25); save();updateStats(); fb.className='feedback-box success show'; fb.innerHTML='โœ… Score: '+score+'% โ€” Great improvement! +'+earnedXP+' XP +'+earnedCoins+' coins
๐ŸŒŸ Improved: '+arenaMissions[state.missionIdx].improved+''; if(state.rooms.arena>=5){setTimeout(function(){renderArena()},1500)} else{state.missionIdx++;setTimeout(function(){renderArena()},1500)} }else{ fb.className='feedback-box info show'; fb.innerHTML='โš ๏ธ Score: '+score+'% โ€” Need 50%+
๐Ÿ’ก Add: style words, colors, animations, tech details, and be more descriptive.'; } } function showArenaAnswer(){ var m=arenaMissions[state.missionIdx]; var a=document.getElementById('arenaAns'); a.className='answer-box show'; a.innerHTML='๐Ÿ“– Expert Prompt:\n\n"'+m.improved+'"\n\n๐Ÿ’ก Notice: specific style, colors, details, and format instructions make prompts better!'; } /* ===== LOGIC REACTOR ===== */ function renderLogic(){ var m=logicMissions[state.missionIdx]; if(!m){backToRooms();return} var completed=state.rooms.logic>=5; var ga=document.getElementById('gameArea'); var rows=m.inputs.map(function(inp,i){return ''+inp.a+''+inp.b+''}).join(''); ga.innerHTML='

๐Ÿ”Œ Logic Reactor โ€” '+m.gate+' Gate

'+ '
๐ŸŽฏ Seekho: '+rooms.find(function(r){return r.id==='logic'}).learning+'
'+ '
'+[0,1,2,3,4].map(function(i){return '
'}).join('')+'
'+ (completed?'':'')+ (!completed?'

'+m.desc+'

'+ ''+rows+'
Input AInput BOutput
'+ '
'+ ''+ '
'+ ''+ ''+ '
':''); } function checkLogic(){ var m=logicMissions[state.missionIdx]; var fb=document.getElementById('logicFb'); var correct=true; for(var i=0;i=5){setTimeout(function(){renderLogic()},1200)} else{state.missionIdx++;setTimeout(function(){renderLogic()},1200)} }else{ fb.className='feedback-box error show'; fb.innerHTML='โŒ Wrong output! Study the truth table again. '+m.desc; } } function showLogicAnswer(){ var m=logicMissions[state.missionIdx]; var a=document.getElementById('logicAns'); var outputs=m.outputs.map(function(v,i){return m.inputs[i].a+' & '+m.inputs[i].b+' โ†’ '+v}).join('\n'); a.className='answer-box show'; a.innerHTML='๐Ÿ“– '+m.gate+' Gate โ€” Correct Outputs:\n\n'+outputs+'\n\n'+m.desc+''; } /* ===== VIRUS ROOM ===== */ function renderVirus(){ var m=virusMissions[state.missionIdx]; if(!m){backToRooms();return} var completed=state.rooms.virus>=5; var ga=document.getElementById('gameArea'); ga.innerHTML='

๐Ÿฆ  Virus Room โ€” Find the Bug

'+ '
๐ŸŽฏ Seekho: '+rooms.find(function(r){return r.id==='virus'}).learning+'
'+ '
'+[0,1,2,3,4].map(function(i){return '
'}).join('')+'
'+ (completed?'':'')+ (!completed?'
'+m.code.replace(//g,'>')+'
'+ '
'+ '
'+ '

๐Ÿ” What is the bug in this code?

'+ ''+ ''+ '
'+ ''+ ''+ ''+ '
':''); } function checkVirus(){ var m=virusMissions[state.missionIdx]; var input=document.getElementById('virusInput'); var fb=document.getElementById('virusFb'); var txt=input.value.trim().toLowerCase(); if(m.type==='none'&&(txt.includes('no bug')||txt.includes('correct')||txt.includes('none'))){ state.xp+=30;state.coins+=25;state.score+=70;state.rooms.virus++; if(window.addGlobalXP)window.addGlobalXP(25); save();updateStats(); fb.className='feedback-box success show'; fb.innerHTML='โœ… Correct! No bug found โ€” clean code! +30 XP +25 coins'; state.missionIdx++;setTimeout(function(){renderVirus()},1200);return; } if(txt.includes(m.bug.toLowerCase().substring(0,10))||txt.includes(m.type)){ state.xp+=30;state.coins+=25;state.score+=70;state.rooms.virus++; if(window.addGlobalXP)window.addGlobalXP(25); save();updateStats(); fb.className='feedback-box success show'; fb.innerHTML='โœ… Correct! Bug found: '+m.bug+' +30 XP +25 coins'; if(state.rooms.virus>=5){setTimeout(function(){renderVirus()},1200)} else{state.missionIdx++;setTimeout(function(){renderVirus()},1200)} }else{ fb.className='feedback-box error show'; fb.innerHTML='โŒ Not the right bug. Hint: '+m.hint; } } function virusHint(){ var m=virusMissions[state.missionIdx]; var h=document.getElementById('virusHint'); h.className='hint-box show'; h.textContent='๐Ÿ’ก '+m.hint; } function showVirusAnswer(){ var m=virusMissions[state.missionIdx]; var a=document.getElementById('virusAns'); var content=m.type==='none'?'โœ… No bug! Code is correct.' : '๐Ÿž Bug: '+m.bug+'\n\nโœ… Fix:\n'+m.fix; a.className='answer-box show'; a.innerHTML='๐Ÿ“– Answer:\n\n'+content+'\n\n๐Ÿ’ก '+m.hint+''; } /* ===== MEMORY VAULT ===== */ function initVault(){ state.memFlipped=[];state.memMatched=[];state.memLock=false; var symbols=vaultSymbols.concat(vaultSymbols); for(var i=symbols.length-1;i>0;i--){var j=Math.floor(Math.random()*(i+1));var t=symbols[i];symbols[i]=symbols[j];symbols[j]=t} state.memSymbols=symbols; } function renderVault(){ var ga=document.getElementById('gameArea'); if(typeof state.memSymbols==='undefined'||state.memSymbols.length===0)initVault(); var completed=state.rooms.vault>=3; var cards=''; for(var i=0;i<16;i++){ var flipped=state.memFlipped.includes(i)||state.memMatched.includes(i); var matched=state.memMatched.includes(i); cards+='
'+(flipped?state.memSymbols[i]:'โ“')+'
'; } ga.innerHTML='

๐Ÿ” Memory Vault

'+ '
๐ŸŽฏ Seekho: '+rooms.find(function(r){return r.id==='vault'}).learning+'
'+ '

Match all pairs to unlock the vault! '+(3-state.rooms.vault)+' rounds left

'+ (completed?'':'')+ '
'+ '
'+cards+'
'+ ''+ (!completed?'
'+ '
':''); } function flipMem(idx){ if(state.memLock||state.memFlipped.includes(idx)||state.memMatched.includes(idx))return; state.memFlipped.push(idx); renderVault(); if(state.memFlipped.length===2){ state.memLock=true; var a=state.memFlipped[0],b=state.memFlipped[1]; if(state.memSymbols[a]===state.memSymbols[b]){ state.memMatched.push(a,b); state.memFlipped=[]; state.memLock=false; if(state.memMatched.length===16){ state.xp+=35;state.coins+=30;state.score+=80;state.rooms.vault++; if(window.addGlobalXP)window.addGlobalXP(35); save();updateStats(); var fb=document.getElementById('vaultFb'); if(fb){fb.className='feedback-box success show';fb.innerHTML='๐ŸŽ‰ All matched! +35 XP +30 coins'} if(state.rooms.vault<3){setTimeout(function(){initVault();renderVault()},1200)} else{setTimeout(function(){renderVault()},1200)} } }else{ setTimeout(function(){ state.memFlipped=[]; state.memLock=false; renderVault(); },800); } } } function showVaultAnswer(){ var a=document.getElementById('vaultAns'); if(typeof state.memSymbols==='undefined'||state.memSymbols.length===0)initVault(); var pairs={}; for(var i=0;i๐Ÿ’ก Yaad rakhein โ€” matching pairs ka pattern identify karein!'; } /* ===== CODER CITY ===== */ function renderCoder(){ var m=coderMissions[state.missionIdx]; if(!m){backToRooms();return} var completed=state.rooms.coder>=5; var ga=document.getElementById('gameArea'); cityTarget=m.target; ga.innerHTML='

๐Ÿ”ซ Coder City โ€” '+m.scene+'

'+ '
๐ŸŽฏ Seekho: '+rooms.find(function(r){return r.id==='coder'}).learning+'
'+ '
'+[0,1,2,3,4].map(function(i){return '
'}).join('')+'
'+ (completed?'':'')+ (!completed?''+ '
'+ 'โšก MISSION: '+m.task+'
'+ '
'+ '
'+ ''+ ''+ '
'+ ''+ ''+ ''+ '
':''); if(!completed){setTimeout(function(){cityInitCanvas();cityStartAnim()},50)} } function checkCoder(){ var m=coderMissions[state.missionIdx]; var input=document.getElementById('coderInput'); var fb=document.getElementById('coderFb'); var txt=input.value.trim().replace(/\s+/g,' ').toLowerCase(); var correct=m.answer.replace(/\s+/g,' ').toLowerCase(); if(txt===correct||txt.includes(m.answer.replace(/'/g,'').toLowerCase().trim())){ state.xp+=25;state.coins+=20;state.score+=60;state.rooms.coder++; if(window.addGlobalXP)window.addGlobalXP(25); save();updateStats(); fb.className='feedback-box success show'; fb.innerHTML='โœ… Headshot! Mission complete! +25 XP +20 coins
๐Ÿ’ป Code executed: '+m.ansDisplay+''; // Visual FX โ€” bullet from player gun to target center var px=590, py=248; var ts=m.target.size||12; var tx=m.target.x+ts/2, ty=m.target.y+ts/2; var frames=35; cityFX=[];cityHit=false; if(m.target.type==='car'){ cityKillTimer=0;cityStop=true;cityHit=false; setTimeout(function(){ cityFX.push({type:'explode',x:tx,y:ty,life:0}); for(var i=0;i<6;i++){var a=i*Math.PI/3;cityFX.push({type:'particle',x:tx,y:ty,vx:Math.cos(a),vy:Math.sin(a),life:0,color:'#FF8800'});} },400); }else{ cityKillTimer=frames; cityFX.push({type:'bullet',x:px,y:py,vx:(tx-px)/frames,vy:(ty-py)/frames,life:0,maxLife:frames}); } if(state.rooms.coder>=5){setTimeout(function(){cityStopAnim();renderCoder()},3000)} else{state.missionIdx++;setTimeout(function(){cityStopAnim();renderCoder()},3000)} }else{ fb.className='feedback-box error show'; fb.innerHTML='โŒ Code failed! Try again.
๐Ÿ’ก Tip: '+m.hint; } } function coderHint(){ var m=coderMissions[state.missionIdx]; var h=document.getElementById('coderHint'); h.className='hint-box show'; h.textContent='๐Ÿ’ก '+m.hint; } function showCoderAnswer(){ var m=coderMissions[state.missionIdx]; var a=document.getElementById('coderAns'); a.className='answer-box show'; a.innerHTML='๐Ÿ“– Correct Code:\n\n'+m.ansDisplay+'\n\n๐Ÿ’ก '+m.hint+' | ๐Ÿ”ซ City safe! Threat neutralized!'; } /* ===== TOAST ===== */ function toast(msg){var t=document.createElement('div');t.style.cssText="position:fixed;bottom:20px;right:20px;padding:12px 20px;background:rgba(10,10,26,0.95);border:1px solid rgba(255,255,255,0.15);border-radius:12px;color:#e8e8f0;font-size:13px;z-index:100;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);box-shadow:0 8px 32px rgba(0,0,0,0.4);max-width:360px;font-family:'Inter',sans-serif";t.textContent=msg;document.body.appendChild(t);setTimeout(function(){t.style.opacity='0';t.style.transition='opacity .3s';setTimeout(function(){t.remove()},300)},2500)} /* ===== INIT ===== */ render();