From b366c86e8d7a939ace07622db387aa0dbe1dd295 Mon Sep 17 00:00:00 2001 From: tmalahie Date: Mon, 1 Apr 2024 23:30:46 +0200 Subject: [PATCH] Add option to disable RD in online mode & challenges Squashed commit of the following: commit d24d550181ffb7548ce3fd4a6de108d488160419 Author: tmalahie Date: Mon Apr 1 23:29:01 2024 +0200 v226 commit 9b3f22671249965f9dcb56189ed8331519b2974f Author: tmalahie Date: Mon Apr 1 16:10:44 2024 +0200 Add option to prevent reverse drift in challenges commit 9deb8f2827319f05825e7c0c7f1cefff8ae1b040 Author: tmalahie Date: Sun Mar 24 17:00:59 2024 +0100 Make RD disable an option commit e1ed11895d7236c2f1578dbd75c2bd24bb12f9d6 Author: tmalahie Date: Sun Mar 24 17:05:19 2024 +0100 v225 commit f22b21c203ca30f36ad033491688db7d795fd08a Author: tmalahie Date: Sat Mar 16 00:06:00 2024 +0100 Clean code commit 057d8f5f7e6591422a1265d4327ab21e010c3234 Author: tmalahie Date: Sat Mar 16 00:05:54 2024 +0100 Prevent users from reverse drifting --- php/api/changeParam.php | 8 --- php/includes/getCourseOptions.php | 32 ------------ php/includes/mk/main.php | 2 +- php/includes/onlineRulesUtils.php | 4 ++ php/includes/utils-challenges.php | 5 ++ scripts/mk.js | 84 ++++++++++++++++++++++++++++--- scripts/mk.v225.js | 1 + scripts/mk.v226.js | 1 + 8 files changed, 90 insertions(+), 47 deletions(-) delete mode 100755 php/api/changeParam.php create mode 100644 scripts/mk.v225.js create mode 100644 scripts/mk.v226.js diff --git a/php/api/changeParam.php b/php/api/changeParam.php deleted file mode 100755 index 8ccf7bfb9..000000000 --- a/php/api/changeParam.php +++ /dev/null @@ -1,8 +0,0 @@ -'5', 'iScreenScale'=>null, 'bMusic'=>'0', 'iSfx'=>'0'); -$isCookieSet = false; -foreach ($settingKeys as $settingKey=>$settingDef) { - if (isset($_COOKIE[$settingKey])) { - $isCookieSet = true; - break; - } -} -if ($isCookieSet) { - ?> -{ - quality: , - music: , - sfx: , - screenscale: -}; -$settingDef) { - if (isset($_COOKIE[$settingKey]) && ($_COOKIE[$settingKey] !== $settingDef)) - echo 'localStorage.setItem("'. $settingKey .'", "'. $_COOKIE[$settingKey] .'");'; -} ?> -setTimeout(function() { - xhr("changeParam.php", "clear=1", function(reponse) { - return (reponse == 1); - }); -}, 1000); - { quality: localStorage.getItem("iQuality") ? +localStorage.getItem("iQuality") : 5, music: localStorage.getItem("bMusic") ? +localStorage.getItem("bMusic"):0, sfx: localStorage.getItem("iSfx") ? +localStorage.getItem("iSfx"):0, screenscale: localStorage.getItem("iScreenScale") ? +localStorage.getItem("iScreenScale"): -} - '; else - echo ''; + echo ''; ?> diff --git a/php/includes/onlineRulesUtils.php b/php/includes/onlineRulesUtils.php index e7480ec20..62e4477ae 100755 --- a/php/includes/onlineRulesUtils.php +++ b/php/includes/onlineRulesUtils.php @@ -93,6 +93,10 @@ 'default' => 0, 'accepted' => array(1,1) ), + 'noRd' => array( + 'default' => 0, + 'accepted' => array(1,1) + ), 'doubleItems' => array( 'default' => 1, 'accepted' => array(1,1) diff --git a/php/includes/utils-challenges.php b/php/includes/utils-challenges.php index 459c14370..38fd8ab0b 100755 --- a/php/includes/utils-challenges.php +++ b/php/includes/utils-challenges.php @@ -511,6 +511,11 @@ 'group' => 'no_action', 'course' => array('vs', 'battle', 'cup', 'mcup', 'bcup', 'mbcup') ), + 'no_rd' => array( + 'description' => $language ? 'without reverse drifting':'sans faire de RD', + 'group' => 'no_action', + 'course' => array('vs', 'battle', 'cup', 'mcup', 'bcup', 'mbcup') + ), 'without_turning' => array( 'description_mockup' => $language ? 'without turning...':'sans tourner...', 'description_lambda' => function($language,&$scope) { diff --git a/scripts/mk.js b/scripts/mk.js index 43b894140..d9e14ad00 100755 --- a/scripts/mk.js +++ b/scripts/mk.js @@ -4135,7 +4135,13 @@ function startGame() { break; case "down": currentPressedKeys[gameAction] = true; - oPlayers[0].speedinc = -0.2; + if (isRdDisabled() && oPlayers[0].driftinc) + oPlayers[0].speedinc = 0; + else { + oPlayers[0].speedinc = -0.2; + if (oPlayers[0].driftinc) + clLocalVars.revDrifted = true; + } break; case "jump": if (pause) break; @@ -4210,7 +4216,7 @@ function startGame() { break; case "down_p2": if (!oPlayers[1]) return; - oPlayers[1].speedinc -= 0.2; + oPlayers[1].speedinc = -0.2; break; case "jump_p2": if (pause) break; @@ -10782,6 +10788,9 @@ function resetDriftSprite(oKart) { function isJumpEnabled() { return !(isOnline && shareLink.options && shareLink.options.noJump); } +function isRdDisabled() { + return (isOnline && shareLink.options && shareLink.options.noRd); +} function isLocalScore() { if (isOnline) return (shareLink.options && shareLink.options.localScore); @@ -12210,6 +12219,11 @@ var challengeRules = { return !clLocalVars.drifted; } }, + "no_rd": { + "success": function(scope) { + return !clLocalVars.revDrifted; + } + }, "avoid_items": { "success": function(scope) { return !clLocalVars.itemsGot; @@ -12826,6 +12840,7 @@ function isSameDistrib(d1,d2) { function reinitLocalVars() { clLocalVars = { drifted: false, + revDrifted: false, stunted: false, itemsGot: false, itemsUsed: false, @@ -19070,6 +19085,7 @@ function privateGameOptions(gameOptions, onProceed) { var timeTrial = this.elements["option-timeTrial"].checked ? 1:0; var noBumps = this.elements["option-noBumps"].checked ? 1:0; var noJump = this.elements["option-noJump"].checked ? 1:0; + var noRd = this.elements["option-noRd"].checked ? 1:0; var doubleItems = this.elements["option-doubleItems"].checked ? 0:1; if (!team) { manualTeams = 0; @@ -19106,6 +19122,7 @@ function privateGameOptions(gameOptions, onProceed) { timeTrial: timeTrial, noBumps: noBumps, noJump: noJump, + noRd: noRd, doubleItems: doubleItems }); oScr.innerHTML = ""; @@ -20377,8 +20394,6 @@ function privateGameOptions(gameOptions, onProceed) { oTr.appendChild(oTd); oTable.appendChild(oTr); - oScroll.appendChild(oTable); - var oTr = document.createElement("tr"); oTr.id = "option-noBumps-ctn"; if (!isOnline) @@ -20415,8 +20430,6 @@ function privateGameOptions(gameOptions, onProceed) { oTr.appendChild(oTd); oTable.appendChild(oTr); - oScroll.appendChild(oTable); - var oTr = document.createElement("tr"); oTr.id = "option-noJump-ctn"; if (!isOnline) @@ -20453,6 +20466,42 @@ function privateGameOptions(gameOptions, onProceed) { oTr.appendChild(oTd); oTable.appendChild(oTr); + var oTr = document.createElement("tr"); + oTr.id = "option-noRd-ctn"; + if (!isOnline) + oTr.style.display = "none"; + var oTd = document.createElement("td"); + oTd.style.textAlign = "center"; + oTd.style.width = (iScreenScale*8) +"px"; + var oCheckbox = document.createElement("input"); + oCheckbox.style.transform = oCheckbox.style.WebkitTransform = oCheckbox.style.MozTransform = "scale("+ Math.round(iScreenScale/3) +")"; + oCheckbox.id = "option-noRd"; + oCheckbox.name = "option-noRd"; + oCheckbox.type = "checkbox"; + if (gameOptions && gameOptions.noRd) + oCheckbox.checked = true; + oTd.appendChild(oCheckbox); + oTr.appendChild(oTd); + + var oTd = document.createElement("td"); + var oLabel = document.createElement("label"); + oLabel.style.cursor = "pointer"; + oLabel.setAttribute("for", "option-noRd"); + var oH1 = document.createElement("h1"); + oH1.style.fontSize = (3*iScreenScale) +"px"; + oH1.style.marginBottom = "0px"; + oH1.innerHTML = toLanguage("Disable Reverse Drift", "Désactiver le Reverse Drift"); + oLabel.appendChild(oH1); + var oDiv = document.createElement("div"); + oDiv.style.fontSize = (2*iScreenScale) +"px"; + oDiv.style.color = "white"; + oDiv.innerHTML = toLanguage("If checked, the famous MKPC drifting technique is blocked", "Si coché, la fameuse technique de dérapage de MKPC est bloquée"); + oLabel.appendChild(oDiv); + oTd.appendChild(oLabel); + oTd.style.padding = Math.round(iScreenScale*1.5) +"px 0"; + oTr.appendChild(oTd); + oTable.appendChild(oTr); + oScroll.appendChild(oTable); oForm.appendChild(oScroll); @@ -21998,6 +22047,7 @@ function selectPlayerScreen(IdJ,newP,nbSels,additionalOptions) { shareLink.options.timeTrial = options.timeTrial; shareLink.options.noBumps = options.noBumps; shareLink.options.noJump = options.noJump; + shareLink.options.noRd = options.noRd; shareLink.options.doubleItems = options.doubleItems; selectedTeams = options.team; selectPlayerScreen(0); @@ -23708,6 +23758,7 @@ var defaultGameOptions = { timeTrial: false, noBumps: false, noJump: false, + noRd: false, doubleItems: true }; function isCustomOptions(linkOptions) { @@ -24214,6 +24265,27 @@ function acceptRulesScreen() { oTable.appendChild(oTr); } + if (shareLink.options.noRd) { + var oTr = document.createElement("tr"); + var oTd = document.createElement("td"); + var oLabel = document.createElement("label"); + oTd.appendChild(oLabel); + + var oH1 = document.createElement("h1"); + oH1.style.fontSize = (3*iScreenScale) +"px"; + oH1.innerHTML = toLanguage("No Reverse Drift", "Pas de Reverse Drift"); + oH1.style.marginBottom = "0px"; + oLabel.appendChild(oH1); + var oDiv = document.createElement("div"); + oDiv.style.fontSize = (2*iScreenScale) +"px"; + oDiv.style.color = "white"; + oDiv.innerHTML = toLanguage("The famous MKPC drifting technique is blocked", "La fameuse technique de dérapage de MKPC est bloquée"); + oLabel.appendChild(oDiv); + oTd.appendChild(oLabel); + oTr.appendChild(oTd); + oTable.appendChild(oTr); + } + oScroll.appendChild(oTable); oForm.appendChild(oScroll); diff --git a/scripts/mk.v225.js b/scripts/mk.v225.js new file mode 100644 index 000000000..8bc48c165 --- /dev/null +++ b/scripts/mk.v225.js @@ -0,0 +1 @@ +var pause,chatting=!1,aPlayers=new Array,aPlaces=new Array,aScores=new Array,aTeams=new Array,aPseudos=new Array,aControllers=new Array,aTracksHist=new Array,iRaceCount=0,fInfos,formulaire,baseCp,baseCp0,pUnlockMap,customDecorData={},customBgData={},nBasePersos,customPersos,selectedDifficulty,updateCtnFullScreen,isFirstLoad=!0,selectedCc=localStorage.getItem("cc")||"150",selectedMirror=!!localStorage.getItem("mirror"),selectedNbTeams=localStorage.getItem("nbTeams")||"2",selectedFriendlyFire=!!localStorage.getItem("friendlyFire"),selectedTeamOpts=0,selectedDoubleItems=0!=localStorage.getItem("doubleitems"),edittingCircuit,dCircuits;if(void 0===edittingCircuit&&(edittingCircuit=!1),void 0===cupOpts)var cupOpts={};else if(cupOpts.keyid){try{cupOpts=JSON.parse(sessionStorage.getItem("cupopt."+cupOpts.keyid))}catch(e){}cupOpts=cupOpts||{}}void 0===dCircuits&&(dCircuits=lCircuits);var isOnline="OL"==page,isMCups=isCup&&4
'+toLanguage("Custom FPS...","Choix des FPS...")+'
";var a=t.querySelector(".customOptionDialog-cursor"),n=t.querySelector(".customOptionDialog-content");function o(){var e=15*a.value;t.querySelector(".customOptionDialog-textValue").innerHTML=e+" FPS"}function i(){document.body.removeChild(t)}function r(){var e=+a.value;addFpsOption(e),setFps(e),i()}return a.value=iFps,o(),a.oninput=function(){o()},t.onclick=function(e){r()},n.style.bottom="5px",n.onclick=function(e){e.stopPropagation()},n.onsubmit=function(){return r(),!1},t.querySelector(".customOptionDialog-submit a").onclick=function(){return i(),!1},void document.body.appendChild(t)}if(localStorage.setItem("nbFrames",e),formulaire&&formulaire.dataset.disabled)return showParamChangeDisclaimer();iFps=e}function openFullscreen(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():void 0}var $mkScreen=document.getElementById("mariokartcontainer");$mkScreen.dataset||($mkScreen.dataset={}),updateCtnFullScreen=function(e){if($mkScreen.dataset.fs=e?1:"",e){var t=Math.min(screen.width/(iWidth*iScreenScale),screen.height/(iHeight*iScreenScale)),a=Math.round(100*t),n=$mkScreen.scrollWidth,e=$mkScreen.style.zoom;if($mkScreen.style.zoom=a+"%",n!=$mkScreen.scrollWidth||e==$mkScreen.style.zoom||100==a){for(var o=0;o
'+toLanguage("Custom size...","Taille personnalisée...")+'
";var o=n.querySelector(".customOptionDialog-cursor"),i=n.querySelector(".customOptionDialog-content");function r(){var e=+o.value;n.querySelector(".customOptionDialog-textValue").innerHTML=e*iWidth+"×"+e*iHeight}function l(){document.body.removeChild(n)}function s(){var e=+o.value;addScreenScaleOption(e),setScreenScale(e),l()}return o.value=a,r(),o.oninput=function(){var e=+o.value;formulaire.dataset.disabled||previewScreenScale(a,e),r()},n.onclick=function(e){s()},i.style.bottom="80px",i.onclick=function(e){e.stopPropagation()},i.onsubmit=function(){return s(),!1},n.querySelector(".customOptionDialog-submit a").onclick=function(){return formulaire.dataset.disabled||previewScreenScale(a,a),l(),!1},void document.body.appendChild(n)}if(t||localStorage.setItem("iScreenScale",e),formulaire&&formulaire.dataset.disabled)return showParamChangeDisclaimer();iScreenScale=e,bRunning&&resetScreen(),previewScreenScale(a,iScreenScale),setSRest()}else{formulaire.screenscale.value=a;e=openFullscreen($mkScreen);e.then&&e.catch?e.then(function(){updateCtnFullScreen(!0),document.onfullscreenchange=function(){updateCtnFullScreen(document.fullscreenElement===$mkScreen)}}).catch(function(){updateCtnFullScreen(!0)}):updateCtnFullScreen(!0)}}}function addCustomOption(e,t,a,n){var o;n=n||1,e.querySelector('option[value="'+t+'"]')||((o=document.createElement("option")).value=t,o.innerHTML=a,e.insertBefore(o,e.childNodes[e.childNodes.length-n])),e.value=t}function addScreenScaleOption(e){addCustomOption(formulaire.screenscale,e,e*iWidth+"×"+e*iHeight,2)}function addFpsOption(e){addCustomOption(formulaire.fps,e,15*e+" FPS")}function previewScreenScale(e,t){for(var a=0;aThey'll apply to your next race.","Les paramètres ont été sauvegardés.
Ils s'appliqueront à la prochaine course"),document.body.appendChild(e),setTimeout(function(){e.classList.add("modes-change-fadeout"),setTimeout(function(){document.body.removeChild(e)},1e3)},3e3)}function setMusic(e){if(e?localStorage.setItem("bMusic",1):localStorage.removeItem("bMusic"),formulaire&&formulaire.dataset.disabled){if(e)return showParamChangeDisclaimer();removeIfExists(mapMusic),removeIfExists(lastMapMusic),removeIfExists(endingMusic)}bMusic=!!e,-1!=gameMenu&&updateMenuMusic(gameMenu,!0)}function setSfx(e){if(e?localStorage.setItem("iSfx",1):localStorage.removeItem("iSfx"),formulaire&&formulaire.dataset.disabled){if(e)return showParamChangeDisclaimer();removeSoundEffects(),oMusicEmbed&&unpauseMusic(mapMusic),removeGameMusics([mapMusic,lastMapMusic,endingMusic])}iSfx=!!e}function removeMenuMusic(e){clearTimeout(oMusicHandler),oMusicEmbed&&document.body.contains(oMusicEmbed)&&(e?document.body.removeChild(oMusicEmbed):fadeOutMusic(oMusicEmbed,1,.8,null,vMusic),oMusicEmbed=void 0),muteOnBlur&&(window.removeEventListener("blur",muteOnBlur),muteOnBlur=void 0),unmuteOnResume&&(window.removeEventListener("focus",unmuteOnResume),unmuteOnResume=void 0)}function removeIfExists(e){e&&(e.yt&&(e.yt.destroy&&(e.yt.isDetroyed=!0,e.yt.destroy()),delete e.yt,delete e.tasks,delete e.opts),document.body.contains(e)&&document.body.removeChild(e),oMusicEmbed==e&&(oMusicEmbed=void 0))}function removeGameMusics(e){if(bMusic||iSfx){for(var t=document.getElementsByClassName("gamemusic"),a=t.length-1;0<=a;a--){var n=t[a];e&&-1!==e.indexOf(n)||document.body.removeChild(n)}oMusicEmbed=void 0}}function removeSoundEffects(){playingCarEngine=void 0,removeIfExists(carEngine),carEngine=void 0,removeIfExists(carEngine2),carEngine2=void 0,removeIfExists(carEngine3),carEngine3=void 0,removeIfExists(carDrift),carDrift=void 0,removeIfExists(carSpark),carSpark=void 0}function clearResources(){oMapImg&&oMapImg.clear&&oMapImg.clear()}function resetEvents(){document.onmousedown=void 0,document.onkeydown=void 0,document.onkeyup=void 0,window.removeEventListener("blur",window.releaseOnBlur),window.releaseOnBlur=void 0,window.removeEventListener("deviceorientation",window.turnOnRotate),window.turnOnRotate=void 0,hideVirtualKeyboard()}function pauseSounds(){if(bMusic||iSfx){clLocalVars.forcePause||(playSoundEffect("musics/events/pause.mp3").className="");for(var e=document.getElementsByClassName("gamemusic"),t=0;tt.length;)o.removeChild(e[0]),e.shift()}}function M(e,t,i,a){for(var n in e)if(oMap[n]){if(e[n].length
';for(var u=d.querySelectorAll("div"),m=0;m"+(oMap.sections?"SECTION":toLanguage("LAP","TOUR"))+' 1/'+oMap.tours+"",m||(c=Math.round(iScreenScale/8)+"px",p=Math.round(iScreenScale/4)+"px",u[m].style.textShadow="-"+p+" 0 black, 0 "+p+" black, "+p+" 0 black, 0 -"+p+" black, -"+c+" -"+c+" black, -"+c+" "+c+" black, "+c+" -"+c+" black, "+c+" "+c+" black")}else{var h=aTeams[i];null==h&&(h=-1),updateBalloonHud(d,{reserve:4,team:h})}l.appendChild(d);var g=document.createElement("div");g.id="objet"+i,g.className="itemWheel",pause&&fInfos.replay||(g.style.left=Math.round(iScreenScale)+"px",g.style.top=Math.round(iScreenScale)+"px",g.style.width=Math.round(26*iScreenScale/3)+"px",g.style.height=Math.round(18*iScreenScale/3)+"px",g.style.visibility="visible");h=document.createElement("div");h.id="roulette"+i,h.className="itemChamber",g.appendChild(h);d=document.createElement("div");d.id="countdown"+i,d.style.position="absolute",d.style.opacity=.8,d.style.width=Math.round(6.6*iScreenScale)+"px",d.style.height=Math.round(4.2*iScreenScale)+"px",d.style.border="solid "+Math.round(.75*iScreenScale)+"px "+primaryColor,d.style.borderRadius=Math.round(1.75*iScreenScale)+"px",d.style.display="none",g.appendChild(d),l.appendChild(g);d=document.createElement("div");d.id="reserve"+i,d.className="itemWheel",pause&&fInfos.replay||(d.style.left=Math.round(.75*iScreenScale)+"px",d.style.top=Math.round(iScreenScale)+"px",d.style.width=Math.round(26*iScreenScale/5)+"px",d.style.height=Math.round(18*iScreenScale/5)+"px",d.style.visibility="hidden"),(h=document.createElement("div")).id="roulette2"+i,h.className="itemChamber",d.appendChild(h),l.appendChild(d);h=document.createElement("div");h.id="lakitu"+i,h.className="pixelated",h.innerHTML="
",h.style.width=9*iScreenScale+"px",h.style.height=Math.round(6.6*iScreenScale)+"px",h.style.fontSize=Math.round(2.3*iScreenScale)+"px",l.appendChild(h);h=document.createElement("div");h.id="infoPlace"+i,h.style.right=Math.round(iScreenScale/2)+"px",h.style.bottom="0px",h.style.fontSize=8*iScreenScale+"px",l.appendChild(h);h=document.getElementById("infos"+i);h||((h=document.getElementById("infos0").cloneNode(!0)).id="infos"+i,$mkScreen.appendChild(h)),h.style.left=10+r+"px",h.style.top=10*iScreenScale+"px",h.style.width=iWidth*iScreenScale+"px",h.style.fontSize=16*iScreenScale+"px",h.style.fontFamily='"NSMBU", Impact',h.style.textAlign="center",h.style.textStroke=h.style.WebkitTextStroke=h.style.MozTextStroke=Math.round(iScreenScale/4)+"px "+primaryColor,h.style.visibility="hidden",h.style.display="",h.style.pointerEvents="none",h.innerHTML='3';var y=document.getElementById("scroller").cloneNode(!0);y.id="scroller"+i,y.className="itemScroller";y.style.left=iScreenScale+"px",y.style.top=Math.round(iScreenScale+ +iScreenScale)+"px",y.style.width=Math.round(26*iScreenScale/3)+"px",y.style.height=Math.round(18*iScreenScale/3-2*iScreenScale*1)+"px",y.style.lineHeight=iScreenScale+"px";for(var f=Math.round(4*iScreenScale),m=0;m=_){if(N=oMap.checkpoint.length&&(x=0),(P=oMap.checkpointCoords[x])&&(k=P.O[0],I=P.O[1],(T=Math.hypot(k-n.x,I-n.y)*Math.hypot(b[0]-C[0],b[1]-C[1]))&&(M-=150*((k-n.x)*(b[0]-C[0])+(I-n.y)*(b[1]-C[1]))/T)),M=oMap.checkpoint.length&&(x=0),(P=oMap.checkpointCoords[x])&&(k=P.O[0],I=P.O[1],(T=Math.hypot(k-n.x,I-n.y)*Math.hypot(b[0]-C[0],b[1]-C[1]))&&(M-=150*((k-n.x)*(b[0]-C[0])+(I-n.y)*(b[1]-C[1]))/T)),Mthis.duration-.44&&(this.currentTime=0,this.parentNode&&this.play())}function loopAfterIntro(e,t,a){var n;e.looper||(n=t+(a-=.15),e.looper=function(){this.currentTime>=n&&(this.currentTime-=a)},e.addEventListener("timeupdate",e.looper,!1))}function startEngineSound(){iSfx&&(carEngine=loadMusic("musics/events/engine.mp3",!0),carEngine2=loadMusic("musics/events/engine2.mp3",!1),carEngine3=loadMusic("musics/events/engine3.mp3",!1),carDrift=loadMusic("musics/events/drift.mp3",!1),carSpark=loadMusic("musics/events/spark.mp3",!1),(playingCarEngine=carEngine).addEventListener("timeupdate",loopWithoutGap,!1),carEngine2.addEventListener("timeupdate",loopWithoutGap,!1),carEngine.permanent=1,carEngine2.permanent=1,carEngine3.permanent=1,carDrift.permanent=1,carSpark.permanent=1,document.body.appendChild(carEngine),document.body.appendChild(carEngine2),document.body.appendChild(carEngine3),document.body.appendChild(carDrift),document.body.appendChild(carSpark))}function updateEngineSound(e){iSfx&&e!=playingCarEngine&&(playingCarEngine&&playingCarEngine.pause(),(playingCarEngine=e)&&playingCarEngine.play())}function startEndMusic(){bMusic&&(removeMenuMusic(!0),removeIfExists(mapMusic),removeIfExists(lastMapMusic)),iSfx&&removeSoundEffects(),bMusic&&(willPlayEndMusic=!0,setTimeout(function(){for(var e=document.getElementsByClassName("gamemusic"),t=[],a=0;a(new Date).getTime())&&oSpecCam.reset()),(itemDistribution=(itemDistribution=selectedItemDistrib)||itemDistributions[getItemMode()][0]).value||(itemDistribution={value:itemDistribution}),ptsDistribution=selectedPtDistrib,m){oMap.arme=[];for(e=0;e=oMap.h?oPlanWidth:oPlanWidth*(oMap.w/oMap.h);i=oMap.w<=oMap.h?oPlanWidth:oPlanWidth*(oMap.h/oMap.w);if(oMap.iW&&oMap.iH&&(U=Math.min(oMap.w/oMap.iW,oMap.h/oMap.iH),oPlanWidth2*=U,i*=U),oPlanWidth2=Math.round(oPlanWidth2),i=Math.round(i),oPlanSize=59*iScreenScale,oPlanSize2=oPlanWidth2,oPlanRealSize=oMap.w,oCharRatio=.8,oPlanRatio=.5,(oPlanDiv=document.createElement("div")).className="mkplan mkplanzoom",oPlanDiv.style.backgroundColor="rgb("+oMap.bgcolor+")",oPlanDiv.style.left=15+iScreenScale*iWidth+"px",oPlanDiv.style.top="9px",oPlanDiv.style.width=oPlanWidth+"px",oPlanDiv.style.height=oPlanWidth+"px",oPlanDiv.style.opacity=.01,(oPlanDiv2=document.createElement("div")).className="mkplan mkplanfull",oPlanDiv2.style.backgroundColor="rgb("+oMap.bgcolor+")",oPlanDiv2.style.width=oPlanWidth+"px",oPlanDiv2.style.height=oPlanWidth+"px",oPlanDiv2.style.opacity=.01,(oPlanCtn=document.createElement("div")).style.position="absolute",oPlanCtn.style.transformOrigin=oPlanCtn.style.WebkitTransformOrigin=oPlanCtn.style.MozTransformOrigin="left",(oPlanCtn2=document.createElement("div")).style.position="absolute",oPlanCtn2.style.left=Math.round((oPlanWidth-oPlanWidth2)/2)+"px",oPlanCtn2.style.top=Math.round((oPlanWidth-i)/2)+"px",oPlanCtn2.style.width=oPlanWidth2+"px",oPlanCtn2.style.height=i+"px",oMapImg.src?((oPlanImg=document.createElement("img")).src=oMapImg.src,oPlanImg.style.width=oPlanSize+"px"):(be=Math.round(oPlanSize*oMap.h/oMap.w),(oPlanImg=document.createElement("canvas")).width=oPlanSize,oPlanImg.height=be,oPlanImg.getContext("2d").drawImage(oMapImg,0,0,oPlanSize,be)),oPlanImg.className="mkplanimg",oPlanCtn.appendChild(oPlanImg),oMapImg.src?(oPlanImg2=document.createElement("img")).src=oMapImg.src:((oPlanImg2=document.createElement("canvas")).width=oPlanSize,oPlanImg2.height=be,oPlanImg2.getContext("2d").drawImage(oMapImg,0,0,oPlanSize,be)),oPlanImg2.className="mkplanimg",oPlanImg2.style.width=oPlanWidth2+"px",oPlanCtn2.appendChild(oPlanImg2),bSelectedMirror&&(oPlanImg.className=oPlanImg2.className="mirrored"),oMap.decor)for(var te in oMap.decor)oPlanDecor[te]=new Array,oPlanDecor2[te]=new Array;oMap.sea&&((oPlanSea=document.createElement("canvas")).style.position="absolute",oPlanSea.style.left="0px",oPlanSea.style.top="0px",oPlanSea.setAttribute("width",oPlanSize+"px"),oPlanSea.setAttribute("height",oPlanSize+"px"),oPlanCtn.appendChild(oPlanSea),(oPlanSea2=document.createElement("canvas")).style.position="absolute",oPlanSea2.style.left="0px",oPlanSea2.style.top="0px",oPlanSea2.setAttribute("width",oPlanWidth2+"px"),oPlanSea2.setAttribute("height",oPlanWidth2+"px"),oPlanCtn2.appendChild(oPlanSea2),bSelectedMirror&&(oPlanSea.className=oPlanSea2.className="mirrored"));for(e=0;e"+toLanguage("GO!","PARTEZ !")+"",document.getElementById("infos"+e).style.fontSize=12*iScreenScale+"px",document.getElementById("infos"+e).style.top=Math.round(12.5*iScreenScale)+"px",1==oPlayers[e].speed?oPlayers[e].speed=11:1 '+(a?"":' ')+' ',l.onkeydown=function(e){var t,a;switch(e.keyCode){case 38:t=-1;break;case 40:t=1;break;case 13:(a=document.activeElement)&&a.onclick&&l.contains(a)&&iSfx&&setTimeout(function(){document.onkeydown||playSoundEffect("musics/events/select.mp3")})}if(t&&(a=document.activeElement)){var n=Array.prototype.slice.call(document.querySelectorAll("#infos0 input, #infos0 button")),o=a,i=n.indexOf(a);if(-1!=i){var r=i;do{if((r+=t)<0&&(r+=n.length),r>=n.length&&(r=0),(o=n[r])&&"none"!=o.style.display&&"hidden"!=o.style.visibility){o.focus(),iSfx&&playSoundEffect("musics/events/move.mp3");break}}while(r!=i)}}},document.getElementById("reprendre").onclick=reprendre,document.getElementById("recommencer").onclick=function(){interruptGame(),removeGameMusics(),removeHUD(),clearResources();for(var e=0;e'+toLanguage("Spectator mode","Mode spectateur")+""+toLanguage("Switch player:","Changer de joueur :")+' ← →'+toLanguage("Exit: Escape","Quitter : Echap")+"",l.style.left=10+iScreenScale+"px",l.style.top=10+iScreenScale+"px",l.style.fontSize=Math.round(1.75*iScreenScale)+"px",l.style.display="",l.style.visibility="",document.body.style.cursor="default")),bCounting=!1},onlineSpectatorState?1:1e3),pause&&fInfos.replay){for(pause=!1,e=0;e=fTurboDriftCpt&&(oPlayers[0].turbodrift=15,clLocalVars.miniTurbo++,clSelected&&clRuleVars[clSelected.id]&&(t=clRuleVars[clSelected.id].mini_turbo)&&updateChallengeHud("miniTurbo",clLocalVars.miniTurbo+t.miniTurbo),oPlayers[0].driftcpt>=fTurboDriftCpt2&&(oPlayers[0].turbodrift+=15,clLocalVars.superTurbo++,clSelected&&clRuleVars[clSelected.id]&&(t=clRuleVars[clSelected.id].super_turbo)&&updateChallengeHud("superTurbo",clLocalVars.superTurbo+t.superTurbo)),oPlayers[0].turbodrift0=oPlayers[0].turbodrift,resetDriftSprite(oPlayers[0])),oPlayers[0].driftcpt=0,oPlayers[0].driftSound&&(oPlayers[0].driftSound.pause(),oPlayers[0].driftSound=void 0)),oPlayers[0].ctrled=!1,oPlayers[0].jumped&&(oPlayers[0].z||oPlayers[0].heightinc)&&(oPlayers[0].ctrled=!0);break;case"rear":clLocalVars.rearView||showRearView(0);break;case"item_p2":case"item_back_p2":case"item_fwd_p2":oPlayers[1].tourne||oPlayers[1].cannon||pause||arme(1,"item_back_p2"===e,"item_fwd_p2"===e);break;case"up_p2":if(!oPlayers[1])return;oPlayers[1].speedinc=0;break;case"left_p2":case"right_p2":if(!oPlayers[1])return;oPlayers[1].rotincdir=0;break;case"down_p2":if(!oPlayers[1])return;oPlayers[1].speedinc=0;break;case"jump_p2":if(pause)break;if(!oPlayers[1])return;delete oPlayers[1].ctrl,oPlayers[1].driftinc&&(oPlayers[1].driftinc=0,oPlayers[1].driftcpt>=fTurboDriftCpt&&(oPlayers[1].turbodrift=15,oPlayers[1].driftcpt>=fTurboDriftCpt2&&(oPlayers[1].turbodrift+=15),oPlayers[1].turbodrift0=oPlayers[1].turbodrift,resetDriftSprite(oPlayers[1])),oPlayers[1].driftcpt=0,oPlayers[1].driftSound&&(oPlayers[1].driftSound.pause(),oPlayers[1].driftSound=void 0)),oPlayers[1].ctrled=!1,oPlayers[1].jumped&&(oPlayers[1].z||oPlayers[1].heightinc)&&(oPlayers[1].ctrled=!0);break;case"rear_p2":if(!oPlayers[1])return;showRearView(1)}}(t))},window.releaseOnBlur=function(){if(!onlineSpectatorId){l={};for(var e=0;e'+(language?"+ Jump
Drift":"+ Saut
Dérapage")+"
",["up","jump"],0,0),ctrlSettings.autoacc&&(e.style.display="none"),addButtonLegacy(" ↑ ","up",1,0).id="virtualbtn-accelerate",addButtonLegacy("Obj","item",2,0,null,null,25),addButtonLegacy("❚❚","pause",3,0,null,null,25),document.getElementById("virtualkeyboard").appendChild(document.createElement("br")),document.getElementById("virtualkeyboard").appendChild(document.createElement("br")),addButtonLegacy(language?"Jump
Drift":"Saut
Dérapage","jump",0,1,null,null,11),addButtonLegacy(" ↓ ","down",1,1),addButtonLegacy(" ← ","left",2,1).id="virtualbtn-left",addButtonLegacy(" → ","right",3,1).id="virtualbtn-right";break;case"h_sym":t(!0),a(!0);break;case"v_sym":a(),t();break;case"vh_sym":a(!0),t(!0);break;default:t(),a()}if(i.ontouchstart=function(e){return e.preventDefault(),!1},i.className="shown","old"===ctrlSettings.layout){i.classList.add("legacy");return i.style.width=Math.round(288)+"px",i.style.height=Math.round(130)+"px",i.style.left=(iScreenScale*iWidth-288)/2+"px",void(i.style.top=40*iScreenScale+"px")}posVirtualKeyboard(i)}function posVirtualKeyboard(e){var t=iScreenScale*iHeight+20;e.style.top=t+"px";var a=e.offsetWidth,n=window.innerHeight-t,n=Math.min(n,Math.round(.45*a)),t=Math.min(window.innerWidth,iWidth*iScreenScale);aMath.max(.2,3*Math.abs(e)))return releaseKey("up"),pressKey("down"),0Math.max(50,3*Math.abs(t))?doReleaseKey(0window.innerHeight,window.turnOnRotate=function(e){var t,a;n&&n.dataset.pressed||o&&o.dataset.pressed||(e=i?(t=e.beta,90<=Math.abs(t)&&(t=Math.sign(t)*(180-Math.abs(t))),a=15,1):(t=e.gamma,90<=e.beta&&(t=-t),a=15,2),a=-Math.sign(t)*Math.pow(Math.abs(t/90),e)*a,rotateToAngle(oPlayers[0],a))},window.addEventListener("deviceorientation",window.turnOnRotate))}function setupVibrate(){navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate||function(){}}function showSpectatorKeyboard(){setupVibrate();var e=document.getElementById("virtualkeyboard");addButton("←",{key:"left",src:"left"}),addButton("→",{key:"right",src:"right"}),e.className="shown spectator",posVirtualKeyboard(e),e.style.height="40px"}var oPressedKeys={},oMusicEmbed;function pressKey(e){oPressedKeys[e]||doPressKey(e)}function doPressKey(e){oPressedKeys[e]=1,document.onkeydown&&document.onkeydown({keyAction:e})}function releaseKey(e){oPressedKeys[e]&&doReleaseKey(e)}function doReleaseKey(e){oPressedKeys[e]=void 0,document.onkeyup&&document.onkeyup({keyAction:e})}function rotateToAngle(e,t){var a=getMirrorFactor();clLocalVars.invertDirs&&(a=-a);var n,a=(t-angleInc(e)*a)/2;return a>e.stats.handling/2?n="left":a<-e.stats.handling/2&&(n="right"),"left"!==n&&releaseKey("left"),"right"!==n&&releaseKey("right"),n&&pressKey(n),{targetDir:a,action:n}}function youtube_parser(e){e=e.match(/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/);return!(!e||11!=e[1].length)&&e[1]}var fSpriteScale=0,fLineScale=0,oContainers=[document.createElement("div")],oPrevFrameStates;oContainers[0].className="game-container",oContainers[0].tabindex=1,formulaire=null,updateCtnFullScreen(1==$mkScreen.dataset.fs),function(){for(var e,t=0;t<2;t++)(e=document.getElementById("infos"+t))&&$mkScreen.removeChild(e);(e=document.createElement("table")).id="infos0",e.setAttribute("cellspacing",1),e.setAttribute("cellpadding",0),e.style.display="none",$mkScreen.appendChild(e)}(),$mkScreen.appendChild(oContainers[0]),pause&&fInfos.player[1]&&(oContainers[1]=oContainers[0].cloneNode(!1),oContainers[1].style.left=12+iWidth*iScreenScale+"px",$mkScreen.appendChild(oContainers[1]));var oScreens=new Array,aStrips=new Array,iCamHeight=24,iCamDist=32,iViewHeight=-10,fFocal=1/Math.tan(Math.PI*Math.PI/360);function resetScreen(){fSpriteScale=iScreenScale/4,fLineScale=1/iScreenScale*iQuality,aStrips=[];for(var e=0;ePlaces'+toLanguage("Team","Équipe")+"Pts",t=0;t'+toPlace(t+1)+' '+r+''+a[i]+""}return n.style.visibility="hidden",n.style.position="absolute",n.style.zIndex=2e4,n.style.left=Math.round(.5*iScreenScale+10)+"px",n.style.top=10*iScreenScale+"px",n.style.backgroundColor="blue",n.style.color=primaryColor,n.style.opacity=.7,n.style.textAlign="center",n.style.fontSize=Math.round(1.5*iScreenScale+2)+"pt",n.style.fontFamily="Courier",n.style.fontWeight="bold",n.style.fontFamily="arial",n.innerHTML=o,$mkScreen.appendChild(n),n}function resetScores(){for(var e=0;e ':' id="enregistrer">')+'';var oTeamTable=document.getElementById("team-table");oTeamTable&&$mkScreen.removeChild(oTeamTable);var oContinue=document.createElement("input"),forceClic3,oQuit,oSave,oReplay,oChangeRace,oClassement;oContinue.type="button",oContinue.style.fontSize=3*iScreenScale+"pt",oContinue.style.width="100%","CM"!=course?oMap.ref%4||"GP"!=course?(isSingle&&!isOnline?oContinue.value=" "+toLanguage(" REPLAY","REJOUER")+" ":"BB"==course?oContinue.value=toLanguage(" NEXT BATTLE\t ","BATAILLE SUIVANTE"):oContinue.value=toLanguage(" NEXT RACE\t ","COURSE SUIVANTE"),forceClic3=!0,oContinue.onclick=function(){forceClic3=!1,nextRace()},isOnline&&setTimeout(function(){forceClic3&&nextRace()},5e3)):(oContinue.value=toLanguage(" NEXT "," SUIVANT "),oContinue.onclick=function(){$mkScreen=document.body,interruptGame();var posX=[29,22,36],posY=[15,17,19],oPlace;document.body.innerHTML=toLanguage("You are","Vous êtes")+' !
'+toLanguage("Back","Retour")+'.';for(var placement=new Array,i=1;i<=aKarts.length;i++)for(var j=0;j';else if(oPlace)break}document.getElementById("position").innerHTML=toPlace(oPlace),oPlace<=3?(document.body.innerHTML+='.',saveParams="pts="+(4-oPlace),"MK"==page?(saveUrl="saveGP.php",saveParams+="&change="+(oMap.map-4)/4):nid&&(saveUrl="cupsave.php",saveParams+=isMCups?"&cup="+cupIDs[oMap.ref/4-1]:"&cup="+nid),saveUrl&&xhr(saveUrl,saveParams,function(reponse){if(reponse){var newPerso,uwPerso,uwPerso;try{newPerso=eval(reponse)}catch(e){return!1}return newPerso&&(uwPerso=toPerso(newPerso),uwPerso=uwPerso.charAt(0).toUpperCase()+uwPerso.substring(1),document.body.innerHTML+='
'+toLanguage("You can now play
with "+uwPerso+" !","Vous pouvez désormais
jouer avec "+uwPerso+" !")+'
'),!0}return!1}),bMusic&&(endGPMusic=startMusic("musics/menu/congrats.mp3",!0,700))):bMusic&&(endGPMusic=startMusic("musics/menu/toobad.mp3",!0,700)),reinitChallengeVars(),clLocalVars.endGP=!0,challengeCheck("end_gp")}):(oQuit=document.getElementById("quitter"),oContinue.style.fontSize=oQuit.style.fontSize=3*iScreenScale+"px",oSave=oContinue.cloneNode(!1),oReplay=oContinue.cloneNode(!1),oChangeRace=oContinue.cloneNode(!1),oClassement=oContinue.cloneNode(!1),oContinue.value=gSelectedPerso?toLanguage(" FACE WITH "," AFFRONTER "):toLanguage(" RETRY "," RÉESSAYER "),oContinue.onclick=function(){interruptGame(),removeGameMusics(),removeHUD(),clearResources(),$mkScreen.removeChild(oContainers[0]),fInfos={player:strPlayer,distribution:itemDistribution,ptsdistrib:ptsDistribution,cc:fSelectedClass,mirror:bSelectedMirror,double_items:oDoubleItemsEnabled,map:oMap.ref,difficulty:iDificulty,perso:gPersos,cpu_route:jTrajets,my_record:gRecord,ow_record:gOverwriteRecord,lap_times:iLapTimes,cl:clSelected},gSelectedPerso?(fInfos.player=[gSelectedPerso],jTrajets||(fInfos.perso=[strPlayer[0]],fInfos.cpu_route=[iTrajet])):2==gOverwriteRecord&&lapTimers.length==oMap.tours&&(fInfos.cpu_route=[iTrajet],fInfos.perso=strPlayer,fInfos.lap_times=lapTimers),document.getElementById("infos0").style.display="none",1==strPlayer.length&&removePlan(),oBgLayers.length=0,resetEvents(),resetApp()},oSave.value=" "+toLanguage("SAVE","ENREGISTRER")+" ",oSave.onclick=function(){document.getElementById("infos0").style.display="none";var oForm=document.createElement("form"),savedRecord;oForm.style.color="black",oForm.style.position="absolute",oForm.style.left=5*iScreenScale+10+"px",oForm.style.top=5*iScreenScale+10+"px",oForm.style.fontSize=4*iScreenScale+"pt",oForm.style.backgroundColor="#FF6",oForm.style.opacity=.8,oForm.style.border="double 4px black",oForm.style.textAlign="center",oForm.style.width=70*iScreenScale-10+"px",oForm.style.zIndex=2e4,oForm.onsubmit=function(){var nom=this.pseudo.value;if(nom){document.body.style.cursor="progress",oValide.style.visibility="hidden",aPara2.style.visibility="hidden";var params="name="+nom+"&perso="+strPlayer[0]+"&time="+getActualGameTimeMS()+"&cc="+getActualCc();switch(page){case"MK":params+="&circuit="+oMap.map;break;case"CI":params+="&creation="+oMap.id;break;case"MA":params+="&map="+oMap.map}function postSaveRecord(reponse){if(reponse){var enregistre;document.body.style.cursor="default";try{enregistre=eval(reponse)}catch(e){return!1}function showBackUi(e){oInput.disabled=!0,oCheckbox.disabled=!0,oValide.parentNode.removeChild(oValide),aPara2.style.fontSize=Math.round(2.5*iScreenScale)+"px",e&&(aPara2.innerHTML=toLanguage("Congratulations "+nom+", your score has been saved successfully ! You placed ","Félicitations "+nom+", votre score a bien été enregistré ! Vous êtes ")+toPlace(enregistre[0])+toLanguage(" out of "+enregistre[1]+" in this race !"," sur "+enregistre[1]+" au classement de ce circuit !"),oSave.style.display="none"),aPara2.style.visibility="",oRetour.focus()}function rollbackUi(){oValide.style.visibility="",oValide.style.marginRight=2*iScreenScale+"px",aPara3.insertBefore(oValide,oRetour),oCheckbox.disabled=!1,oInput.disabled=!1,oInput.select()}if(Array.isArray(enregistre))if(savedRecord=enregistre,oCheckbox.checked){oSave.style.display="none",oValide.style.display="none";var aSmall=document.createElement("span");aSmall.style.fontSize=Math.round(2.5*iScreenScale)+"px",aSmall.innerHTML=toLanguage("Saving ghost...","Enregistrement du fantôme..."),aPara2.appendChild(aSmall),aPara2.style.visibility="";var oRequest="map="+getCreationId(oMap)+"&type="+getCreationTable()+"&perso="+strPlayer[0]+"&time="+getActualGameTimeMS()+"×="+JSON.stringify(lapTimers)+"&cc="+getActualCc();for(i=0;idelete ghosts to save space','Vous avez dépassé votre quota de fantômes enregistrés. Vous pouvez supprimer des fantômes pour gagner de l\'espace'),rollbackUi(),!0)})}else showBackUi(!0);else{switch(showBackUi(!1),enregistre){case 0:aPara2.innerHTML=toLanguage("You did a better score on this race before.
Your score has not been registered.","Vous avez fait un meilleur score sur ce circuit.
Votre temps n'a donc pas été enregistré.");break;case 1:aPara2.innerHTML=toLanguage('This username is already used, please choose another one. If it\'s you, log-in to your account and try again.','Ce pseudo est déjà utilisé, veuillez en choisir un autre. S\'il s\'agit de vous, connectez-vous et réessayez.');break;default:aPara2.innerHTML=toLanguage("An unknown error occured, please try again later","Une erreur inconnue est survenue, veuillez réessayer ultérieurement")}0!=enregistre&&rollbackUi()}return!0}return!1}savedRecord?postSaveRecord(savedRecord):xhr("records.php",params,postSaveRecord),recorder=nom}return!1};var aPara1=document.createElement("p");aPara1.innerHTML=toLanguage("Username: ","Pseudo : "),aPara1.style.margin=iScreenScale+"px";var oInput=document.createElement("input");oInput.type="text",oInput.name="pseudo",oInput.value=recorder,oInput.size=15,oInput.maxlength=18,oInput.style.fontSize=3*iScreenScale+"px",oInput.onkeydown=function(e){e.stopPropagation()},oInput.onkeyup=function(e){e.stopPropagation()},aPara1.appendChild(oInput);var aPara12=aPara1.cloneNode(!1),oCheckLabel=document.createElement("label");oCheckLabel.style.display="inline-block";var oCheckbox=document.createElement("input");oCheckbox.type="checkbox",oCheckbox.name="saveghost",oCheckbox.checked=!0,oCheckbox.style.transform=oCheckbox.style.WebkitTransform=oCheckbox.style.MozTransform="scale("+(iScreenScale/6).toFixed(1)+")",oCheckLabel.appendChild(oCheckbox);var oCheckSpan=document.createElement("span");oCheckSpan.style.fontSize=2*iScreenScale+"px",oCheckSpan.innerHTML=" "+toLanguage("Save ghost","Enregistrer le fantôme"),oCheckLabel.appendChild(oCheckSpan),aPara12.appendChild(oCheckLabel),gRecord<=timerMS&&(oCheckbox.checked=!1,aPara12.style.display="none");var aPara2=aPara1.cloneNode(!1),oValide=document.createElement("input");oValide.type="submit",oValide.value=" "+toLanguage("Submit","Valider")+" ",oValide.style.fontSize=5*iScreenScale+"px",oValide.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",oRetour.style.fontSize=4*iScreenScale+"px"},aPara2.appendChild(oValide);var aPara3=aPara1.cloneNode(!1),oRetour=document.createElement("input");oRetour.type="button",oRetour.value=" "+toLanguage("Back","Retour")+" ",oRetour.style.fontSize=4*iScreenScale+"px",oRetour.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",oValide.style.fontSize=4*iScreenScale+"px"},oRetour.onclick=function(){$mkScreen.removeChild(oForm),document.getElementById("infos0").style.display="",oContinue.focus()},aPara3.appendChild(oRetour),oForm.appendChild(aPara1),oForm.appendChild(aPara12),oForm.appendChild(aPara2),oForm.appendChild(aPara3),$mkScreen.appendChild(oForm),oForm.style.height=oForm.scrollHeight+"px",oInput.select()},gSelectedPerso&&(oSave.style.display="none"),document.getElementById("enregistrer").appendChild(oSave),oReplay.value=toLanguage("REPLAY","REVOIR"),oReplay.onclick=function(){interruptGame(),removeGameMusics(),removeHUD(),clearResources();for(var e=0;eiHeight*iScreenScale||t+n*iScreenScale<9*iScreenScale?l[o][0].style.display="none":(l[o][0].style.display="block",l[o][0].style.left=Math.round(e-i/2)+"px",l[o][0].style.top=Math.round(a)+"px",this.h!=this.w?l[o][1].style.width=Math.round(i)*this.nbSprites+"px":l[o][1].style.width="",l[o][1].style.height=Math.round(r)+"px",l[o][0].style.width=Math.round(i)+"px",l[o][0].style.height=Math.round(r)+"px",l[o][1].style.left=-(Math.round(i)*l[o][2])+"px")},this[t].render=function(e,t){var a=t.size||1,n=(t.x-e.x)*getMirrorFactor(),o=t.y-e.y,i=e.rotation*Math.PI/180*getMirrorFactor(),e=n*Math.cos(i)-o*Math.sin(i),n=n*Math.sin(i)+o*Math.cos(i),o=-iCamHeight,i=iCamDist+n,t=t.z?correctCamZ(t.z,i):0,i=o/i*iCamDist+iCamHeight-iViewHeight+t,e=-e/(n+iCamDist)*iCamDist;this.div.style.zIndex=Math.round(1e4-n);e=(iWidth/2+e)*iScreenScale,i=(iHeight-i)*iScreenScale,a*=fFocal/(fFocal+n);this.draw(e,i,a,t)},this[t].setState=function(e){l[this.i][2]=e},this[t].getState=function(){return l[this.i][2]},this[t].div=n,this[t].img=a,l.push([n,a,0])}var o=this;this[0].unshow=function(){o[0].suppr(),o[0].unshown=!0},this[0].suppr=function(){if(!o[0].unshown)for(var e=0;e>3]&1<<(7&s)&&(o|=1<=c.length?c.push(c[i].concat(c[i][0])):i!==p&&c.push(c[i].concat(c[o][0])),l=(r=c[o]).length,a=0;a>2,C.transparencyGiven=!!(1&e),C.delayTime=n.data[n.pos++]+(n.data[n.pos++]<<8),C.transparencyIndex=n.data[n.pos++],n.pos++):t===s.COMMENT?C.comment+=n.readSubBlocks():t===s.APPExt?(n.pos+=1,"NETSCAPE"===n.getString(8)?n.pos+=8:(n.pos+=3,n.readSubBlocks())):(t===s.UNKNOWN&&(n.pos+=13),n.readSubBlocks())}function y(){if(void 0!==C.cancel&&!0===C.cancel)return m(),void("function"==typeof C.cancelCallback&&C.cancelCallback.bind(C)({type:"canceled",path:[C]}));var e=n.data[n.pos++];if(e===s.IMAGE){if(d(),C.firstFrameOnly)return void m()}else{if(e===s.EOF)return void m();g()}C.frames.length&&"function"==typeof C.onloadone&&(C.image=C.frames[0].image,C.onloadone.bind(C)({type:"load",path:[C]}),delete C.onloadone),"function"==typeof C.onprogress&&C.onprogress({bytesRead:n.pos,totalBytes:n.data.length,frame:C.frames.length}),t=setTimeout(y,0)}function f(e){"function"==typeof C.onerror&&C.onerror.bind(this)({type:e,path:[this]}),C.onload=C.onerror=void 0,C.loading=!1}function S(){C.currentFrame=0,C.nextFrameAt=C.lastFrameAt=(new Date).valueOf(),"function"==typeof C.onload&&C.onload.bind(C)({type:"load",path:[C]}),C.onerror=C.onload=void 0}function v(e){(n=new c(e)).pos+=6,C.width=n.data[n.pos++]+(n.data[n.pos++]<<8),C.height=n.data[n.pos++]+(n.data[n.pos++]<<8),e=n.data[n.pos++],C.colorRes=(112&e)>>4,C.globalColourCount=1<<1+(7&e),C.bgColourIndex=n.data[n.pos++],n.pos++,128&e&&(C.globalColourTable=p(C.globalColourCount)),t=setTimeout(y,0)}function b(){var e;0===C.playSpeed?C.pause():(e=C.playSpeed<0?(--C.currentFrame,C.currentFrame<0&&(C.currentFrame=C.frames.length-1),e=C.currentFrame,--e<0&&(e=C.frames.length-1),-C.frames[e].delay/C.playSpeed):(C.currentFrame+=1,C.currentFrame%=C.frames.length,+C.frames[C.currentFrame].delay/C.playSpeed),C.image=C.frames[C.currentFrame].image,a=setTimeout(b,e))}var C={onload:null,onerror:null,onprogress:null,onloadall:null,paused:!1,playing:!1,waitTillDone:!0,loading:!1,firstFrameOnly:!1,width:null,height:null,frames:[],comment:"",length:0,currentFrame:0,frameCount:0,playSpeed:1,lastFrame:null,image:null,playOnLoad:!0,load:function(e){var t=new XMLHttpRequest;t.responseType="arraybuffer",t.onload=function(e){404===e.target.status?f("File not found"):200<=e.target.status&&e.target.status<300?v(t.response):f("Loading error : "+e.target.status)},t.open("GET",e,!0),t.send(),t.onerror=function(e){f("File error")},this.src=e,this.loading=!0},cancel:function(e){return!C.complete&&(C.cancelCallback=e,C.cancel=!0)},play:function(){C.playing||(C.paused=!1,C.playing=!0,b())},pause:function(){C.paused=!0,C.playing=!1,clearTimeout(a)},seek:function(e){clearTimeout(a),e<0&&(e=0),e*=1e3,e%=C.length;for(var t=0;e>C.frames[t].time+C.frames[t].delay&&tiHeight*iScreenScale||a+o*iScreenScale<12*iScreenScale?i.style.display="none":(i.style.display="block",n=Math.round(r.sprite[e].h*fSpriteScale*n),i.style.left=Math.round(t)+"px",i.style.top=Math.round(a-n/2)+"px")},e.render=function(e,t,a){var n=a.size||1,o=(a.x-t.x)*getMirrorFactor(),i=a.y-t.y,r=t.rotation*Math.PI/180*getMirrorFactor(),t=o*Math.cos(r)-i*Math.sin(r),o=o*Math.sin(r)+i*Math.cos(r),i=-iCamHeight,r=iCamDist+o,a=correctCamZ(a.z,r),r=i/r*iCamDist+iCamHeight-iViewHeight+a,t=-t/(o+iCamDist)*iCamDist;this.div[e].style.zIndex=Math.round(1e4-o);t=(iWidth/2+t)*iScreenScale,r=(iHeight-r)*iScreenScale,n*=fFocal/(fFocal+o);this.draw(e,t,r,n,a)},e}var prevScreenCur=0,prevScreenOpacity=0,prevScreenFade=0;function clonePreviousScreen(e,t){if(prevScreenDelay){var a=oPrevFrameStates[e];a[prevScreenCur].canvas.getContext("2d").drawImage(oScreens[e],0,0);for(var n=0;n=r&&(t.countstate++,t.countdown=0,t.countstate>=i.countdowns.length&&detruit(t))},del:function(e){if(e.sprites){for(var t=0;tMath.PI&&(p=d-p),Math.abs(p)>Math.PI/2)return h=c.using[0].x,g=c.using[0].y,t.x=h,t.y=g,"bobomb"===c.using[0].type&&touche_bobomb(h,g,onlyThisItems([c.using[0]]))?void 0:(detruit(t),void(c.using[0]&&detruit(c.using[0],!0)));c.using[0].x-=2*direction(0,c.rotation),c.using[0].y-=2*direction(1,c.rotation)}t.x=h,t.y=g,a=4}else{T=Math.sqrt(T);var u=(c.x-t.x)*o/T,m=(c.y-t.y)*o/T,h=t.x+u,g=t.y+m;75=y.length&&(t.aipoint=0)));else if(!t.z){if(r&&(0<=t.aipoint||0<=t.target)&&!(50=u.length&&(e.aipoint=0))),-1==e.aipoint)if(0=e[4].length&&(e[5]-=2,e[6]=-1))}}},fire3star:{unbreaking:!0,transparent:!0,hidden:!0,preinit:function(e){oMap.decor.fireballs||(oMap.decor.fireballs=new Array),this.linkedSprite={type:"fireballs",start:oMap.decor.fireballs.length};for(var t=0;tr*r&&(e[5]=-1)}for(a=0;a=r.length&&(e[6]=0)):(a+=s*t/l,n+=c*t/l,t=0),0i+o?e[4]-=o:e[4]=i);for(var p=0;p=e[4].length&&(e[5]-=2,e[6]=-1);var c,p=e[4][e[5]];c=!i||0=e[4].length&&(e[5]=0),a-=l):(e[0]+=i*a/l,e[1]+=r*a/l,a=0)}var s=e[4][e[5]],c=e[4][(e[5]||e[4].length)-1],p=180*Math.atan2(s[0]-c[0],s[1]-c[1])/Math.PI;if(!isNaN(p))for(var d=0;do&&(a=o*Math.sign(a),e[5][3]=-e[5][3]),a+=Math.sqrt(2*(Math.cos(a)-Math.cos(t)))/16*e[5][3],e[4]=a;e[0]=e[5][0]+30*Math.sin(a)*Math.sin(n),e[1]=e[5][1]+30*Math.sin(a)*Math.cos(n);for(var i=-6*(1-Math.cos(a)),r=0;r=itemDistribution.value.length&&(e=itemDistribution.value.length-1,n=itemDistribution.value.length);for(var i,r=e;r'}var syncItems=[];function detruit(e,t){isOnline&&((e=getItemToDestroy(e)).deleted=1,syncItems.push(e)),supprime(e,t)}function supprime(e,t){var a=e.type,n=items[a].indexOf(e);if(-1!=n){var o=itemBehaviors[a];if(e.sprite){for(var i=0;ia[0]&&e<=a[0]+a[2]&&t>a[1]&&t<=a[1]+a[3]}function pointInPolygon(e,t,a){for(var n=!1,o=0,i=a.length-1;o=o[s]:i[s]>=o[s]+o[s+2]&&i[s]+r[s]<=o[s]+o[s+2]){var p=1-s,c=i[p]+((c?o[s]:o[s]+o[s+2])-i[s])*r[p]/r[s];if(c>=o[p]&&c<=o[p]+o[2+p])return 1}}}function pointCrossPolygon(e,t,a,n,o){for(var i=0;ih[0]-d&&lh[1]-d&&sh[0]-d&&eh[1]-d&&toMap.w-5||t>oMap.h-5||e<4||t<4)return 1}else if(e>=oMap.w||t>=oMap.h||e<0||t<0)return 1;for(var g=0,y=oMap.collision.rectangle,m=0;moMap.w-5||s>oMap.h-5||l<4||s<4)return}else if(l>=oMap.w||s>=oMap.h||l<0||s<0)return;for(m=0;moMap.w-5||f<4)&&(y.dir=[0,oMap.h]),(S>oMap.h-5||S<4)&&(y.dir=[oMap.w,0])):((f>=oMap.w||f<0)&&(y.dir=[0,oMap.h]),(S>=oMap.h||S<0)&&(y.dir=[oMap.w,0]))),oMap.decor&&!a.skipDecor)for(var n in oMap.decor)for(var o=0;oi[0]-7&&ei[1]-7&&tn.x-5&&en.y-5&&toMap.w?(e=oMap.w-.5,c=!0):e<=0&&(e=.5,c=!0),t>oMap.h?(t=oMap.h-.5,c=!0):t<=0&&(t=.5,c=!0),oMap.trous)for(var o in oMap.trous){for(var i=oMap.trous[o].rectangle,r=0;r"+t.title+": "+t.value+""+(null!=t.out_of?"/"+t.out_of+"":""),t=a.getElementsByTagName("span"),oChallengeCpts.appendChild(a),clHud[e]={$cpt:a,$label:t[0],$value:t[1],$outOf:t[2]})}function updateChallengeHud(e,t){clHud[e]&&(clHud[e].$value.innerText=t)}var challengeRules={finish_circuit:{verify:"end_game",is_tt_compatible:!0,reset_on_fail:!0,success:lambdaReturnsTrue},finish_circuit_first:{verify:"end_game",is_tt_compatible:!0,reset_on_fail:!0,success:function(e){return"CM"!=course&&1==oPlayers[0].place}},finish_circuit_time:{verify:"end_game",is_tt_compatible:!0,reset_on_fail:!0,success:function(e){return getActualGameTime()<=e.value}},finish_arena:{verify:"end_game",reset_on_fail:!0,success:lambdaReturnsTrue},finish_arena_first:{verify:"end_game",reset_on_fail:!0,success:function(e){return 1==oPlayers[0].place}},hit:{verify:"each_hit",initLocalVars:function(e){clLocalVars.myItems=[],clLocalVars.nbHits=0},initSelected:function(e){addChallengeHud("hits",{title:toLanguage("Hits","Touchés"),value:clLocalVars.nbHits,out_of:e.value})},success:function(e){if(clLocalVars.nbHits>=e.value)return!0}},eliminate:{verify:"each_kill",initLocalVars:function(e){clLocalVars.myItems=[],clLocalVars.killed=[],clLocalVars.nbKills=0,clLocalVars.nbHits=0},initSelected:function(e){addChallengeHud("kills",{title:toLanguage("Defeated","Eliminés"),value:clLocalVars.nbKills,out_of:e.value})},success:function(e){if(clLocalVars.nbKills>=e.value)return!0}},survive:{verify:"each_frame",success:function(e){if(getActualGameTime()>=e.value)return!0}},reach_zone:{verify:"each_frame",initLocalVars:function(e){e.zones||(e.zones=classifyByShape(e.value))},success:function(e){for(var e=e.zones,t=oPlayers[0].x,a=oPlayers[0].y,n=e.rectangle,o=0;o=o.length)return!0}}}},hit_items:{verify:"each_item",initLocalVars:function(e){clLocalVars.nbItems=0,clLocalVars.itemsHit=[],setTimeout(function(){clLocalVars.itemsHit.length=oMap.arme.length})},initSelected:function(e){setTimeout(function(){addChallengeHud("items",{title:toLanguage("Items","Objets"),value:clLocalVars.nbItems,out_of:oMap.arme.length})})},success:function(e){if(clLocalVars.nbItems>=oMap.arme.length)return!0}},collect_coins:{verify:"each_coin",initLocalVars:function(e){clLocalVars.nbCoins=0,e.nb||(e.nb=e.value.length)},initSelected:function(e){if(!oMap.coins){oMap.coins=[];for(var t=0;t=e.nb)return!0}},destroy_decors:{verify:"each_decor_hit",initLocalVars:function(t){var e;clLocalVars.nbDecorHits||(clLocalVars.nbDecorHits={}),clLocalVars.nbDecorHits[t.value]=0,t.nb||(e=oMap.decor[t.value]||[],t.nb=e.length,t.shouldInitToAll=!0),t.shouldInitToAll&&setTimeout(function(){var e=oMap.decor[t.value]||[];t.nb=e.length})},initSelected:function(e){setTimeout(function(){addChallengeHud("decors",{title:toLanguage("Destroyed","Détruit"),value:0,out_of:e.nb})})},success:function(e){if(clLocalVars.nbDecorHits[e.value]>=e.nb)return!0}},gold_cup:{verify:"end_gp",initRuleVars:function(){return{nbcircuits:0}},success:function(e,t){if(clLocalVars.endGP&&4==t.nbcircuits)return 1==oPlayers[0].place},next_circuit:function(e){e.nbcircuits++}},gold_cups:{verify:"end_gp",initRuleVars:function(e){return{challenge:e,nbcircuits:0}},success:function(e,t){if(clLocalVars.endGP&&4==t.nbcircuits)return 1==oPlayers[0].place},post_success:function(e,t){var a=(a=getSessionStorage("cl"+t.challenge.id+".gold_cups"))||"{}";if(a=JSON.parse(a),t.challenge.data.constraints.every(e=>"cc"===e.type))for(var n=0;n"cc"===e.type))for(var n=0;n=e.value?(deleteSessionStorage("cl"+t.challenge.id+".gold_cups"),!0):(setSessionStorage("cl"+t.challenge.id+".gold_cups",JSON.stringify(a)),showChallengePartialSuccess(t.challenge,{nb:Object.keys(a).length,total:e.value}),!1)},next_circuit:function(e){e.nbcircuits++}},finish_circuits_first:{verify:"end_game",initRuleVars:function(){return{nbcircuits:1}},initSelected:function(e,t){t&&t.nbcircuits&&addChallengeHud("races",{title:"BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),value:t.nbcircuits,out_of:e.value})},success:function(e,t){return 1==oPlayers[0].place&&(t.nbcircuits>=e.value||void 0)},next_circuit:function(e){e.nbcircuits++}},pts_greater:{verify:"end_game",initRuleVars:function(){return clGlobalVars.nbcircuits?{}:{nbcircuits:1,initialscore:0}},initSelected:function(e,t){t&&t.nbcircuits&&addChallengeHud("races",{title:"BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),value:t.nbcircuits,out_of:e.value})},success:function(e,t){if(t.nbcircuits==e.value&&aScores[0]>=e.pts)return!0},next_circuit:function(e){e.nbcircuits++}},pts_equals:{verify:"end_game",initRuleVars:function(){return clGlobalVars.nbcircuits?{}:{nbcircuits:1}},initSelected:function(e,t){t&&t.nbcircuits&&addChallengeHud("races",{title:"BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),value:t.nbcircuits,out_of:e.value})},success:function(e,t){if(t.nbcircuits==e.value&&aScores[0]==e.pts)return!0},next_circuit:function(e){e.nbcircuits++}},game_mode:{success:function(e){return course==["VS","CM"][e.value]}},game_mode_cup:{success:function(e){return course==["GP","VS"][e.value]}},difficulty:{success:function(e){return iDificulty==4+.5*(2-e.value)}},no_teams:{success:function(e){return!iTeamPlay}},participants:{success:function(e){return aKarts.length==e.value}},cc:{initRuleVars:function(e,t){return{relSpeed:getRelSpeedFromCc(+t.value)}},success:function(e,t){if(t)return t.relSpeed===fSelectedClass&&(null===e.mirror||!e.mirror==!bSelectedMirror)}},balloons:{success:function(e){return(!oPlayers[0].lost||clLocalVars.gagnant==oPlayers[0])&&oPlayers[0].ballons.length+oPlayers[0].reserve>=e.value}},balloons_lost:{initSelected:function(e,t){addChallengeHud("balloons",{title:toLanguage("Balloons","Ballons"),value:clLocalVars.lostBalloons,out_of:e.value})},success:function(e){return(!oPlayers[0].loose||clLocalVars.gagnant==oPlayers[0])&&clLocalVars.lostBalloons<=e.value}},balloons_inflate:{initSelected:function(e,t){addChallengeHud("inflated",{title:toLanguage("Inflated","Gonflés"),value:clLocalVars.inflatedBalloons,out_of:e.value})},success:function(e){return clLocalVars.inflatedBalloons<=e.value}},balloons_player:{initRuleVars:function(){return{}},initSelected:function(e,t){t.selected=!0,clLocalVars.isSetup=!0,oPlayers[0].reserve=e.value-oPlayers[0].ballons.length,updateBalloonHud(document.getElementById("compteur0"),oPlayers[0])},success:function(e,t){return!!t.selected}},balloons_cpu:{initRuleVars:function(){return{}},initSelected:function(e,t){t.selected=!0,clLocalVars.isSetup=!0;for(var a=oPlayers.length;a=e.value}},start_pos:{initSelected:function(e){if(clLocalVars.startPos=e.value,clLocalVars.isSetup=!0,e.no_cpu){aKarts.length=strPlayer.length;for(var t=0;t=e.value)return!0},next_circuit:function(e){e&&(e.miniTurbo+=clLocalVars.miniTurbo)}},super_turbo:{initRuleVars:function(){return{superTurbo:0}},initSelected:function(e,t){t&&addChallengeHud("superTurbo",{title:"Super Turbos",value:clLocalVars.superTurbo+t.superTurbo,out_of:e.value})},success:function(e,t){if(t&&t.superTurbo+clLocalVars.superTurbo>=e.value)return!0},next_circuit:function(e){e&&(e.superTurbo+=clLocalVars.superTurbo)}},stunts:{initRuleVars:function(){return{stunts:0}},initSelected:function(e,t){t&&addChallengeHud("stunts",{title:toLanguage("Tricks","Figures"),value:clLocalVars.stunts+t.stunts,out_of:e.value})},success:function(e,t){if(t&&t.stunts+clLocalVars.stunts>=e.value)return!0},next_circuit:function(e){e&&(e.stunts+=clLocalVars.stunts)}},position:{success:function(e){if(oPlayers[0].place==e.value)return!0}},position_lower:{success:function(e){if(oPlayers[0].place<=e.value)return!0}},with_pts:{verify:"end_game",initRuleVars:function(){return clGlobalVars.nbcircuits?{}:{firstAttempt:!0}},success:function(e,t){if(t.firstAttempt&&aScores[0]>=e.value)return!0}},different_circuits:{initRuleVars:function(){return{played_circuits:{}}},success:function(e,t){return!t.played_circuits[oMap.ref]},next_circuit:function(e){e.played_circuits[oMap.ref]=!0}}};function addCreationChallenges(e,t){t=challenges[e][t];if(t)for(var a=t.list,n=0;nstar

'+n+'

'+o+'
'+i+'
",(t=document.getElementsByClassName("challenge-popup")).length?$mkScreen.insertBefore(a,t[0]):$mkScreen.appendChild(a),r=0,function e(){r<1?(a.style.opacity=r,r+=.2,setTimeout(e,40)):a.style.opacity=1}(),focusOnChallengeClose())}function showChallengePopup(t,a){if(!document.getElementById("challenge-popup-"+t.id)){var e=a.pts,n=document.createElement("div");n.id="challenge-popup-"+t.id,n.className="challenge-popup",n.style.width=56*iScreenScale+"px",n.style.left=12*iScreenScale+"px",n.style.top=Math.round(4.5*iScreenScale)+"px",n.style.padding=Math.round(1.5*iScreenScale)+"px",n.style.paddingBottom=5*iScreenScale+"px",n.style.border="inset "+Math.round(.5*iScreenScale)+"px #7B0",n.style.fontSize=2*iScreenScale+"px",n.style.opacity=0;var o=language?"Challenge completed!":"Défi réussi !",i=t.description.main,r=(language?"You receive a reward of "+e+" pt"+(2<=e?"s":"")+".":"Vous recevez "+e+" pt"+(2<=e?"s":"")+" en récompense.")+"
",l="";a.pts_advent&&(s=(c=a.pts_advent)+"",a.pts_advent_extra&&(s+="+"+a.pts_advent_extra,c+=a.pts_advent_extra),l='
🎁 '+(language?"Advent calendar: you receive a bonus reward of "+s+" pt"+(2<=c?"s":"")+"!!":"Calendrier de l'avent : vous recevez un bonus de "+s+" pt"+(2<=c?"s":"")+" !!")+"
",e||(e=!0,r=""));var s=language?"Your challenge points go from "+a.pts_before+" to "+a.pts_after+"!":"Vos points défis passent de "+a.pts_before+" à "+a.pts_after+" !",c=language?"Close":"Fermer";if(n.innerHTML='
star

'+o+'

'+i+"
"+(e?'
'+r+l+s+"
":"")+(0<=a.rating?'
'+toLanguage("Rate this challenge:","Notez ce défi :")+'
'+toLanguage("Thanks","Merci")+"
":"")+(a.publish?'
'+toLanguage("You can now","Vous pouvez maintenant")+' '+toLanguage("publish challenge","publier le défi")+".
":"")+'",0<=a.rating){var p=n.getElementsByClassName("challenge-rating-stars");(p=p[0]).style.position="relative",p.style.marginLeft=Math.round(.4*iScreenScale)+"px",p.style.marginRight=Math.round(.4*iScreenScale)+"px",p.style.top=Math.round(.4*iScreenScale)+"px";function d(){for(var e=+this.rating,t=0;t"+e.name+"!":"Vous pouvez désormais jouer avec "+e.name+" !",(i=document.createElement("img")).src=getSpriteSrc(e.sprites),i.alt=e.name,i.className="pixelated",i.style.visibility="hidden",o=language?"Close":"Fermer",t.innerHTML='
star

'+a+'

'+n+'
",t.getElementsByClassName("challenge-popup-reward-ch")[0].appendChild(i),i.onload=function(){var e=this.parentNode,t=iScreenScale/8,a=Math.round(t*this.naturalWidth/24),t=Math.round(t*this.naturalHeight);e.style.width=a+"px",e.style.height=t+"px",this.style.width=24*a+"px",this.style.height=t+"px",this.style.visibility=""},(i=document.getElementsByClassName("challenge-popup")).length?$mkScreen.insertBefore(t,i[0]):$mkScreen.appendChild(t),r=0,function e(){r<1?(t.style.opacity=r,r+=.2,setTimeout(e,40)):t.style.opacity=1}())}function focusOnChallengeClose(){var e=document.querySelectorAll(".challenge-popup .challenge-popup-close a");e.length?e[e.length-1].focus():(e=document.getElementById("reprendre"))?e.focus():(e=document.getElementById("octn"))&&e.focus()}function showClSelectedPopup(){var t=document.createElement("div");t.style.fontSize=2*iScreenScale+"px",t.className="clselected-popup",t.style.left=27*iScreenScale+"px",t.style.top=iHeight*iScreenScale+"px",t.innerHTML='
'+toLanguage("Challenge selected :","Défi sélectionné:")+" "+(clSelected.name||clSelected.description.main)+"
",t.querySelector(".clselected-close a").onclick=function(){return document.body.removeChild(t),!1},document.body.appendChild(t);var a=1;setTimeout(function e(){0o.x-4&&eo.y-4&&to.x-4&&eo.y-4&&tn.x-4&&en.y-4&&to.x-4&&eo.y-4&&ta.x-5&&ea.y-5&&ta.x-5&&ea.y-5&&ti.x-5&&ei.y-5&&t=oMap.checkpoint.length&&(t=0);var a=oMap.checkpointCoords[t];if(!a)return 0;var n=projete(e.x,e.y,a.A[0],a.A[1],a.B[0],a.B[1]),t=a.A[0]+n*a.u[0],a=a.A[1]+n*a.u[1],a=Math.hypot(t-e.x,a-e.y);return e.tours*oMap.checkpoint.length+getCpScore(e)-a/1e4}function getRankScores(){return aKarts.map(function(e){return getRankScore(e)})}function places(e,t,a){for(var n=aKarts[e],o=!a,i=0;ioMap.tours||r.loose?onlineSpectatorId&&!finishing&&(document.getElementById("infoPlace"+i).style.visibility="hidden"):o=!1}if(!o){var l=1;if("BB"==course||!(n.tours>oMap.tours)&&oMap.checkpoint.length){for(var s=t[e],i=0;iaKarts[i].initialPlace)&&l++}n.loose||(n.place=l),finishing||(e=getScreenPlayerIndex(e))=oMap.checkpoint.length&&(r=0,i++);var l=oMap.checkpointCoords[r],s=l.O[0],l=l.O[1];a+=Math.hypot(s-n,l-o),n=s,o=l}return a+=Math.hypot(t.x-n,t.y-o)}function checkpoint(e,t,a){var n,o=[e.x-t,e.y-a],i=200=oMap.checkpoint.length&&(d-=oMap.checkpoint.length),d!=l;d++)if(!oMap.checkpoint[d][4]){p=!1;break}if(p)return l==n||void(e.demitours=l)}}}function getCheckpointCoords(e){var t=e[0],a=e[1],n=e[2];switch(e[3]){case 0:case 1:var o=e[3],i={A:[t,a],u:[o?n:0,o?0:n],v:[o?0:15,o?15:0],O:[t+(o?n/2:8),a+(o?8:n/2)]};break;default:var r=e[3]*Math.PI/2,l=Math.cos(r),s=Math.sin(r),c=t+7.5,p=a+7.5,o=e[2]/2-7.5,r=c+o*s,c=p+o*l,p=n*s,o=15*l,l=-n*l,s=15*s;i={A:[r-(p+o)/2,c-(l+s)/2],u:[p,l],v:[o,s],O:[r,c]}}return i.B=[i.A[0]+i.u[0],i.A[1]+i.u[1]],i.C=[i.A[0]+i.v[0],i.A[1]+i.v[1]],i.D=[i.B[0]+i.v[0],i.B[1]+i.v[1]],i}function int8ToHexString(e){return[].slice.call(e).map(function(e){return e.toString(16).padStart(2,"0")}).join("")}function hexStringToInt8(e){return new Uint8Array(e.match(/../g).map(function(e){return parseInt(e,16)})).buffer}function itemDataToHex(e,t){switch(e){case"double":return int8ToHexString(new Uint8Array(new Float64Array([t]).buffer,0,8));case"float":return int8ToHexString(new Uint8Array(new Float32Array([t]).buffer,0,4));case"int":return int8ToHexString(new Uint8Array(new Int32Array([t]).buffer,0,4));case"short":return int8ToHexString(new Uint8Array(new Int16Array([t]).buffer,0,2));case"byte":return int8ToHexString(new Uint8Array(new Int8Array([t]).buffer,0,1))}}function hexToItemData(e,t){switch(e){case"double":return new Float64Array(hexStringToInt8(t))[0];case"float":return new Float32Array(hexStringToInt8(t))[0];case"int":return new Int32Array(hexStringToInt8(t))[0];case"short":return new Int16Array(hexStringToInt8(t))[0];case"byte":return new Int8Array(hexStringToInt8(t))[0]}}function itemDataLength(e){switch(e){case"double":return 16;case"float":case"int":return 8;case"short":return 4;case"byte":return 2}}function resetDatas(){var e=oPlayers[0],Q="BB"!=course?["x","y","z","speed","speedinc","heightinc","rotation","rotincdir","rotinc","drift","driftinc","driftcpt","size","tourne","tombe","arme","stash","tours","demitours","champi","etoile","megachampi","billball","place"]:["x","y","z","speed","speedinc","heightinc","rotation","rotincdir","rotinc","drift","driftinc","driftcpt","size","tourne","tombe","arme","stash","ballons","reserve","champi","etoile","megachampi"],t="BB"!=course?["finaltime"]:[],Z=Q.concat("aipoint"),a={player:[],extra:{},item:[],lastcon:connecte},n=[{params:a.player,mapping:Q,kart:e}];if(onlineSpectatorId)delete a.player;else{for(var o=0;oI;){var T=L.ballons.length-1;L.ballons[T][0].suppr(),L.ballons.pop()}}break;default:L[x[P]]=I}}if(25<=L.billball&&!f?(L.sprite[0].img.src="images/sprites/sprite_billball.png",resetSpriteHeight(L.sprite[0]),L.aipoint=void 0):50<=L.etoile&&!y?L.sprite[0].img.src=getStarSrc(L.personnage):(y&&!L.etoile||f&&!L.billball)&&(L.sprite[0].img.src=getSpriteSrc(L.personnage),resumeSpriteSize(L.sprite[0])),C&&C.startsWith("champi")&&(C!==L.arme||"champior"===C)&&L.champi>b?L.champiType=CHAMPI_TYPE_ITEM:L.champi||delete L.champiType,L.aipoint>=L.aipoints.length&&(L.aipoint=0),M!==L.tours&&(p=getScreenPlayerIndex(s))=fTurboDriftCpt&&L.driftSprite[0].setState(1),v=fTurboDriftCpt2&&L.driftSprite[0].setState(2)),!L.turnSound&&L.tourne&&(L.turnSound=playDistSound(L,"musics/events/spin.mp3","BB"==course?80:50),L.frminv||(L.frminv=10)),L.turnSound&&!L.tourne&&(L.turnSound=void 0);for(P=r[0][1];P'+a[1]+'
'+timeStr(a[5])+"":u[t][0].innerHTML=a[1],u[t][0].id="j"+t,u[t][1]=document.createElement("td"),u[t][1].innerHTML=a[2];var o=document.createElement("small");if(o.innerHTML=(a[3]<0?"":"+")+a[3],n.appendChild(r),n.appendChild(u[t][0]),u[t][1].appendChild(o),n.appendChild(u[t][1]),iTeamPlay){n.style.textShadow="-1px 0 #603, 0 1px #603, 1px 0 #603, 0 -1px #603";for(var i=0;i=n&&(n=h[3][i][2],o=i);var r=h[3][e];h[3][e]=h[3][o],h[3][o]=r}for(e=0;ei&&(a.speed=i),a.speed<-i/4&&(a.speed=-i/4);var r=kartInstantSpeed(a),l=r[0],s=r[1],c=a.x+l,p=a.y+s,d=a.x,u=a.y;a.z||a.heightinc?handleHeightInc(a)&&(delete a.jumped,a.driftinc&&carDrift&&!a.driftSound&&kartIsPlayer(a)&&(carDrift.currentTime=0,carDrift.play(),a.driftSound=carDrift)):(clLocalVars.autoAccelerate&&!a.cpu&&a.accelerate(),a.speed+=a.speedinc,(isCup&&22!=oMap.skin&&30!=oMap.skin||!isCup&&oMap.smartjump)&&a.cpu&&(tombe(c,p)&&!sauts(d,u,l,s)||(q=ralenti(c,p))&&(J=getOffroadProps(a,q))&&a.speed-1.01*a.speedinc>J.speed&&!a.protect&&!a.champi)&&(a.z=1,a.heightinc=.5,a.jumped=!0));i=!(isOnline&&e&&a.controller!=identifiant||onlineSpectatorId);if(i&&!a.loose){var m=a.using;if(a.tourne){m=[];for(n=0;na.speedinc&&(a.speed=Math.min(.75*a.speed,a.speed+.5-a.speedinc)),collisionDecor||(3=fTurboDriftCpt+5)&&(a.driftcpt-=5),a.cpu||(clLocalVars.touchedWalls=!0));for(n=5;0Y&&(loseBall(e),stopDrifting(e),a.spin(Z),a.frminv=24,a.speed=2.5*Math.sign(a.speed),loseUsingItems(a)))),collisionFloor&&(W=collisionFloor.z),a.speedinc||(a.speed*=a.sliding?.95:.9),a.cannon||handleCannon(a,inCannon(d,u,a.x,a.y))&&(stopDrifting(e),a.protect=!0,a.jumped=!0,a.tourne&&(a.tourne=2),delete a.shift,a.cpu||(clLocalVars.cannons++,clSelected&&clRuleVars[clSelected.id]&&(ee=clRuleVars[clSelected.id].max_cannons)&&updateChallengeHud("cannons",clLocalVars.cannons+ee.cannons)),a.boostSound||(a.boostSound=playIfShould(a,"musics/events/boost.mp3"),a.boostSound&&(a.boostSound.onended=function(){a.boostSound=void 0,document.body.removeChild(this)}))),!a.teleport&&i){var Z=inTeleport(a.x,a.y);if(Z){a.aX=a.x,a.aY=a.y,a.aRotation=a.rotation,a.x=Z[0],a.y=Z[1],a.rotation=90*Z[2],a.teleport=5,h=!0,playIfShould(a,"musics/events/teleport.mp3"),a.speed<0&&(a.speed=0);for(n=0;n=a.aipoints.length&&(a.aipoint=0)))}}if(a.sliding=void 0,!a.z){if(a.heightinc||(a.ctrled=!1,a.fell=!1,W?a.z0=W:a.z0&&delete a.z0),a.figuring&&(a.turbodrift=15,a.turbodrift0=a.turbodrift,a.driftcpt=0),handleJump(a,sauts(d,u,l,s)))a.speed=11*cappedRelSpeed(a),a.figuring=!1,a.figstate=0,a.cpu||(clLocalVars.jumps++,clSelected&&clRuleVars[clSelected.id]&&(ee=clRuleVars[clSelected.id].max_jumps)&&updateChallengeHud("jumps",clLocalVars.jumps+ee.jumps)),a.bounceSound||(a.bounceSound=playIfShould(a,"musics/events/jump.mp3"),a.bounceSound&&(a.bounceSound.onended=function(){a.bounceSound=void 0,document.body.removeChild(this)}));else{if(i&&(G=tombe(a.x,a.y,oMap.checkpoint&&a.demitours?oMap.checkpoint[a.demitours+1!=oMap.checkpoint.length?a.demitours+1:0][3]:0)),G){1==G?isBattle&&simplified?(G=[a.x,a.y,a.rotation],a.x>oMap.w-1?(G[0]=oMap.w-50,a.y>oMap.h-1?(G[1]=oMap.h-50,G[2]=225):a.y<0?(G[1]=50,G[2]=315):(G[1]=a.y-a.y%100+50,G[2]=270)):a.y>oMap.h-1?(G[1]=oMap.h-50,a.x<0?(G[0]=50,G[2]=135):(G[0]=a.x-a.x%100+50,G[2]=180)):a.x<0?(G[0]=50,a.y<0?(G[1]=50,G[2]=45):(G[1]=a.y-a.y%100+50,G[2]=90)):(G[1]=50,G[0]=a.x-a.x%100+50,G[2]=0)):G=oMap.startposition[0]:isNaN(G[0])&&(G=oMap.startposition[(a.initialPlace-1)%oMap.startposition.length]),a.aX=a.x,a.aY=a.y,a.aRotation=a.rotation,a.x=G[0],a.y=G[1],a.rotation=90*G[2],a.speed=0,a.protect=!1,a.figuring=!1,a.figstate=0,a.fell=!0,a.champi=0,delete a.champiType,delete a.champior,delete a.champior0,a.cpu&&(a.aipoint=void 0),a.tombe=20,a.frminv=10,a.ctrled=!0,a.z=10,a.tourne=0,stopDrifting(e),supprArme(e),deleteUsingItems(a);for(var ee,te=getScreenPlayerIndex(n),n=0;n.8*a.turbodrift0||!(q=ralenti(c,p))||((J=getOffroadProps(a,q)).speed*=cappedRelSpeed(),J.sliding&&(a.sliding=J.sliding),a.speed>J.speed&&(a.speed=J.speed),stopDrifting(e)),a.tourne||(K=flowShift(c,p,a.protect)),K&&a.cpu&&100<=K[0]*K[0]+K[1]*K[1]&&(l+K[0])*l+(s+K[1])*s<0&&(a.collided=!0,a.horizontality=[K[1],-K[0]]);a.figuring=!1,a.figstate=0}if(K){a.shift||(a.shift=[0,0,0]);for(n=0;n<3;n++)a.shift[n]=.7*a.shift[n]+.3*K[n];a.shift[0]*a.shift[0]+a.shift[1]*a.shift[1]+300*a.shift[2]*a.shift[2]<.01&&delete a.shift}else delete a.shift}if(a.cpu||h||updateSpeedometer(e,d,u),moveUsingItems(a,t),"BB"!=course){if(checkpoint(a,l,s)){var ne=aKarts.length;a.demitours=getNextCp(a),a.tours++;p=oMap.checkpointCoords[0];oMap.sections&&(p=oMap.checkpointCoords[oMap.checkpointCoords.length-1]);h=1,t=intersectionLineLine(d,u,d+l,u+s,p.A[0],p.A[1],p.B[0],p.B[1]);0<=t[0]&&t[0]oMap.tours&&a.place++;if(isOnline&&!a.finaltime&&(a.finaltime=timeTrialMode()?p:(new Date).getTime()-tnCourse),kartIsPlayer(a)&&!finishing){for(showTimer(timerMS=p),"CM"!=course&&(document.getElementById("infoPlace"+e).innerHTML=a.place);a.using.length;){var ie=bMusic,re=iSfx;iSfx=bMusic=!1,arme(e),bMusic=ie,iSfx=re}if(a.arme=!1,stopDrifting(e),supprArme(e),resetWrongWay(a),a.billball&&(a.billball=1),a.cpu=!0,$speedometers[e]&&($speedometers[e].style.display="none"),a.aipoint=0,a.lastAItime=0,a.maxspeed=5.7,a.maxspeed0=a.maxspeed,!oPlayers[1-e]||oPlayers[1-e].cpu){if(isOnline){var le=document.getElementById("infos0");le.style.left=15*iScreenScale+"px",le.innerHTML="";t=document.createElement("tr"),h=document.createElement("td");h.style.fontSize=8*iScreenScale+"px",h.style.color="#F80",h.innerHTML=toLanguage("    FINISH !","TERMINÉ !"),t.appendChild(h);p=document.createElement("tr"),h=document.createElement("td");h.style.fontSize=Math.round(4.5*iScreenScale+10)+"px",h.style.color="#FF0",h.innerHTML=toLanguage("      Please wait...","Veuillez patienter..."),p.appendChild(h),le.appendChild(t),le.appendChild(p),le.style.display="",document.getElementById("infoPlace0").style.visibility="hidden",finishing=!0}else{if("CM"!=course){for(var se=getRankScores(),n=0;nPlaces'+toLanguage("Player","Joueur")+"Pts",de=(Math.round(1.25*aKarts.length),""),ue="";iTeamPlay&&(de="; text-shadow: -1px 0 #603, 0 1px #603, 1px 0 #603, 0 -1px #603",ue=' style="padding: 0 '+Math.round(iScreenScale/2)+'px"');for(var me=getPointDistribution(),n=0;n'+toPlace(n+1)+' "+toPerso(he)+'"+aScores[o]+"+"+Le+"",aScores[o]+=Le,o=ne)}pe+='',document.getElementById("infos0").style.border="solid 1px black",document.getElementById("infos0").style.opacity=.7,document.getElementById("infos0").style.fontSize=Math.round(1.77*iScreenScale-.5)+"pt",document.getElementById("infos0").style.fontFamily="Courier",document.getElementById("infos0").style.top=3*iScreenScale+"px",document.getElementById("infos0").style.left=Math.round(24*iScreenScale+10+(strPlayer.length-1)/2*(iWidth*iScreenScale+2))+"px",document.getElementById("infos0").style.backgroundColor=iTeamPlay?"blue":"#063",document.getElementById("infos0").style.color=primaryColor,document.getElementById("infos0").innerHTML=pe,handleRankingStyle(),(Re=document.createElement("input")).type="button",Re.id="octn",Re.value=toLanguage("CONTINUE","CONTINUER"),Re.style.width="100%",Re.style.height="100%",Re.style.fontSize=3*iScreenScale+"pt",Re.onclick=classement,document.getElementById("continuer").appendChild(Re),document.getElementById("infos0").style.display="";var ge=document.body.scrollTop;Re.focus(),document.body.scrollTop=ge}else{document.getElementById("infos0").style.fontSize=5*iScreenScale+"px",document.getElementById("infos0").style.fontWeight="bold",document.getElementById("infos0").style.color="white";var ye=Math.ceil(iScreenScale/4)+"px";sShadow="-"+ye+" 0 "+(Me="black")+", 0 "+ye+" "+Me+", "+ye+" 0 "+Me+", 0 -"+ye+" "+Me;for(var fe="",Se=lapTimers[0],n=1;n'+(n+1)+". "+timeStr(lapTimers[n])+""}document.getElementById("infos0").style.top=7*iScreenScale+10+"px",document.getElementById("infos0").innerHTML=''+document.getElementById("temps0").innerHTML+''+fe+"",document.getElementById("infos0").style.display="",(Re=document.createElement("input")).type="button",Re.id="octn",Re.value=toLanguage("CONTINUE","CONTINUER"),Re.style.width="100%",Re.style.height="100%",Re.style.fontSize=3*iScreenScale+"pt",Re.onclick=function(){document.getElementById("infos0").style.display="none";var e=document.createElement("div");e.style.color="black",e.style.position="absolute",e.style.left=5*iScreenScale+10+"px",e.style.top=5*iScreenScale+10+"px",e.style.fontSize=4*iScreenScale+"pt",e.style.backgroundColor="#FF6",e.style.opacity=.8,e.style.border="double 4px black",e.style.textAlign="center",e.style.width=70*iScreenScale-10+"px",e.style.height=25*iScreenScale-10+"px",e.style.zIndex=2e4;var t=document.createElement("p");t.innerHTML=toLanguage('Save the time to the record list ?','Enregistrer le temps dans la liste des records ?'),t.style.margin=iScreenScale+"px";var a=t.cloneNode(!1),n=document.createElement("input");n.type="button",n.value=" "+toLanguage("Yes","Oui")+" ",n.style.marginRight=iScreenScale+"px",n.style.fontSize=4*iScreenScale+"px",n.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",o.style.fontSize=4*iScreenScale+"px"},n.onclick=function(){$mkScreen.removeChild(e),continuer(),document.getElementById("enregistrer").getElementsByTagName("input")[0].onclick()},a.appendChild(n);var o=document.createElement("input");o.type="button",o.value=" "+toLanguage("No","Non")+" ",o.style.fontSize=4*iScreenScale+"px",o.style.marginLeft=iScreenScale+"px",o.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",n.style.fontSize=4*iScreenScale+"px"},o.onclick=function(){$mkScreen.removeChild(e),document.getElementById("infos0").style.display="",continuer()},a.appendChild(o),e.appendChild(t),e.appendChild(a),$mkScreen.appendChild(e),(gRecord<=timerMS?o:n).focus()},document.getElementById("continuer").appendChild(Re),document.getElementById("infos0").style.display="",Re.focus()}handleEndRace()}resetEvents(),window.onbeforeunload=logGameTime}}else onlineSpectatorId&&!finishing&&te "+a.tours,a.time=40,bMusic||iSfx)if(a.tours==oMap.tours){for(var be,Ce=!0,n=0;nPlaces'+toLanguage("Player","Joueur")+"Pts",Ie="",Te=1,de="",ue="";iTeamPlay&&(de="; text-shadow: -1px 0 #603, 0 1px #603, 1px 0 #603, 0 -1px #603",ue=' style="padding: 0 '+Math.round(iScreenScale/2)+'px"');for(var we,n=0;n'+toPlace(Ee+1)+' "+toPerso(he)+'"+aScores[n]+(Le?"+1":"")+"";Le?Ie=Ee+Ie:(Ie+=Ee,Te++),aScores[n]+=Le}pe+=Ie,pe+='',document.getElementById("infos0").style.border="solid 1px black",document.getElementById("infos0").style.opacity=.7,document.getElementById("infos0").style.fontSize=Math.round(1.77*iScreenScale-.5)+"pt",document.getElementById("infos0").style.fontFamily="Courier",document.getElementById("infos0").style.top=3*iScreenScale+"px",document.getElementById("infos0").style.left=Math.round(24*iScreenScale+10+(strPlayer.length-1)/2*(iWidth*iScreenScale+2))+"px",document.getElementById("infos0").style.backgroundColor=iTeamPlay?"blue":"#063",document.getElementById("infos0").style.color=primaryColor,document.getElementById("infos0").innerHTML=pe,handleRankingStyle(),(Re=document.createElement("input")).type="button",Re.id="octn",Re.value=toLanguage("CONTINUE","CONTINUER"),Re.style.width="100%",Re.style.height="100%",Re.style.fontSize=3*iScreenScale+"pt",Re.onclick=classement,document.getElementById("continuer").appendChild(Re),document.getElementById("infos0").style.display="";ge=document.body.scrollTop;for(Re.focus(),document.body.scrollTop=ge,n=0;nRe*Ae?a.maxspeed0=Re*Ae:a.maxspeed0-qe&&(a.maxspeed=qe,a.speed=Math.max(qe*cappedRelSpeed(a),a.speed)),a.turbodrift--),a.champi&&(a.maxspeed=11,a.champi--,a.champi||delete a.champiType),a.billball){if(a.z=2,a.heightinc=0,a.speed=Math.min(30,13*cappedRelSpeed()),null!=a.aipoint)(Ge=a.aipoints[a.aipoint])?(U=Ge[0]-a.x)*U+(_e=Ge[1]-a.y)*_e<2e3&&(inTeleport(Ge[0],Ge[1])||(a.aipoint++,a.aipoint>=a.aipoints.length&&(a.aipoint=0))):_e=U=0;else{var Ne=a.demitours+1;Ne>=oMap.checkpoint.length&&(Ne=0);var _e=(Fe=oMap.checkpointCoords[Ne])?(U=Fe.O[0]-a.x,Fe.O[1]-a.y):U=0;e:for(n=0;nFe[0]-35&&a.xFe[1]-35&&a.y=fTurboDriftCpt2){for(var a=0;a=fTurboDriftCpt){for(a=0;a':""}var s=document.getElementById("scroller"+e),c=document.getElementById("objet"+e);t.stash?(document.getElementById("reserve"+e).style.visibility="visible",c.style.left=Math.round(3*iScreenScale)+"px",c.style.top=Math.round(3*iScreenScale)+"px",s.style.left=Math.round(3*iScreenScale)+"px",s.style.top=Math.round(3*iScreenScale+ +iScreenScale)+"px"):(document.getElementById("reserve"+e).style.visibility="hidden",c.style.left=Math.round(iScreenScale)+"px",c.style.top=Math.round(iScreenScale)+"px",s.style.left=iScreenScale+"px",s.style.top=Math.round(iScreenScale+ +iScreenScale)+"px")}function updateItemCountdownHud(e,t){var a,n,o,i,r,l=document.getElementById("countdown"+e);l&&(0i-Math.PI+o&&t.push([a,n]),r>i-Math.PI-o&&t.push([a,0]),l.style.clipPath="polygon("+t.map(function(e){return e[0]+"px "+e[1]+"px"}).join(", ")):(l.style.display="none",l.style.clipPath=""))}function updateLapHud(e){for(var t=getPlayerAtScreen(e),a=document.querySelectorAll("#compteur"+e+" .tour"),n=0;n=e.aipoints.length){if(oMap.sections||e.tours>=oMap.tours)return 1/0;o=0}var i=e.aipoints[o];if(n+=Math.hypot(i[0]-a[0],i[1]-a[1]),t=o,a=e.aipoints[t],t==e.aipoint)return 1/0}}function hasShortcutItem(e,t){return!e.using.length&&(25==e.roulette&&isShortcutItem(e.arme,t))}function isShortcutItem(e,t){return isShortcutItemKey(e,t)}function isShortcutItemKey(e,t){return!!e&&(!t||t[2].itemsDict[e])}function hasExtraShortcutItem(e,t){if(25==e.roulette2&&isShortcutItem(e.stash,t))return 1;if(isShortcutItemKey("champi",t))switch(e.arme){case"champiX2":case"champiX3":return 1;case"champior":if(e.champior)return 1}}var fMaxRotInCp=10,nextBlueShellCooldown;function ai(u){var e=isBattle&&simplified,t=isBattle&&complete,a=!isBattle&&complete;if(null==u.aipoint)if(delete u.aishortcut,"BB"!=course)for(var n=1/0,o=0;ooMap.tours||u.ballons&&!u.ballons.length&&!u.loose)return u.speedinc=0,u.rotinc=0,void(u.rotincdir=0);if(u.tourne)return u.speedinc=!u.z&&1=u.aipoints.length&&(g=0),m=u.aipoints[g])):((L=y-1)<0&&(L+=u.aipoints.length),(g=y+1)>=u.aipoints.length&&(g=0),h=u.aipoints[L],d=u.aipoints[y],m=u.aipoints[g]);else if(e){h=[u.lastAI%6*100+50,100*Math.floor(u.lastAI/6)+50],d=[u.aipoint%6*100+50,100*Math.floor(u.aipoint/6)+50],m=[h[0]+2*(d[0]-h[0]),h[1]+2*(d[1]-h[1])];var f=Math.floor(u.x/100)+6*Math.floor(u.y/100);if(f!=u.lastAI){var S=!0;if(0<=u.speed&&!u.tombe){var v=(d[0]-u.x)*(d[0]-u.x)+(d[1]-u.y)*(d[1]-u.y);switch(oMap.skin){case 27:S=v<1500;break;case 48:S=v<900}}if(S){(P=u.aipoints[f])&&P.length||(P=[],f%6&&P.push(f-1),f%6<5&&P.push(f+1),6<=f&&P.push(f-6),f<30&&P.push(f+6),-1!=(E=P.indexOf(u.lastAI))&&P.splice(E,1));var b=u.lastAI;for(u.lastAI=f;u.aipoint=P[Math.floor(Math.random()*P.length)],b==u.aipoint&&1N&&(u.randShift=N*Math.sign(u.randShift))));var D,B,f=projete(u.x,u.y,h[0],h[1],d[0],d[1]),w=h[0]+f*(d[0]-h[0]),L=h[1]+f*(d[1]-h[1]),H=Math.hypot(u.x-w,u.y-L);if(k||I||(H=0,u.nextAiStop=0,f=1),!(f>=u.nextAiStop&&Hu.recovertime&&(u.randShift=Math.random()*u.recovertime/2-u.recovertime/4,u.recovertime+=30,u.decision=-u.decision,u.collidesince=1,e&&(u.lastAI=u.aipoint)):(u.collidesince=1,u.decision||(z=direction(0,u.rotation),O=direction(1,u.rotation),R=u.horizontality[0],A=u.horizontality[1],u.decision=0=10*me&&(se+=.15*(se-u.rotation)*me)),isNaN(se)&&(se=u.rotation)),_=nearestAngle(180*_/Math.PI,se,360),isNaN(_)&&(_=se),isNaN(V)&&(V=d[0]),isNaN(F)&&(F=d[1]);var pe=_-se;u.rotinc=Math.max(Math.min(pe,fMaxRotInCp),-fMaxRotInCp);var de=Math.abs(pe),s=de;isBattle&&(de*=Math.pow(de/10,1.5)),l=Math.hypot(V-u.x,F-u.y);var ue,me=Math.atan2(V-h[0],F-h[1])-u.rotation,se=(Math.abs(Math.sin(me))+de*Math.PI/180/2)/y,c=l/se;"BB"!=course||(me=Math.max(5,se/1.57))250+50*Math.random()&&!e&&(u.aipoint=void 0);break}"BB"!=course?inTeleport(d[0],d[1])||(null!=u.aishortcut&&u.aishortcuts[u.aipoint]?(B=(D=u.aishortcuts[u.aipoint])[0],u.aishortcut=u.aipoints.length&&(u.aipoint=0))):(u.lastAI=u.aipoint,delete u.lastAIpt,-1!=u.nextAI?u.aipoint=u.nextAI:u.aipoint=void 0,u.nextAI=void 0),u.nextAiStop=void 0,u.randShift=void 0,u.lastAItime=0}if((25==u.roulette||u.using[0])&&!u.tourne&&!u.cannon){var he=!1;function ge(e,t,a,n,o){for(var i=e*e,r=t*t,l=(isOnline?aKarts:strPlayer).length,s=0;soPlayers[0].place)||"BB"==course)&&.5=d*c[2][3]&&(c[2][2]=d,1==p?(c[3][0]=2,c[2][3]=-c[2][3]):(c[3][0]=0,c[2][3]=0,c[3][1]=1+Math.floor(50*Math.random())))}p&&c[0].redraw(c)}if(oMap.bumpers)for(a=0;a=l&&(v.theta-=l)}}var previouslyPressedBtns=[],cycleHandler;function handleGamepadEvents(){if(gameControls.gamepad)for(var e=0;emapMusic.opts.end:0===mapMusic.yt.getPlayerState()&&e>mapMusic.yt.getDuration()-1)||(t=mapMusic.opts.start||0)=aKarts.length&&(oSpecCam.playerId=0);break;case"quit":return document.location.reload(),!1;default:return!0}oSpecCam.reset();var t,a=getPlayerAtScreen(0);return(isBattle?!a.loose:a.tours<=oMap.tours)&&((t=document.getElementById("infoPlace0")).style.visibility="",t.innerHTML=a.place,-1!=a.team&&(t.style.color=cTeamColors.light[a.team])),isBattle?updateBalloonHud(document.getElementById("compteur0"),a):updateLapHud(0),!1}function releaseOverEvents(){for(var e=document.querySelectorAll(":hover"),t=0;tThe principle is simple: a private link is generated, you send this link to the concerned members, and you can start playing.":"L'option "partie privée" vous permet de jouer uniquement avec les personnes de votre choix.
Le principe est simple : un lien privé est généré, vous envoyez ce lien aux membres concernés, et vous pouvez commencer à jouer.",e.appendChild(a);a=document.createElement("input");a.type="button",a.value=toLanguage("Generate private link","Générer un lien privé"),a.style.fontSize=3*iScreenScale+"px",a.style.position="absolute",a.style.width=35*iScreenScale+"px",a.style.left=23*iScreenScale+"px",a.style.top=28*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),privateLink(t)},e.appendChild(a),(a=document.createElement("input")).type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),shareLink.options=null,selectPlayerScreen(0)},e.appendChild(a),(a=document.createElement("input")).type="button",a.value=toLanguage("Private game options...","Options de la partie privée..."),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=52*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),privateGameOptions(shareLink.options,function(e){e&&(shareLink.options=e,t=e),privateGame(t)})},e.appendChild(a),oContainers[0].appendChild(e)}function privateGameOptions(e,M){var x=document.createElement("div"),t=x.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black",(g=toTitle(isOnline?toLanguage("Private game options","Options partie privée"):toLanguage("Online game options","Options mode en ligne"),0)).style.fontSize=7*iScreenScale+"px",x.appendChild(g);var a=document.createElement("form");a.style.position="absolute",a.style.left="0px",a.style.top=8*iScreenScale+"px",a.style.width=iWidth*iScreenScale+"px",a.onsubmit=function(e){e.preventDefault();var t=this.elements["option-teams"].checked?1:0,a=this.elements["option-manualTeams"].checked?1:0,n=this.elements["option-friendlyFire"].checked?1:0,o=+this.elements["option-nbTeams"].value,i=JSON.parse(this.elements["option-teamOpts"].value),r=this.elements["option-friendly"].checked?1:0,l=+this.elements["option-localScore"].checked?1:0;r||(l=0);var s=+this.elements["option-minPlayers"].value,c=+this.elements["option-maxPlayers"].value,p=parseInt(this.elements["option-cc"].value),d=this.elements["option-cc"].value.endsWith("m"),u=JSON.parse(this.elements["option-itemDistrib"].value),m=JSON.parse(this.elements["option-ptDistrib"].value),h=this.elements["option-cpu"].checked?1:0,g=+this.elements["option-cpuCount"].value,y=+this.elements["option-cpuLevel"].value,f=(f=this.elements["option-cpuNames"].dataset.value)&&JSON.parse(f),S=(S=this.elements["option-cpuChars"].dataset.value)&&JSON.parse(S),v=this.elements["option-timeTrial"].checked?1:0,b=this.elements["option-noBumps"].checked?1:0,C=this.elements["option-noJump"].checked?1:0,e=this.elements["option-doubleItems"].checked?0:1;t||(n=i=a=0),v&&(b=0),h||(g=defaultGameOptions.cpuCount,y=defaultGameOptions.cpuLevel,f=defaultGameOptions.cpuNames,S=defaultGameOptions.cpuChars),M({team:t,manualTeams:a,friendlyFire:n,nbTeams:o,teamOpts:i,friendly:r,localScore:l,minPlayers:s,maxPlayers:c,cc:p,mirror:d,itemDistrib:u,ptDistrib:m,cpu:h,cpuCount:g,cpuLevel:y,cpuNames:f,cpuChars:S,timeTrial:v,noBumps:b,noJump:C,doubleItems:e}),x.innerHTML="",oContainers[0].removeChild(x)};var n=document.createElement("div");n.style.height=Math.round(21*iScreenScale+18)+"px",n.style.overflow="auto";var o=document.createElement("table");o.style.marginLeft="auto",o.style.marginRight="auto";var i=document.createElement("tr");(l=document.createElement("td")).style.textAlign="center",l.style.width=8*iScreenScale+"px";var r=document.createElement("input");r.style.transform=r.style.WebkitTransform=r.style.MozTransform="scale("+Math.round(iScreenScale/3)+")",r.id="option-teams",r.name="option-teams",r.type="checkbox",e&&e.team&&(r.checked=!0),r.onchange=function(){this.checked?(document.getElementById("option-manualTeams-ctn").style.display="",isOnline&&(document.getElementById("option-nbTeams-ctn").style.display="",document.getElementById("option-friendlyFire-ctn").style.display="")):(document.getElementById("option-manualTeams-ctn").style.display="none",document.getElementById("option-nbTeams-ctn").style.display="none",document.getElementById("option-friendlyFire-ctn").style.display="none")},l.appendChild(r),i.appendChild(l);var l=document.createElement("td"),s=document.createElement("label");s.style.cursor="pointer",s.setAttribute("for","option-teams");var c=document.createElement("h1");c.style.fontSize=3*iScreenScale+"px",c.style.marginBottom="0px",c.innerHTML=toLanguage("Team games","Parties par équipe"),s.appendChild(c);var p=document.createElement("div");p.style.fontSize=2*iScreenScale+"px",p.style.color="white",p.innerHTML=toLanguage("If enabled, 2 teams are selected in each game. Your objective: defeat the opposing team.","Si activé, 2 équipes sont sélectionnées à chaque partie. Votre objectif : vaincre l'équipe adverse."),s.appendChild(p),l.appendChild(s),l.style.padding=Math.round(1.5*iScreenScale)+"px 0",i.appendChild(l),o.appendChild(i),(i=document.createElement("tr")).id="option-manualTeams-ctn",e&&e.team||(i.style.display="none"),(l=document.createElement("td")).style.textAlign="center",l.style.width=8*iScreenScale+"px",(r=document.createElement("input")).style.position="relative",r.style.left=Math.round(1.5*iScreenScale)+"px",r.style.transform=r.style.WebkitTransform=r.style.MozTransform="scale("+Math.round(iScreenScale/3)+")",r.id="option-manualTeams",r.name="option-manualTeams",r.type="checkbox",e&&e.team&&e.manualTeams&&(r.checked=!0),l.appendChild(r),i.appendChild(l);l=document.createElement("td");if((s=document.createElement("label")).style.cursor="pointer",s.style.display="inline-block",s.setAttribute("for","option-manualTeams"),(c=document.createElement("h1")).style.marginTop=0,c.style.marginLeft=Math.round(1.5*iScreenScale)+"px",c.style.fontSize=3*iScreenScale+"px",c.style.marginBottom="0px",c.innerHTML=toLanguage("Manual selection","Sélection manuelle"),s.appendChild(c),(p=document.createElement("div")).style.paddingLeft=Math.round(1.5*iScreenScale)+"px",p.style.fontSize=2*iScreenScale+"px",p.style.color="white",p.innerHTML=toLanguage("If enabled, teams are selected manually at each game.","Si activé, les équipes sont sélectionnées manuellement à chaque partie. Sinon, les équipes sont formées automatiquement en fonction du niveau de chaque joueur."),s.appendChild(p),l.appendChild(s),i.appendChild(l),!isOnline)for(var d=i.getElementsByTagName("td"),u=0;uthis.getAttribute("max")&&(e=this.getAttribute("max"),this.value=e);var t=JSON.parse(document.getElementById("option-teamOpts").value);if(t){t.length=e;for(var a=[],n=0;ni){e.insertBefore(n,s);break}if(s.value==n.value){n=s;break}}n.parentNode||e.insertBefore(n,r[r.length-1]),e.value=o}(l=document.createElement("td")).setAttribute("colspan",2),(m=document.createElement("div")).style.display="flex",m.style.flexDirection="row",m.style.alignItems="center",(h=document.createElement("div")).style.paddingLeft=3*iScreenScale+"px",h.style.paddingRight=3*iScreenScale+"px",(s=document.createElement("label")).style.cursor="pointer",s.setAttribute("for","option-cc"),(c=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",c.innerHTML=toLanguage("Class","Cylindrée"),c.style.marginTop=iScreenScale+"px",c.style.marginBottom="0px",s.appendChild(c),h.appendChild(s),m.appendChild(h),(h=document.createElement("div")).style.display="inline-block",(y=document.createElement("select")).id="option-cc",y.name="option-cc",y.style.backgroundColor="black",y.style.width=12*iScreenScale+"px",y.style.fontSize=Math.round(2.5*iScreenScale)+"px",y.style.marginTop=Math.round(1.5*iScreenScale)+"px";var v=[50,100,150,150,200],b=[!1,!1,!1,!0,!1];isOnline||(b=[!(v=[150,150,200]),!0,!1]);var C=!1,P=150;e&&e.cc&&(P=e.cc);var k=!1;e&&e.mirror&&(k=!0);for(u=0;u×

'+toLanguage("Load private game options","Charger options partie privée")+"

"+toLanguage("This menu lets you import options from a previous private game.","Ce menu vous permet d'importer des options d'une partie privée précédente.")+'
",n.querySelector(".private-link-form").onsubmit=function(e){e.preventDefault(),o(e.target.elements["private-link"].value)};var i=n.querySelector(".saved-links"),r=loadOptionLinks();function t(){for(var e=0;e',function(t){a.onclick=function(){o(t.url)},a.querySelector(".saved-link-edit").onclick=function(){var e=prompt(toLanguage("New options name:","Renommer ces options :"),t.name);e&&e!==t.name&&(t.name=e,l())},a.querySelector(".saved-link-del").onclick=function(){confirm(toLanguage('Delete options set "'+t.name+'"?',"Supprimer le jeu d'options \""+t.name+'" ?'))&&(r.splice(r.indexOf(t),1),l())},a.querySelector(".saved-link-options").onclick=function(e){e.stopPropagation()}}(t),i.appendChild(a)}r.length?shareLink.key||(n.querySelector(".saved-links-add").style.display="none"):(i.innerHTML='",shareLink.key||(n.querySelector(".saved-links-ctn").style.display="none"))}function l(){storeOptionLinks(r),i.innerHTML="",t()}t();e=n.querySelector(".close");e.style.left=(iWidth-9)*iScreenScale+5+"px",e.onclick=function(e){e.preventDefault(),x.removeChild(n)},n.querySelector(".saved-links-add a").onclick=function(e){e.preventDefault();e=prompt(toLanguage("Name for your options set:","Nom pour le jeu d'options :"));e&&(r.push({name:e,url:document.location.href}),n.querySelector(".saved-links-add").style.display="none",l())},x.appendChild(n)},x.appendChild(g),oContainers[0].appendChild(x)}function loadOptionLinks(){var e=localStorage.getItem("privgameopts");return e?JSON.parse(e):[]}function storeOptionLinks(e){e.sort(function(e,t){return e.name.localeCompare(t.name)}),localStorage.setItem("privgameopts",JSON.stringify(e))}function privateLink(e){var l=document.createElement("div"),t=l.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black",l.appendChild(toTitle(toLanguage("Private game","Partie privée"),0));var s=isCustomOptions(e);xhr("privateGame.php",s?"options="+encodeURIComponent(JSON.stringify(e)):null,function(e){if(e){var t=shareLink.url,a=shareLink.params.slice(0);a.push("key="+e);var n,o,i,r=t+"?"+a.join("&"),a=document.createElement("div");return a.style.position="absolute",a.style.left="0px",a.style.top=12*iScreenScale+"px",a.style.width=iWidth*iScreenScale+"px",a.style.textAlign="center",a.style.fontSize=3*iScreenScale+"px",a.style.color="#CFC",a.innerHTML=language?'The following private link has been generated:
'+r+"

Enjoy game :)":'Le lien privé suivant a été généré :
'+r+"

Bonne partie :)",l.appendChild(a),s&&((n=document.createElement("input")).type="button",n.style.position="absolute",n.style.right=+iScreenScale+"px",n.style.top=33*iScreenScale+"px",n.style.fontSize=Math.round(1.7*iScreenScale)+"px",n.value="☆ "+toLanguage("Save game options...","Sauvegarder options partie privée"),n.onclick=function(){var t,a,e=prompt(toLanguage("Options name:","Nom des options :"));e&&(t=loadOptionLinks(),a={name:e,url:r},t.push(a),storeOptionLinks(t),l.removeChild(n),l.appendChild(o),i.onclick=function(e){e.preventDefault(),t.splice(t.indexOf(a),1),storeOptionLinks(t),l.removeChild(o),l.appendChild(n)})},l.appendChild(n),(o=document.createElement("div")).style.color="white",o.style.position="absolute",o.style.left=+iScreenScale+"px",o.style.width=iScreenScale*(iWidth-2)+"px",o.style.top=33*iScreenScale+"px",o.style.textAlign="center",o.style.fontSize=2*iScreenScale+"px",o.innerHTML=toLanguage("Options saved, you can access them by clicking on "Load options..." in private game options screen ","Options sauvegardées, vous pourrez y accéder en cliquannt sur "Charger des options..." dans les options de partie privée "),(i=document.createElement("a")).href="#null",i.style.color="#ccf",i.style.textDecoration="none",i.innerHTML=toLanguage("[Undo]","[Annuler]"),o.appendChild(i)),!0}return!1}),oContainers[0].appendChild(l)}function selectTypeScreen(){var e=document.createElement("div"),t=e.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black";var a=new Image;if(a.src="images/mariokart.png",a.style.position="absolute",a.style.width=Math.round(42.5*iScreenScale)+"px",a.style.height=5*iScreenScale+"px",a.style.left=Math.round((iWidth-42.5)/2*iScreenScale)+"px",a.style.top=2*iScreenScale+"px",e.appendChild(a),(t=e.style).width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black",oContainers[0].appendChild(e),"MK"==page){var n=11;(r=document.createElement("input")).type="button",r.value="Grand Prix",r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=10*iScreenScale+"px",r.style.top=n*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="GP",e.innerHTML="",oContainers[0].removeChild(e),selectPlayerScreen(0)},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Time trial","Contre-la-montre"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=41*iScreenScale+"px",r.style.top=n*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="CM",e.innerHTML="",oContainers[0].removeChild(e),selectPlayerScreen(0)},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("VS","Course VS"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=iScreenScale+"px",r.style.top=(n+8)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="VS",e.innerHTML="",oContainers[0].removeChild(e),selectNbJoueurs()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Battle","Bataille"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=50*iScreenScale+"px",r.style.top=(n+8)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="BB",e.innerHTML="",oContainers[0].removeChild(e),selectNbJoueurs()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Track builder","Éditeur de circuit"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=10*iScreenScale+"px",r.style.top=(n+16)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),selectTypeCreate()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Online race","Course en ligne"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=41*iScreenScale+"px",r.style.top=(n+16)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="VS",e.innerHTML="",oContainers[0].removeChild(e),selectOnlineScreen()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Home","Accueil"),r.style.fontSize=2*iScreenScale+"px",r.style.position="absolute",r.style.left=2*iScreenScale+"px",r.style.top=35*iScreenScale+2+"px",r.onclick=function(){document.location.href="index.php"},e.appendChild(r)}else{var o,r,n=12,l=[toLanguage("VS","Course VS")],s=["VS"];for(isSingle||(l.unshift("Grand Prix"),s.unshift("GP")),(hasChallenges()||myCircuit)&&(l.push(toLanguage("Challenges","Défis")),s.push("CH")),!nid&&isSingle||(l.push(toLanguage("Time Trial","Contre-la-montre")),s.push("CM")),!nid||isSingle&&complete&&!cShared||(l.push(toLanguage("Online race","Course en ligne")),s.push("CL")),!isSingle&&cupScore&&((p=new Image).src="images/cups/cup"+(4-cupScore)+".png",p.style.width=Math.round(4*iScreenScale)+"px",p.style.height=Math.round(4*iScreenScale)+"px",p.style.position="absolute",l.length<5?(p.style.left=3*iScreenScale+"px",p.style.top=Math.round((n+4)*iScreenScale)+"px"):(p.style.left=5*iScreenScale+"px",p.style.top=Math.round((n-1)*iScreenScale)+"px"),p.className="pixelated",e.appendChild(p)),i=0;i

'+o.name+'

'+o.description+"
",i.style.display="flex",i.style.direction="column",i.style.alignItems="center",i.style.width="100%",i.style.fontSize=Math.round(1.9*iScreenScale)+"px",i.style.margin=Math.round(1.5*iScreenScale)+"px 0",i.className="fakebtn",i.onclick=function(){t.innerHTML="",oContainers[0].removeChild(t),selectTrackCreate(e)},n.appendChild(i)}t.appendChild(n);e=document.createElement("a");e.style.color="#CCF",e.style.fontSize=Math.round(2.5*iScreenScale)+"px",e.style.position="absolute",e.style.left=toLanguage(30,29)*iScreenScale+"px",e.style.top=35*iScreenScale+"px",e.href="creations.php",e.onclick=function(){},e.innerHTML=toLanguage("List of creations","Liste des créations"),t.appendChild(e),oContainers[0].appendChild(t);e=document.createElement("input");e.type="button",e.value=toLanguage("Back","Retour"),e.style.fontSize=2*iScreenScale+"px",e.style.position="absolute",e.style.left=2*iScreenScale+"px",e.style.top=35*iScreenScale+"px",e.onclick=function(){t.innerHTML="",oContainers[0].removeChild(t),selectTypeScreen()},t.appendChild(e),updateMenuMusic(0)}function selectTrackCreate(e){var t=document.createElement("div"),a=t.style;a.width=iWidth*iScreenScale+"px",a.height=iHeight*iScreenScale+"px",a.border="solid 1px black",a.backgroundColor="black";a=toTitle(e?toLanguage("Complete track builder","Éditeur complet"):toLanguage("Quick track builder","Éditeur simplifié"),0);a.style.fontSize=Math.round(7*iScreenScale)+"px",t.appendChild(a);var n=[{name:toLanguage("Circuit","Circuit"),url:e?"draw.php":"create.php",thumbnail:"help/build-circuit.png"},{name:toLanguage("Cup - Circuits","Coupe - Circuits"),url:e?"completecup.php":"simplecup.php",thumbnail:"help/build-cup-circuit.png"},{name:toLanguage("Multicup - Circuits","Multicoupe - Circuits"),url:e?"completecups.php":"simplecups.php",thumbnail:"help/build-multicup-circuit.png"},{name:toLanguage("Arena","Arène"),url:e?"course.php":"arene.php",thumbnail:"help/build-arena.png"},{name:toLanguage("Cup - Arenas","Coupe - Arènes"),url:e?"completecup.php?battle":"simplecup.php?battle",thumbnail:"help/build-cup-arena.png"},{name:toLanguage("Multicup - Arenas","Multicoupe - Arènes"),url:e?"completecups.php?battle":"simplecups.php?battle",thumbnail:"help/build-multicup-arena.png"}],o=document.createElement("div");o.style.display="grid",o.style.position="absolute",o.style.left=14*iScreenScale+"px",o.style.top=9*iScreenScale+"px",o.style.width=60*iScreenScale+"px",o.style.display="grid",o.style.gridTemplateColumns=14*iScreenScale+"px "+18*iScreenScale+"px "+20*iScreenScale+"px",o.style.columnGap=2*iScreenScale+"px",o.style.fontSize=2*iScreenScale+"px",o.style.textAlign="center",o.style.backgroundColor="#000C",o.style.paddingBottom="1px",o.style.zIndex=1;for(e=0;e
'+i.name+"
",r.onmouseover=function(){this.style.backgroundColor="rgb(38 85 177)"},r.onmouseout=function(){this.style.backgroundColor=""},r.style.cursor="pointer",o.appendChild(r)}t.appendChild(o);a=document.createElement("a");a.style.color="#CCF",a.style.fontSize=Math.round(2.5*iScreenScale)+"px",a.style.position="absolute",a.style.left=toLanguage(30,29)*iScreenScale+"px",a.style.top=36*iScreenScale+"px",a.href="creations.php",a.onclick=function(){},a.innerHTML=toLanguage("List of creations","Liste des créations"),t.appendChild(a),oContainers[0].appendChild(t);a=document.createElement("input");a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=36*iScreenScale+"px",a.onclick=function(){t.innerHTML="",oContainers[0].removeChild(t),selectTypeCreate()},t.appendChild(a),oContainers[0].appendChild(t),updateMenuMusic(0)}function selectPlayerScreen(IdJ,newP,nbSels,additionalOptions){var isCustomSel=void 0!==nbSels,force=-1===IdJ;if(force&&(IdJ=0),!IdJ){for(joueurs in strPlayer=[],aPlayers=[],cp)aPlayers.push(joueurs);updateCommandSheet()}var itemMode=getItemMode(),modeItemDistributions=itemDistributions[itemMode].concat(customItemDistrib[itemMode]),modePtDistributions=ptDistributions.concat(customPtDistrib),selectedOpponents;fInfos=fInfos||{};var oScr=document.createElement("div");newP&&(oScr.style.visibility="hidden");var oStyle=oScr.style;oStyle.width=iWidth*iScreenScale+"px",oStyle.height=iHeight*iScreenScale+"px",oStyle.border="solid 1px black",oStyle.backgroundColor="black";var shrinkAll=("VS"==course||"BB"==course)&&!clSelected,oTitle,oMsg,oMsg,oTitle;isCustomSel?(oMsg=isOnline?toLanguage("Choose CPU","Choisissez ordi")+" "+(IdJ-1):IdJ>=oContainers.length?toLanguage("Choose CPU","Choisissez ordi")+" "+(IdJ+1-oContainers.length):1==oContainers.length?toLanguage("Choose player","Choisissez joueur"):toLanguage("Choose player ","Choisissez joueur ")+(IdJ+1),oTitle=toTitle(oMsg,-1),oTitle.style.color="#F90"):oTitle=toTitle(toLanguage("Select a player","Choisissez un joueur"),-1),shrinkAll&&(oTitle.style.fontSize=Math.round(7.5*iScreenScale)+"px"),oScr.appendChild(oTitle);var baseY=shrinkAll?8:10,customCharsEnabled=0!==cupOpts.customchars,cTable=document.createElement("table");cTable.style.display="none",cTable.style.position="absolute",cTable.style.zIndex=2,cTable.style.top=36*iScreenScale+16+"px",cTable.style.left=25*iScreenScale-60+"px",cTable.style.textAlign="left",cTable.style.fontSize=2*iScreenScale+"px",cTable.style.color="white",cTable.style.backgroundColor="black",cTable.style.backgroundColor="rgba(0,0,0, 0.8)",cTable.setAttribute("cellpadding",2),cTable.setAttribute("cellspacing",2),document.body.appendChild(cTable);var hTr=document.createElement("tr"),hTd1=document.createElement("td");hTd1.innerHTML=" ",hTr.appendChild(hTd1);var hTd2=document.createElement("td");hTd2.innerHTML=" ",hTd2.style.fontWeight="bold",hTr.appendChild(hTd2),cTable.appendChild(hTr);for(var sCaracteristiques=[toLanguage("Acceleration","Accélération"),toLanguage("Max speed","Vitesse max"),toLanguage("Handling","Maniabilité"),toLanguage("Weight","Poids")],dCaracteristiques=new Array,i=0,rotateHandler;i=oContainers.length;o--)aPlayers.push(strPlayer[o]);strPlayer.splice(oContainers.length)}else if(selectedOpponents){for(o=0;owithout playing on them","Cochez cette case pour voir
les courses sans y participer"),style:function(e){return{left:e.left-10*iScreenScale+"px",top:e.top+4*iScreenScale+"px",backgroundColor:"rgba(51,51,160, 0.95)"}}}),oScr.appendChild($spectatorModeCtn)}else if("VS"==course||"BB"==course){var oForm=document.createElement("form");if(oForm.onsubmit=function(){return!1},oForm.style.position="absolute",oForm.style.top=(baseY+21)*iScreenScale-5+"px",oForm.style.left=18*iScreenScale+"px",oForm.style.fontSize=2*iScreenScale+"px",oForm.style.zIndex=2,IdJ||newP||(iDificulty=selectedDifficulty,fInfos.nbPlayers=selectedPlayers,fInfos.teams=selectedTeams,fInfos.nbteams=+selectedNbTeams,fInfos.friendlyFire=!!selectedFriendlyFire),"VS"==course){var oDiffDiv=document.createElement("label");oDiffDiv.appendChild(document.createTextNode(toLanguage("Difficulty: ","Difficulté : ")));var iDifficulties=[toLanguage("Easy","Facile"),toLanguage("Medium","Moyen"),toLanguage("Difficult","Difficile"),toLanguage("Extreme","Extrême"),toLanguage("Impossible","Impossible")],oSelect=document.createElement("select");oSelect.name="difficulty",oSelect.style.width="auto",oSelect.style.fontSize=2*iScreenScale+"px",oSelect.style.marginRight="10px",oSelect.onchange=function(){selectedDifficulty=this.selectedIndex};for(var i=0;iparseInt(t)){i=document.createElement("option");i.value=t,i.innerHTML=a,e.insertBefore(i,n[o]),e.selectedIndex=o;break}}e.value=t}oSelect.name="nbj",oSelect.style.width=3*iScreenScale+20+"px",oSelect.style.fontSize=2*iScreenScale+"px";for(var i=2;i<=8;i++){var oOption=document.createElement("option");oOption.value=i,oOption.innerHTML=i,oSelect.appendChild(oOption)}var oOption=document.createElement("option");oOption.value=-1,oOption.innerHTML=toLanguage("More...","Plus..."),oSelect.appendChild(oOption),setCustomValue(oSelect,fInfos.nbPlayers),oSelect.onchange=function(){var e;-1==this.value&&(e=parseInt(prompt(toLanguage("Number of players:","Nombre de joueurs :"))),!isNaN(e)&&1=itemDistributions[itemMode].length?"inline-block":"none")},tDiv.appendChild(oItemSelect);var oItemCustomActions=document.createElement("div");oItemCustomActions.style.display="none",oItemCustomActions.style.marginLeft=+iScreenScale+"px";var oItemCustomEdit=document.createElement("input");oItemCustomEdit.type="button",oItemCustomEdit.style.backgroundColor="rgb(51, 160, 51)",oItemCustomEdit.style.color="white",oItemCustomEdit.style.fontSize=Math.round(2.5*iScreenScale)+"px",oItemCustomEdit.value="✎",oItemCustomEdit.onclick=function(){selectItemScreen(oScr,function(e){customItemDistrib[itemMode][oItemSelect.value-itemDistributions[itemMode].length]=e,localStorage.setItem("itemsets",JSON.stringify(customItemDistrib)),localStorage.setItem("itemset."+itemMode,+oItemSelect.value),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0})},modeItemDistributions[oItemSelect.value])},oItemCustomActions.appendChild(oItemCustomEdit);var oItemCustomDel=document.createElement("input");oItemCustomDel.type="button",oItemCustomDel.style.marginLeft=Math.round(.5*iScreenScale)+"px",oItemCustomDel.style.backgroundColor="rgb(204, 51, 51)",oItemCustomDel.style.color="white",oItemCustomDel.value="×",oItemCustomDel.style.fontSize=Math.round(2.5*iScreenScale)+"px",oItemCustomDel.onclick=function(){var e=modeItemDistributions[oItemSelect.value].name;confirm(toLanguage('Delete item set "'+e+'"?','Supprimer le set "'+e+'" ?'))&&(customItemDistrib[itemMode].splice(oItemSelect.value-itemDistributions[itemMode].length,1),localStorage.setItem("itemsets",JSON.stringify(customItemDistrib)),localStorage.setItem("itemset."+itemMode,0),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0}))},oItemCustomActions.appendChild(oItemCustomDel),tDiv.appendChild(oItemCustomActions);var selectedItemSetId=localStorage.getItem("itemset."+itemMode);selectedItemSetId&&(oItemSelect.selectedIndex=selectedItemSetId,oItemSelect.onchange()),cDiv.appendChild(tDiv),oTd.appendChild(cDiv),oTr.appendChild(oTd),oTable.appendChild(oTr);var oTable=document.createElement("table");if(oTable.style.marginLeft="auto",oTable.style.marginRight="auto",oScroll.appendChild(oTable),"BB"!=course){var oTr=document.createElement("tr"),oTd=document.createElement("td");oTd.setAttribute("colspan",2);var cDiv=document.createElement("div");cDiv.style.display="flex",cDiv.style.flexDirection="row",cDiv.style.alignItems="center";var tDiv=document.createElement("div");tDiv.style.paddingLeft=3*iScreenScale+"px",tDiv.style.paddingRight=3*iScreenScale+"px";var oLabel=document.createElement("label");oLabel.style.cursor="pointer",oLabel.setAttribute("for","option-ptDistrib");var oH1=document.createElement("h1");oH1.style.fontSize=3*iScreenScale+"px",oH1.innerHTML=toLanguage("Point distribution :","Distribution des points :"),oH1.style.marginTop=iScreenScale+"px",oH1.style.marginBottom="0px",oLabel.appendChild(oH1),tDiv.appendChild(oLabel),cDiv.appendChild(tDiv);var tDiv=document.createElement("div");tDiv.style.display="inline-block",oPointSelect=document.createElement("select"),oPointSelect.id="option-ptDistrib",oPointSelect.name="option-ptDistrib",oPointSelect.style.backgroundColor="black",oPointSelect.style.width=24*iScreenScale+"px",oPointSelect.style.fontSize=Math.round(2.5*iScreenScale)+"px",oPointSelect.style.marginTop=Math.round(1.5*iScreenScale)+"px";for(var i=0;i=ptDistributions.length?"inline-block":"none")},tDiv.appendChild(oPointSelect);var oPtCustomActions=document.createElement("div");oPtCustomActions.style.display="none",oPtCustomActions.style.marginLeft=+iScreenScale+"px";var oPtCustomEdit=document.createElement("input");oPtCustomEdit.type="button",oPtCustomEdit.style.backgroundColor="rgb(51, 160, 51)",oPtCustomEdit.style.color="white",oPtCustomEdit.style.fontSize=Math.round(2.5*iScreenScale)+"px",oPtCustomEdit.value="✎",oPtCustomEdit.onclick=function(){selectPtScreen(oScr,function(e){customPtDistrib[oPointSelect.value-ptDistributions.length]=e,localStorage.setItem("ptsets",JSON.stringify(customPtDistrib)),localStorage.setItem("ptset",+oPointSelect.value),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0})},modePtDistributions[oPointSelect.value])},oPtCustomActions.appendChild(oPtCustomEdit);var oPtCustomDel=document.createElement("input");oPtCustomDel.type="button",oPtCustomDel.style.marginLeft=Math.round(.5*iScreenScale)+"px",oPtCustomDel.style.backgroundColor="rgb(204, 51, 51)",oPtCustomDel.style.color="white",oPtCustomDel.value="×",oPtCustomDel.style.fontSize=Math.round(2.5*iScreenScale)+"px",oPtCustomDel.onclick=function(){var e=modePtDistributions[oPointSelect.value].name;confirm(toLanguage('Delete point set "'+e+'"?','Supprimer le set "'+e+'" ?'))&&(customPtDistrib.splice(oPointSelect.value-ptDistributions.length,1),localStorage.setItem("ptsets",JSON.stringify(customPtDistrib)),localStorage.setItem("ptset",0),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0}))},oPtCustomActions.appendChild(oPtCustomDel),tDiv.appendChild(oPtCustomActions);var selectedPtSetId=localStorage.getItem("ptset");selectedPtSetId&&(oPointSelect.selectedIndex=selectedPtSetId,oPointSelect.onchange()),cDiv.appendChild(tDiv),oTd.appendChild(cDiv),oTr.appendChild(oTd),oTable.appendChild(oTr)}var oTr=document.createElement("tr"),oTd=document.createElement("td");oTd.style.textAlign="center",oTd.style.width=8*iScreenScale+"px",oTd.style.paddingLeft=2*iScreenScale+"px";var oDoubleItemCheckbox=document.createElement("input");oDoubleItemCheckbox.style.transform=oDoubleItemCheckbox.style.WebkitTransform=oDoubleItemCheckbox.style.MozTransform="scale("+Math.round(iScreenScale/3)+")",oDoubleItemCheckbox.id="option-doubleItems",oDoubleItemCheckbox.name="option-doubleItems",oDoubleItemCheckbox.type="checkbox",oDoubleItemCheckbox.checked=!selectedDoubleItems,oTd.appendChild(oDoubleItemCheckbox),oTr.appendChild(oTd);var oTd=document.createElement("td"),oLabel=document.createElement("label");oLabel.style.cursor="pointer",oLabel.setAttribute("for","option-doubleItems");var oH1=document.createElement("h1");oH1.style.fontSize=3*iScreenScale+"px",oH1.style.margin=Math.round(.5*iScreenScale)+"px auto",oH1.innerHTML=toLanguage("Disable double items","Désactiver les double objets"),oLabel.appendChild(oH1),oTd.appendChild(oLabel),oTd.style.padding=Math.round(1.5*iScreenScale)+"px 0",oTr.appendChild(oTd),oTable.appendChild(oTr),oMoreOptionsScreen.appendChild(oScroll);var oPInput=document.createElement("input");oPInput.type="button",oPInput.value=toLanguage("Back","Retour"),oPInput.style.fontSize=2*iScreenScale+"px",oPInput.style.position="absolute",oPInput.style.left=4*iScreenScale+"px",oPInput.style.top=32*iScreenScale+"px",oPInput.onclick=function(){oMoreOptionsScreen.style.display="none"},oMoreOptionsScreen.appendChild(oPInput)}oScr.appendChild(oForm),isCustomSel&&(oForm.style.display="none")}else if("CM"==course){if(clSelected){var ccConstraint=getCcConstraint(clSelected);150!=ccConstraint&&200!=ccConstraint||(oClassSelect=document.createElement("input"),oClassSelect.type="hidden",oClassSelect.value=ccConstraint)}else{var oDiv=document.createElement("div");oDiv.style.position="absolute",oDiv.style.left=10*iScreenScale-10+"px",oDiv.style.top=32*iScreenScale+"px",oDiv.style.width=60*iScreenScale+"px",oDiv.style.fontSize=3*iScreenScale+"px",oDiv.style.textAlign="center";var oLabel=document.createElement("label");oLabel.innerHTML=toLanguage("Class: ","Cylindrée : "),oClassSelect=document.createElement("select"),oClassSelect.name="cc",oClassSelect.style.width=12*iScreenScale+"px",oClassSelect.style.fontSize=3*iScreenScale+"px";for(var oClasses=[150,200],i=0;i"+toLanguage("Class","Cylindrée ")+': ','"],submitVal:toLanguage("Validate","Valider"),submit:function(e){var t=+e.target.elements.cc.value,e=+e.target.elements.mirror.checked;n(a,t,e),a.currentValue=a.value},close:function(){a.value=a.currentValue}}).querySelector('input[name="cc"]').select():a.currentValue=a.value}function selectItemScreen(r,l,s){s=s||{};var c=document.createElement("div");c.style.position="absolute",c.style.width="100%",c.style.height="100%",c.style.left="0px",c.style.top="0px",c.style.zIndex=4,c.style.backgroundColor="#000";var p=document.createElement("table");p.style.color="white",p.style.textAlign="center",p.style.position="absolute",p.style.left=5*iScreenScale+"px",p.setAttribute("cellpadding",0),p.setAttribute("cellspacing",0);var d=getItemMode(),u={},e=itemDistributions[d].concat(customItemDistrib[d]);selectedItemDistrib.value&&-1==e.indexOf(selectedItemDistrib)&&e.push(selectedItemDistrib);for(var t=0;t=m.length&&(v.style.display="none"),(g=document.createElement("td")).setAttribute("colspan",u.length+1),v.appendChild(g),(g=document.createElement("td")).style.paddingRight=iScreenScale+"px";var b=document.createElement("input");b.type="button",b.value="+",b.style.fontSize=2*iScreenScale+"px",b.style.lineHeight=2*iScreenScale+"px",b.style.padding=Math.round(iScreenScale/4-1)+" "+Math.round(iScreenScale/2+2)+"px",b.onclick=function(){p.insertBefore(S(f.length),v),f.length>=m.length&&(v.style.display="none")},s.readOnly&&(b.style.display="none"),g.appendChild(b),v.appendChild(g),p.appendChild(v),c.appendChild(p);b=document.createElement("input");function C(e){var t=[];if(e&&!f.length)return alert(toLanguage("You must have at least 1 row in your table","Votre table doit comporter au moins 1 ligne")),null;for(var a=0;a

'+toLanguage("Concurrent items","Objets simultanés")+'

'+toLanguage("Cooldown","Cooldown")+'

'+toLanguage("Double items","Double objets")+'

'+toLanguage("Back","Retour")+'',n.querySelector(".item-submit a").onclick=function(){return c.removeChild(n),!1};var t,o=n.querySelector("form");for(t in o.onsubmit=function(e){for(var t in e.preventDefault(),k){var a=o.elements[t];"checkbox"===a.type?k[t]=a.checked:k[t]=a.value}c.removeChild(n)},k){var a=o.elements[t];s.readOnly&&(a.disabled=!0),"checkbox"===a.type?a.checked=!!k[t]:a.value=k[t]}s.readOnly&&(n.querySelector('.item-submit input[type="submit"]').style.display="none"),c.appendChild(n)},b.appendChild(M)),s.readOnly||((M=document.createElement("input")).type="submit",M.style.fontSize=2*iScreenScale+"px",M.value=toLanguage("Validate!","Valider !"),M.style.marginLeft=iScreenScale+"px",b.appendChild(M),(M=document.createElement("a")).href="#null",M.style.color="#CCF",M.innerHTML=toLanguage("Export/Import...","Exporter/importer"),M.style.fontSize=Math.round(1.6*iScreenScale)+"px",M.style.marginLeft=Math.round(2.5*iScreenScale)+"px",M.style.position="relative",M.style.top=-Math.round(iScreenScale/2)+"px",M.onclick=function(e){e.preventDefault();var r=document.createElement("div");r.className="fsmask item-export-screen",r.style.fontSize=2*iScreenScale+"px",r.innerHTML='
'+toLanguage("Export","Exporter")+'
'+toLanguage("Import","Importer")+'
'+toLanguage("Export: Copy this text to share this distribution with other players.","Exporter : Copiez ce texte pour partager cette distribution avec d'autres joueurs.")+'
'+toLanguage("Import: Paste a new text to import distribution shared by another player.","Importer : Collez un texte pour importer la distribution d'un autre joueur.")+'
';for(var t=r.querySelectorAll(".tab-buttons .tab-button"),a=r.querySelectorAll(".tabs .tab"),n=0;n=f.length&&p.insertBefore(S(f.length),v);for(var a=importedDistrib[t],n=f[t].querySelectorAll('.item-distrib input[type="number"]'),o=0;oimportedDistrib.length;)p.removeChild(f[f.length-1]);f.length>=m.length?v.style.display="none":v.style.display=""},c.appendChild(r)},b.appendChild(M),-1===u.indexOf("carapacenoire")&&(c.tabIndex=0,c.style.outline="none",x="darkshell",P="",c.onkeydown=function(e){e=e.key;if(1===e.length){if(e=e.toLowerCase(),!x.startsWith(P+=e))return P="",void(x.startsWith(e)&&(P=e));P===x&&confirm("Enable dark shell item?")&&(m[m.length-1].carapacenoire=0,r.removeChild(c),selectItemScreen(r,l,s))}},setTimeout(function(){c.focus()},1))),c.appendChild(b),r.appendChild(c)}function selectPtScreen(l,s,c){c=c||{};var p=document.createElement("div");p.style.position="absolute",p.style.width="100%",p.style.height="100%",p.style.left="0px",p.style.top="0px",p.style.zIndex=4,p.style.backgroundColor="#000";var e=document.createElement("form");e.onsubmit=function(){var e=this.elements["pt[]"];e.length||(e=[e]);for(var t=[],a=0;at.length;)n(t.length);for(;ee.onclick).filter(e=>!e.disabled).filter(e=>!e.dataset.noselect).filter(e=>{e=e.getBoundingClientRect();return 0=strPlayer.length){for(var t=new Array(selectedNbTeams).fill(0),e=0;e[Show]','Distribution personnalisée [Voir]'),(r=o.querySelector("a")).style.color="#CCF",r.onclick=function(){return selectedItemDistrib=l,selectItemScreen(e,function(){},Object.assign({},l,{readOnly:!0})),!1}):(r=getItemMode(),(l=itemDistributions[r][shareLink.options.itemDistrib]).value.length?o.innerHTML=l.name:o.innerHTML=toLanguage("No item","Aucun objet")),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.cpuCount&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("Possible addition of bots","Ajout possible de bots"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("If there are not enough players, some bots will be added to the game so that there are at least "+shareLink.options.cpuCount+" participants.","S'il n'y a pas assez de joueurs, des bots seront ajoutés à la partie pour qu'il y ait au minimum "+shareLink.options.cpuCount+" participants"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.timeTrial&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("Time trial mode","Mode Contre-le-montre"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("Games are played like in time trial: no item boxes, no collisions with other players (they are ghosts), and you start with 3 shrooms.","Les parties se déroulent comme en CLM : pas de boîtes à objets, pas de collisions avec les autres joueurs (ce sont des fantômes), et vous commencez avec 3 champis."),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.noBumps&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("No collisions between karts","Pas de collisions entre les karts"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("Karts are not impacted when they hit each other","Les karts ne sont pas impactés lorsqu'ils se rentrent dedans"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.noJump&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("No kart jumps","Sauts désactivés"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("It's impossible to perform a jump, drift or trick","Il est impossible de faire des sauts, dérapages ou figures"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),n.appendChild(t),a.appendChild(n),(o=document.createElement("div")).style.textAlign="center",o.style.marginTop=2*iScreenScale+"px";n=document.createElement("input");n.type="button",n.value=toLanguage("Accept and play","Accepter et jouer"),n.style.fontSize=3*iScreenScale+"px",n.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),shareLink.accepted=!0,searchCourse()},o.appendChild(n),a.appendChild(o),e.appendChild(a);a=document.createElement("input");a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),selectPlayerScreen(0)},e.appendChild(a),oContainers[0].appendChild(e)}function selectChallengesScreen(){var n=document.createElement("div"),e=n.style;e.width=iWidth*iScreenScale+"px",e.height=iHeight*iScreenScale+"px",e.border="solid 1px black",e.backgroundColor="black";var t=toTitle(toLanguage("Challenges","Défis"),0);t.style.fontSize=7*iScreenScale+"px",n.appendChild(t);var a=document.createElement("div");a.style.position="absolute",a.style.left="0px",a.style.top=9*iScreenScale+"px",a.style.width=iWidth*iScreenScale+"px";var o,e=document.createElement("div");e.style.maxHeight=24*iScreenScale+"px",e.style.overflowX="hidden",e.style.overflowY="auto";t=hasChallenges();if(t){document.getElementById("comment-connect")&&((w=document.createElement("div")).style.width=(iWidth-5)*iScreenScale+"px",w.style.marginLeft="auto",w.style.marginRight="auto",w.style.marginBottom=Math.round(1.5*iScreenScale)+"px",w.style.textAlign="center",w.innerHTML=language?'You are not connected. The challenges you complete will not be saved. Click here to log in or register.':'Vous n\'êtes pas connecté. Les défis réussis ne seront pas sauvegardés. Cliquez ici pour vous connecter ou vous inscrire.',w.style.fontSize=Math.round(1.8*iScreenScale)+"px",e.appendChild(w));var i=document.createElement("table");i.style.width=(iWidth-3)*iScreenScale+"px",i.style.marginLeft="auto",i.style.marginRight="auto",i.style.borderCollapse="collapse";var r=[],l=[];for(m in challenges)for(var s in challenges[m])for(var c=(u=challenges[m][s]).list,p=0;p'+escapeSpecialChars(u.name)+"",y.style.textAlign="center",y.style.margin="0px",y.style.fontSize=Math.round(4*iScreenScale)+"px",y.style.paddingTop=Math.round(.5*iScreenScale)+"px",y.style.paddingBottom=Math.round(.5*iScreenScale)+"px",y.style.backgroundColor="#fa7c1b",y.style.color="white",C.appendChild(y),S.appendChild(C),i.appendChild(S)}var S,v="active"==h.status&&h.succeeded,b=v?"#9E9":"white";(S=document.createElement("tr")).style.border="solid 1px "+b,v&&(S.style.backgroundColor="#031"),(C=document.createElement("td")).style.padding=iScreenScale+" "+iScreenScale+"px",h.name&&((y=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",y.style.marginTop="0px",y.style.marginBottom="0px",y.innerText=h.name,C.appendChild(y));var C,M=document.createElement("div");if(h.name||h.description.extra?M.style.fontSize=2*iScreenScale+"px":M.style.fontSize=Math.round(2.5*iScreenScale)+"px",M.style.color=b,M.style.fontWeight="bold",M.innerHTML=h.description.main,C.appendChild(M),h.description.extra&&((M=document.createElement("div")).style.fontSize=Math.round(1.6*iScreenScale)+"px",M.style.color=b,M.innerHTML=h.description.extra,C.appendChild(M)),"active"!=h.status){switch((M=document.createElement("div")).style.fontSize=Math.round(1.6*iScreenScale)+"px",M.style.color="#FC0",h.status){case"pending_completion":M.innerHTML=toLanguage("This challenge is pending completion. Succeed it to publish it.","Ce défi est en attente de réussite. Réussissez-le pour le publier.");break;case"pending_publication":M.innerHTML=toLanguage("This challenge is pending publication. Click on "Manage challenges" to publish it.","Ce défi est en attente de publication. Cliquez sur "Gérer les défis" pour le publier.");break;case"pending_moderation":M.innerHTML=toLanguage("This challenge is pending moderation. It will be published once a validator validates it.","Ce défi est en attente de modération. Il sera publié dès qu'un modérateur l'aura validé.")}M.style.fontWeight="bold",C.appendChild(M)}S.appendChild(C),(C=document.createElement("td")).style.padding=iScreenScale+" "+iScreenScale+"px",C.style.width=12*iScreenScale+"px",C.style.textAlign="center",h.succeeded&&((P=document.createElement("div")).innerHTML=''+toLanguage("Completed","Réussi"),P.style.whiteSpace="nowrap",P.style.fontSize=Math.round(iScreenScale*(language?2:2.2))+"px",P.style.backgroundColor="#33A033",P.style.display="inline-block",P.style.padding="0px "+Math.round(.8*iScreenScale)+"px",P.style.borderRadius=Math.round(.6*iScreenScale)+"px",P.style.color="white",P.style.marginBottom=Math.round(.5*iScreenScale)+"px",P.style.marginTop=Math.round(.5*iScreenScale)+"px",C.appendChild(P));var x,v=document.createElement("div"),b=document.createElement("img");if(b.src="images/challenges/difficulty"+h.difficulty.level+".png",b.alt="D",b.style.width=2*iScreenScale+"px",v.appendChild(b),(P=document.createElement("span")).style.color=h.difficulty.color,P.style.fontSize=Math.round(1.7*iScreenScale)+"px",P.style.position="relative",P.style.top="-1px",P.innerHTML=" "+h.difficulty.name,v.appendChild(P),C.appendChild(v),h.winners.length){(v=document.createElement("div")).style.cursor="help";var P,b=document.createElement("img");h.succeeded||(v.style.marginBottom=Math.round(.5*iScreenScale)+"px"),b.src="images/cups/cup1.png",b.alt="W",b.style.width=2*iScreenScale+"px",v.appendChild(b),(P=document.createElement("span")).style.color="white",P.style.fontSize=Math.round(1.7*iScreenScale)+"px",P.style.position="relative",P.style.top="-2px",P.innerHTML=" "+h.winners.length;for(var k=''+toLanguage("Succeeded by:","Réussi par :")+"",I=0;I'+h.winners[I].nick;v.dataset||(v.dataset={}),v.dataset.title=k,v.appendChild(P),v.onmouseover=function(e){var t;D||((D=document.createElement("div")).className="ranking_activeplayertitle",D.innerHTML=this.dataset.title,D.style.position="fixed",D.style.padding=Math.round(iScreenScale/2)+"px "+iScreenScale+"px",D.style.borderRadius=iScreenScale+"px",D.style.zIndex=10,D.style.backgroundColor="rgba(51,160,51, 0.95)",D.style.color="white",D.style.fontSize=Math.round(1.8*iScreenScale)+"px",D.style.lineHeight=Math.round(2*iScreenScale)+"px",D.style.visibility="hidden",$mkScreen.appendChild(D),t=this.getBoundingClientRect(),D.style.left=Math.round(t.left+(this.scrollWidth-D.scrollWidth)/2)+"px",D.style.top=t.top+this.scrollHeight+5+"px",D.style.visibility="visible")},v.onmouseout=function(){D&&($mkScreen.removeChild(D),D=void 0)},C.appendChild(v)}function T(e,t,a){n.innerHTML="",oContainers[0].removeChild(n),(clSelected=e).trackId=t,clSelected.trackType=a,localStorage.removeItem("itemset."+getItemMode()),xhr("challengeTry.php","challenge="+e.id,function(e){if(!e)return!1;try{e=JSON.parse(e)}catch(e){return!1}for(var t in clSelected.autoset=e,course="",e)window[t]=e[t];return course?selectPlayerScreen(0):selectMainPage(),delete window.selectedPerso,showClSelectedPopup(),!0})}h.succeeded?((L=document.createElement("a")).href="#null",L.innerHTML=toLanguage("Replay","Rejouer"),L.style.color="white",L.style.fontSize=Math.round(1.7*iScreenScale)+"px",function(e,t,a){L.onclick=function(){return T(e,t,a),!1}}(h,s,m),C.appendChild(L)):((x=document.createElement("input")).type="button",x.value=toLanguage("Take up","Relever"),x.style.width=11*iScreenScale+"px",x.style.fontSize=Math.round(2.4*iScreenScale)+"px",function(e,t,a){x.onclick=function(){T(e,t,a)}}(h,s,m),C.appendChild(x)),S.appendChild(C),i.appendChild(S)}e.appendChild(i)}else{e.style.textAlign="center",(M=document.createElement("div")).style.fontSize=3*iScreenScale+"px",M.style.marginTop=3*iScreenScale+"px",M.style.marginBottom=2*iScreenScale+"px",M.style.marginLeft="auto",M.style.marginRight="auto",M.style.width=60*iScreenScale+"px",M.style.color="white",M.innerHTML=toLanguage("This circuit has no challenges. Create some right now, it's fast and easy!","Ce circuit ne comporte aucun défi. Créez-en dès maintenant, c'est facile et rapide !"),e.appendChild(M);var w=document.createElement("input");w.type="button",w.style.fontSize=3*iScreenScale+"px",w.style.paddingLeft=2*iScreenScale+"px",w.style.paddingRight=2*iScreenScale+"px",w.value=toLanguage("Go to challenge editor","Accéder à l'éditeur de défis"),w.onclick=function(){openChallengeEditor()},e.appendChild(w)}a.appendChild(e),n.appendChild(a);a=document.createElement("input");if((a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){n.innerHTML="",oContainers[0].removeChild(n),selectMainPage()},n.appendChild(a),t)&&(myCircuit&&((a=document.createElement("input")).type="button",a.value=toLanguage("Manage challenges...","Gérer les défis..."),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.right=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){openChallengeEditor()},n.appendChild(a)),clRewards.length)){var L=document.createElement("a");o?L.href="persoLocked.php?cl="+o:"undefined"!=typeof commentType&&"undefined"!=typeof commentCircuit&&(L.href="persoLocked.php?cltype="+commentType+"&clrace="+commentCircuit),L.target="_blank",L.style.color="white",L.style.textDecoration="none",L.onclick=function(){return window.open(this.href,"persoLock","scrollbars=1, resizable=1, width=500, height=500"),!1};t=document.createElement("img");t.src="images/challenges/unlocking.png",t.alt=toLanguage("Unlocking characters","Persos à débloquer"),t.style.height=2*iScreenScale+"px",t.style.marginRight=Math.round(.55*iScreenScale)+"px",t.style.position="relative",t.style.top=Math.round(.2*iScreenScale)+"px",L.appendChild(t);var E=0;if(myCircuit)L.innerHTML+=clRewards.length;else{for(p=0;pcongratulations!","Tous les persos ont été
débloqués, félicitations !"),L.style.color="#0F8",L.style.fontWeight="bold"):L.dataset.title=E?toLanguage(a,"Plus que "+a)+" "+toLanguage("character"+t+" left to unlock","perso"+t+" à débloquer"):a+" "+toLanguage("character"+t+" to unlock","perso"+t+" à débloquer"),L.onmouseover=function(){var e;this.style.opacity=.7,D||((D=document.createElement("div")).className="ranking_activeplayertitle",D.style.textAlign="center",D.innerHTML=this.dataset.title,D.style.position="fixed",D.style.padding=Math.round(iScreenScale/2)+"px "+iScreenScale+"px",D.style.borderRadius=iScreenScale+"px",D.style.zIndex=10,D.style.backgroundColor="rgba(102,153,160, 0.95)",D.style.color="white",D.style.fontSize=Math.round(1.8*iScreenScale)+"px",D.style.lineHeight=Math.round(2*iScreenScale)+"px",D.style.visibility="hidden",$mkScreen.appendChild(D),e=this.getBoundingClientRect(),D.style.left=Math.round(e.left+(this.scrollWidth-D.scrollWidth)/2)+"px",D.style.top=e.top-D.scrollHeight-5+"px",D.style.visibility="visible")},L.onmouseout=function(){this.style.opacity="",D&&($mkScreen.removeChild(D),D=void 0)},n.appendChild(L)}oContainers[0].appendChild(n)}function searchCourse(e){e=e||{};var n=document.createElement("div"),t=n.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black";var a=document.createElement("div");a.style.position="absolute",a.style.left="0px",a.style.top=4*iScreenScale+"px",a.style.width=iScreenScale*iWidth+"px",a.style.fontSize=4*iScreenScale+"",a.style.textAlign="center",a.innerHTML=toLanguage("Searching for other players
Please wait...","Recherche d'autres joueurs
Veuillez patienter..."),n.appendChild(a);t=document.createElement("label");t.style.position="absolute",t.style.left="0px",t.style.top=15*iScreenScale-9+"px",t.style.width=iScreenScale*iWidth+"px",t.style.textAlign="center";var o=document.createElement("input");o.type="checkbox",o.id="iAlert",o.style.transform=o.style.WebkitTransform=o.style.MozTransform="scale("+iScreenScale/6+") translateY(8%)",o.style.transformOrigin=o.style.WebkitTransformOrigin=o.style.MozTransformOrigin="bottom right",t.appendChild(o);a=document.createElement("span");a.setAttribute("for","iAlert"),a.style.fontSize=2*iScreenScale+"pt",a.style.marginLeft="5px",a.innerHTML=toLanguage("Notify me when opponents have been found","M'alerter lorsque des adversaires ont été trouvés"),t.appendChild(a),n.appendChild(t);var i=0,r=document.createElement("div");r.style.position="absolute",r.style.left="0px",r.style.top=21*iScreenScale+"px",r.style.width=41*iScreenScale*2+"px",r.style.height=Math.round(8.5*iScreenScale)+"px",r.style.overflow="hidden";for(var l=0;l<41;l++){var s=document.createElement("img");s.src="images/cLoading.png",s.className="pixelated",s.style.width=2*iScreenScale+"px",s.style.position="absolute",s.style.left=l*iScreenScale*2+"px",s.style.top="0px",r.appendChild(s)}n.appendChild(r);var c=document.createElement("div");c.style.position="absolute",c.style.left="0px",c.style.top=Math.round(17.5*iScreenScale)+"px",c.style.width=iScreenScale*iWidth+"px",c.style.textAlign="center",c.style.fontSize=2*iScreenScale+"px",c.style.color="#0B0",c.style.display="none",c.style.backgroundColor="rgba(0,0,0, 0.7)",c.innerHTML=toLanguage(' currently online. You\'ll join them as soon as they finish their '+(isBattle?"battle":"race"),' actuellement en ligne. Vous les rejoindrez une fois leur partie terminée'),n.appendChild(c);var p=document.createElement("div");p.style.position="absolute",p.style.left="0px",p.style.top=Math.round(17.5*iScreenScale)+"px",p.style.width=iScreenScale*iWidth+"px",p.style.textAlign="center",p.style.fontSize=2*iScreenScale+"px",p.style.color="#0B0",p.style.display="none",p.style.backgroundColor="rgba(0,0,0, 0.7)",p.innerHTML=toLanguage(' currently waiting, left before the game begins...',' actuellement en attente. Plus que pour que la partie commence'),n.appendChild(p);var d=1,u=iScreenScale/2,m=getOnlineCourseParams(e),h=m+(m?"&":"")+"nojoin",g=!!e.enableSpectatorMode;function y(){d&&(--d||xhr("getCourse.php",g?h:m,function(e){if(!e)return!1;try{e=JSON.parse(e)}catch(e){return!1}var t,a;return e.found?(t=o.checked,n.innerHTML="",oContainers[0].removeChild(n),t&&((a=document.createElement("embed")).src="musics/mkalert.wav",a.setAttribute("loop",!1),a.setAttribute("autostart",!0),a.style.position="absolute",a.style.left="-1000px",a.style.top="-1000px",document.body.appendChild(a),t=(new Date).getTime(),alert(toLanguage("Opponents have been found !\nGood luck !","Des adversaires ont été trouvés !\nBonne chance !")),e.time-=Math.round(((new Date).getTime()-t)/1e3),document.body.removeChild(a)),handleMatchmakingSuccess(e)):(d=10,e.nb_players?(e.nb_players<2&&(e.nb_players=2),document.getElementById("nb-active-players").innerHTML=e.nb_players+" "+toLanguage("players","joueurs"),p.style.display="none",c.style.display="block"):e.pending_players?((a=document.getElementById("nb-pending-players")).dataset.pendingCourse=e.pending_course,a.innerHTML=e.pending_players+" "+toLanguage("player","joueur")+(1"),t.innerHTML=e,t.style.left=Math.max(iScreenScale,Math.round(o.left+(o.width-t.scrollWidth)/2))+"px"):t.style.visibility="hidden",!0})}})}y(),f(c.querySelector("#nb-active-players"),"active_players"),f(p.querySelector("#nb-pending-players"),"pending_players"),shareLink.key||xhr("sendCourseNotifs.php",null,function(e){return!0});a=document.createElement("input");a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){y=function(){},n.innerHTML="",oContainers[0].removeChild(n),selectPlayerScreen(0,void 0,void 0,{enableSpectatorMode:g})},n.appendChild(a),oContainers[0].appendChild(n);t=document.createElement("div");t.style.position="absolute",t.style.left=28*iScreenScale+"px",t.style.top=34*iScreenScale+"px",t.style.fontSize=Math.round(2.5*iScreenScale)+"px",t.style.display="flex",t.style.alignItems="center";e=document.createElement("label");e.style.display="inline-flex",e.style.alignItems="center",e.style.cursor="pointer",e.style.gap=Math.round(.5*iScreenScale)+"px",e.style.marginRight=iScreenScale+"px";a=document.createElement("input");a.type="checkbox",a.checked=g,a.style.transform="scale("+iScreenScale/6+")",a.style.transformOrigin="center",a.style.marginRight=Math.round(1.5*iScreenScale-6)+"px",a.onclick=function(){g=this.checked},e.appendChild(a);a=document.createElement("span");a.innerHTML=toLanguage("Spectator mode","Mode spectateur"),e.appendChild(a),t.appendChild(e);e=document.createElement("a");e.href="#null",e.style.color="#CCF",e.innerHTML="[?]",e.style.cursor="help",e.onclick=function(){return!1},e.dataset.noselect="1",t.appendChild(e),addFancyTitle({elt:e,title:toLanguage("Check this to see races
without playing on them","Cochez cette case pour voir
les courses sans y participer"),style:function(e){return{left:e.left-10*iScreenScale+"px",top:e.top-6*iScreenScale+"px",backgroundColor:"rgba(51,51,160, 0.95)"}}}),n.appendChild(t),updateMenuMusic(0)}function getOnlineCourseParams(e){var t="";return isCup?isMCups?t+="mid="+nid:isSingle?t+=(complete?"i":"id")+"="+nid+(isBattle?"&battle":""):t+=(complete?"c":"s")+"id="+nid:isBattle&&(t+="battle"),shareLink.key&&(t+=(t?"&":"")+"key="+shareLink.key),e.spectator?t+=(t?"&":"")+"spectator="+e.spectator:e.course&&(t+=(t?"&":"")+"course="+e.course),t}function handleMatchmakingSuccess(e){e.time<1&&(e.time=1),e.spectator&&(setSpectatorId(e.spectator),e.spectatorState&&(onlineSpectatorState=e.spectatorState)),selectMapScreen({racecountdown:e.time-5}),dRest(),setTimeout(setChat,1)}function addFancyTitle(t){var a,n,o=t.elt;o.onmouseover=function(){var e;a||(o.style.opacity=.9,(a=document.createElement("div")).className="ranking_activeplayertitle",a.innerHTML=t.title,a.style.position="fixed",a.style.padding=Math.round(iScreenScale/2)+"px "+iScreenScale+"px",a.style.borderRadius=iScreenScale+"px",a.style.zIndex=10,a.style.color="white",a.style.fontSize=Math.round(1.8*iScreenScale)+"px",a.style.lineHeight=Math.round(2*iScreenScale)+"px",a.style.visibility="hidden",$mkScreen.appendChild(a),t.style&&(e=o.getBoundingClientRect(),Object.assign(a.style,t.style(e))),a.style.visibility="visible",clearInterval(n),n=setInterval(function(){a&&(document.body.contains(o)||($mkScreen.removeChild(a),clearInterval(n),a=void 0))},1e3),t.onShow&&t.onShow(a))},o.onmouseout=function(){a&&(o.style.opacity="",$mkScreen.removeChild(a),clearInterval(n),a=void 0)}}function chooseRandMap(){"MK"==page?"BB"!=course?chooseWithin(0,NBCIRCUITS):chooseWithin(NBCIRCUITS,12):isSingle?choose(1):isBattle?isCup?chooseWithin(0,aAvailableMaps.length):chooseWithin(NBCIRCUITS,12):chooseWithin(0,NBCIRCUITS)}function chooseWithin(e,t){for(var a=e+t,n={},o=e+1;o<=a;o++)n[o]=1;for(o=0;o=y[I=R]&&(O=0,R++)):(T=Math.min(p,c-(v-v%p)),k=v%p,I=Math.floor(v/p)),g<=I)break;(I-=h)<0||((w=document.createElement("img")).className="pixelated",w.style.width=C*iScreenScale+"px",w.style.height=C*iScreenScale+"px",w.style.cursor="pointer",w.style.position="absolute",L=(iWidth+M+1)/2+(k-T/2)*(C+M),z=(x+P)/2+(I-u/2)*(C+x),w.style.left=Math.round(L*iScreenScale)+"px",w.style.top=Math.round(z*iScreenScale)+"px",cupOpts.icons?"number"==typeof cupOpts.icons[v]?w.src="images/cups/"+d[cupOpts.icons[v]]+".gif":function(e,t){w.onload=function(){this.naturalWidth>this.naturalHeight?(this.style.width=C*iScreenScale+"px",this.style.top=Math.round((t+C*(1-this.naturalHeight/this.naturalWidth)/2)*iScreenScale)+"px",this.style.height="auto"):(this.style.width="auto",this.style.height=C*iScreenScale+"px",this.style.left=Math.round((e+C*(1-this.naturalWidth/this.naturalHeight)/2)*iScreenScale)+"px")},w.src=cupOpts.icons[v]}(L,z):w.src="images/cups/"+d[v%d.length]+".gif","BB"==course?w.alt=v+NBCIRCUITS/4:w.alt=v,E=iScreenScale,w.onmouseover=function(){var e=new Image;e.src=getMapSelectorSrc(v),e.alt=4*this.alt+4,e.style.border="double 4px white",e.style.width="100%",e.style.height="100%",e.className="pixelated",bSelectedMirror&&(e.className+=" mirrored"),e.id="maps",document.getElementById("dMaps").appendChild(e),document.getElementById("dMaps").style.display="block",function e(t,a){var n,o;document.getElementById("maps")&&document.getElementById("maps").alt==a&&(a%4!=0?a++:a-=3,n=document.getElementById("dMaps"),o=mapNameOf(t,a-1),n.appendChild(o),document.getElementById("maps").alt=a,document.getElementById("maps").src=getMapSelectorSrc(a-1),setTimeout(function(){try{n.removeChild(o)}catch(e){return}e(t,a)},1e3))}(E,4*this.alt+4);var t,a=cupPayloads[this.alt];a&&(s.innerHTML="",(e=a.name)&&((a=a.prefix)&&((t=document.createElement("span")).innerText=a,t.style.fontSize="0.7em",s.appendChild(t)),(t=document.createElement("span")).innerText=e,s.appendChild(t),e=a?a+e:e,e=Math.min(Math.max(8/Math.sqrt(e.length),1.45),3),l.style.fontSize=Math.round(e*iScreenScale)+"px",l.style.display="flex",s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.gap="0.25em"))},w.onmouseout=function(){document.getElementById("dMaps").style.display="none",document.getElementById("dMaps").innerHTML="",l.style.display="none"},w.onclick=function(){A(),selectRaceScreen(4*this.alt)},isCup||"BB"!=course||(D=[toLanguage("SNES Stages","Arènes SNES"),toLanguage("GBA Stages","Arènes GBA"),toLanguage("DS Stages","Arènes DS")],(B=document.createElement("div")).style.position="absolute",B.style.left=Math.round((L-M/2)*iScreenScale)+"px",B.style.top=Math.round((z+.9*C)*iScreenScale)+"px",B.style.width=(C+M)*iScreenScale+"px",B.style.fontSize=3*iScreenScale+"px",B.style.color="white",B.style.textAlign="center",B.innerHTML=D[v],n.appendChild(B)),n.appendChild(w),"GP"==course?(B=+ptsGP.charAt(v))&&((H=new Image).src="images/cups/cup"+(4-B)+".png",H.style.width=Math.round(4*iScreenScale*C/7)+"px",H.style.height=Math.round(4*iScreenScale*C/7)+"px",H.style.position="absolute",H.style.left=Math.round((L+4*C/7)*iScreenScale)+"px",H.style.top=Math.round((z+4*C/7)*iScreenScale)+"px",H.className="pixelated",n.appendChild(H)):isMCups&&!isOnline&&((H=document.createElement("a")).style.position="absolute",H.style.left=Math.round((L+5*C/7)*iScreenScale)+"px",H.style.top=Math.round((z+5*C/7)*iScreenScale)+"px",H.style.backgroundColor="rgba(0,50,128, 0.5)",H.style.padding="4px",H.style.borderRadius="50%",H.href="?cid="+cupIDs[v],H.title=toLanguage("Link to this cup","Lien vers cette coupe"),H.onmouseover=function(){this.style.backgroundColor="rgba(0,102,153, 0.8)"},H.onmouseout=function(){this.style.backgroundColor="rgba(0,50,128, 0.5)"},(z=document.createElement("img")).src="images/clink.png",z.style.width=Math.round(C*iScreenScale*2/7)+"px",H.appendChild(z),n.appendChild(H)))}"VS"==course||"BB"==course?((r=document.createElement("input")).type="button",r.value=toLanguage("Random","Aléatoire"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=34*iScreenScale-10+"px",r.style.top=30*iScreenScale+"px",r.onclick=function(){i=!1,A(),chooseRandMap()},n.appendChild(r)):"GP"==course?oContainers[0].appendChild(n):"CM"==course&&((r=document.createElement("input")).type="button",r.value=toLanguage("Rankings","Classement"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=33*iScreenScale-10+"px",r.style.top=30*iScreenScale+"px",r.onclick=openRankings,n.appendChild(r)),showRaceCountIfRelevant(n),cupOpts.pages&&cupOpts.pages.length&&((r=document.createElement("input")).type="button",r.value="◄",r.style.fontSize=Math.round(2.5*iScreenScale)+"px",r.style.position="absolute",r.style.left=72*iScreenScale+"px",r.style.top=(isOnline?31:34)*iScreenScale+"px",r.className="disablable",r.onclick=function(){e.page--,A(),selectMapScreen(e)},r.disabled=e.page<=0,n.appendChild(r),(r=document.createElement("input")).type="button",r.value="►",r.style.fontSize=Math.round(2.5*iScreenScale)+"px",r.style.position="absolute",r.style.left=76*iScreenScale+"px",r.style.top=(isOnline?31:34)*iScreenScale+"px",r.className="disablable",r.onclick=function(){e.page++,A(),selectMapScreen(e)},r.disabled=e.page>=cupOpts.pages.length,n.appendChild(r)),isOnline&&(handleSpectatorLink(function(){i=!1,A()}),setTimeout(function(){i&&(A(),chooseRandMap())},1e3*document.getElementById("racecountdown").innerHTML)),updateMenuMusic(1)}else selectRaceScreen(0);function A(){document.getElementById("dMaps").style.display="none",document.getElementById("dMaps").innerHTML="",n.innerHTML="",oContainers[0].removeChild(n)}}function setMapSrc(e,t,a,n){isCup?setTimeout(function(){e.src=n},100*(a-t)):e.src=n}function rankingsLink(e){var t=getActualCc();switch(page){case"MK":return"classement.php?map="+e.map+"&cc="+t;case"CI":return"classement.php?circuit="+e.id+"&cc="+t;case"MA":return"classement.php?draw="+e.map+"&cc="+t}}function globalRankingsLink(){var e=getActualCc();if(isMCups)return"classement.php?mcup="+nid+"&cc="+e;switch(page){case"MK":return"classement.php?cc="+e;case"CI":return"classement.php"+(isSingle?"?circuit="+nid:"?scup="+nid)+"&cc="+e;case"MA":return"classement.php"+(isSingle?"?draw="+nid:"?ccup="+nid)+"&cc="+e}}function openRankings(){open(globalRankingsLink())}function exitCircuit(){var e=document.getElementById("changeRace"),t=document.getElementById("supprRace");e&&!t?e.click():document.location.href="index.php"}function showRaceCountIfRelevant(e){var t,a;"CM"!=course&&iRaceCount&&isLocalScore()&&(t=document.createElement("div"),a="BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),t.innerHTML=a+" "+(iRaceCount+1),t.style.fontSize=2*iScreenScale+"px",t.style.position="absolute",t.style.color="#ccc",t.style.right=3*iScreenScale+"px",t.style.top=(isOnline?isSingle||isMCups||!isCup?31:27:35)*iScreenScale+"px",e.appendChild(t))}function appendContainers(){for(var e=1;e=gameRules.minPlayers){for(aPlayers=new Array,aIDs=new Array,aPlaces=new Array,aPseudos=new Array,aControllers=new Array,shareLink.options&&shareLink.options.cpu&&(cpuLevel=shareLink.options.cpuLevel||0,cpuLevel=2-cpuLevel,iDificulty=4+.5*cpuLevel,isBattle&&(iDificulty=4.5)),fSelectedClass=gameRules.cc?getRelSpeedFromCc(gameRules.cc):1,bSelectedMirror=!!gameRules.mirror,0<=gameRules.raceCount&&(iRaceCount=gameRules.raceCount),aTeams=new Array,i=0;i=tThen-(new Date).getTime()&&(e=!1)}e?(trs[cCursor].style.backgroundColor="",trs[cCursor].style.color="",++cCursor==nbChoices&&(cCursor=0),trs[cCursor].style.backgroundColor="#F80",trs[cCursor].style.color="white",cTime=Math.round(1.05*cTime),setTimeout(moveCursor,cTime)):clignote(0)}function clignote(e){trs[cCursor].style.backgroundColor=e%2?"":"#F80",trs[cCursor].style.color=e%2?"":"white",e<4?setTimeout(function(){clignote(e+1)},100):setTimeout(function(){$mkScreen.removeChild(oTable),proceedOnlineRaceSelection(rCode)},500),1==e&&(trs[cCursor].getElementsByTagName("td")[0].innerHTML=dCircuits[choixJoueurs[cCursor][2]-1])}oMap=oMaps[aAvailableMaps[choixJoueurs[rCode[1]][2]-1]],onlineSpectatorState?($mkScreen.removeChild(oTable),setTimeout(function(){proceedOnlineRaceSelection(rCode)},500)):moveCursor()}else{if(onlineSpectatorState)return setSpectatorId(void 0),backToSearch(),!0;var oDiv=document.createElement("div");oDiv.style.position="absolute",oDiv.style.left=10*iScreenScale+10+"px",oDiv.style.top=20*iScreenScale+10+"px",oDiv.style.fontSize=2*iScreenScale+"pt",oDiv.innerHTML=1choixJoueurs.length&&(selectedNbTeams=choixJoueurs.length,selectedTeamOpts&&(selectedTeamOpts.length=selectedNbTeams)),t.manualTeams?(setupTeamColors(),selectOnlineTeams(e,choixJoueurs,playerIsSelecter())):resetGame(e)}function rePosSpectatorLink(){var e,t=document.getElementById("spectatormode");t&&(e=oTable.getBoundingClientRect(),t.style.top=Math.max(e.bottom+5,38*iScreenScale+15)+"px")}onlineSpectatorId?(waitHandler=setTimeout(waitForChoice,1),onlineSpectatorState||showSpectatorLink({toggled:!0,click:function(){clearTimeout(waitHandler),waitHandler=null,$mkScreen.removeChild(oTable)}})):(xhr("chooseMap.php","joueur="+strPlayer+"&map="+map+("BB"==course?"&battle":"")+(rand?"&rand":""),refreshTab),hideSpectatorLink(),window.onbeforeunload=function(){return language?"Caution, if you leave the game, you are considered loser":"Attention, si vous quittez la partie, vous êtes considéré comme perdant"});var waitHandler=0;function waitForChoice(){var e=[];onlineSpectatorId&&e.push("spectator="+onlineSpectatorId),"BB"==course&&e.push("battle"),xhr("getMap.php",e.join("&"),refreshTab)}oTable.appendChild(oTBody),$mkScreen.appendChild(oTable),document.getElementById("waitrace").style.visibility="hidden",updateMenuMusic(1),formulaire.dataset.disabled=1,bMusic&&(startMusicHandler=setInterval(function(){oMapImg&&(loadMapMusic(),clearInterval(startMusicHandler))},onlineSpectatorState?10:500))}function leaveRaceWheelScreen(){clearRaceWheenScreen(),removeMenuMusic(),removeGameMusics(),chatting=!1;var e={enableSpectatorMode:!!onlineSpectatorId};setSpectatorId(void(iRaceCount=0)),searchCourse(e)}function clearRaceWheenScreen(){clearInterval(startMusicHandler),formulaire.dataset.disabled="",hideSpectatorLink()}function setSpectatorId(e){(onlineSpectatorId=e)||(onlineSpectatorState=void 0),rtcService&&rtcService.setSpectatorId(onlineSpectatorId)}function selectOnlineTeams(s,e,t){var y=document.createElement("div"),a=y.style;a.width=iWidth*iScreenScale+"px",a.height=iHeight*iScreenScale+"px",a.border="solid 1px black",a.backgroundColor="black";var n=selectedTeamOpts&&selectedTeamOpts.some(function(e){return e.name}),a=toTitle(toLanguage("Team selection","Sélection des équipes"),.5);n?(a.style.top="0px",a.style.fontSize=Math.round(5*iScreenScale)+"px"):a.style.fontSize=Math.round(7*iScreenScale)+"px",y.appendChild(a);var c=document.createElement("div");if(c.style.display="none",c.style.position="absolute",c.style.zIndex=5e4,c.style.left=iScreenScale+"px",c.style.top=10*iScreenScale+"px",c.style.width=(iWidth-2)*iScreenScale+"px",c.style.height=iScreenScale*(iHeight-10)+"px",c.style.overflow="auto",c.style.textAlign="center",n){c.style.top=7.5*iScreenScale+"px",c.style.paddingTop=2.5*iScreenScale+"px",(C=document.createElement("div")).style.position="absolute",C.style.left=iScreenScale+"px",C.style.top="0px",C.style.width=(iWidth-2)*iScreenScale+"px",C.style.textAlign="center",C.style.fontSize=2*iScreenScale+"px",C.style.whiteSpace="nowrap",C.style.color="white";for(var o=0;ochacun pour soi."),function(){clearTimeout(h);var e="noteams";isBattle&&(e+="&battle"),isSingle&&(e+="&single"),m(),xhr("chooseTeams.php",e,function(e){if(!e)return!1;var t;try{t=JSON.parse(e)}catch(e){return!1}return l(t),!0})})},p.appendChild(n);n=document.createElement("input");function r(e,t,a){var n=document.createElement("div");n.id="online-teams-confirm",n.style.position="absolute",n.style.left=0,n.style.top=0,n.style.width=iWidth*iScreenScale+"px",n.style.height=iHeight*iScreenScale+"px",n.style.backgroundColor="rgba(0,0,0, 0.5)",n.style.zIndex=6e4;var o=document.createElement("div");o.style.position="absolute",o.style.zIndex=6e4,o.style.left=Math.round(iScreenScale*iWidth/2)+"px",o.style.top=Math.round(iScreenScale*iHeight/2)+"px",o.style.width=40*iScreenScale+"px",o.style.transform=o.style.WebkitTransform=o.style.MozTransform="translate(-50%, -50%)",o.style.backgroundColor="gray",o.style.border="solid 1px silver",o.onclick=function(e){e.stopPropagation()};var i=document.createElement("div");i.style.marginTop=iScreenScale+"px",i.style.marginBottom=Math.round(iScreenScale/2)+"px",i.style.fontSize=Math.round(2.5*iScreenScale)+"px",i.style.textAlign="center",i.style.marginLeft=2*iScreenScale+"px",i.style.marginRight=2*iScreenScale+"px",i.style.color="#FE9",i.innerHTML=e,o.appendChild(i);i=document.createElement("div");i.style.marginBottom=iScreenScale+"px",i.style.textAlign="center",i.style.marginLeft=Math.round(1.5*iScreenScale)+"px",i.style.marginRight=Math.round(1.5*iScreenScale)+"px",i.style.fontSize=Math.round(1.8*iScreenScale)+"px",i.style.color="white",i.innerHTML=t,o.appendChild(i);t=document.createElement("div");t.style.textAlign="center",t.style.marginBottom=iScreenScale+"px";var r=document.createElement("input");r.type="button",r.style.marginRight=Math.round(iScreenScale/2)+"px",r.value="Ok",r.style.fontSize=Math.round(2*iScreenScale)+"px",r.onclick=function(){return y.removeChild(n),a(),!1},t.appendChild(r);i=document.createElement("input");return i.type="button",i.value=toLanguage("Cancel","Annuler"),i.style.marginLeft=Math.round(iScreenScale/2)+"px",i.style.fontSize=Math.round(2*iScreenScale)+"px",i.onclick=n.onclick=function(){return y.removeChild(n),!1},t.appendChild(i),o.appendChild(t),n.appendChild(o),y.appendChild(n),setTimeout(function(){r.focus()},1),n}function S(e){f.innerHTML="";for(var t=v.reduce(function(e,t){return Math.max(e,t.length)},0),a=0;afor all players. Use this option if you're waiting for more players for example.",'Attention, vous êtes sur le point d\'annuler la partie pour tous les joueurs. Utilisez cette option si vous attendez plus de joueurs par exemple.'),function(){clearTimeout(h);var e="cancel";isBattle&&(e+="&battle"),m(),xhr("chooseTeams.php",e,function(e){if(!e)return!1;try{JSON.parse(e)}catch(e){return!1}return u(),!0})})},p.appendChild(n),y.appendChild(p);for(var v=new Array(selectedNbTeams),o=0;o30 seconds left to choose the next race','Il vous reste 30 secondes pour choisir la prochaine course'),team:toLanguage('There are 10 seconds left to choose the teams','Il vous reste 10 secondes pour choisir les équipes')},(a=document.createElement("div")).id="wait"+e,a.className="wait",a.innerHTML=t[e],document.getElementById("mariokartcontainer").appendChild(a)),a.style.left=2*iScreenScale+10+"px",a.style.top=35*iScreenScale+10+"px",a.style.minWidth=iScreenScale*(iWidth-4)+"px",a.style.fontSize=3*iScreenScale+"px")}function showSpectatorLink(t){hideSpectatorLink();var e=document.createElement("div");e.id="spectatormode",e.style.left=2*iScreenScale+10+"px",e.style.top=38*iScreenScale+15+"px",e.style.width=iScreenScale*(iWidth-4)+"px",e.style.fontSize=Math.round(2.25*iScreenScale)+"px";var a=document.createElement("img");a.src="images/ic_spectator.png",a.alt="Toggle",a.style.height=Math.round(1.75*iScreenScale)+"px",a.style.marginRight=Math.round(iScreenScale/4)+"px",e.appendChild(a);var a=document.createElement("a"),n=!(a.href="#null");t.toggled?(a.innerHTML=toLanguage("Exit spectator mode","Quitter le mode spectateur"),a.onclick=function(e){e.preventDefault(),n||(n=!0,t.click(),xhr("getCourse.php",getOnlineCourseParams({spectator:onlineSpectatorId}),function(e){if(!e)return!1;try{e=JSON.parse(e)}catch(e){return!1}return e.found?(clearRaceWheenScreen(),setSpectatorId(void 0),handleMatchmakingSuccess(e)):(choose(),hideSpectatorLink(),showExitSpectatorFailMessage()),!0}))}):(a.title=toLanguage("You'll see games but not play on it","Vous verrez les parties mais ne jouerez pas dedans"),a.innerHTML=toLanguage("Switch to spectator mode","Passer en mode spectateur"),a.onclick=function(e){e.preventDefault(),n||(n=!0,t.click(),xhr("spectatorMode.php","",function(e){return 0",l=0;l'+(l+1)+". "+timeStr(n[l]);oPersoLapTimes.dataset.title=r}}function multiGhosts(n){oScr.innerHTML="";var e=gID-3,t=gID+4;e<0?t-=e:t>n.length&&(e-=t-n.length),e=Math.max(e,0),t=Math.min(t,n.length),(gIDs=new Array).length=t-e;for(var a=0,o=e;o=n.length&&(gIDs[e]=0),writeTime(n[gIDs[e]][1],n[gIDs[e]][2],n[gIDs[e]][3],n[gIDs[e]][4],t,a)}}(a,p,s),i.appendChild(u),l.appendChild(s),r.appendChild(l),i.appendChild(r),oScr.appendChild(i),a++}var m=gIDs.length,h=document.createElement("div");h.style.textAlign="center",h.style.position="absolute",h.style.left=2*iScreenScale+"px",h.style.top=29*iScreenScale+"px",h.style.width=76*iScreenScale+"px",h.style.color="white";var g=document.createElement("span");g.style.fontSize=Math.round(2.5*iScreenScale)+"px",g.innerHTML=toLanguage("Number of ghosts:","Nombre de fantômes :"),g.style.marginRight=Math.round(1.2*iScreenScale)+"px",h.appendChild(g);var y=document.createElement("input");y.type="button",y.value="-",y.style.fontSize=3*iScreenScale+"px",y.onclick=function(){m--,oScr.querySelectorAll(".igScr")[m].style.visibility="hidden",b()};var f=document.createElement("span");f.style.fontSize=Math.round(2.5*iScreenScale)+"px",f.style.marginLeft=f.style.marginRight=Math.round(1.5*iScreenScale)+"px";var S=document.createElement("input");S.type="button",S.value="+",S.onclick=function(){oScr.querySelectorAll(".igScr")[m].style.visibility="visible",m++,b()},y.className=S.className="disablable",y.style.borderRadius=S.style.borderRadius="50%",y.style.fontSize=y.style.lineHeight=S.style.fontSize=S.style.lineHeight=3*iScreenScale+"px",y.style.width=y.style.height=S.style.width=S.style.height=4*iScreenScale+"px",h.appendChild(y),h.appendChild(f),h.appendChild(S),oScr.appendChild(h);h=document.createElement("input");h.type="button",h.value=toLanguage("Back","Retour"),h.style.fontSize=2*iScreenScale+"px",h.style.position="absolute",h.style.left=2*iScreenScale+"px",h.style.top=36*iScreenScale+"px",h.onclick=function(){oScr.innerHTML="",oContainers[0].removeChild(oScr),selectFantomeScreen(ghostsData,map,{times:n,id:gID})},oScr.appendChild(h);var v=document.createElement("input");function b(){f.innerHTML=m,v.value=toLanguage("Face with "+m+" ghost"+(1=gIDs.length}v.type="button",b(),v.style.fontSize=Math.round(2.5*iScreenScale)+"px",v.style.position="absolute",v.style.right=5*iScreenScale-10+"px",v.style.top=35*iScreenScale+"px",v.onclick=function(){gIDs.length=m,seeGhost(!1)},oScr.appendChild(v);h=document.createElement("input");h.type="button",h.value=toLanguage("See race","Voir la course"),h.style.fontSize=Math.round(2.5*iScreenScale)+"px",h.style.position="absolute",h.style.right=33*iScreenScale-10+"px",h.style.top=35*iScreenScale+"px",h.onclick=function(){gIDs.length=m,seeGhost(!0)},oScr.appendChild(h)}function showGhosts(){if(gTimes.length){for(i=0;i=ghostsData[3];)gID--;!gID&&1=gTimes.length&&(gID=0),writeTime(gTimes[gID][1],gTimes[gID][2],gTimes[gID][3],gTimes[gID][4]),ghostsData)&&gTimes[gID][0]===ghostsData[0];e++);},oScr.appendChild(o);var r,o=document.createElement("input");o.id="ffDroite",o.type="button",o.value="⏭",o.style.fontSize=4*iScreenScale+"px",o.style.position="absolute",o.style.left=72*iScreenScale+"px",o.style.top=a+"px",o.style.height=n+"px",o.onclick=function(){gID=gTimes.length-1,writeTime(gTimes[gID][1],gTimes[gID][2],gTimes[gID][3],gTimes[gID][4])},oScr.appendChild(o),ghostsData?oScr.style.visibility="visible":oContainers[0].appendChild(oScr),writeTime(gTimes[gID][1],gTimes[gID][2],gTimes[gID][3],gTimes[gID][4]),OPFace&&(OPFace.style.display="none"),document.body.style.cursor="default",(OPFace7=document.createElement("input")).type="button",OPFace7.value=toLanguage("7 ghosts...","7 fantômes..."),OPFace7.style.fontSize=2*iScreenScale+"px",OPFace7.style.position="absolute",OPFace7.style.right=2*iScreenScale+"px",OPFace7.style.top=36*iScreenScale+"px",OPFace7.onmouseover=function(){r||((r=document.createElement("div")).style.position="absolute",r.style.textAlign="center",r.style.fontSize=2*iScreenScale+"px",r.style.width=30*iScreenScale+"px",r.style.right=2*iScreenScale+"px",r.style.bottom=4*iScreenScale+"px",r.style.backgroundColor="rgba(204,192,178,0.95)",r.style.padding=Math.round(iScreenScale/2)+" "+iScreenScale+"px",r.style.color="#363330",r.innerHTML=toLanguage("Play with 7 ghosts with the same level as the ghost above","Affronter 7 fantômes du même niveau que le fantôme ci-dessus"),r.style.borderBottomLeftRadius=iScreenScale+"px",r.style.borderTopRightRadius=iScreenScale+"px",oScr.appendChild(r))},OPFace7.onmouseout=function(){r&&(oScr.removeChild(r),r=null)},OPFace7.onclick=function(){r&&(oScr.removeChild(r),r=null),multiGhosts(gTimes)},oScr.appendChild(OPFace7)}else if(ghostsData)alert(language?"No other record for this circuit yet":"Aucun autre record pour ce circuit"),oScr.style.visibility="visible",gID=-1,document.body.style.cursor="default";else{oScr.innerHTML="";try{oContainers[0].removeChild(oScr)}catch(e){}document.body.style.cursor="default",gPersos.length=0,resetGame(aAvailableMaps[map])}}function otherGhosts(){document.body.style.cursor="progress",ghostsData&&(oScr.style.visibility="hidden"),xhr("otherghosts.php","map="+getCreationId(oMaps[aAvailableMaps[map]])+"&type="+getCreationTable()+"&cc="+getActualCc(),function(reponse){if(reponse){try{gTimes=eval(reponse)}catch(e){return!1}return showGhosts(),!0}return!1})}function seeGhost(replay){if(replay&&(pause=!0,fInfos.replay=!0,gSelectedPerso=strPlayer[0]),-1==gID)oScr.innerHTML="",oContainers[0].removeChild(oScr),gOverwriteRecord=1,replay?(strPlayer[0]=ghostsData[1],iRecord=ghostsData[3],iLapTimes=ghostsData[4],iTrajet=ghostsData[5]):(gPersos=[ghostsData[1]],iLapTimes=ghostsData[4],jTrajets=[ghostsData[5]]),resetGame(aAvailableMaps[map]);else{var xhrUrl,xhrData;if(oScr.innerHTML="",oContainers[0].removeChild(oScr),document.body.style.cursor="progress",gIDs){xhrUrl="ghostsrace.php",xhrData="";for(var i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'"):""}function stripSpecialChars(e){return e.replace(/&[#\w]+;/g,"_").replace(/<\w+>(.+?)<\/\w+>/g,"$1")}function mapNameOf(e,t){var a=document.createElement("div"),n=isCup?Math.min(Math.max(9/Math.sqrt(stripSpecialChars(lCircuits[t]).length),1.4),4):2.1;a.style.fontSize=Math.round(e*n)+"px",a.className="mapname",a.style.textAlign="center",a.innerHTML=dCircuits[t];t=a.querySelector("small");return t&&(t.style.fontSize=2*iScreenScale+"px"),a}function addOption(e,t,a,n,o,i){document.getElementById(e).innerHTML=t.replace(/ /g," "),document.getElementById(a).innerHTML="";var r,l=document.createElement("select");l.name=n;for(var s=0;s'+e+"
")+'Edit',document.getElementById("commandes-edit").onclick=function(){editCommands()}}}function updateCommandSheet(){var a=getCommands(null,2),n=navigator.platform&&0<=navigator.platform.toUpperCase().indexOf("MAC");function e(e,t){var a=language?"P":"J";return 1==oContainers.length?e:a+"1 : "+e+"; "+a+"2 : "+t}function t(e){var t=a[e],e=t[0];return t[1]&&n&&(e=t[1]),getKeyName(e)}displayCommands(""+toLanguage("Move","Se diriger")+" : "+e(t("up")+t("left")+t("down")+t("right"),t("up_p2")+t("left_p2")+t("down_p2")+t("right_p2"))+'
'+toLanguage("Use item","Utiliser un objet")+" : "+e(t("item"),t("item_p2"))+"
"+toLanguage("Item backwards","Objet en arrière")+" : "+e(t("item_back"),t("item_back_p2"))+"
"+("BB"==course?"":""+toLanguage("Item forwards","Objet en avant")+" : "+e(t("item_fwd"),t("item_fwd_p2"))+"

")+""+toLanguage("Jump/drift","Sauter/déraper")+" : "+e(t("jump"),t("jump_p2"))+("BB"==course?"
"+toLanguage("Inflate a balloon","Gonfler un ballon")+" : "+e(t("balloon"),t("balloon_p2")):"")+"
"+toLanguage("Rear/Front view","Vue arrière/avant")+" : "+e(t("rear"),t("rear_p2"))+"
"+toLanguage("Pause","Mettre en pause")+" : "+t("pause")+"
"+toLanguage("Quit","Quitter")+" : "+t("quit"))}function editCommands(n){clearInterval(pollingGamepadsHandler);var e=!!n,a=(n=n||{}).currentTab||0,u=n.selectedPlayer||0,m=n.selectedDevice||"keyboard",t=u+1,o=document.getElementById("control-editor-mask");if(!o||(document.body.removeChild(o),e)){(o=document.createElement("div")).id="control-editor-mask",o.onclick=function(){editCommands()};var i=document.createElement("div");i.className="control-editor",i.onclick=function(e){e.stopPropagation()};var r=document.createElement("div");r.className="control-header";e=document.createElement("div");e.innerHTML=toLanguage("Game settings","Paramètres du jeu"),r.appendChild(e);e=document.createElement("button");e.className="control-close",e.innerHTML="×",e.onclick=function(){editCommands()},r.appendChild(e),i.appendChild(r);var l=document.createElement("div");l.className="control-tabs";for(var s=[toLanguage("Edit controls","Modifier les contrôles"),toLanguage("Advanced settings","Paramètres avancés")],c=0;c div")[e].classList.add("control-window-active"),a=e,n.currentTab=a},l.appendChild(t)}(c);i.appendChild(l);e=document.createElement("div");e.className="control-window";r=document.createElement("div");if(r.className="control-window-active",!n.pc&&isMobile()){var p=(p=localStorage.getItem("settings.ctrl"))?JSON.parse(p):{},d=document.createElement("div");d.className="control-main-title",d.innerHTML=toLanguage("Command interface","Interface de commandes"),r.appendChild(d);var h=document.createElement("div");h.className="control-type-values";for(var g=[{id:"keyboard",name:toLanguage("Virtual Keyboard","Clavier virtuel"),description:toLanguage("Shows buttons that behave like keys in a keyboard","Affiche des boutons pour simuler les touches d'un clavier"),dropdown:function(e){var t=document.createElement("label"),a=document.createElement("span");a.innerHTML=toLanguage("Keyboard layout:","Disposition des touches :"),t.appendChild(a);var n,o=document.createElement("select"),i={"":toLanguage("Default","Par défaut"),h_sym:toLanguage("Horizontal symmetry","Symétrie horizontale"),v_sym:toLanguage("Vertical symmetry","Symétrie verticale"),vh_sym:toLanguage("Both symmetries","Symétrie mixte"),old:toLanguage("Old version","Ancienne version")},r=p.layout||"";for(n in i){var l=document.createElement("option");(l.value=n)===r&&(l.selected="selected"),l.innerHTML=i[n],o.appendChild(l)}t.appendChild(o),o.onchange=function(){this.value?p.layout=this.value:delete p.layout,localStorage.setItem("settings.ctrl",JSON.stringify(p))},e.appendChild(t)}},{id:"gestures",name:toLanguage("Touch controls","Contrôles tactiles"),description:toLanguage("Swipe the screen to go in the desired direction. Controls similar to Mario Kart Tour","Balayez l'écran pour vous diriger dans la direction souhaitée. Contrôles similaires à Mario Kart Tour"),dropdown:function(e){var t=document.createElement("a");t.className="control-touch-help",t.href="#null",t.innerHTML=toLanguage("How touch controls work...","Aide sur les contrôles tactiles..."),t.onclick=function(){return window.open("helpTouchCtrls.php","help","scrollbars=1, resizable=1, width=500, height=500"),!1},e.appendChild(t)}},{id:"external",name:toLanguage("External controller","Contrôleur externe"),description:toLanguage("Connect an external keyboard or gamepad","Connetez un clavier ou une manette externe"),dropdown:function(e){var t=document.createElement("a");t.className="control-ext-settings",t.href="#null",t.innerHTML=toLanguage("Controller settings...","Paramètres du contrôlleur..."),t.onclick=function(){return n.pc=!0,editCommands(n),!1},e.appendChild(t)}}],y=p.mode||"keyboard",c=0;c🎮',t.innerHTML+="
"+toLanguage("Connect a gamepad and press any button to continue","Connectez une manette et appuyez sur n'importe quel bouton pour continuer")+"
",r.appendChild(t),clearInterval(pollingGamepadsHandler),pollingGamepadsHandler=setInterval(function(){for(var e=navigator.getGamepads(),t=0;t"+toLanguage("Selected:","Séléctionné :")+" "+I["_name"+P],q.appendChild(W),(K=document.createElement("a")).href="#null",K.innerHTML=toLanguage("[Reset]","[Réinitiliser]"),K.onclick=function(){if(confirm(toLanguage("Reset controller selection?","Réinitialiser la sélection de la manette ?"))){delete I["_id"+P],delete I["_name"+P];for(var e=0;e div")[a].click()}else document.querySelector("#commandes strong")&&updateCommandSheet();function $(e,t){var a=document.createElement("label"),n=document.createElement("input");n.type="checkbox",n.checked=!!B[e],a.appendChild(n);var o=document.createElement("span");o.innerHTML=t,a.appendChild(o),n.onclick=function(){this.checked?B[e]=1:delete B[e],localStorage.setItem("settings",JSON.stringify(B))},D.appendChild(a)}}function getKeyName(e,t){if("gamepad"!==t)return this.keyMatching||(this.keyMatching=["","","","Break","","","","","Backspace","Tab","","","Clear","Enter","","","Shift","Ctrl","Alt","Pause","CapsLock","Hangul","","","","Hanja","",toLanguage("Escape","Échap"),"Conversion","Non-conversion","","",toLanguage("Spacebar","Espace"),"PageUp","PageDown","End","Home","←","↑","→","↓","Select","Print","Execute",toLanguage("Print Screen","ImpEcr"),"Inser",toLanguage("Delete","Suppr"),"Help","0","1","2","3","4","5","6","7","8","9",":","=","<","=","","SS","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","Meta","Meta","Meta","","Sleep","0","1","2","3","4","5","6","7","8","9","×","+",".","-",".","/","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","F13","F14","F15","F16","F17","F18","F19","F20","F21","F22","F23","F24","","","","","","","","","NumLock","ScrollLock","","","","","","","","","","","","","","","^","!","؛","#","$","Ù","PageDown","PageUp","Refresh",")","*","~","Home","-","Vol. down","Vol. up","Next","Previous","Stop","Play/pause","@","Mute","Vol. down","Vol. up","","","Ñ","=",",","#",".","/","%","°",",","","","","","","","","","","","","","","","","","","","","","","","","","{","\\","}","'","`","Meta","AltGr","<","","","","Compose","Ç","","Forward","Back","Non-conversion","","","","","Alphanumeric","","Hiragana","Half-width","Kanji","","","","","","","Unlock Trackpad","","","","Toggle Touchpad"]),this.keyMatching[e]||"#"+e;for(var a=[],n=0;n"+t+""}function toTitle(e,t){var a=document.createElement("div");return a.style.width=iWidth*iScreenScale+"px",a.style.fontSize=Math.round(8*iScreenScale)+"px",a.style.fontWeight="normal",a.style.position="absolute",a.style.left="0px",a.style.top=Math.round(t*iScreenScale)+"px",a.style.textAlign="center",a.style.color=primaryColor,a.innerHTML=e,a.style.fontFamily="Tahoma",a}function ucwords(e){return e.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,function(e){return e.toUpperCase()})}function toPerso(e){if(isCustomPerso(e))return customPersos[e].name;var t=e;return language?"maskass"==e?t="shy guy":"skelerex"==e?t="dry bones":"harmonie"==e?t="rosalina":"roi_boo"==e?t="king boo":"frere_marto"==e?t="hammer bro":"bowser_skelet"==e?t="dry bowser":"flora_piranha"==e&&(t="petey piranha"):"frere_marto"==e&&(t="frère marto"),t=ucwords(t=t.replace(/_/g," "))}var isMobileCache=!!(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)),$commandes;function isMobile(){return isMobileCache}function isChatting(){return isOnline&&(document.forms[1]&&(document.forms[1].elements.rMessage&&document.activeElement==document.forms[1].elements.rMessage))}function onButtonTouch(e){e&&e.preventDefault(),this.style.backgroundColor="#603",this.dataset.pressed="1",navigator.vibrate(30);for(var t=this.dataset.key.split(","),a=0;a"+toLanguage("Message not sent (reason: "+t+")","Message non envoyé (raison : "+t+")")+"",oMessages.appendChild(e),oMessages.scrollTop=oMessages.scrollHeight-oMessages.clientHeight),!0}),rMessage.value=""),!1},oChat.appendChild(oConnectes),oChat.appendChild(oMessages),oChat.appendChild(oRepondre);var iChatLastMsg=0;rtcService=rtcService||RTCService({spectatorId:onlineSpectatorId}),refreshChat(),vConnectes.disabled=!0,rtcService.getVocChat({callback:function(e){e&&(vConnectes.style.display="none",vChatActions.style.display="inline-block"),vConnectes.disabled=!1}}),document.body.insertBefore(oChat,$mkScreen);try{handleChatPos()}catch(e){console.error(e)}}function removeBlockDialog(){return oBlockDialog&&(oChat.removeChild(oBlockDialog),oBlockDialog=null,1)}function showMemberList(title,blockedFn,onSelect){var oBlockTitle,oBlockClose,oBlockMembers;removeBlockDialog()||(oBlockDialog=document.createElement("div"),oBlockDialog.className="online-chat-blockdialog",oBlockDialog.style.position="absolute",oBlockDialog.style.left="85px",oBlockDialog.style.top="8%",oBlockDialog.style.width="200px",oBlockDialog.style.border="double 4px silver",oBlockDialog.style.backgroundColor="#222",oBlockTitle=document.createElement("h1"),oBlockTitle.innerHTML=title,oBlockDialog.appendChild(oBlockTitle),oBlockClose=document.createElement("input"),oBlockClose.type="button",oBlockClose.onclick=function(){removeBlockDialog()},oBlockClose.value="×",oBlockDialog.appendChild(oBlockClose),oBlockMembers=document.createElement("div"),oBlockMembers.className="online-chat-blockdialog-members",xhr("listCoursePlayers.php",onlineSpectatorId?"spectator="+onlineSpectatorId:"",function(reponse){if(reponse){try{var rCode=eval(reponse)}catch(e){return!1}for(var i=0;i
Spectator
Voc
',jConnectes.appendChild(sNom)),isIcon=!1,sNom.querySelector(".online-chat-playerlistname").innerText=cPlayer.name,cPlayer.spectator?(sNom.querySelector(".online-chat-spectator").style.display="",isIcon=!0):sNom.querySelector(".online-chat-spectator").style.display="none",cPlayer.peer?(isIcon=!0,sNom.querySelector(".online-chat-playerlisticonwrapper").style.display="",sNom.querySelector(".online-chat-playerlisticonwrapper img").src="images/"+(cPlayer.muted?"ic_muted":"ic_voc")+".png",cPeer=rtcService.getPeer(cPlayer.peer),cPeer&&cPeer.audio&&(cPeer.recorderHandler||function(o,i){var e,r,l;i&&(e=new AudioContext,r=e.createAnalyser(),e.createMediaStreamSource(o.audio.srcObject).connect(r),l=new Uint8Array(r.fftSize),o.recorderHandler=setInterval(function(){if(!o.audio.parentNode||!document.body.contains(i)||!cPlayerPeers[identifiant])return clearInterval(o.recorderHandler),delete o.recorderHandler,r.disconnect(),i.style.width="",i.style.height="",i.style.left="",void(i.style.top="");r.getByteTimeDomainData(l);for(var e=0,t=0;t
'+toLanguage("Custom FPS...","Choix des FPS...")+'
";var a=t.querySelector(".customOptionDialog-cursor"),n=t.querySelector(".customOptionDialog-content");function o(){var e=15*a.value;t.querySelector(".customOptionDialog-textValue").innerHTML=e+" FPS"}function i(){document.body.removeChild(t)}function r(){var e=+a.value;addFpsOption(e),setFps(e),i()}return a.value=iFps,o(),a.oninput=function(){o()},t.onclick=function(e){r()},n.style.bottom="5px",n.onclick=function(e){e.stopPropagation()},n.onsubmit=function(){return r(),!1},t.querySelector(".customOptionDialog-submit a").onclick=function(){return i(),!1},void document.body.appendChild(t)}if(localStorage.setItem("nbFrames",e),formulaire&&formulaire.dataset.disabled)return showParamChangeDisclaimer();iFps=e}function openFullscreen(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():void 0}var $mkScreen=document.getElementById("mariokartcontainer");$mkScreen.dataset||($mkScreen.dataset={}),updateCtnFullScreen=function(e){if($mkScreen.dataset.fs=e?1:"",e){var t=Math.min(screen.width/(iWidth*iScreenScale),screen.height/(iHeight*iScreenScale)),a=Math.round(100*t),n=$mkScreen.scrollWidth,e=$mkScreen.style.zoom;if($mkScreen.style.zoom=a+"%",n!=$mkScreen.scrollWidth||e==$mkScreen.style.zoom||100==a){for(var o=0;o
'+toLanguage("Custom size...","Taille personnalisée...")+'
";var o=n.querySelector(".customOptionDialog-cursor"),i=n.querySelector(".customOptionDialog-content");function r(){var e=+o.value;n.querySelector(".customOptionDialog-textValue").innerHTML=e*iWidth+"×"+e*iHeight}function l(){document.body.removeChild(n)}function s(){var e=+o.value;addScreenScaleOption(e),setScreenScale(e),l()}return o.value=a,r(),o.oninput=function(){var e=+o.value;formulaire.dataset.disabled||previewScreenScale(a,e),r()},n.onclick=function(e){s()},i.style.bottom="80px",i.onclick=function(e){e.stopPropagation()},i.onsubmit=function(){return s(),!1},n.querySelector(".customOptionDialog-submit a").onclick=function(){return formulaire.dataset.disabled||previewScreenScale(a,a),l(),!1},void document.body.appendChild(n)}if(t||localStorage.setItem("iScreenScale",e),formulaire&&formulaire.dataset.disabled)return showParamChangeDisclaimer();iScreenScale=e,bRunning&&resetScreen(),previewScreenScale(a,iScreenScale),setSRest()}else{formulaire.screenscale.value=a;e=openFullscreen($mkScreen);e.then&&e.catch?e.then(function(){updateCtnFullScreen(!0),document.onfullscreenchange=function(){updateCtnFullScreen(document.fullscreenElement===$mkScreen)}}).catch(function(){updateCtnFullScreen(!0)}):updateCtnFullScreen(!0)}}}function addCustomOption(e,t,a,n){var o;n=n||1,e.querySelector('option[value="'+t+'"]')||((o=document.createElement("option")).value=t,o.innerHTML=a,e.insertBefore(o,e.childNodes[e.childNodes.length-n])),e.value=t}function addScreenScaleOption(e){addCustomOption(formulaire.screenscale,e,e*iWidth+"×"+e*iHeight,2)}function addFpsOption(e){addCustomOption(formulaire.fps,e,15*e+" FPS")}function previewScreenScale(e,t){for(var a=0;aThey'll apply to your next race.","Les paramètres ont été sauvegardés.
Ils s'appliqueront à la prochaine course"),document.body.appendChild(e),setTimeout(function(){e.classList.add("modes-change-fadeout"),setTimeout(function(){document.body.removeChild(e)},1e3)},3e3)}function setMusic(e){if(e?localStorage.setItem("bMusic",1):localStorage.removeItem("bMusic"),formulaire&&formulaire.dataset.disabled){if(e)return showParamChangeDisclaimer();removeIfExists(mapMusic),removeIfExists(lastMapMusic),removeIfExists(endingMusic)}bMusic=!!e,-1!=gameMenu&&updateMenuMusic(gameMenu,!0)}function setSfx(e){if(e?localStorage.setItem("iSfx",1):localStorage.removeItem("iSfx"),formulaire&&formulaire.dataset.disabled){if(e)return showParamChangeDisclaimer();removeSoundEffects(),oMusicEmbed&&unpauseMusic(mapMusic),removeGameMusics([mapMusic,lastMapMusic,endingMusic])}iSfx=!!e}function removeMenuMusic(e){clearTimeout(oMusicHandler),oMusicEmbed&&document.body.contains(oMusicEmbed)&&(e?document.body.removeChild(oMusicEmbed):fadeOutMusic(oMusicEmbed,1,.8,null,vMusic),oMusicEmbed=void 0),muteOnBlur&&(window.removeEventListener("blur",muteOnBlur),muteOnBlur=void 0),unmuteOnResume&&(window.removeEventListener("focus",unmuteOnResume),unmuteOnResume=void 0)}function removeIfExists(e){e&&(e.yt&&(e.yt.destroy&&(e.yt.isDetroyed=!0,e.yt.destroy()),delete e.yt,delete e.tasks,delete e.opts),document.body.contains(e)&&document.body.removeChild(e),oMusicEmbed==e&&(oMusicEmbed=void 0))}function removeGameMusics(e){if(bMusic||iSfx){for(var t=document.getElementsByClassName("gamemusic"),a=t.length-1;0<=a;a--){var n=t[a];e&&-1!==e.indexOf(n)||document.body.removeChild(n)}oMusicEmbed=void 0}}function removeSoundEffects(){playingCarEngine=void 0,removeIfExists(carEngine),carEngine=void 0,removeIfExists(carEngine2),carEngine2=void 0,removeIfExists(carEngine3),carEngine3=void 0,removeIfExists(carDrift),carDrift=void 0,removeIfExists(carSpark),carSpark=void 0}function clearResources(){oMapImg&&oMapImg.clear&&oMapImg.clear()}function resetEvents(){document.onmousedown=void 0,document.onkeydown=void 0,document.onkeyup=void 0,window.removeEventListener("blur",window.releaseOnBlur),window.releaseOnBlur=void 0,window.removeEventListener("deviceorientation",window.turnOnRotate),window.turnOnRotate=void 0,hideVirtualKeyboard()}function pauseSounds(){if(bMusic||iSfx){clLocalVars.forcePause||(playSoundEffect("musics/events/pause.mp3").className="");for(var e=document.getElementsByClassName("gamemusic"),t=0;tt.length;)o.removeChild(e[0]),e.shift()}}function M(e,t,i,a){for(var n in e)if(oMap[n]){if(e[n].length
';for(var u=d.querySelectorAll("div"),m=0;m"+(oMap.sections?"SECTION":toLanguage("LAP","TOUR"))+' 1/'+oMap.tours+"",m||(c=Math.round(iScreenScale/8)+"px",p=Math.round(iScreenScale/4)+"px",u[m].style.textShadow="-"+p+" 0 black, 0 "+p+" black, "+p+" 0 black, 0 -"+p+" black, -"+c+" -"+c+" black, -"+c+" "+c+" black, "+c+" -"+c+" black, "+c+" "+c+" black")}else{var h=aTeams[i];null==h&&(h=-1),updateBalloonHud(d,{reserve:4,team:h})}l.appendChild(d);var g=document.createElement("div");g.id="objet"+i,g.className="itemWheel",pause&&fInfos.replay||(g.style.left=Math.round(iScreenScale)+"px",g.style.top=Math.round(iScreenScale)+"px",g.style.width=Math.round(26*iScreenScale/3)+"px",g.style.height=Math.round(18*iScreenScale/3)+"px",g.style.visibility="visible");h=document.createElement("div");h.id="roulette"+i,h.className="itemChamber",g.appendChild(h);d=document.createElement("div");d.id="countdown"+i,d.style.position="absolute",d.style.opacity=.8,d.style.width=Math.round(6.6*iScreenScale)+"px",d.style.height=Math.round(4.2*iScreenScale)+"px",d.style.border="solid "+Math.round(.75*iScreenScale)+"px "+primaryColor,d.style.borderRadius=Math.round(1.75*iScreenScale)+"px",d.style.display="none",g.appendChild(d),l.appendChild(g);d=document.createElement("div");d.id="reserve"+i,d.className="itemWheel",pause&&fInfos.replay||(d.style.left=Math.round(.75*iScreenScale)+"px",d.style.top=Math.round(iScreenScale)+"px",d.style.width=Math.round(26*iScreenScale/5)+"px",d.style.height=Math.round(18*iScreenScale/5)+"px",d.style.visibility="hidden"),(h=document.createElement("div")).id="roulette2"+i,h.className="itemChamber",d.appendChild(h),l.appendChild(d);h=document.createElement("div");h.id="lakitu"+i,h.className="pixelated",h.innerHTML="
",h.style.width=9*iScreenScale+"px",h.style.height=Math.round(6.6*iScreenScale)+"px",h.style.fontSize=Math.round(2.3*iScreenScale)+"px",l.appendChild(h);h=document.createElement("div");h.id="infoPlace"+i,h.style.right=Math.round(iScreenScale/2)+"px",h.style.bottom="0px",h.style.fontSize=8*iScreenScale+"px",l.appendChild(h);h=document.getElementById("infos"+i);h||((h=document.getElementById("infos0").cloneNode(!0)).id="infos"+i,$mkScreen.appendChild(h)),h.style.left=10+r+"px",h.style.top=10*iScreenScale+"px",h.style.width=iWidth*iScreenScale+"px",h.style.fontSize=16*iScreenScale+"px",h.style.fontFamily='"NSMBU", Impact',h.style.textAlign="center",h.style.textStroke=h.style.WebkitTextStroke=h.style.MozTextStroke=Math.round(iScreenScale/4)+"px "+primaryColor,h.style.visibility="hidden",h.style.display="",h.style.pointerEvents="none",h.innerHTML='3';var y=document.getElementById("scroller").cloneNode(!0);y.id="scroller"+i,y.className="itemScroller";y.style.left=iScreenScale+"px",y.style.top=Math.round(iScreenScale+ +iScreenScale)+"px",y.style.width=Math.round(26*iScreenScale/3)+"px",y.style.height=Math.round(18*iScreenScale/3-2*iScreenScale*1)+"px",y.style.lineHeight=iScreenScale+"px";for(var f=Math.round(4*iScreenScale),m=0;m=_){if(N=oMap.checkpoint.length&&(x=0),(P=oMap.checkpointCoords[x])&&(k=P.O[0],T=P.O[1],(I=Math.hypot(k-n.x,T-n.y)*Math.hypot(b[0]-C[0],b[1]-C[1]))&&(M-=150*((k-n.x)*(b[0]-C[0])+(T-n.y)*(b[1]-C[1]))/I)),M=oMap.checkpoint.length&&(x=0),(P=oMap.checkpointCoords[x])&&(k=P.O[0],T=P.O[1],(I=Math.hypot(k-n.x,T-n.y)*Math.hypot(b[0]-C[0],b[1]-C[1]))&&(M-=150*((k-n.x)*(b[0]-C[0])+(T-n.y)*(b[1]-C[1]))/I)),Mthis.duration-.44&&(this.currentTime=0,this.parentNode&&this.play())}function loopAfterIntro(e,t,a){var n;e.looper||(n=t+(a-=.15),e.looper=function(){this.currentTime>=n&&(this.currentTime-=a)},e.addEventListener("timeupdate",e.looper,!1))}function startEngineSound(){iSfx&&(carEngine=loadMusic("musics/events/engine.mp3",!0),carEngine2=loadMusic("musics/events/engine2.mp3",!1),carEngine3=loadMusic("musics/events/engine3.mp3",!1),carDrift=loadMusic("musics/events/drift.mp3",!1),carSpark=loadMusic("musics/events/spark.mp3",!1),(playingCarEngine=carEngine).addEventListener("timeupdate",loopWithoutGap,!1),carEngine2.addEventListener("timeupdate",loopWithoutGap,!1),carEngine.permanent=1,carEngine2.permanent=1,carEngine3.permanent=1,carDrift.permanent=1,carSpark.permanent=1,document.body.appendChild(carEngine),document.body.appendChild(carEngine2),document.body.appendChild(carEngine3),document.body.appendChild(carDrift),document.body.appendChild(carSpark))}function updateEngineSound(e){iSfx&&e!=playingCarEngine&&(playingCarEngine&&playingCarEngine.pause(),(playingCarEngine=e)&&playingCarEngine.play())}function startEndMusic(){bMusic&&(removeMenuMusic(!0),removeIfExists(mapMusic),removeIfExists(lastMapMusic)),iSfx&&removeSoundEffects(),bMusic&&(willPlayEndMusic=!0,setTimeout(function(){for(var e=document.getElementsByClassName("gamemusic"),t=[],a=0;a(new Date).getTime())&&oSpecCam.reset()),(itemDistribution=(itemDistribution=selectedItemDistrib)||itemDistributions[getItemMode()][0]).value||(itemDistribution={value:itemDistribution}),ptsDistribution=selectedPtDistrib,m){oMap.arme=[];for(e=0;e=oMap.h?oPlanWidth:oPlanWidth*(oMap.w/oMap.h);i=oMap.w<=oMap.h?oPlanWidth:oPlanWidth*(oMap.h/oMap.w);if(oMap.iW&&oMap.iH&&(U=Math.min(oMap.w/oMap.iW,oMap.h/oMap.iH),oPlanWidth2*=U,i*=U),oPlanWidth2=Math.round(oPlanWidth2),i=Math.round(i),oPlanSize=59*iScreenScale,oPlanSize2=oPlanWidth2,oPlanRealSize=oMap.w,oCharRatio=.8,oPlanRatio=.5,(oPlanDiv=document.createElement("div")).className="mkplan mkplanzoom",oPlanDiv.style.backgroundColor="rgb("+oMap.bgcolor+")",oPlanDiv.style.left=15+iScreenScale*iWidth+"px",oPlanDiv.style.top="9px",oPlanDiv.style.width=oPlanWidth+"px",oPlanDiv.style.height=oPlanWidth+"px",oPlanDiv.style.opacity=.01,(oPlanDiv2=document.createElement("div")).className="mkplan mkplanfull",oPlanDiv2.style.backgroundColor="rgb("+oMap.bgcolor+")",oPlanDiv2.style.width=oPlanWidth+"px",oPlanDiv2.style.height=oPlanWidth+"px",oPlanDiv2.style.opacity=.01,(oPlanCtn=document.createElement("div")).style.position="absolute",oPlanCtn.style.transformOrigin=oPlanCtn.style.WebkitTransformOrigin=oPlanCtn.style.MozTransformOrigin="left",(oPlanCtn2=document.createElement("div")).style.position="absolute",oPlanCtn2.style.left=Math.round((oPlanWidth-oPlanWidth2)/2)+"px",oPlanCtn2.style.top=Math.round((oPlanWidth-i)/2)+"px",oPlanCtn2.style.width=oPlanWidth2+"px",oPlanCtn2.style.height=i+"px",oMapImg.src?((oPlanImg=document.createElement("img")).src=oMapImg.src,oPlanImg.style.width=oPlanSize+"px"):(be=Math.round(oPlanSize*oMap.h/oMap.w),(oPlanImg=document.createElement("canvas")).width=oPlanSize,oPlanImg.height=be,oPlanImg.getContext("2d").drawImage(oMapImg,0,0,oPlanSize,be)),oPlanImg.className="mkplanimg",oPlanCtn.appendChild(oPlanImg),oMapImg.src?(oPlanImg2=document.createElement("img")).src=oMapImg.src:((oPlanImg2=document.createElement("canvas")).width=oPlanSize,oPlanImg2.height=be,oPlanImg2.getContext("2d").drawImage(oMapImg,0,0,oPlanSize,be)),oPlanImg2.className="mkplanimg",oPlanImg2.style.width=oPlanWidth2+"px",oPlanCtn2.appendChild(oPlanImg2),bSelectedMirror&&(oPlanImg.className=oPlanImg2.className="mirrored"),oMap.decor)for(var te in oMap.decor)oPlanDecor[te]=new Array,oPlanDecor2[te]=new Array;oMap.sea&&((oPlanSea=document.createElement("canvas")).style.position="absolute",oPlanSea.style.left="0px",oPlanSea.style.top="0px",oPlanSea.setAttribute("width",oPlanSize+"px"),oPlanSea.setAttribute("height",oPlanSize+"px"),oPlanCtn.appendChild(oPlanSea),(oPlanSea2=document.createElement("canvas")).style.position="absolute",oPlanSea2.style.left="0px",oPlanSea2.style.top="0px",oPlanSea2.setAttribute("width",oPlanWidth2+"px"),oPlanSea2.setAttribute("height",oPlanWidth2+"px"),oPlanCtn2.appendChild(oPlanSea2),bSelectedMirror&&(oPlanSea.className=oPlanSea2.className="mirrored"));for(e=0;e"+toLanguage("GO!","PARTEZ !")+"",document.getElementById("infos"+e).style.fontSize=12*iScreenScale+"px",document.getElementById("infos"+e).style.top=Math.round(12.5*iScreenScale)+"px",1==oPlayers[e].speed?oPlayers[e].speed=11:1 '+(a?"":' ')+' ',l.onkeydown=function(e){var t,a;switch(e.keyCode){case 38:t=-1;break;case 40:t=1;break;case 13:(a=document.activeElement)&&a.onclick&&l.contains(a)&&iSfx&&setTimeout(function(){document.onkeydown||playSoundEffect("musics/events/select.mp3")})}if(t&&(a=document.activeElement)){var n=Array.prototype.slice.call(document.querySelectorAll("#infos0 input, #infos0 button")),o=a,i=n.indexOf(a);if(-1!=i){var r=i;do{if((r+=t)<0&&(r+=n.length),r>=n.length&&(r=0),(o=n[r])&&"none"!=o.style.display&&"hidden"!=o.style.visibility){o.focus(),iSfx&&playSoundEffect("musics/events/move.mp3");break}}while(r!=i)}}},document.getElementById("reprendre").onclick=reprendre,document.getElementById("recommencer").onclick=function(){interruptGame(),removeGameMusics(),removeHUD(),clearResources();for(var e=0;e'+toLanguage("Spectator mode","Mode spectateur")+""+toLanguage("Switch player:","Changer de joueur :")+' ← →'+toLanguage("Exit: Escape","Quitter : Echap")+"",l.style.left=10+iScreenScale+"px",l.style.top=10+iScreenScale+"px",l.style.fontSize=Math.round(1.75*iScreenScale)+"px",l.style.display="",l.style.visibility="",document.body.style.cursor="default")),bCounting=!1},onlineSpectatorState?1:1e3),pause&&fInfos.replay){for(pause=!1,e=0;e=fTurboDriftCpt&&(oPlayers[0].turbodrift=15,clLocalVars.miniTurbo++,clSelected&&clRuleVars[clSelected.id]&&(t=clRuleVars[clSelected.id].mini_turbo)&&updateChallengeHud("miniTurbo",clLocalVars.miniTurbo+t.miniTurbo),oPlayers[0].driftcpt>=fTurboDriftCpt2&&(oPlayers[0].turbodrift+=15,clLocalVars.superTurbo++,clSelected&&clRuleVars[clSelected.id]&&(t=clRuleVars[clSelected.id].super_turbo)&&updateChallengeHud("superTurbo",clLocalVars.superTurbo+t.superTurbo)),oPlayers[0].turbodrift0=oPlayers[0].turbodrift,resetDriftSprite(oPlayers[0])),oPlayers[0].driftcpt=0,oPlayers[0].driftSound&&(oPlayers[0].driftSound.pause(),oPlayers[0].driftSound=void 0)),oPlayers[0].ctrled=!1,oPlayers[0].jumped&&(oPlayers[0].z||oPlayers[0].heightinc)&&(oPlayers[0].ctrled=!0);break;case"rear":clLocalVars.rearView||showRearView(0);break;case"item_p2":case"item_back_p2":case"item_fwd_p2":oPlayers[1].tourne||oPlayers[1].cannon||pause||arme(1,"item_back_p2"===e,"item_fwd_p2"===e);break;case"up_p2":if(!oPlayers[1])return;oPlayers[1].speedinc=0;break;case"left_p2":case"right_p2":if(!oPlayers[1])return;oPlayers[1].rotincdir=0;break;case"down_p2":if(!oPlayers[1])return;oPlayers[1].speedinc=0;break;case"jump_p2":if(pause)break;if(!oPlayers[1])return;delete oPlayers[1].ctrl,oPlayers[1].driftinc&&(oPlayers[1].driftinc=0,oPlayers[1].driftcpt>=fTurboDriftCpt&&(oPlayers[1].turbodrift=15,oPlayers[1].driftcpt>=fTurboDriftCpt2&&(oPlayers[1].turbodrift+=15),oPlayers[1].turbodrift0=oPlayers[1].turbodrift,resetDriftSprite(oPlayers[1])),oPlayers[1].driftcpt=0,oPlayers[1].driftSound&&(oPlayers[1].driftSound.pause(),oPlayers[1].driftSound=void 0)),oPlayers[1].ctrled=!1,oPlayers[1].jumped&&(oPlayers[1].z||oPlayers[1].heightinc)&&(oPlayers[1].ctrled=!0);break;case"rear_p2":if(!oPlayers[1])return;showRearView(1)}}(t))},window.releaseOnBlur=function(){if(!onlineSpectatorId){l={};for(var e=0;e'+(language?"+ Jump
Drift":"+ Saut
Dérapage")+"
",["up","jump"],0,0),ctrlSettings.autoacc&&(e.style.display="none"),addButtonLegacy(" ↑ ","up",1,0).id="virtualbtn-accelerate",addButtonLegacy("Obj","item",2,0,null,null,25),addButtonLegacy("❚❚","pause",3,0,null,null,25),document.getElementById("virtualkeyboard").appendChild(document.createElement("br")),document.getElementById("virtualkeyboard").appendChild(document.createElement("br")),addButtonLegacy(language?"Jump
Drift":"Saut
Dérapage","jump",0,1,null,null,11),addButtonLegacy(" ↓ ","down",1,1),addButtonLegacy(" ← ","left",2,1).id="virtualbtn-left",addButtonLegacy(" → ","right",3,1).id="virtualbtn-right";break;case"h_sym":t(!0),a(!0);break;case"v_sym":a(),t();break;case"vh_sym":a(!0),t(!0);break;default:t(),a()}if(i.ontouchstart=function(e){return e.preventDefault(),!1},i.className="shown","old"===ctrlSettings.layout){i.classList.add("legacy");return i.style.width=Math.round(288)+"px",i.style.height=Math.round(130)+"px",i.style.left=(iScreenScale*iWidth-288)/2+"px",void(i.style.top=40*iScreenScale+"px")}posVirtualKeyboard(i)}function posVirtualKeyboard(e){var t=iScreenScale*iHeight+20;e.style.top=t+"px";var a=e.offsetWidth,n=window.innerHeight-t,n=Math.min(n,Math.round(.45*a)),t=Math.min(window.innerWidth,iWidth*iScreenScale);aMath.max(.2,3*Math.abs(e)))return releaseKey("up"),pressKey("down"),0Math.max(50,3*Math.abs(t))?doReleaseKey(0window.innerHeight,window.turnOnRotate=function(e){var t,a;n&&n.dataset.pressed||o&&o.dataset.pressed||(e=i?(t=e.beta,90<=Math.abs(t)&&(t=Math.sign(t)*(180-Math.abs(t))),a=15,1):(t=e.gamma,90<=e.beta&&(t=-t),a=15,2),a=-Math.sign(t)*Math.pow(Math.abs(t/90),e)*a,rotateToAngle(oPlayers[0],a))},window.addEventListener("deviceorientation",window.turnOnRotate))}function setupVibrate(){navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate||function(){}}function showSpectatorKeyboard(){setupVibrate();var e=document.getElementById("virtualkeyboard");addButton("←",{key:"left",src:"left"}),addButton("→",{key:"right",src:"right"}),e.className="shown spectator",posVirtualKeyboard(e),e.style.height="40px"}var oPressedKeys={},oMusicEmbed;function pressKey(e){oPressedKeys[e]||doPressKey(e)}function doPressKey(e){oPressedKeys[e]=1,document.onkeydown&&document.onkeydown({keyAction:e})}function releaseKey(e){oPressedKeys[e]&&doReleaseKey(e)}function doReleaseKey(e){oPressedKeys[e]=void 0,document.onkeyup&&document.onkeyup({keyAction:e})}function rotateToAngle(e,t){var a=getMirrorFactor();clLocalVars.invertDirs&&(a=-a);var n,a=(t-angleInc(e)*a)/2;return a>e.stats.handling/2?n="left":a<-e.stats.handling/2&&(n="right"),"left"!==n&&releaseKey("left"),"right"!==n&&releaseKey("right"),n&&pressKey(n),{targetDir:a,action:n}}function youtube_parser(e){e=e.match(/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/);return!(!e||11!=e[1].length)&&e[1]}var fSpriteScale=0,fLineScale=0,oContainers=[document.createElement("div")],oPrevFrameStates;oContainers[0].className="game-container",oContainers[0].tabindex=1,formulaire=null,updateCtnFullScreen(1==$mkScreen.dataset.fs),function(){for(var e,t=0;t<2;t++)(e=document.getElementById("infos"+t))&&$mkScreen.removeChild(e);(e=document.createElement("table")).id="infos0",e.setAttribute("cellspacing",1),e.setAttribute("cellpadding",0),e.style.display="none",$mkScreen.appendChild(e)}(),$mkScreen.appendChild(oContainers[0]),pause&&fInfos.player[1]&&(oContainers[1]=oContainers[0].cloneNode(!1),oContainers[1].style.left=12+iWidth*iScreenScale+"px",$mkScreen.appendChild(oContainers[1]));var oScreens=new Array,aStrips=new Array,iCamHeight=24,iCamDist=32,iViewHeight=-10,fFocal=1/Math.tan(Math.PI*Math.PI/360);function resetScreen(){fSpriteScale=iScreenScale/4,fLineScale=1/iScreenScale*iQuality,aStrips=[];for(var e=0;ePlaces'+toLanguage("Team","Équipe")+"Pts",t=0;t'+toPlace(t+1)+' '+r+''+a[i]+""}return n.style.visibility="hidden",n.style.position="absolute",n.style.zIndex=2e4,n.style.left=Math.round(.5*iScreenScale+10)+"px",n.style.top=10*iScreenScale+"px",n.style.backgroundColor="blue",n.style.color=primaryColor,n.style.opacity=.7,n.style.textAlign="center",n.style.fontSize=Math.round(1.5*iScreenScale+2)+"pt",n.style.fontFamily="Courier",n.style.fontWeight="bold",n.style.fontFamily="arial",n.innerHTML=o,$mkScreen.appendChild(n),n}function resetScores(){for(var e=0;e ':' id="enregistrer">')+'';var oTeamTable=document.getElementById("team-table");oTeamTable&&$mkScreen.removeChild(oTeamTable);var oContinue=document.createElement("input"),forceClic3,oQuit,oSave,oReplay,oChangeRace,oClassement;oContinue.type="button",oContinue.style.fontSize=3*iScreenScale+"pt",oContinue.style.width="100%","CM"!=course?oMap.ref%4||"GP"!=course?(isSingle&&!isOnline?oContinue.value=" "+toLanguage(" REPLAY","REJOUER")+" ":"BB"==course?oContinue.value=toLanguage(" NEXT BATTLE\t ","BATAILLE SUIVANTE"):oContinue.value=toLanguage(" NEXT RACE\t ","COURSE SUIVANTE"),forceClic3=!0,oContinue.onclick=function(){forceClic3=!1,nextRace()},isOnline&&setTimeout(function(){forceClic3&&nextRace()},5e3)):(oContinue.value=toLanguage(" NEXT "," SUIVANT "),oContinue.onclick=function(){$mkScreen=document.body,interruptGame();var posX=[29,22,36],posY=[15,17,19],oPlace;document.body.innerHTML=toLanguage("You are","Vous êtes")+' !
'+toLanguage("Back","Retour")+'.';for(var placement=new Array,i=1;i<=aKarts.length;i++)for(var j=0;j';else if(oPlace)break}document.getElementById("position").innerHTML=toPlace(oPlace),oPlace<=3?(document.body.innerHTML+='.',saveParams="pts="+(4-oPlace),"MK"==page?(saveUrl="saveGP.php",saveParams+="&change="+(oMap.map-4)/4):nid&&(saveUrl="cupsave.php",saveParams+=isMCups?"&cup="+cupIDs[oMap.ref/4-1]:"&cup="+nid),saveUrl&&xhr(saveUrl,saveParams,function(reponse){if(reponse){var newPerso,uwPerso,uwPerso;try{newPerso=eval(reponse)}catch(e){return!1}return newPerso&&(uwPerso=toPerso(newPerso),uwPerso=uwPerso.charAt(0).toUpperCase()+uwPerso.substring(1),document.body.innerHTML+='
'+toLanguage("You can now play
with "+uwPerso+" !","Vous pouvez désormais
jouer avec "+uwPerso+" !")+'
'),!0}return!1}),bMusic&&(endGPMusic=startMusic("musics/menu/congrats.mp3",!0,700))):bMusic&&(endGPMusic=startMusic("musics/menu/toobad.mp3",!0,700)),reinitChallengeVars(),clLocalVars.endGP=!0,challengeCheck("end_gp")}):(oQuit=document.getElementById("quitter"),oContinue.style.fontSize=oQuit.style.fontSize=3*iScreenScale+"px",oSave=oContinue.cloneNode(!1),oReplay=oContinue.cloneNode(!1),oChangeRace=oContinue.cloneNode(!1),oClassement=oContinue.cloneNode(!1),oContinue.value=gSelectedPerso?toLanguage(" FACE WITH "," AFFRONTER "):toLanguage(" RETRY "," RÉESSAYER "),oContinue.onclick=function(){interruptGame(),removeGameMusics(),removeHUD(),clearResources(),$mkScreen.removeChild(oContainers[0]),fInfos={player:strPlayer,distribution:itemDistribution,ptsdistrib:ptsDistribution,cc:fSelectedClass,mirror:bSelectedMirror,double_items:oDoubleItemsEnabled,map:oMap.ref,difficulty:iDificulty,perso:gPersos,cpu_route:jTrajets,my_record:gRecord,ow_record:gOverwriteRecord,lap_times:iLapTimes,cl:clSelected},gSelectedPerso?(fInfos.player=[gSelectedPerso],jTrajets||(fInfos.perso=[strPlayer[0]],fInfos.cpu_route=[iTrajet])):2==gOverwriteRecord&&lapTimers.length==oMap.tours&&(fInfos.cpu_route=[iTrajet],fInfos.perso=strPlayer,fInfos.lap_times=lapTimers),document.getElementById("infos0").style.display="none",1==strPlayer.length&&removePlan(),oBgLayers.length=0,resetEvents(),resetApp()},oSave.value=" "+toLanguage("SAVE","ENREGISTRER")+" ",oSave.onclick=function(){document.getElementById("infos0").style.display="none";var oForm=document.createElement("form"),savedRecord;oForm.style.color="black",oForm.style.position="absolute",oForm.style.left=5*iScreenScale+10+"px",oForm.style.top=5*iScreenScale+10+"px",oForm.style.fontSize=4*iScreenScale+"pt",oForm.style.backgroundColor="#FF6",oForm.style.opacity=.8,oForm.style.border="double 4px black",oForm.style.textAlign="center",oForm.style.width=70*iScreenScale-10+"px",oForm.style.zIndex=2e4,oForm.onsubmit=function(){var nom=this.pseudo.value;if(nom){document.body.style.cursor="progress",oValide.style.visibility="hidden",aPara2.style.visibility="hidden";var params="name="+nom+"&perso="+strPlayer[0]+"&time="+getActualGameTimeMS()+"&cc="+getActualCc();switch(page){case"MK":params+="&circuit="+oMap.map;break;case"CI":params+="&creation="+oMap.id;break;case"MA":params+="&map="+oMap.map}function postSaveRecord(reponse){if(reponse){var enregistre;document.body.style.cursor="default";try{enregistre=eval(reponse)}catch(e){return!1}function showBackUi(e){oInput.disabled=!0,oCheckbox.disabled=!0,oValide.parentNode.removeChild(oValide),aPara2.style.fontSize=Math.round(2.5*iScreenScale)+"px",e&&(aPara2.innerHTML=toLanguage("Congratulations "+nom+", your score has been saved successfully ! You placed ","Félicitations "+nom+", votre score a bien été enregistré ! Vous êtes ")+toPlace(enregistre[0])+toLanguage(" out of "+enregistre[1]+" in this race !"," sur "+enregistre[1]+" au classement de ce circuit !"),oSave.style.display="none"),aPara2.style.visibility="",oRetour.focus()}function rollbackUi(){oValide.style.visibility="",oValide.style.marginRight=2*iScreenScale+"px",aPara3.insertBefore(oValide,oRetour),oCheckbox.disabled=!1,oInput.disabled=!1,oInput.select()}if(Array.isArray(enregistre))if(savedRecord=enregistre,oCheckbox.checked){oSave.style.display="none",oValide.style.display="none";var aSmall=document.createElement("span");aSmall.style.fontSize=Math.round(2.5*iScreenScale)+"px",aSmall.innerHTML=toLanguage("Saving ghost...","Enregistrement du fantôme..."),aPara2.appendChild(aSmall),aPara2.style.visibility="";var oRequest="map="+getCreationId(oMap)+"&type="+getCreationTable()+"&perso="+strPlayer[0]+"&time="+getActualGameTimeMS()+"×="+JSON.stringify(lapTimers)+"&cc="+getActualCc();for(i=0;idelete ghosts to save space','Vous avez dépassé votre quota de fantômes enregistrés. Vous pouvez supprimer des fantômes pour gagner de l\'espace'),rollbackUi(),!0)})}else showBackUi(!0);else{switch(showBackUi(!1),enregistre){case 0:aPara2.innerHTML=toLanguage("You did a better score on this race before.
Your score has not been registered.","Vous avez fait un meilleur score sur ce circuit.
Votre temps n'a donc pas été enregistré.");break;case 1:aPara2.innerHTML=toLanguage('This username is already used, please choose another one. If it\'s you, log-in to your account and try again.','Ce pseudo est déjà utilisé, veuillez en choisir un autre. S\'il s\'agit de vous, connectez-vous et réessayez.');break;default:aPara2.innerHTML=toLanguage("An unknown error occured, please try again later","Une erreur inconnue est survenue, veuillez réessayer ultérieurement")}0!=enregistre&&rollbackUi()}return!0}return!1}savedRecord?postSaveRecord(savedRecord):xhr("records.php",params,postSaveRecord),recorder=nom}return!1};var aPara1=document.createElement("p");aPara1.innerHTML=toLanguage("Username: ","Pseudo : "),aPara1.style.margin=iScreenScale+"px";var oInput=document.createElement("input");oInput.type="text",oInput.name="pseudo",oInput.value=recorder,oInput.size=15,oInput.maxlength=18,oInput.style.fontSize=3*iScreenScale+"px",oInput.onkeydown=function(e){e.stopPropagation()},oInput.onkeyup=function(e){e.stopPropagation()},aPara1.appendChild(oInput);var aPara12=aPara1.cloneNode(!1),oCheckLabel=document.createElement("label");oCheckLabel.style.display="inline-block";var oCheckbox=document.createElement("input");oCheckbox.type="checkbox",oCheckbox.name="saveghost",oCheckbox.checked=!0,oCheckbox.style.transform=oCheckbox.style.WebkitTransform=oCheckbox.style.MozTransform="scale("+(iScreenScale/6).toFixed(1)+")",oCheckLabel.appendChild(oCheckbox);var oCheckSpan=document.createElement("span");oCheckSpan.style.fontSize=2*iScreenScale+"px",oCheckSpan.innerHTML=" "+toLanguage("Save ghost","Enregistrer le fantôme"),oCheckLabel.appendChild(oCheckSpan),aPara12.appendChild(oCheckLabel),gRecord<=timerMS&&(oCheckbox.checked=!1,aPara12.style.display="none");var aPara2=aPara1.cloneNode(!1),oValide=document.createElement("input");oValide.type="submit",oValide.value=" "+toLanguage("Submit","Valider")+" ",oValide.style.fontSize=5*iScreenScale+"px",oValide.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",oRetour.style.fontSize=4*iScreenScale+"px"},aPara2.appendChild(oValide);var aPara3=aPara1.cloneNode(!1),oRetour=document.createElement("input");oRetour.type="button",oRetour.value=" "+toLanguage("Back","Retour")+" ",oRetour.style.fontSize=4*iScreenScale+"px",oRetour.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",oValide.style.fontSize=4*iScreenScale+"px"},oRetour.onclick=function(){$mkScreen.removeChild(oForm),document.getElementById("infos0").style.display="",oContinue.focus()},aPara3.appendChild(oRetour),oForm.appendChild(aPara1),oForm.appendChild(aPara12),oForm.appendChild(aPara2),oForm.appendChild(aPara3),$mkScreen.appendChild(oForm),oForm.style.height=oForm.scrollHeight+"px",oInput.select()},gSelectedPerso&&(oSave.style.display="none"),document.getElementById("enregistrer").appendChild(oSave),oReplay.value=toLanguage("REPLAY","REVOIR"),oReplay.onclick=function(){interruptGame(),removeGameMusics(),removeHUD(),clearResources();for(var e=0;eiHeight*iScreenScale||t+n*iScreenScale<9*iScreenScale?l[o][0].style.display="none":(l[o][0].style.display="block",l[o][0].style.left=Math.round(e-i/2)+"px",l[o][0].style.top=Math.round(a)+"px",this.h!=this.w?l[o][1].style.width=Math.round(i)*this.nbSprites+"px":l[o][1].style.width="",l[o][1].style.height=Math.round(r)+"px",l[o][0].style.width=Math.round(i)+"px",l[o][0].style.height=Math.round(r)+"px",l[o][1].style.left=-(Math.round(i)*l[o][2])+"px")},this[t].render=function(e,t){var a=t.size||1,n=(t.x-e.x)*getMirrorFactor(),o=t.y-e.y,i=e.rotation*Math.PI/180*getMirrorFactor(),e=n*Math.cos(i)-o*Math.sin(i),n=n*Math.sin(i)+o*Math.cos(i),o=-iCamHeight,i=iCamDist+n,t=t.z?correctCamZ(t.z,i):0,i=o/i*iCamDist+iCamHeight-iViewHeight+t,e=-e/(n+iCamDist)*iCamDist;this.div.style.zIndex=Math.round(1e4-n);e=(iWidth/2+e)*iScreenScale,i=(iHeight-i)*iScreenScale,a*=fFocal/(fFocal+n);this.draw(e,i,a,t)},this[t].setState=function(e){l[this.i][2]=e},this[t].getState=function(){return l[this.i][2]},this[t].div=n,this[t].img=a,l.push([n,a,0])}var o=this;this[0].unshow=function(){o[0].suppr(),o[0].unshown=!0},this[0].suppr=function(){if(!o[0].unshown)for(var e=0;e>3]&1<<(7&s)&&(o|=1<=c.length?c.push(c[i].concat(c[i][0])):i!==p&&c.push(c[i].concat(c[o][0])),l=(r=c[o]).length,a=0;a>2,C.transparencyGiven=!!(1&e),C.delayTime=n.data[n.pos++]+(n.data[n.pos++]<<8),C.transparencyIndex=n.data[n.pos++],n.pos++):t===s.COMMENT?C.comment+=n.readSubBlocks():t===s.APPExt?(n.pos+=1,"NETSCAPE"===n.getString(8)?n.pos+=8:(n.pos+=3,n.readSubBlocks())):(t===s.UNKNOWN&&(n.pos+=13),n.readSubBlocks())}function y(){if(void 0!==C.cancel&&!0===C.cancel)return m(),void("function"==typeof C.cancelCallback&&C.cancelCallback.bind(C)({type:"canceled",path:[C]}));var e=n.data[n.pos++];if(e===s.IMAGE){if(d(),C.firstFrameOnly)return void m()}else{if(e===s.EOF)return void m();g()}C.frames.length&&"function"==typeof C.onloadone&&(C.image=C.frames[0].image,C.onloadone.bind(C)({type:"load",path:[C]}),delete C.onloadone),"function"==typeof C.onprogress&&C.onprogress({bytesRead:n.pos,totalBytes:n.data.length,frame:C.frames.length}),t=setTimeout(y,0)}function f(e){"function"==typeof C.onerror&&C.onerror.bind(this)({type:e,path:[this]}),C.onload=C.onerror=void 0,C.loading=!1}function S(){C.currentFrame=0,C.nextFrameAt=C.lastFrameAt=(new Date).valueOf(),"function"==typeof C.onload&&C.onload.bind(C)({type:"load",path:[C]}),C.onerror=C.onload=void 0}function v(e){(n=new c(e)).pos+=6,C.width=n.data[n.pos++]+(n.data[n.pos++]<<8),C.height=n.data[n.pos++]+(n.data[n.pos++]<<8),e=n.data[n.pos++],C.colorRes=(112&e)>>4,C.globalColourCount=1<<1+(7&e),C.bgColourIndex=n.data[n.pos++],n.pos++,128&e&&(C.globalColourTable=p(C.globalColourCount)),t=setTimeout(y,0)}function b(){var e;0===C.playSpeed?C.pause():(e=C.playSpeed<0?(--C.currentFrame,C.currentFrame<0&&(C.currentFrame=C.frames.length-1),e=C.currentFrame,--e<0&&(e=C.frames.length-1),-C.frames[e].delay/C.playSpeed):(C.currentFrame+=1,C.currentFrame%=C.frames.length,+C.frames[C.currentFrame].delay/C.playSpeed),C.image=C.frames[C.currentFrame].image,a=setTimeout(b,e))}var C={onload:null,onerror:null,onprogress:null,onloadall:null,paused:!1,playing:!1,waitTillDone:!0,loading:!1,firstFrameOnly:!1,width:null,height:null,frames:[],comment:"",length:0,currentFrame:0,frameCount:0,playSpeed:1,lastFrame:null,image:null,playOnLoad:!0,load:function(e){var t=new XMLHttpRequest;t.responseType="arraybuffer",t.onload=function(e){404===e.target.status?f("File not found"):200<=e.target.status&&e.target.status<300?v(t.response):f("Loading error : "+e.target.status)},t.open("GET",e,!0),t.send(),t.onerror=function(e){f("File error")},this.src=e,this.loading=!0},cancel:function(e){return!C.complete&&(C.cancelCallback=e,C.cancel=!0)},play:function(){C.playing||(C.paused=!1,C.playing=!0,b())},pause:function(){C.paused=!0,C.playing=!1,clearTimeout(a)},seek:function(e){clearTimeout(a),e<0&&(e=0),e*=1e3,e%=C.length;for(var t=0;e>C.frames[t].time+C.frames[t].delay&&tiHeight*iScreenScale||a+o*iScreenScale<12*iScreenScale?i.style.display="none":(i.style.display="block",n=Math.round(r.sprite[e].h*fSpriteScale*n),i.style.left=Math.round(t)+"px",i.style.top=Math.round(a-n/2)+"px")},e.render=function(e,t,a){var n=a.size||1,o=(a.x-t.x)*getMirrorFactor(),i=a.y-t.y,r=t.rotation*Math.PI/180*getMirrorFactor(),t=o*Math.cos(r)-i*Math.sin(r),o=o*Math.sin(r)+i*Math.cos(r),i=-iCamHeight,r=iCamDist+o,a=correctCamZ(a.z,r),r=i/r*iCamDist+iCamHeight-iViewHeight+a,t=-t/(o+iCamDist)*iCamDist;this.div[e].style.zIndex=Math.round(1e4-o);t=(iWidth/2+t)*iScreenScale,r=(iHeight-r)*iScreenScale,n*=fFocal/(fFocal+o);this.draw(e,t,r,n,a)},e}var prevScreenCur=0,prevScreenOpacity=0,prevScreenFade=0;function clonePreviousScreen(e,t){if(prevScreenDelay){var a=oPrevFrameStates[e];a[prevScreenCur].canvas.getContext("2d").drawImage(oScreens[e],0,0);for(var n=0;n=r&&(t.countstate++,t.countdown=0,t.countstate>=i.countdowns.length&&detruit(t))},del:function(e){if(e.sprites){for(var t=0;tMath.PI&&(p=d-p),Math.abs(p)>Math.PI/2)return h=c.using[0].x,g=c.using[0].y,t.x=h,t.y=g,"bobomb"===c.using[0].type&&touche_bobomb(h,g,onlyThisItems([c.using[0]]))?void 0:(detruit(t),void(c.using[0]&&detruit(c.using[0],!0)));c.using[0].x-=2*direction(0,c.rotation),c.using[0].y-=2*direction(1,c.rotation)}t.x=h,t.y=g,a=4}else{I=Math.sqrt(I);var u=(c.x-t.x)*o/I,m=(c.y-t.y)*o/I,h=t.x+u,g=t.y+m;75=y.length&&(t.aipoint=0)));else if(!t.z){if(r&&(0<=t.aipoint||0<=t.target)&&!(50=u.length&&(e.aipoint=0))),-1==e.aipoint)if(0=e[4].length&&(e[5]-=2,e[6]=-1))}}},fire3star:{unbreaking:!0,transparent:!0,hidden:!0,preinit:function(e){oMap.decor.fireballs||(oMap.decor.fireballs=new Array),this.linkedSprite={type:"fireballs",start:oMap.decor.fireballs.length};for(var t=0;tr*r&&(e[5]=-1)}for(a=0;a=r.length&&(e[6]=0)):(a+=s*t/l,n+=c*t/l,t=0),0i+o?e[4]-=o:e[4]=i);for(var p=0;p=e[4].length&&(e[5]-=2,e[6]=-1);var c,p=e[4][e[5]];c=!i||0=e[4].length&&(e[5]=0),a-=l):(e[0]+=i*a/l,e[1]+=r*a/l,a=0)}var s=e[4][e[5]],c=e[4][(e[5]||e[4].length)-1],p=180*Math.atan2(s[0]-c[0],s[1]-c[1])/Math.PI;if(!isNaN(p))for(var d=0;do&&(a=o*Math.sign(a),e[5][3]=-e[5][3]),a+=Math.sqrt(2*(Math.cos(a)-Math.cos(t)))/16*e[5][3],e[4]=a;e[0]=e[5][0]+30*Math.sin(a)*Math.sin(n),e[1]=e[5][1]+30*Math.sin(a)*Math.cos(n);for(var i=-6*(1-Math.cos(a)),r=0;r=itemDistribution.value.length&&(e=itemDistribution.value.length-1,n=itemDistribution.value.length);for(var i,r=e;r'}var syncItems=[];function detruit(e,t){isOnline&&((e=getItemToDestroy(e)).deleted=1,syncItems.push(e)),supprime(e,t)}function supprime(e,t){var a=e.type,n=items[a].indexOf(e);if(-1!=n){var o=itemBehaviors[a];if(e.sprite){for(var i=0;ia[0]&&e<=a[0]+a[2]&&t>a[1]&&t<=a[1]+a[3]}function pointInPolygon(e,t,a){for(var n=!1,o=0,i=a.length-1;o=o[s]:i[s]>=o[s]+o[s+2]&&i[s]+r[s]<=o[s]+o[s+2]){var p=1-s,c=i[p]+((c?o[s]:o[s]+o[s+2])-i[s])*r[p]/r[s];if(c>=o[p]&&c<=o[p]+o[2+p])return 1}}}function pointCrossPolygon(e,t,a,n,o){for(var i=0;ih[0]-d&&lh[1]-d&&sh[0]-d&&eh[1]-d&&toMap.w-5||t>oMap.h-5||e<4||t<4)return 1}else if(e>=oMap.w||t>=oMap.h||e<0||t<0)return 1;for(var g=0,y=oMap.collision.rectangle,m=0;moMap.w-5||s>oMap.h-5||l<4||s<4)return}else if(l>=oMap.w||s>=oMap.h||l<0||s<0)return;for(m=0;moMap.w-5||f<4)&&(y.dir=[0,oMap.h]),(S>oMap.h-5||S<4)&&(y.dir=[oMap.w,0])):((f>=oMap.w||f<0)&&(y.dir=[0,oMap.h]),(S>=oMap.h||S<0)&&(y.dir=[oMap.w,0]))),oMap.decor&&!a.skipDecor)for(var n in oMap.decor)for(var o=0;oi[0]-7&&ei[1]-7&&tn.x-5&&en.y-5&&toMap.w?(e=oMap.w-.5,c=!0):e<=0&&(e=.5,c=!0),t>oMap.h?(t=oMap.h-.5,c=!0):t<=0&&(t=.5,c=!0),oMap.trous)for(var o in oMap.trous){for(var i=oMap.trous[o].rectangle,r=0;r"+t.title+": "+t.value+""+(null!=t.out_of?"/"+t.out_of+"":""),t=a.getElementsByTagName("span"),oChallengeCpts.appendChild(a),clHud[e]={$cpt:a,$label:t[0],$value:t[1],$outOf:t[2]})}function updateChallengeHud(e,t){clHud[e]&&(clHud[e].$value.innerText=t)}var challengeRules={finish_circuit:{verify:"end_game",is_tt_compatible:!0,reset_on_fail:!0,success:lambdaReturnsTrue},finish_circuit_first:{verify:"end_game",is_tt_compatible:!0,reset_on_fail:!0,success:function(e){return"CM"!=course&&1==oPlayers[0].place}},finish_circuit_time:{verify:"end_game",is_tt_compatible:!0,reset_on_fail:!0,success:function(e){return getActualGameTime()<=e.value}},finish_arena:{verify:"end_game",reset_on_fail:!0,success:lambdaReturnsTrue},finish_arena_first:{verify:"end_game",reset_on_fail:!0,success:function(e){return 1==oPlayers[0].place}},hit:{verify:"each_hit",initLocalVars:function(e){clLocalVars.myItems=[],clLocalVars.nbHits=0},initSelected:function(e){addChallengeHud("hits",{title:toLanguage("Hits","Touchés"),value:clLocalVars.nbHits,out_of:e.value})},success:function(e){if(clLocalVars.nbHits>=e.value)return!0}},eliminate:{verify:"each_kill",initLocalVars:function(e){clLocalVars.myItems=[],clLocalVars.killed=[],clLocalVars.nbKills=0,clLocalVars.nbHits=0},initSelected:function(e){addChallengeHud("kills",{title:toLanguage("Defeated","Eliminés"),value:clLocalVars.nbKills,out_of:e.value})},success:function(e){if(clLocalVars.nbKills>=e.value)return!0}},survive:{verify:"each_frame",success:function(e){if(getActualGameTime()>=e.value)return!0}},reach_zone:{verify:"each_frame",initLocalVars:function(e){e.zones||(e.zones=classifyByShape(e.value))},success:function(e){for(var e=e.zones,t=oPlayers[0].x,a=oPlayers[0].y,n=e.rectangle,o=0;o=o.length)return!0}}}},hit_items:{verify:"each_item",initLocalVars:function(e){clLocalVars.nbItems=0,clLocalVars.itemsHit=[],setTimeout(function(){clLocalVars.itemsHit.length=oMap.arme.length})},initSelected:function(e){setTimeout(function(){addChallengeHud("items",{title:toLanguage("Items","Objets"),value:clLocalVars.nbItems,out_of:oMap.arme.length})})},success:function(e){if(clLocalVars.nbItems>=oMap.arme.length)return!0}},collect_coins:{verify:"each_coin",initLocalVars:function(e){clLocalVars.nbCoins=0,e.nb||(e.nb=e.value.length)},initSelected:function(e){if(!oMap.coins){oMap.coins=[];for(var t=0;t=e.nb)return!0}},destroy_decors:{verify:"each_decor_hit",initLocalVars:function(t){var e;clLocalVars.nbDecorHits||(clLocalVars.nbDecorHits={}),clLocalVars.nbDecorHits[t.value]=0,t.nb||(e=oMap.decor[t.value]||[],t.nb=e.length,t.shouldInitToAll=!0),t.shouldInitToAll&&setTimeout(function(){var e=oMap.decor[t.value]||[];t.nb=e.length})},initSelected:function(e){setTimeout(function(){addChallengeHud("decors",{title:toLanguage("Destroyed","Détruit"),value:0,out_of:e.nb})})},success:function(e){if(clLocalVars.nbDecorHits[e.value]>=e.nb)return!0}},gold_cup:{verify:"end_gp",initRuleVars:function(){return{nbcircuits:0}},success:function(e,t){if(clLocalVars.endGP&&4==t.nbcircuits)return 1==oPlayers[0].place},next_circuit:function(e){e.nbcircuits++}},gold_cups:{verify:"end_gp",initRuleVars:function(e){return{challenge:e,nbcircuits:0}},success:function(e,t){if(clLocalVars.endGP&&4==t.nbcircuits)return 1==oPlayers[0].place},post_success:function(e,t){var a=(a=getSessionStorage("cl"+t.challenge.id+".gold_cups"))||"{}";if(a=JSON.parse(a),t.challenge.data.constraints.every(e=>"cc"===e.type))for(var n=0;n"cc"===e.type))for(var n=0;n=e.value?(deleteSessionStorage("cl"+t.challenge.id+".gold_cups"),!0):(setSessionStorage("cl"+t.challenge.id+".gold_cups",JSON.stringify(a)),showChallengePartialSuccess(t.challenge,{nb:Object.keys(a).length,total:e.value}),!1)},next_circuit:function(e){e.nbcircuits++}},finish_circuits_first:{verify:"end_game",initRuleVars:function(){return{nbcircuits:1}},initSelected:function(e,t){t&&t.nbcircuits&&addChallengeHud("races",{title:"BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),value:t.nbcircuits,out_of:e.value})},success:function(e,t){return 1==oPlayers[0].place&&(t.nbcircuits>=e.value||void 0)},next_circuit:function(e){e.nbcircuits++}},pts_greater:{verify:"end_game",initRuleVars:function(){return clGlobalVars.nbcircuits?{}:{nbcircuits:1,initialscore:0}},initSelected:function(e,t){t&&t.nbcircuits&&addChallengeHud("races",{title:"BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),value:t.nbcircuits,out_of:e.value})},success:function(e,t){if(t.nbcircuits==e.value&&aScores[0]>=e.pts)return!0},next_circuit:function(e){e.nbcircuits++}},pts_equals:{verify:"end_game",initRuleVars:function(){return clGlobalVars.nbcircuits?{}:{nbcircuits:1}},initSelected:function(e,t){t&&t.nbcircuits&&addChallengeHud("races",{title:"BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),value:t.nbcircuits,out_of:e.value})},success:function(e,t){if(t.nbcircuits==e.value&&aScores[0]==e.pts)return!0},next_circuit:function(e){e.nbcircuits++}},game_mode:{success:function(e){return course==["VS","CM"][e.value]}},game_mode_cup:{success:function(e){return course==["GP","VS"][e.value]}},difficulty:{success:function(e){return iDificulty==4+.5*(2-e.value)}},no_teams:{success:function(e){return!iTeamPlay}},participants:{success:function(e){return aKarts.length==e.value}},cc:{initRuleVars:function(e,t){return{relSpeed:getRelSpeedFromCc(+t.value)}},success:function(e,t){if(t)return t.relSpeed===fSelectedClass&&(null===e.mirror||!e.mirror==!bSelectedMirror)}},balloons:{success:function(e){return(!oPlayers[0].lost||clLocalVars.gagnant==oPlayers[0])&&oPlayers[0].ballons.length+oPlayers[0].reserve>=e.value}},balloons_lost:{initSelected:function(e,t){addChallengeHud("balloons",{title:toLanguage("Balloons","Ballons"),value:clLocalVars.lostBalloons,out_of:e.value})},success:function(e){return(!oPlayers[0].loose||clLocalVars.gagnant==oPlayers[0])&&clLocalVars.lostBalloons<=e.value}},balloons_inflate:{initSelected:function(e,t){addChallengeHud("inflated",{title:toLanguage("Inflated","Gonflés"),value:clLocalVars.inflatedBalloons,out_of:e.value})},success:function(e){return clLocalVars.inflatedBalloons<=e.value}},balloons_player:{initRuleVars:function(){return{}},initSelected:function(e,t){t.selected=!0,clLocalVars.isSetup=!0,oPlayers[0].reserve=e.value-oPlayers[0].ballons.length,updateBalloonHud(document.getElementById("compteur0"),oPlayers[0])},success:function(e,t){return!!t.selected}},balloons_cpu:{initRuleVars:function(){return{}},initSelected:function(e,t){t.selected=!0,clLocalVars.isSetup=!0;for(var a=oPlayers.length;a=e.value}},start_pos:{initSelected:function(e){if(clLocalVars.startPos=e.value,clLocalVars.isSetup=!0,e.no_cpu){aKarts.length=strPlayer.length;for(var t=0;t=e.value)return!0},next_circuit:function(e){e&&(e.miniTurbo+=clLocalVars.miniTurbo)}},super_turbo:{initRuleVars:function(){return{superTurbo:0}},initSelected:function(e,t){t&&addChallengeHud("superTurbo",{title:"Super Turbos",value:clLocalVars.superTurbo+t.superTurbo,out_of:e.value})},success:function(e,t){if(t&&t.superTurbo+clLocalVars.superTurbo>=e.value)return!0},next_circuit:function(e){e&&(e.superTurbo+=clLocalVars.superTurbo)}},stunts:{initRuleVars:function(){return{stunts:0}},initSelected:function(e,t){t&&addChallengeHud("stunts",{title:toLanguage("Tricks","Figures"),value:clLocalVars.stunts+t.stunts,out_of:e.value})},success:function(e,t){if(t&&t.stunts+clLocalVars.stunts>=e.value)return!0},next_circuit:function(e){e&&(e.stunts+=clLocalVars.stunts)}},position:{success:function(e){if(oPlayers[0].place==e.value)return!0}},position_lower:{success:function(e){if(oPlayers[0].place<=e.value)return!0}},with_pts:{verify:"end_game",initRuleVars:function(){return clGlobalVars.nbcircuits?{}:{firstAttempt:!0}},success:function(e,t){if(t.firstAttempt&&aScores[0]>=e.value)return!0}},different_circuits:{initRuleVars:function(){return{played_circuits:{}}},success:function(e,t){return!t.played_circuits[oMap.ref]},next_circuit:function(e){e.played_circuits[oMap.ref]=!0}}};function addCreationChallenges(e,t){t=challenges[e][t];if(t)for(var a=t.list,n=0;nstar

'+n+'

'+o+'
'+i+'
",(t=document.getElementsByClassName("challenge-popup")).length?$mkScreen.insertBefore(a,t[0]):$mkScreen.appendChild(a),r=0,function e(){r<1?(a.style.opacity=r,r+=.2,setTimeout(e,40)):a.style.opacity=1}(),focusOnChallengeClose())}function showChallengePopup(t,a){if(!document.getElementById("challenge-popup-"+t.id)){var e=a.pts,n=document.createElement("div");n.id="challenge-popup-"+t.id,n.className="challenge-popup",n.style.width=56*iScreenScale+"px",n.style.left=12*iScreenScale+"px",n.style.top=Math.round(4.5*iScreenScale)+"px",n.style.padding=Math.round(1.5*iScreenScale)+"px",n.style.paddingBottom=5*iScreenScale+"px",n.style.border="inset "+Math.round(.5*iScreenScale)+"px #7B0",n.style.fontSize=2*iScreenScale+"px",n.style.opacity=0;var o=language?"Challenge completed!":"Défi réussi !",i=t.description.main,r=(language?"You receive a reward of "+e+" pt"+(2<=e?"s":"")+".":"Vous recevez "+e+" pt"+(2<=e?"s":"")+" en récompense.")+"
",l="";a.pts_advent&&(s=(c=a.pts_advent)+"",a.pts_advent_extra&&(s+="+"+a.pts_advent_extra,c+=a.pts_advent_extra),l='
🎁 '+(language?"Advent calendar: you receive a bonus reward of "+s+" pt"+(2<=c?"s":"")+"!!":"Calendrier de l'avent : vous recevez un bonus de "+s+" pt"+(2<=c?"s":"")+" !!")+"
",e||(e=!0,r=""));var s=language?"Your challenge points go from "+a.pts_before+" to "+a.pts_after+"!":"Vos points défis passent de "+a.pts_before+" à "+a.pts_after+" !",c=language?"Close":"Fermer";if(n.innerHTML='
star

'+o+'

'+i+"
"+(e?'
'+r+l+s+"
":"")+(0<=a.rating?'
'+toLanguage("Rate this challenge:","Notez ce défi :")+'
'+toLanguage("Thanks","Merci")+"
":"")+(a.publish?'
'+toLanguage("You can now","Vous pouvez maintenant")+' '+toLanguage("publish challenge","publier le défi")+".
":"")+'",0<=a.rating){var p=n.getElementsByClassName("challenge-rating-stars");(p=p[0]).style.position="relative",p.style.marginLeft=Math.round(.4*iScreenScale)+"px",p.style.marginRight=Math.round(.4*iScreenScale)+"px",p.style.top=Math.round(.4*iScreenScale)+"px";function d(){for(var e=+this.rating,t=0;t"+e.name+"!":"Vous pouvez désormais jouer avec "+e.name+" !",(i=document.createElement("img")).src=getSpriteSrc(e.sprites),i.alt=e.name,i.className="pixelated",i.style.visibility="hidden",o=language?"Close":"Fermer",t.innerHTML='
star

'+a+'

'+n+'
",t.getElementsByClassName("challenge-popup-reward-ch")[0].appendChild(i),i.onload=function(){var e=this.parentNode,t=iScreenScale/8,a=Math.round(t*this.naturalWidth/24),t=Math.round(t*this.naturalHeight);e.style.width=a+"px",e.style.height=t+"px",this.style.width=24*a+"px",this.style.height=t+"px",this.style.visibility=""},(i=document.getElementsByClassName("challenge-popup")).length?$mkScreen.insertBefore(t,i[0]):$mkScreen.appendChild(t),r=0,function e(){r<1?(t.style.opacity=r,r+=.2,setTimeout(e,40)):t.style.opacity=1}())}function focusOnChallengeClose(){var e=document.querySelectorAll(".challenge-popup .challenge-popup-close a");e.length?e[e.length-1].focus():(e=document.getElementById("reprendre"))?e.focus():(e=document.getElementById("octn"))&&e.focus()}function showClSelectedPopup(){var t=document.createElement("div");t.style.fontSize=2*iScreenScale+"px",t.className="clselected-popup",t.style.left=27*iScreenScale+"px",t.style.top=iHeight*iScreenScale+"px",t.innerHTML='
'+toLanguage("Challenge selected :","Défi sélectionné:")+" "+(clSelected.name||clSelected.description.main)+"
",t.querySelector(".clselected-close a").onclick=function(){return document.body.removeChild(t),!1},document.body.appendChild(t);var a=1;setTimeout(function e(){0o.x-4&&eo.y-4&&to.x-4&&eo.y-4&&tn.x-4&&en.y-4&&to.x-4&&eo.y-4&&ta.x-5&&ea.y-5&&ta.x-5&&ea.y-5&&ti.x-5&&ei.y-5&&t=oMap.checkpoint.length&&(t=0);var a=oMap.checkpointCoords[t];if(!a)return 0;var n=projete(e.x,e.y,a.A[0],a.A[1],a.B[0],a.B[1]),t=a.A[0]+n*a.u[0],a=a.A[1]+n*a.u[1],a=Math.hypot(t-e.x,a-e.y);return e.tours*oMap.checkpoint.length+getCpScore(e)-a/1e4}function getRankScores(){return aKarts.map(function(e){return getRankScore(e)})}function places(e,t,a){for(var n=aKarts[e],o=!a,i=0;ioMap.tours||r.loose?onlineSpectatorId&&!finishing&&(document.getElementById("infoPlace"+i).style.visibility="hidden"):o=!1}if(!o){var l=1;if("BB"==course||!(n.tours>oMap.tours)&&oMap.checkpoint.length){for(var s=t[e],i=0;iaKarts[i].initialPlace)&&l++}n.loose||(n.place=l),finishing||(e=getScreenPlayerIndex(e))=oMap.checkpoint.length&&(r=0,i++);var l=oMap.checkpointCoords[r],s=l.O[0],l=l.O[1];a+=Math.hypot(s-n,l-o),n=s,o=l}return a+=Math.hypot(t.x-n,t.y-o)}function checkpoint(e,t,a){var n,o=[e.x-t,e.y-a],i=200=oMap.checkpoint.length&&(d-=oMap.checkpoint.length),d!=l;d++)if(!oMap.checkpoint[d][4]){p=!1;break}if(p)return l==n||void(e.demitours=l)}}}function getCheckpointCoords(e){var t=e[0],a=e[1],n=e[2];switch(e[3]){case 0:case 1:var o=e[3],i={A:[t,a],u:[o?n:0,o?0:n],v:[o?0:15,o?15:0],O:[t+(o?n/2:8),a+(o?8:n/2)]};break;default:var r=e[3]*Math.PI/2,l=Math.cos(r),s=Math.sin(r),c=t+7.5,p=a+7.5,o=e[2]/2-7.5,r=c+o*s,c=p+o*l,p=n*s,o=15*l,l=-n*l,s=15*s;i={A:[r-(p+o)/2,c-(l+s)/2],u:[p,l],v:[o,s],O:[r,c]}}return i.B=[i.A[0]+i.u[0],i.A[1]+i.u[1]],i.C=[i.A[0]+i.v[0],i.A[1]+i.v[1]],i.D=[i.B[0]+i.v[0],i.B[1]+i.v[1]],i}function int8ToHexString(e){return[].slice.call(e).map(function(e){return e.toString(16).padStart(2,"0")}).join("")}function hexStringToInt8(e){return new Uint8Array(e.match(/../g).map(function(e){return parseInt(e,16)})).buffer}function itemDataToHex(e,t){switch(e){case"double":return int8ToHexString(new Uint8Array(new Float64Array([t]).buffer,0,8));case"float":return int8ToHexString(new Uint8Array(new Float32Array([t]).buffer,0,4));case"int":return int8ToHexString(new Uint8Array(new Int32Array([t]).buffer,0,4));case"short":return int8ToHexString(new Uint8Array(new Int16Array([t]).buffer,0,2));case"byte":return int8ToHexString(new Uint8Array(new Int8Array([t]).buffer,0,1))}}function hexToItemData(e,t){switch(e){case"double":return new Float64Array(hexStringToInt8(t))[0];case"float":return new Float32Array(hexStringToInt8(t))[0];case"int":return new Int32Array(hexStringToInt8(t))[0];case"short":return new Int16Array(hexStringToInt8(t))[0];case"byte":return new Int8Array(hexStringToInt8(t))[0]}}function itemDataLength(e){switch(e){case"double":return 16;case"float":case"int":return 8;case"short":return 4;case"byte":return 2}}function resetDatas(){var e=oPlayers[0],Q="BB"!=course?["x","y","z","speed","speedinc","heightinc","rotation","rotincdir","rotinc","drift","driftinc","driftcpt","size","tourne","tombe","arme","stash","tours","demitours","champi","etoile","megachampi","billball","place"]:["x","y","z","speed","speedinc","heightinc","rotation","rotincdir","rotinc","drift","driftinc","driftcpt","size","tourne","tombe","arme","stash","ballons","reserve","champi","etoile","megachampi"],t="BB"!=course?["finaltime"]:[],Z=Q.concat("aipoint"),a={player:[],extra:{},item:[],lastcon:connecte},n=[{params:a.player,mapping:Q,kart:e}];if(onlineSpectatorId)delete a.player;else{for(var o=0;oT;){var I=L.ballons.length-1;L.ballons[I][0].suppr(),L.ballons.pop()}}break;default:L[x[P]]=T}}if(25<=L.billball&&!f?(L.sprite[0].img.src="images/sprites/sprite_billball.png",resetSpriteHeight(L.sprite[0]),L.aipoint=void 0):50<=L.etoile&&!y?L.sprite[0].img.src=getStarSrc(L.personnage):(y&&!L.etoile||f&&!L.billball)&&(L.sprite[0].img.src=getSpriteSrc(L.personnage),resumeSpriteSize(L.sprite[0])),C&&C.startsWith("champi")&&(C!==L.arme||"champior"===C)&&L.champi>b?L.champiType=CHAMPI_TYPE_ITEM:L.champi||delete L.champiType,L.aipoint>=L.aipoints.length&&(L.aipoint=0),M!==L.tours&&(p=getScreenPlayerIndex(s))=fTurboDriftCpt&&L.driftSprite[0].setState(1),v=fTurboDriftCpt2&&L.driftSprite[0].setState(2)),!L.turnSound&&L.tourne&&(L.turnSound=playDistSound(L,"musics/events/spin.mp3","BB"==course?80:50),L.frminv||(L.frminv=10)),L.turnSound&&!L.tourne&&(L.turnSound=void 0);for(P=r[0][1];P'+a[1]+'
'+timeStr(a[5])+"":u[t][0].innerHTML=a[1],u[t][0].id="j"+t,u[t][1]=document.createElement("td"),u[t][1].innerHTML=a[2];var o=document.createElement("small");if(o.innerHTML=(a[3]<0?"":"+")+a[3],n.appendChild(r),n.appendChild(u[t][0]),u[t][1].appendChild(o),n.appendChild(u[t][1]),iTeamPlay){n.style.textShadow="-1px 0 #603, 0 1px #603, 1px 0 #603, 0 -1px #603";for(var i=0;i=n&&(n=h[3][i][2],o=i);var r=h[3][e];h[3][e]=h[3][o],h[3][o]=r}for(e=0;ei&&(a.speed=i),a.speed<-i/4&&(a.speed=-i/4);var r=kartInstantSpeed(a),l=r[0],s=r[1],c=a.x+l,p=a.y+s,d=a.x,u=a.y;a.z||a.heightinc?handleHeightInc(a)&&(delete a.jumped,a.driftinc&&carDrift&&!a.driftSound&&kartIsPlayer(a)&&(carDrift.currentTime=0,carDrift.play(),a.driftSound=carDrift)):(clLocalVars.autoAccelerate&&!a.cpu&&a.accelerate(),a.speed+=a.speedinc,(isCup&&22!=oMap.skin&&30!=oMap.skin||!isCup&&oMap.smartjump)&&a.cpu&&(tombe(c,p)&&!sauts(d,u,l,s)||(q=ralenti(c,p))&&(J=getOffroadProps(a,q))&&a.speed-1.01*a.speedinc>J.speed&&!a.protect&&!a.champi)&&(a.z=1,a.heightinc=.5,a.jumped=!0));i=!(isOnline&&e&&a.controller!=identifiant||onlineSpectatorId);if(i&&!a.loose){var m=a.using;if(a.tourne){m=[];for(n=0;na.speedinc&&(a.speed=Math.min(.75*a.speed,a.speed+.5-a.speedinc)),collisionDecor||(3=fTurboDriftCpt+5)&&(a.driftcpt-=5),a.cpu||(clLocalVars.touchedWalls=!0));for(n=5;0Y&&(loseBall(e),stopDrifting(e),a.spin(Z),a.frminv=24,a.speed=2.5*Math.sign(a.speed),loseUsingItems(a)))),collisionFloor&&(K=collisionFloor.z),a.speedinc||(a.speed*=a.sliding?.95:.9),a.cannon||handleCannon(a,inCannon(d,u,a.x,a.y))&&(stopDrifting(e),a.protect=!0,a.jumped=!0,a.tourne&&(a.tourne=2),delete a.shift,a.cpu||(clLocalVars.cannons++,clSelected&&clRuleVars[clSelected.id]&&(ee=clRuleVars[clSelected.id].max_cannons)&&updateChallengeHud("cannons",clLocalVars.cannons+ee.cannons)),a.boostSound||(a.boostSound=playIfShould(a,"musics/events/boost.mp3"),a.boostSound&&(a.boostSound.onended=function(){a.boostSound=void 0,document.body.removeChild(this)}))),!a.teleport&&i){var Z=inTeleport(a.x,a.y);if(Z){a.aX=a.x,a.aY=a.y,a.aRotation=a.rotation,a.x=Z[0],a.y=Z[1],a.rotation=90*Z[2],a.teleport=5,h=!0,playIfShould(a,"musics/events/teleport.mp3"),a.speed<0&&(a.speed=0);for(n=0;n=a.aipoints.length&&(a.aipoint=0)))}}if(a.sliding=void 0,!a.z){if(a.heightinc||(a.ctrled=!1,a.fell=!1,K?a.z0=K:a.z0&&delete a.z0),a.figuring&&(a.turbodrift=15,a.turbodrift0=a.turbodrift,a.driftcpt=0),handleJump(a,sauts(d,u,l,s)))a.speed=11*cappedRelSpeed(a),a.figuring=!1,a.figstate=0,a.cpu||(clLocalVars.jumps++,clSelected&&clRuleVars[clSelected.id]&&(ee=clRuleVars[clSelected.id].max_jumps)&&updateChallengeHud("jumps",clLocalVars.jumps+ee.jumps)),a.bounceSound||(a.bounceSound=playIfShould(a,"musics/events/jump.mp3"),a.bounceSound&&(a.bounceSound.onended=function(){a.bounceSound=void 0,document.body.removeChild(this)}));else{if(i&&(G=tombe(a.x,a.y,oMap.checkpoint&&a.demitours?oMap.checkpoint[a.demitours+1!=oMap.checkpoint.length?a.demitours+1:0][3]:0)),G){1==G?isBattle&&simplified?(G=[a.x,a.y,a.rotation],a.x>oMap.w-1?(G[0]=oMap.w-50,a.y>oMap.h-1?(G[1]=oMap.h-50,G[2]=225):a.y<0?(G[1]=50,G[2]=315):(G[1]=a.y-a.y%100+50,G[2]=270)):a.y>oMap.h-1?(G[1]=oMap.h-50,a.x<0?(G[0]=50,G[2]=135):(G[0]=a.x-a.x%100+50,G[2]=180)):a.x<0?(G[0]=50,a.y<0?(G[1]=50,G[2]=45):(G[1]=a.y-a.y%100+50,G[2]=90)):(G[1]=50,G[0]=a.x-a.x%100+50,G[2]=0)):G=oMap.startposition[0]:isNaN(G[0])&&(G=oMap.startposition[(a.initialPlace-1)%oMap.startposition.length]),a.aX=a.x,a.aY=a.y,a.aRotation=a.rotation,a.x=G[0],a.y=G[1],a.rotation=90*G[2],a.speed=0,a.protect=!1,a.figuring=!1,a.figstate=0,a.fell=!0,a.champi=0,delete a.champiType,delete a.champior,delete a.champior0,a.cpu&&(a.aipoint=void 0),a.tombe=20,a.frminv=10,a.ctrled=!0,a.z=10,a.tourne=0,stopDrifting(e),supprArme(e),deleteUsingItems(a);for(var ee,te=getScreenPlayerIndex(n),n=0;n.8*a.turbodrift0||!(q=ralenti(c,p))||((J=getOffroadProps(a,q)).speed*=cappedRelSpeed(),J.sliding&&(a.sliding=J.sliding),a.speed>J.speed&&(a.speed=J.speed),stopDrifting(e)),a.tourne||(W=flowShift(c,p,a.protect)),W&&a.cpu&&100<=W[0]*W[0]+W[1]*W[1]&&(l+W[0])*l+(s+W[1])*s<0&&(a.collided=!0,a.horizontality=[W[1],-W[0]]);a.figuring=!1,a.figstate=0}if(W){a.shift||(a.shift=[0,0,0]);for(n=0;n<3;n++)a.shift[n]=.7*a.shift[n]+.3*W[n];a.shift[0]*a.shift[0]+a.shift[1]*a.shift[1]+300*a.shift[2]*a.shift[2]<.01&&delete a.shift}else delete a.shift}if(a.cpu||h||updateSpeedometer(e,d,u),moveUsingItems(a,t),"BB"!=course){if(checkpoint(a,l,s)){var ne=aKarts.length;a.demitours=getNextCp(a),a.tours++;p=oMap.checkpointCoords[0];oMap.sections&&(p=oMap.checkpointCoords[oMap.checkpointCoords.length-1]);h=1,t=intersectionLineLine(d,u,d+l,u+s,p.A[0],p.A[1],p.B[0],p.B[1]);0<=t[0]&&t[0]oMap.tours&&a.place++;if(isOnline&&!a.finaltime&&(a.finaltime=timeTrialMode()?p:(new Date).getTime()-tnCourse),kartIsPlayer(a)&&!finishing){for(showTimer(timerMS=p),"CM"!=course&&(document.getElementById("infoPlace"+e).innerHTML=a.place);a.using.length;){var ie=bMusic,re=iSfx;iSfx=bMusic=!1,arme(e),bMusic=ie,iSfx=re}if(a.arme=!1,stopDrifting(e),supprArme(e),resetWrongWay(a),a.billball&&(a.billball=1),a.cpu=!0,$speedometers[e]&&($speedometers[e].style.display="none"),a.aipoint=0,a.lastAItime=0,a.maxspeed=5.7,a.maxspeed0=a.maxspeed,!oPlayers[1-e]||oPlayers[1-e].cpu){if(isOnline){var le=document.getElementById("infos0");le.style.left=15*iScreenScale+"px",le.innerHTML="";t=document.createElement("tr"),h=document.createElement("td");h.style.fontSize=8*iScreenScale+"px",h.style.color="#F80",h.innerHTML=toLanguage("    FINISH !","TERMINÉ !"),t.appendChild(h);p=document.createElement("tr"),h=document.createElement("td");h.style.fontSize=Math.round(4.5*iScreenScale+10)+"px",h.style.color="#FF0",h.innerHTML=toLanguage("      Please wait...","Veuillez patienter..."),p.appendChild(h),le.appendChild(t),le.appendChild(p),le.style.display="",document.getElementById("infoPlace0").style.visibility="hidden",finishing=!0}else{if("CM"!=course){for(var se=getRankScores(),n=0;nPlaces'+toLanguage("Player","Joueur")+"Pts",de=(Math.round(1.25*aKarts.length),""),ue="";iTeamPlay&&(de="; text-shadow: -1px 0 #603, 0 1px #603, 1px 0 #603, 0 -1px #603",ue=' style="padding: 0 '+Math.round(iScreenScale/2)+'px"');for(var me=getPointDistribution(),n=0;n'+toPlace(n+1)+' "+toPerso(he)+'"+aScores[o]+"+"+Le+"",aScores[o]+=Le,o=ne)}pe+='',document.getElementById("infos0").style.border="solid 1px black",document.getElementById("infos0").style.opacity=.7,document.getElementById("infos0").style.fontSize=Math.round(1.77*iScreenScale-.5)+"pt",document.getElementById("infos0").style.fontFamily="Courier",document.getElementById("infos0").style.top=3*iScreenScale+"px",document.getElementById("infos0").style.left=Math.round(24*iScreenScale+10+(strPlayer.length-1)/2*(iWidth*iScreenScale+2))+"px",document.getElementById("infos0").style.backgroundColor=iTeamPlay?"blue":"#063",document.getElementById("infos0").style.color=primaryColor,document.getElementById("infos0").innerHTML=pe,handleRankingStyle(),(Re=document.createElement("input")).type="button",Re.id="octn",Re.value=toLanguage("CONTINUE","CONTINUER"),Re.style.width="100%",Re.style.height="100%",Re.style.fontSize=3*iScreenScale+"pt",Re.onclick=classement,document.getElementById("continuer").appendChild(Re),document.getElementById("infos0").style.display="";var ge=document.body.scrollTop;Re.focus(),document.body.scrollTop=ge}else{document.getElementById("infos0").style.fontSize=5*iScreenScale+"px",document.getElementById("infos0").style.fontWeight="bold",document.getElementById("infos0").style.color="white";var ye=Math.ceil(iScreenScale/4)+"px";sShadow="-"+ye+" 0 "+(Me="black")+", 0 "+ye+" "+Me+", "+ye+" 0 "+Me+", 0 -"+ye+" "+Me;for(var fe="",Se=lapTimers[0],n=1;n'+(n+1)+". "+timeStr(lapTimers[n])+""}document.getElementById("infos0").style.top=7*iScreenScale+10+"px",document.getElementById("infos0").innerHTML=''+document.getElementById("temps0").innerHTML+''+fe+"",document.getElementById("infos0").style.display="",(Re=document.createElement("input")).type="button",Re.id="octn",Re.value=toLanguage("CONTINUE","CONTINUER"),Re.style.width="100%",Re.style.height="100%",Re.style.fontSize=3*iScreenScale+"pt",Re.onclick=function(){document.getElementById("infos0").style.display="none";var e=document.createElement("div");e.style.color="black",e.style.position="absolute",e.style.left=5*iScreenScale+10+"px",e.style.top=5*iScreenScale+10+"px",e.style.fontSize=4*iScreenScale+"pt",e.style.backgroundColor="#FF6",e.style.opacity=.8,e.style.border="double 4px black",e.style.textAlign="center",e.style.width=70*iScreenScale-10+"px",e.style.height=25*iScreenScale-10+"px",e.style.zIndex=2e4;var t=document.createElement("p");t.innerHTML=toLanguage('Save the time to the record list ?','Enregistrer le temps dans la liste des records ?'),t.style.margin=iScreenScale+"px";var a=t.cloneNode(!1),n=document.createElement("input");n.type="button",n.value=" "+toLanguage("Yes","Oui")+" ",n.style.marginRight=iScreenScale+"px",n.style.fontSize=4*iScreenScale+"px",n.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",o.style.fontSize=4*iScreenScale+"px"},n.onclick=function(){$mkScreen.removeChild(e),continuer(),document.getElementById("enregistrer").getElementsByTagName("input")[0].onclick()},a.appendChild(n);var o=document.createElement("input");o.type="button",o.value=" "+toLanguage("No","Non")+" ",o.style.fontSize=4*iScreenScale+"px",o.style.marginLeft=iScreenScale+"px",o.onmouseover=function(){this.style.fontSize=5*iScreenScale+"px",n.style.fontSize=4*iScreenScale+"px"},o.onclick=function(){$mkScreen.removeChild(e),document.getElementById("infos0").style.display="",continuer()},a.appendChild(o),e.appendChild(t),e.appendChild(a),$mkScreen.appendChild(e),(gRecord<=timerMS?o:n).focus()},document.getElementById("continuer").appendChild(Re),document.getElementById("infos0").style.display="",Re.focus()}handleEndRace()}resetEvents(),window.onbeforeunload=logGameTime}}else onlineSpectatorId&&!finishing&&te "+a.tours,a.time=40,bMusic||iSfx)if(a.tours==oMap.tours){for(var be,Ce=!0,n=0;nPlaces'+toLanguage("Player","Joueur")+"Pts",Te="",Ie=1,de="",ue="";iTeamPlay&&(de="; text-shadow: -1px 0 #603, 0 1px #603, 1px 0 #603, 0 -1px #603",ue=' style="padding: 0 '+Math.round(iScreenScale/2)+'px"');for(var we,n=0;n'+toPlace(Ee+1)+' "+toPerso(he)+'"+aScores[n]+(Le?"+1":"")+"";Le?Te=Ee+Te:(Te+=Ee,Ie++),aScores[n]+=Le}pe+=Te,pe+='',document.getElementById("infos0").style.border="solid 1px black",document.getElementById("infos0").style.opacity=.7,document.getElementById("infos0").style.fontSize=Math.round(1.77*iScreenScale-.5)+"pt",document.getElementById("infos0").style.fontFamily="Courier",document.getElementById("infos0").style.top=3*iScreenScale+"px",document.getElementById("infos0").style.left=Math.round(24*iScreenScale+10+(strPlayer.length-1)/2*(iWidth*iScreenScale+2))+"px",document.getElementById("infos0").style.backgroundColor=iTeamPlay?"blue":"#063",document.getElementById("infos0").style.color=primaryColor,document.getElementById("infos0").innerHTML=pe,handleRankingStyle(),(Re=document.createElement("input")).type="button",Re.id="octn",Re.value=toLanguage("CONTINUE","CONTINUER"),Re.style.width="100%",Re.style.height="100%",Re.style.fontSize=3*iScreenScale+"pt",Re.onclick=classement,document.getElementById("continuer").appendChild(Re),document.getElementById("infos0").style.display="";ge=document.body.scrollTop;for(Re.focus(),document.body.scrollTop=ge,n=0;nRe*Ae?a.maxspeed0=Re*Ae:a.maxspeed0-qe&&(a.maxspeed=qe,a.speed=Math.max(qe*cappedRelSpeed(a),a.speed)),a.turbodrift--),a.champi&&(a.maxspeed=11,a.champi--,a.champi||delete a.champiType),a.billball){if(a.z=2,a.heightinc=0,a.speed=Math.min(30,13*cappedRelSpeed()),null!=a.aipoint)(Ge=a.aipoints[a.aipoint])?(U=Ge[0]-a.x)*U+(_e=Ge[1]-a.y)*_e<2e3&&(inTeleport(Ge[0],Ge[1])||(a.aipoint++,a.aipoint>=a.aipoints.length&&(a.aipoint=0))):_e=U=0;else{var Ne=a.demitours+1;Ne>=oMap.checkpoint.length&&(Ne=0);var _e=(Fe=oMap.checkpointCoords[Ne])?(U=Fe.O[0]-a.x,Fe.O[1]-a.y):U=0;e:for(n=0;nFe[0]-35&&a.xFe[1]-35&&a.y=fTurboDriftCpt2){for(var a=0;a=fTurboDriftCpt){for(a=0;a':""}var s=document.getElementById("scroller"+e),c=document.getElementById("objet"+e);t.stash?(document.getElementById("reserve"+e).style.visibility="visible",c.style.left=Math.round(3*iScreenScale)+"px",c.style.top=Math.round(3*iScreenScale)+"px",s.style.left=Math.round(3*iScreenScale)+"px",s.style.top=Math.round(3*iScreenScale+ +iScreenScale)+"px"):(document.getElementById("reserve"+e).style.visibility="hidden",c.style.left=Math.round(iScreenScale)+"px",c.style.top=Math.round(iScreenScale)+"px",s.style.left=iScreenScale+"px",s.style.top=Math.round(iScreenScale+ +iScreenScale)+"px")}function updateItemCountdownHud(e,t){var a,n,o,i,r,l=document.getElementById("countdown"+e);l&&(0i-Math.PI+o&&t.push([a,n]),r>i-Math.PI-o&&t.push([a,0]),l.style.clipPath="polygon("+t.map(function(e){return e[0]+"px "+e[1]+"px"}).join(", ")):(l.style.display="none",l.style.clipPath=""))}function updateLapHud(e){for(var t=getPlayerAtScreen(e),a=document.querySelectorAll("#compteur"+e+" .tour"),n=0;n=e.aipoints.length){if(oMap.sections||e.tours>=oMap.tours)return 1/0;o=0}var i=e.aipoints[o];if(n+=Math.hypot(i[0]-a[0],i[1]-a[1]),t=o,a=e.aipoints[t],t==e.aipoint)return 1/0}}function hasShortcutItem(e,t){return!e.using.length&&(25==e.roulette&&isShortcutItem(e.arme,t))}function isShortcutItem(e,t){return isShortcutItemKey(e,t)}function isShortcutItemKey(e,t){return!!e&&(!t||t[2].itemsDict[e])}function hasExtraShortcutItem(e,t){if(25==e.roulette2&&isShortcutItem(e.stash,t))return 1;if(isShortcutItemKey("champi",t))switch(e.arme){case"champiX2":case"champiX3":return 1;case"champior":if(e.champior)return 1}}var fMaxRotInCp=10,nextBlueShellCooldown;function ai(u){var e=isBattle&&simplified,t=isBattle&&complete,a=!isBattle&&complete;if(null==u.aipoint)if(delete u.aishortcut,"BB"!=course)for(var n=1/0,o=0;ooMap.tours||u.ballons&&!u.ballons.length&&!u.loose)return u.speedinc=0,u.rotinc=0,void(u.rotincdir=0);if(u.tourne)return u.speedinc=!u.z&&1=u.aipoints.length&&(g=0),m=u.aipoints[g])):((L=y-1)<0&&(L+=u.aipoints.length),(g=y+1)>=u.aipoints.length&&(g=0),h=u.aipoints[L],d=u.aipoints[y],m=u.aipoints[g]);else if(e){h=[u.lastAI%6*100+50,100*Math.floor(u.lastAI/6)+50],d=[u.aipoint%6*100+50,100*Math.floor(u.aipoint/6)+50],m=[h[0]+2*(d[0]-h[0]),h[1]+2*(d[1]-h[1])];var f=Math.floor(u.x/100)+6*Math.floor(u.y/100);if(f!=u.lastAI){var S=!0;if(0<=u.speed&&!u.tombe){var v=(d[0]-u.x)*(d[0]-u.x)+(d[1]-u.y)*(d[1]-u.y);switch(oMap.skin){case 27:S=v<1500;break;case 48:S=v<900}}if(S){(P=u.aipoints[f])&&P.length||(P=[],f%6&&P.push(f-1),f%6<5&&P.push(f+1),6<=f&&P.push(f-6),f<30&&P.push(f+6),-1!=(E=P.indexOf(u.lastAI))&&P.splice(E,1));var b=u.lastAI;for(u.lastAI=f;u.aipoint=P[Math.floor(Math.random()*P.length)],b==u.aipoint&&1N&&(u.randShift=N*Math.sign(u.randShift))));var D,B,f=projete(u.x,u.y,h[0],h[1],d[0],d[1]),w=h[0]+f*(d[0]-h[0]),L=h[1]+f*(d[1]-h[1]),H=Math.hypot(u.x-w,u.y-L);if(k||T||(H=0,u.nextAiStop=0,f=1),!(f>=u.nextAiStop&&Hu.recovertime&&(u.randShift=Math.random()*u.recovertime/2-u.recovertime/4,u.recovertime+=30,u.decision=-u.decision,u.collidesince=1,e&&(u.lastAI=u.aipoint)):(u.collidesince=1,u.decision||(z=direction(0,u.rotation),O=direction(1,u.rotation),R=u.horizontality[0],A=u.horizontality[1],u.decision=0=10*me&&(se+=.15*(se-u.rotation)*me)),isNaN(se)&&(se=u.rotation)),_=nearestAngle(180*_/Math.PI,se,360),isNaN(_)&&(_=se),isNaN(V)&&(V=d[0]),isNaN(F)&&(F=d[1]);var pe=_-se;u.rotinc=Math.max(Math.min(pe,fMaxRotInCp),-fMaxRotInCp);var de=Math.abs(pe),s=de;isBattle&&(de*=Math.pow(de/10,1.5)),l=Math.hypot(V-u.x,F-u.y);var ue,me=Math.atan2(V-h[0],F-h[1])-u.rotation,se=(Math.abs(Math.sin(me))+de*Math.PI/180/2)/y,c=l/se;"BB"!=course||(me=Math.max(5,se/1.57))250+50*Math.random()&&!e&&(u.aipoint=void 0);break}"BB"!=course?inTeleport(d[0],d[1])||(null!=u.aishortcut&&u.aishortcuts[u.aipoint]?(B=(D=u.aishortcuts[u.aipoint])[0],u.aishortcut=u.aipoints.length&&(u.aipoint=0))):(u.lastAI=u.aipoint,delete u.lastAIpt,-1!=u.nextAI?u.aipoint=u.nextAI:u.aipoint=void 0,u.nextAI=void 0),u.nextAiStop=void 0,u.randShift=void 0,u.lastAItime=0}if((25==u.roulette||u.using[0])&&!u.tourne&&!u.cannon){var he=!1;function ge(e,t,a,n,o){for(var i=e*e,r=t*t,l=(isOnline?aKarts:strPlayer).length,s=0;soPlayers[0].place)||"BB"==course)&&.5=d*c[2][3]&&(c[2][2]=d,1==p?(c[3][0]=2,c[2][3]=-c[2][3]):(c[3][0]=0,c[2][3]=0,c[3][1]=1+Math.floor(50*Math.random())))}p&&c[0].redraw(c)}if(oMap.bumpers)for(a=0;a=l&&(v.theta-=l)}}var previouslyPressedBtns=[],cycleHandler;function handleGamepadEvents(){if(gameControls.gamepad)for(var e=0;emapMusic.opts.end:0===mapMusic.yt.getPlayerState()&&e>mapMusic.yt.getDuration()-1)||(t=mapMusic.opts.start||0)=aKarts.length&&(oSpecCam.playerId=0);break;case"quit":return document.location.reload(),!1;default:return!0}oSpecCam.reset();var t,a=getPlayerAtScreen(0);return(isBattle?!a.loose:a.tours<=oMap.tours)&&((t=document.getElementById("infoPlace0")).style.visibility="",t.innerHTML=a.place,-1!=a.team&&(t.style.color=cTeamColors.light[a.team])),isBattle?updateBalloonHud(document.getElementById("compteur0"),a):updateLapHud(0),!1}function releaseOverEvents(){for(var e=document.querySelectorAll(":hover"),t=0;tThe principle is simple: a private link is generated, you send this link to the concerned members, and you can start playing.":"L'option "partie privée" vous permet de jouer uniquement avec les personnes de votre choix.
Le principe est simple : un lien privé est généré, vous envoyez ce lien aux membres concernés, et vous pouvez commencer à jouer.",e.appendChild(a);a=document.createElement("input");a.type="button",a.value=toLanguage("Generate private link","Générer un lien privé"),a.style.fontSize=3*iScreenScale+"px",a.style.position="absolute",a.style.width=35*iScreenScale+"px",a.style.left=23*iScreenScale+"px",a.style.top=28*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),privateLink(t)},e.appendChild(a),(a=document.createElement("input")).type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),shareLink.options=null,selectPlayerScreen(0)},e.appendChild(a),(a=document.createElement("input")).type="button",a.value=toLanguage("Private game options...","Options de la partie privée..."),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=52*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),privateGameOptions(shareLink.options,function(e){e&&(shareLink.options=e,t=e),privateGame(t)})},e.appendChild(a),oContainers[0].appendChild(e)}function privateGameOptions(e,x){var P=document.createElement("div"),t=P.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black",(g=toTitle(isOnline?toLanguage("Private game options","Options partie privée"):toLanguage("Online game options","Options mode en ligne"),0)).style.fontSize=7*iScreenScale+"px",P.appendChild(g);var a=document.createElement("form");a.style.position="absolute",a.style.left="0px",a.style.top=8*iScreenScale+"px",a.style.width=iWidth*iScreenScale+"px",a.onsubmit=function(e){e.preventDefault();var t=this.elements["option-teams"].checked?1:0,a=this.elements["option-manualTeams"].checked?1:0,n=this.elements["option-friendlyFire"].checked?1:0,o=+this.elements["option-nbTeams"].value,i=JSON.parse(this.elements["option-teamOpts"].value),r=this.elements["option-friendly"].checked?1:0,l=+this.elements["option-localScore"].checked?1:0;r||(l=0);var s=+this.elements["option-minPlayers"].value,c=+this.elements["option-maxPlayers"].value,p=parseInt(this.elements["option-cc"].value),d=this.elements["option-cc"].value.endsWith("m"),u=JSON.parse(this.elements["option-itemDistrib"].value),m=JSON.parse(this.elements["option-ptDistrib"].value),h=this.elements["option-cpu"].checked?1:0,g=+this.elements["option-cpuCount"].value,y=+this.elements["option-cpuLevel"].value,f=(f=this.elements["option-cpuNames"].dataset.value)&&JSON.parse(f),S=(S=this.elements["option-cpuChars"].dataset.value)&&JSON.parse(S),v=this.elements["option-timeTrial"].checked?1:0,b=this.elements["option-noBumps"].checked?1:0,C=this.elements["option-noJump"].checked?1:0,M=this.elements["option-noRd"].checked?1:0,e=this.elements["option-doubleItems"].checked?0:1;t||(n=i=a=0),v&&(b=0),h||(g=defaultGameOptions.cpuCount,y=defaultGameOptions.cpuLevel,f=defaultGameOptions.cpuNames,S=defaultGameOptions.cpuChars),x({team:t,manualTeams:a,friendlyFire:n,nbTeams:o,teamOpts:i,friendly:r,localScore:l,minPlayers:s,maxPlayers:c,cc:p,mirror:d,itemDistrib:u,ptDistrib:m,cpu:h,cpuCount:g,cpuLevel:y,cpuNames:f,cpuChars:S,timeTrial:v,noBumps:b,noJump:C,noRd:M,doubleItems:e}),P.innerHTML="",oContainers[0].removeChild(P)};var n=document.createElement("div");n.style.height=Math.round(21*iScreenScale+18)+"px",n.style.overflow="auto";var o=document.createElement("table");o.style.marginLeft="auto",o.style.marginRight="auto";var i=document.createElement("tr");(l=document.createElement("td")).style.textAlign="center",l.style.width=8*iScreenScale+"px";var r=document.createElement("input");r.style.transform=r.style.WebkitTransform=r.style.MozTransform="scale("+Math.round(iScreenScale/3)+")",r.id="option-teams",r.name="option-teams",r.type="checkbox",e&&e.team&&(r.checked=!0),r.onchange=function(){this.checked?(document.getElementById("option-manualTeams-ctn").style.display="",isOnline&&(document.getElementById("option-nbTeams-ctn").style.display="",document.getElementById("option-friendlyFire-ctn").style.display="")):(document.getElementById("option-manualTeams-ctn").style.display="none",document.getElementById("option-nbTeams-ctn").style.display="none",document.getElementById("option-friendlyFire-ctn").style.display="none")},l.appendChild(r),i.appendChild(l);var l=document.createElement("td"),s=document.createElement("label");s.style.cursor="pointer",s.setAttribute("for","option-teams");var c=document.createElement("h1");c.style.fontSize=3*iScreenScale+"px",c.style.marginBottom="0px",c.innerHTML=toLanguage("Team games","Parties par équipe"),s.appendChild(c);var p=document.createElement("div");p.style.fontSize=2*iScreenScale+"px",p.style.color="white",p.innerHTML=toLanguage("If enabled, 2 teams are selected in each game. Your objective: defeat the opposing team.","Si activé, 2 équipes sont sélectionnées à chaque partie. Votre objectif : vaincre l'équipe adverse."),s.appendChild(p),l.appendChild(s),l.style.padding=Math.round(1.5*iScreenScale)+"px 0",i.appendChild(l),o.appendChild(i),(i=document.createElement("tr")).id="option-manualTeams-ctn",e&&e.team||(i.style.display="none"),(l=document.createElement("td")).style.textAlign="center",l.style.width=8*iScreenScale+"px",(r=document.createElement("input")).style.position="relative",r.style.left=Math.round(1.5*iScreenScale)+"px",r.style.transform=r.style.WebkitTransform=r.style.MozTransform="scale("+Math.round(iScreenScale/3)+")",r.id="option-manualTeams",r.name="option-manualTeams",r.type="checkbox",e&&e.team&&e.manualTeams&&(r.checked=!0),l.appendChild(r),i.appendChild(l);l=document.createElement("td");if((s=document.createElement("label")).style.cursor="pointer",s.style.display="inline-block",s.setAttribute("for","option-manualTeams"),(c=document.createElement("h1")).style.marginTop=0,c.style.marginLeft=Math.round(1.5*iScreenScale)+"px",c.style.fontSize=3*iScreenScale+"px",c.style.marginBottom="0px",c.innerHTML=toLanguage("Manual selection","Sélection manuelle"),s.appendChild(c),(p=document.createElement("div")).style.paddingLeft=Math.round(1.5*iScreenScale)+"px",p.style.fontSize=2*iScreenScale+"px",p.style.color="white",p.innerHTML=toLanguage("If enabled, teams are selected manually at each game.","Si activé, les équipes sont sélectionnées manuellement à chaque partie. Sinon, les équipes sont formées automatiquement en fonction du niveau de chaque joueur."),s.appendChild(p),l.appendChild(s),i.appendChild(l),!isOnline)for(var d=i.getElementsByTagName("td"),u=0;uthis.getAttribute("max")&&(e=this.getAttribute("max"),this.value=e);var t=JSON.parse(document.getElementById("option-teamOpts").value);if(t){t.length=e;for(var a=[],n=0;ni){e.insertBefore(n,s);break}if(s.value==n.value){n=s;break}}n.parentNode||e.insertBefore(n,r[r.length-1]),e.value=o}(l=document.createElement("td")).setAttribute("colspan",2),(m=document.createElement("div")).style.display="flex",m.style.flexDirection="row",m.style.alignItems="center",(h=document.createElement("div")).style.paddingLeft=3*iScreenScale+"px",h.style.paddingRight=3*iScreenScale+"px",(s=document.createElement("label")).style.cursor="pointer",s.setAttribute("for","option-cc"),(c=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",c.innerHTML=toLanguage("Class","Cylindrée"),c.style.marginTop=iScreenScale+"px",c.style.marginBottom="0px",s.appendChild(c),h.appendChild(s),m.appendChild(h),(h=document.createElement("div")).style.display="inline-block",(y=document.createElement("select")).id="option-cc",y.name="option-cc",y.style.backgroundColor="black",y.style.width=12*iScreenScale+"px",y.style.fontSize=Math.round(2.5*iScreenScale)+"px",y.style.marginTop=Math.round(1.5*iScreenScale)+"px";var v=[50,100,150,150,200],b=[!1,!1,!1,!0,!1];isOnline||(b=[!(v=[150,150,200]),!0,!1]);var C=!1,M=150;e&&e.cc&&(M=e.cc);var k=!1;e&&e.mirror&&(k=!0);for(u=0;u×

'+toLanguage("Load private game options","Charger options partie privée")+"

"+toLanguage("This menu lets you import options from a previous private game.","Ce menu vous permet d'importer des options d'une partie privée précédente.")+'
",n.querySelector(".private-link-form").onsubmit=function(e){e.preventDefault(),o(e.target.elements["private-link"].value)};var i=n.querySelector(".saved-links"),r=loadOptionLinks();function t(){for(var e=0;e',function(t){a.onclick=function(){o(t.url)},a.querySelector(".saved-link-edit").onclick=function(){var e=prompt(toLanguage("New options name:","Renommer ces options :"),t.name);e&&e!==t.name&&(t.name=e,l())},a.querySelector(".saved-link-del").onclick=function(){confirm(toLanguage('Delete options set "'+t.name+'"?',"Supprimer le jeu d'options \""+t.name+'" ?'))&&(r.splice(r.indexOf(t),1),l())},a.querySelector(".saved-link-options").onclick=function(e){e.stopPropagation()}}(t),i.appendChild(a)}r.length?shareLink.key||(n.querySelector(".saved-links-add").style.display="none"):(i.innerHTML='",shareLink.key||(n.querySelector(".saved-links-ctn").style.display="none"))}function l(){storeOptionLinks(r),i.innerHTML="",t()}t();e=n.querySelector(".close");e.style.left=(iWidth-9)*iScreenScale+5+"px",e.onclick=function(e){e.preventDefault(),P.removeChild(n)},n.querySelector(".saved-links-add a").onclick=function(e){e.preventDefault();e=prompt(toLanguage("Name for your options set:","Nom pour le jeu d'options :"));e&&(r.push({name:e,url:document.location.href}),n.querySelector(".saved-links-add").style.display="none",l())},P.appendChild(n)},P.appendChild(g),oContainers[0].appendChild(P)}function loadOptionLinks(){var e=localStorage.getItem("privgameopts");return e?JSON.parse(e):[]}function storeOptionLinks(e){e.sort(function(e,t){return e.name.localeCompare(t.name)}),localStorage.setItem("privgameopts",JSON.stringify(e))}function privateLink(e){var l=document.createElement("div"),t=l.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black",l.appendChild(toTitle(toLanguage("Private game","Partie privée"),0));var s=isCustomOptions(e);xhr("privateGame.php",s?"options="+encodeURIComponent(JSON.stringify(e)):null,function(e){if(e){var t=shareLink.url,a=shareLink.params.slice(0);a.push("key="+e);var n,o,i,r=t+"?"+a.join("&"),a=document.createElement("div");return a.style.position="absolute",a.style.left="0px",a.style.top=12*iScreenScale+"px",a.style.width=iWidth*iScreenScale+"px",a.style.textAlign="center",a.style.fontSize=3*iScreenScale+"px",a.style.color="#CFC",a.innerHTML=language?'The following private link has been generated:
'+r+"

Enjoy game :)":'Le lien privé suivant a été généré :
'+r+"

Bonne partie :)",l.appendChild(a),s&&((n=document.createElement("input")).type="button",n.style.position="absolute",n.style.right=+iScreenScale+"px",n.style.top=33*iScreenScale+"px",n.style.fontSize=Math.round(1.7*iScreenScale)+"px",n.value="☆ "+toLanguage("Save game options...","Sauvegarder options partie privée"),n.onclick=function(){var t,a,e=prompt(toLanguage("Options name:","Nom des options :"));e&&(t=loadOptionLinks(),a={name:e,url:r},t.push(a),storeOptionLinks(t),l.removeChild(n),l.appendChild(o),i.onclick=function(e){e.preventDefault(),t.splice(t.indexOf(a),1),storeOptionLinks(t),l.removeChild(o),l.appendChild(n)})},l.appendChild(n),(o=document.createElement("div")).style.color="white",o.style.position="absolute",o.style.left=+iScreenScale+"px",o.style.width=iScreenScale*(iWidth-2)+"px",o.style.top=33*iScreenScale+"px",o.style.textAlign="center",o.style.fontSize=2*iScreenScale+"px",o.innerHTML=toLanguage("Options saved, you can access them by clicking on "Load options..." in private game options screen ","Options sauvegardées, vous pourrez y accéder en cliquannt sur "Charger des options..." dans les options de partie privée "),(i=document.createElement("a")).href="#null",i.style.color="#ccf",i.style.textDecoration="none",i.innerHTML=toLanguage("[Undo]","[Annuler]"),o.appendChild(i)),!0}return!1}),oContainers[0].appendChild(l)}function selectTypeScreen(){var e=document.createElement("div"),t=e.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black";var a=new Image;if(a.src="images/mariokart.png",a.style.position="absolute",a.style.width=Math.round(42.5*iScreenScale)+"px",a.style.height=5*iScreenScale+"px",a.style.left=Math.round((iWidth-42.5)/2*iScreenScale)+"px",a.style.top=2*iScreenScale+"px",e.appendChild(a),(t=e.style).width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black",oContainers[0].appendChild(e),"MK"==page){var n=11;(r=document.createElement("input")).type="button",r.value="Grand Prix",r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=10*iScreenScale+"px",r.style.top=n*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="GP",e.innerHTML="",oContainers[0].removeChild(e),selectPlayerScreen(0)},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Time trial","Contre-la-montre"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=41*iScreenScale+"px",r.style.top=n*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="CM",e.innerHTML="",oContainers[0].removeChild(e),selectPlayerScreen(0)},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("VS","Course VS"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=iScreenScale+"px",r.style.top=(n+8)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="VS",e.innerHTML="",oContainers[0].removeChild(e),selectNbJoueurs()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Battle","Bataille"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=50*iScreenScale+"px",r.style.top=(n+8)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="BB",e.innerHTML="",oContainers[0].removeChild(e),selectNbJoueurs()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Track builder","Éditeur de circuit"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=10*iScreenScale+"px",r.style.top=(n+16)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),selectTypeCreate()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Online race","Course en ligne"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=41*iScreenScale+"px",r.style.top=(n+16)*iScreenScale+"px",r.style.width=29*iScreenScale+"px",r.onclick=function(){course="VS",e.innerHTML="",oContainers[0].removeChild(e),selectOnlineScreen()},e.appendChild(r),(r=document.createElement("input")).type="button",r.value=toLanguage("Home","Accueil"),r.style.fontSize=2*iScreenScale+"px",r.style.position="absolute",r.style.left=2*iScreenScale+"px",r.style.top=35*iScreenScale+2+"px",r.onclick=function(){document.location.href="index.php"},e.appendChild(r)}else{var o,r,n=12,l=[toLanguage("VS","Course VS")],s=["VS"];for(isSingle||(l.unshift("Grand Prix"),s.unshift("GP")),(hasChallenges()||myCircuit)&&(l.push(toLanguage("Challenges","Défis")),s.push("CH")),!nid&&isSingle||(l.push(toLanguage("Time Trial","Contre-la-montre")),s.push("CM")),!nid||isSingle&&complete&&!cShared||(l.push(toLanguage("Online race","Course en ligne")),s.push("CL")),!isSingle&&cupScore&&((p=new Image).src="images/cups/cup"+(4-cupScore)+".png",p.style.width=Math.round(4*iScreenScale)+"px",p.style.height=Math.round(4*iScreenScale)+"px",p.style.position="absolute",l.length<5?(p.style.left=3*iScreenScale+"px",p.style.top=Math.round((n+4)*iScreenScale)+"px"):(p.style.left=5*iScreenScale+"px",p.style.top=Math.round((n-1)*iScreenScale)+"px"),p.className="pixelated",e.appendChild(p)),i=0;i

'+o.name+'

'+o.description+"
",i.style.display="flex",i.style.direction="column",i.style.alignItems="center",i.style.width="100%",i.style.fontSize=Math.round(1.9*iScreenScale)+"px",i.style.margin=Math.round(1.5*iScreenScale)+"px 0",i.className="fakebtn",i.onclick=function(){t.innerHTML="",oContainers[0].removeChild(t),selectTrackCreate(e)},n.appendChild(i)}t.appendChild(n);e=document.createElement("a");e.style.color="#CCF",e.style.fontSize=Math.round(2.5*iScreenScale)+"px",e.style.position="absolute",e.style.left=toLanguage(30,29)*iScreenScale+"px",e.style.top=35*iScreenScale+"px",e.href="creations.php",e.onclick=function(){},e.innerHTML=toLanguage("List of creations","Liste des créations"),t.appendChild(e),oContainers[0].appendChild(t);e=document.createElement("input");e.type="button",e.value=toLanguage("Back","Retour"),e.style.fontSize=2*iScreenScale+"px",e.style.position="absolute",e.style.left=2*iScreenScale+"px",e.style.top=35*iScreenScale+"px",e.onclick=function(){t.innerHTML="",oContainers[0].removeChild(t),selectTypeScreen()},t.appendChild(e),updateMenuMusic(0)}function selectTrackCreate(e){var t=document.createElement("div"),a=t.style;a.width=iWidth*iScreenScale+"px",a.height=iHeight*iScreenScale+"px",a.border="solid 1px black",a.backgroundColor="black";a=toTitle(e?toLanguage("Complete track builder","Éditeur complet"):toLanguage("Quick track builder","Éditeur simplifié"),0);a.style.fontSize=Math.round(7*iScreenScale)+"px",t.appendChild(a);var n=[{name:toLanguage("Circuit","Circuit"),url:e?"draw.php":"create.php",thumbnail:"help/build-circuit.png"},{name:toLanguage("Cup - Circuits","Coupe - Circuits"),url:e?"completecup.php":"simplecup.php",thumbnail:"help/build-cup-circuit.png"},{name:toLanguage("Multicup - Circuits","Multicoupe - Circuits"),url:e?"completecups.php":"simplecups.php",thumbnail:"help/build-multicup-circuit.png"},{name:toLanguage("Arena","Arène"),url:e?"course.php":"arene.php",thumbnail:"help/build-arena.png"},{name:toLanguage("Cup - Arenas","Coupe - Arènes"),url:e?"completecup.php?battle":"simplecup.php?battle",thumbnail:"help/build-cup-arena.png"},{name:toLanguage("Multicup - Arenas","Multicoupe - Arènes"),url:e?"completecups.php?battle":"simplecups.php?battle",thumbnail:"help/build-multicup-arena.png"}],o=document.createElement("div");o.style.display="grid",o.style.position="absolute",o.style.left=14*iScreenScale+"px",o.style.top=9*iScreenScale+"px",o.style.width=60*iScreenScale+"px",o.style.display="grid",o.style.gridTemplateColumns=14*iScreenScale+"px "+18*iScreenScale+"px "+20*iScreenScale+"px",o.style.columnGap=2*iScreenScale+"px",o.style.fontSize=2*iScreenScale+"px",o.style.textAlign="center",o.style.backgroundColor="#000C",o.style.paddingBottom="1px",o.style.zIndex=1;for(e=0;e
'+i.name+"
",r.onmouseover=function(){this.style.backgroundColor="rgb(38 85 177)"},r.onmouseout=function(){this.style.backgroundColor=""},r.style.cursor="pointer",o.appendChild(r)}t.appendChild(o);a=document.createElement("a");a.style.color="#CCF",a.style.fontSize=Math.round(2.5*iScreenScale)+"px",a.style.position="absolute",a.style.left=toLanguage(30,29)*iScreenScale+"px",a.style.top=36*iScreenScale+"px",a.href="creations.php",a.onclick=function(){},a.innerHTML=toLanguage("List of creations","Liste des créations"),t.appendChild(a),oContainers[0].appendChild(t);a=document.createElement("input");a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=36*iScreenScale+"px",a.onclick=function(){t.innerHTML="",oContainers[0].removeChild(t),selectTypeCreate()},t.appendChild(a),oContainers[0].appendChild(t),updateMenuMusic(0)}function selectPlayerScreen(IdJ,newP,nbSels,additionalOptions){var isCustomSel=void 0!==nbSels,force=-1===IdJ;if(force&&(IdJ=0),!IdJ){for(joueurs in strPlayer=[],aPlayers=[],cp)aPlayers.push(joueurs);updateCommandSheet()}var itemMode=getItemMode(),modeItemDistributions=itemDistributions[itemMode].concat(customItemDistrib[itemMode]),modePtDistributions=ptDistributions.concat(customPtDistrib),selectedOpponents;fInfos=fInfos||{};var oScr=document.createElement("div");newP&&(oScr.style.visibility="hidden");var oStyle=oScr.style;oStyle.width=iWidth*iScreenScale+"px",oStyle.height=iHeight*iScreenScale+"px",oStyle.border="solid 1px black",oStyle.backgroundColor="black";var shrinkAll=("VS"==course||"BB"==course)&&!clSelected,oTitle,oMsg,oMsg,oTitle;isCustomSel?(oMsg=isOnline?toLanguage("Choose CPU","Choisissez ordi")+" "+(IdJ-1):IdJ>=oContainers.length?toLanguage("Choose CPU","Choisissez ordi")+" "+(IdJ+1-oContainers.length):1==oContainers.length?toLanguage("Choose player","Choisissez joueur"):toLanguage("Choose player ","Choisissez joueur ")+(IdJ+1),oTitle=toTitle(oMsg,-1),oTitle.style.color="#F90"):oTitle=toTitle(toLanguage("Select a player","Choisissez un joueur"),-1),shrinkAll&&(oTitle.style.fontSize=Math.round(7.5*iScreenScale)+"px"),oScr.appendChild(oTitle);var baseY=shrinkAll?8:10,customCharsEnabled=0!==cupOpts.customchars,cTable=document.createElement("table");cTable.style.display="none",cTable.style.position="absolute",cTable.style.zIndex=2,cTable.style.top=36*iScreenScale+16+"px",cTable.style.left=25*iScreenScale-60+"px",cTable.style.textAlign="left",cTable.style.fontSize=2*iScreenScale+"px",cTable.style.color="white",cTable.style.backgroundColor="black",cTable.style.backgroundColor="rgba(0,0,0, 0.8)",cTable.setAttribute("cellpadding",2),cTable.setAttribute("cellspacing",2),document.body.appendChild(cTable);var hTr=document.createElement("tr"),hTd1=document.createElement("td");hTd1.innerHTML=" ",hTr.appendChild(hTd1);var hTd2=document.createElement("td");hTd2.innerHTML=" ",hTd2.style.fontWeight="bold",hTr.appendChild(hTd2),cTable.appendChild(hTr);for(var sCaracteristiques=[toLanguage("Acceleration","Accélération"),toLanguage("Max speed","Vitesse max"),toLanguage("Handling","Maniabilité"),toLanguage("Weight","Poids")],dCaracteristiques=new Array,i=0,rotateHandler;i=oContainers.length;o--)aPlayers.push(strPlayer[o]);strPlayer.splice(oContainers.length)}else if(selectedOpponents){for(o=0;owithout playing on them","Cochez cette case pour voir
les courses sans y participer"),style:function(e){return{left:e.left-10*iScreenScale+"px",top:e.top+4*iScreenScale+"px",backgroundColor:"rgba(51,51,160, 0.95)"}}}),oScr.appendChild($spectatorModeCtn)}else if("VS"==course||"BB"==course){var oForm=document.createElement("form");if(oForm.onsubmit=function(){return!1},oForm.style.position="absolute",oForm.style.top=(baseY+21)*iScreenScale-5+"px",oForm.style.left=18*iScreenScale+"px",oForm.style.fontSize=2*iScreenScale+"px",oForm.style.zIndex=2,IdJ||newP||(iDificulty=selectedDifficulty,fInfos.nbPlayers=selectedPlayers,fInfos.teams=selectedTeams,fInfos.nbteams=+selectedNbTeams,fInfos.friendlyFire=!!selectedFriendlyFire),"VS"==course){var oDiffDiv=document.createElement("label");oDiffDiv.appendChild(document.createTextNode(toLanguage("Difficulty: ","Difficulté : ")));var iDifficulties=[toLanguage("Easy","Facile"),toLanguage("Medium","Moyen"),toLanguage("Difficult","Difficile"),toLanguage("Extreme","Extrême"),toLanguage("Impossible","Impossible")],oSelect=document.createElement("select");oSelect.name="difficulty",oSelect.style.width="auto",oSelect.style.fontSize=2*iScreenScale+"px",oSelect.style.marginRight="10px",oSelect.onchange=function(){selectedDifficulty=this.selectedIndex};for(var i=0;iparseInt(t)){i=document.createElement("option");i.value=t,i.innerHTML=a,e.insertBefore(i,n[o]),e.selectedIndex=o;break}}e.value=t}oSelect.name="nbj",oSelect.style.width=3*iScreenScale+20+"px",oSelect.style.fontSize=2*iScreenScale+"px";for(var i=2;i<=8;i++){var oOption=document.createElement("option");oOption.value=i,oOption.innerHTML=i,oSelect.appendChild(oOption)}var oOption=document.createElement("option");oOption.value=-1,oOption.innerHTML=toLanguage("More...","Plus..."),oSelect.appendChild(oOption),setCustomValue(oSelect,fInfos.nbPlayers),oSelect.onchange=function(){var e;-1==this.value&&(e=parseInt(prompt(toLanguage("Number of players:","Nombre de joueurs :"))),!isNaN(e)&&1=itemDistributions[itemMode].length?"inline-block":"none")},tDiv.appendChild(oItemSelect);var oItemCustomActions=document.createElement("div");oItemCustomActions.style.display="none",oItemCustomActions.style.marginLeft=+iScreenScale+"px";var oItemCustomEdit=document.createElement("input");oItemCustomEdit.type="button",oItemCustomEdit.style.backgroundColor="rgb(51, 160, 51)",oItemCustomEdit.style.color="white",oItemCustomEdit.style.fontSize=Math.round(2.5*iScreenScale)+"px",oItemCustomEdit.value="✎",oItemCustomEdit.onclick=function(){selectItemScreen(oScr,function(e){customItemDistrib[itemMode][oItemSelect.value-itemDistributions[itemMode].length]=e,localStorage.setItem("itemsets",JSON.stringify(customItemDistrib)),localStorage.setItem("itemset."+itemMode,+oItemSelect.value),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0})},modeItemDistributions[oItemSelect.value])},oItemCustomActions.appendChild(oItemCustomEdit);var oItemCustomDel=document.createElement("input");oItemCustomDel.type="button",oItemCustomDel.style.marginLeft=Math.round(.5*iScreenScale)+"px",oItemCustomDel.style.backgroundColor="rgb(204, 51, 51)",oItemCustomDel.style.color="white",oItemCustomDel.value="×",oItemCustomDel.style.fontSize=Math.round(2.5*iScreenScale)+"px",oItemCustomDel.onclick=function(){var e=modeItemDistributions[oItemSelect.value].name;confirm(toLanguage('Delete item set "'+e+'"?','Supprimer le set "'+e+'" ?'))&&(customItemDistrib[itemMode].splice(oItemSelect.value-itemDistributions[itemMode].length,1),localStorage.setItem("itemsets",JSON.stringify(customItemDistrib)),localStorage.setItem("itemset."+itemMode,0),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0}))},oItemCustomActions.appendChild(oItemCustomDel),tDiv.appendChild(oItemCustomActions);var selectedItemSetId=localStorage.getItem("itemset."+itemMode);selectedItemSetId&&(oItemSelect.selectedIndex=selectedItemSetId,oItemSelect.onchange()),cDiv.appendChild(tDiv),oTd.appendChild(cDiv),oTr.appendChild(oTd),oTable.appendChild(oTr);var oTable=document.createElement("table");if(oTable.style.marginLeft="auto",oTable.style.marginRight="auto",oScroll.appendChild(oTable),"BB"!=course){var oTr=document.createElement("tr"),oTd=document.createElement("td");oTd.setAttribute("colspan",2);var cDiv=document.createElement("div");cDiv.style.display="flex",cDiv.style.flexDirection="row",cDiv.style.alignItems="center";var tDiv=document.createElement("div");tDiv.style.paddingLeft=3*iScreenScale+"px",tDiv.style.paddingRight=3*iScreenScale+"px";var oLabel=document.createElement("label");oLabel.style.cursor="pointer",oLabel.setAttribute("for","option-ptDistrib");var oH1=document.createElement("h1");oH1.style.fontSize=3*iScreenScale+"px",oH1.innerHTML=toLanguage("Point distribution :","Distribution des points :"),oH1.style.marginTop=iScreenScale+"px",oH1.style.marginBottom="0px",oLabel.appendChild(oH1),tDiv.appendChild(oLabel),cDiv.appendChild(tDiv);var tDiv=document.createElement("div");tDiv.style.display="inline-block",oPointSelect=document.createElement("select"),oPointSelect.id="option-ptDistrib",oPointSelect.name="option-ptDistrib",oPointSelect.style.backgroundColor="black",oPointSelect.style.width=24*iScreenScale+"px",oPointSelect.style.fontSize=Math.round(2.5*iScreenScale)+"px",oPointSelect.style.marginTop=Math.round(1.5*iScreenScale)+"px";for(var i=0;i=ptDistributions.length?"inline-block":"none")},tDiv.appendChild(oPointSelect);var oPtCustomActions=document.createElement("div");oPtCustomActions.style.display="none",oPtCustomActions.style.marginLeft=+iScreenScale+"px";var oPtCustomEdit=document.createElement("input");oPtCustomEdit.type="button",oPtCustomEdit.style.backgroundColor="rgb(51, 160, 51)",oPtCustomEdit.style.color="white",oPtCustomEdit.style.fontSize=Math.round(2.5*iScreenScale)+"px",oPtCustomEdit.value="✎",oPtCustomEdit.onclick=function(){selectPtScreen(oScr,function(e){customPtDistrib[oPointSelect.value-ptDistributions.length]=e,localStorage.setItem("ptsets",JSON.stringify(customPtDistrib)),localStorage.setItem("ptset",+oPointSelect.value),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0})},modePtDistributions[oPointSelect.value])},oPtCustomActions.appendChild(oPtCustomEdit);var oPtCustomDel=document.createElement("input");oPtCustomDel.type="button",oPtCustomDel.style.marginLeft=Math.round(.5*iScreenScale)+"px",oPtCustomDel.style.backgroundColor="rgb(204, 51, 51)",oPtCustomDel.style.color="white",oPtCustomDel.value="×",oPtCustomDel.style.fontSize=Math.round(2.5*iScreenScale)+"px",oPtCustomDel.onclick=function(){var e=modePtDistributions[oPointSelect.value].name;confirm(toLanguage('Delete point set "'+e+'"?','Supprimer le set "'+e+'" ?'))&&(customPtDistrib.splice(oPointSelect.value-ptDistributions.length,1),localStorage.setItem("ptsets",JSON.stringify(customPtDistrib)),localStorage.setItem("ptset",0),oScr.innerHTML="",oContainers[0].removeChild(oScr),selectPlayerScreen(IdJ,newP,nbSels,{openOptions:!0}))},oPtCustomActions.appendChild(oPtCustomDel),tDiv.appendChild(oPtCustomActions);var selectedPtSetId=localStorage.getItem("ptset");selectedPtSetId&&(oPointSelect.selectedIndex=selectedPtSetId,oPointSelect.onchange()),cDiv.appendChild(tDiv),oTd.appendChild(cDiv),oTr.appendChild(oTd),oTable.appendChild(oTr)}var oTr=document.createElement("tr"),oTd=document.createElement("td");oTd.style.textAlign="center",oTd.style.width=8*iScreenScale+"px",oTd.style.paddingLeft=2*iScreenScale+"px";var oDoubleItemCheckbox=document.createElement("input");oDoubleItemCheckbox.style.transform=oDoubleItemCheckbox.style.WebkitTransform=oDoubleItemCheckbox.style.MozTransform="scale("+Math.round(iScreenScale/3)+")",oDoubleItemCheckbox.id="option-doubleItems",oDoubleItemCheckbox.name="option-doubleItems",oDoubleItemCheckbox.type="checkbox",oDoubleItemCheckbox.checked=!selectedDoubleItems,oTd.appendChild(oDoubleItemCheckbox),oTr.appendChild(oTd);var oTd=document.createElement("td"),oLabel=document.createElement("label");oLabel.style.cursor="pointer",oLabel.setAttribute("for","option-doubleItems");var oH1=document.createElement("h1");oH1.style.fontSize=3*iScreenScale+"px",oH1.style.margin=Math.round(.5*iScreenScale)+"px auto",oH1.innerHTML=toLanguage("Disable double items","Désactiver les double objets"),oLabel.appendChild(oH1),oTd.appendChild(oLabel),oTd.style.padding=Math.round(1.5*iScreenScale)+"px 0",oTr.appendChild(oTd),oTable.appendChild(oTr),oMoreOptionsScreen.appendChild(oScroll);var oPInput=document.createElement("input");oPInput.type="button",oPInput.value=toLanguage("Back","Retour"),oPInput.style.fontSize=2*iScreenScale+"px",oPInput.style.position="absolute",oPInput.style.left=4*iScreenScale+"px",oPInput.style.top=32*iScreenScale+"px",oPInput.onclick=function(){oMoreOptionsScreen.style.display="none"},oMoreOptionsScreen.appendChild(oPInput)}oScr.appendChild(oForm),isCustomSel&&(oForm.style.display="none")}else if("CM"==course){if(clSelected){var ccConstraint=getCcConstraint(clSelected);150!=ccConstraint&&200!=ccConstraint||(oClassSelect=document.createElement("input"),oClassSelect.type="hidden",oClassSelect.value=ccConstraint)}else{var oDiv=document.createElement("div");oDiv.style.position="absolute",oDiv.style.left=10*iScreenScale-10+"px",oDiv.style.top=32*iScreenScale+"px",oDiv.style.width=60*iScreenScale+"px",oDiv.style.fontSize=3*iScreenScale+"px",oDiv.style.textAlign="center";var oLabel=document.createElement("label");oLabel.innerHTML=toLanguage("Class: ","Cylindrée : "),oClassSelect=document.createElement("select"),oClassSelect.name="cc",oClassSelect.style.width=12*iScreenScale+"px",oClassSelect.style.fontSize=3*iScreenScale+"px";for(var oClasses=[150,200],i=0;i"+toLanguage("Class","Cylindrée ")+': ','"],submitVal:toLanguage("Validate","Valider"),submit:function(e){var t=+e.target.elements.cc.value,e=+e.target.elements.mirror.checked;n(a,t,e),a.currentValue=a.value},close:function(){a.value=a.currentValue}}).querySelector('input[name="cc"]').select():a.currentValue=a.value}function selectItemScreen(r,l,s){s=s||{};var c=document.createElement("div");c.style.position="absolute",c.style.width="100%",c.style.height="100%",c.style.left="0px",c.style.top="0px",c.style.zIndex=4,c.style.backgroundColor="#000";var p=document.createElement("table");p.style.color="white",p.style.textAlign="center",p.style.position="absolute",p.style.left=5*iScreenScale+"px",p.setAttribute("cellpadding",0),p.setAttribute("cellspacing",0);var d=getItemMode(),u={},e=itemDistributions[d].concat(customItemDistrib[d]);selectedItemDistrib.value&&-1==e.indexOf(selectedItemDistrib)&&e.push(selectedItemDistrib);for(var t=0;t=m.length&&(v.style.display="none"),(g=document.createElement("td")).setAttribute("colspan",u.length+1),v.appendChild(g),(g=document.createElement("td")).style.paddingRight=iScreenScale+"px";var b=document.createElement("input");b.type="button",b.value="+",b.style.fontSize=2*iScreenScale+"px",b.style.lineHeight=2*iScreenScale+"px",b.style.padding=Math.round(iScreenScale/4-1)+" "+Math.round(iScreenScale/2+2)+"px",b.onclick=function(){p.insertBefore(S(f.length),v),f.length>=m.length&&(v.style.display="none")},s.readOnly&&(b.style.display="none"),g.appendChild(b),v.appendChild(g),p.appendChild(v),c.appendChild(p);b=document.createElement("input");function C(e){var t=[];if(e&&!f.length)return alert(toLanguage("You must have at least 1 row in your table","Votre table doit comporter au moins 1 ligne")),null;for(var a=0;a

'+toLanguage("Concurrent items","Objets simultanés")+'

'+toLanguage("Cooldown","Cooldown")+'

'+toLanguage("Double items","Double objets")+'

'+toLanguage("Back","Retour")+'',n.querySelector(".item-submit a").onclick=function(){return c.removeChild(n),!1};var t,o=n.querySelector("form");for(t in o.onsubmit=function(e){for(var t in e.preventDefault(),k){var a=o.elements[t];"checkbox"===a.type?k[t]=a.checked:k[t]=a.value}c.removeChild(n)},k){var a=o.elements[t];s.readOnly&&(a.disabled=!0),"checkbox"===a.type?a.checked=!!k[t]:a.value=k[t]}s.readOnly&&(n.querySelector('.item-submit input[type="submit"]').style.display="none"),c.appendChild(n)},b.appendChild(M)),s.readOnly||((M=document.createElement("input")).type="submit",M.style.fontSize=2*iScreenScale+"px",M.value=toLanguage("Validate!","Valider !"),M.style.marginLeft=iScreenScale+"px",b.appendChild(M),(M=document.createElement("a")).href="#null",M.style.color="#CCF",M.innerHTML=toLanguage("Export/Import...","Exporter/importer"),M.style.fontSize=Math.round(1.6*iScreenScale)+"px",M.style.marginLeft=Math.round(2.5*iScreenScale)+"px",M.style.position="relative",M.style.top=-Math.round(iScreenScale/2)+"px",M.onclick=function(e){e.preventDefault();var r=document.createElement("div");r.className="fsmask item-export-screen",r.style.fontSize=2*iScreenScale+"px",r.innerHTML='
'+toLanguage("Export","Exporter")+'
'+toLanguage("Import","Importer")+'
'+toLanguage("Export: Copy this text to share this distribution with other players.","Exporter : Copiez ce texte pour partager cette distribution avec d'autres joueurs.")+'
'+toLanguage("Import: Paste a new text to import distribution shared by another player.","Importer : Collez un texte pour importer la distribution d'un autre joueur.")+'
';for(var t=r.querySelectorAll(".tab-buttons .tab-button"),a=r.querySelectorAll(".tabs .tab"),n=0;n=f.length&&p.insertBefore(S(f.length),v);for(var a=importedDistrib[t],n=f[t].querySelectorAll('.item-distrib input[type="number"]'),o=0;oimportedDistrib.length;)p.removeChild(f[f.length-1]);f.length>=m.length?v.style.display="none":v.style.display=""},c.appendChild(r)},b.appendChild(M),-1===u.indexOf("carapacenoire")&&(c.tabIndex=0,c.style.outline="none",x="darkshell",P="",c.onkeydown=function(e){e=e.key;if(1===e.length){if(e=e.toLowerCase(),!x.startsWith(P+=e))return P="",void(x.startsWith(e)&&(P=e));P===x&&confirm("Enable dark shell item?")&&(m[m.length-1].carapacenoire=0,r.removeChild(c),selectItemScreen(r,l,s))}},setTimeout(function(){c.focus()},1))),c.appendChild(b),r.appendChild(c)}function selectPtScreen(l,s,c){c=c||{};var p=document.createElement("div");p.style.position="absolute",p.style.width="100%",p.style.height="100%",p.style.left="0px",p.style.top="0px",p.style.zIndex=4,p.style.backgroundColor="#000";var e=document.createElement("form");e.onsubmit=function(){var e=this.elements["pt[]"];e.length||(e=[e]);for(var t=[],a=0;at.length;)n(t.length);for(;ee.onclick).filter(e=>!e.disabled).filter(e=>!e.dataset.noselect).filter(e=>{e=e.getBoundingClientRect();return 0=strPlayer.length){for(var t=new Array(selectedNbTeams).fill(0),e=0;e[Show]','Distribution personnalisée [Voir]'),(r=o.querySelector("a")).style.color="#CCF",r.onclick=function(){return selectedItemDistrib=l,selectItemScreen(e,function(){},Object.assign({},l,{readOnly:!0})),!1}):(r=getItemMode(),(l=itemDistributions[r][shareLink.options.itemDistrib]).value.length?o.innerHTML=l.name:o.innerHTML=toLanguage("No item","Aucun objet")),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.cpuCount&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("Possible addition of bots","Ajout possible de bots"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("If there are not enough players, some bots will be added to the game so that there are at least "+shareLink.options.cpuCount+" participants.","S'il n'y a pas assez de joueurs, des bots seront ajoutés à la partie pour qu'il y ait au minimum "+shareLink.options.cpuCount+" participants"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.timeTrial&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("Time trial mode","Mode Contre-le-montre"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("Games are played like in time trial: no item boxes, no collisions with other players (they are ghosts), and you start with 3 shrooms.","Les parties se déroulent comme en CLM : pas de boîtes à objets, pas de collisions avec les autres joueurs (ce sont des fantômes), et vous commencez avec 3 champis."),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.noBumps&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("No collisions between karts","Pas de collisions entre les karts"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("Karts are not impacted when they hit each other","Les karts ne sont pas impactés lorsqu'ils se rentrent dedans"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.noJump&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("No kart jumps","Sauts désactivés"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("It's impossible to perform a jump, drift or trick","Il est impossible de faire des sauts, dérapages ou figures"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),shareLink.options.noRd&&(s=document.createElement("tr"),c=document.createElement("td"),p=document.createElement("label"),c.appendChild(p),(d=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",d.innerHTML=toLanguage("No Reverse Drift","Pas de Reverse Drift"),d.style.marginBottom="0px",p.appendChild(d),(o=document.createElement("div")).style.fontSize=2*iScreenScale+"px",o.style.color="white",o.innerHTML=toLanguage("The famous MKPC drifting technique is blocked","La fameuse technique de dérapage de MKPC est bloquée"),p.appendChild(o),c.appendChild(p),s.appendChild(c),t.appendChild(s)),n.appendChild(t),a.appendChild(n),(o=document.createElement("div")).style.textAlign="center",o.style.marginTop=2*iScreenScale+"px";n=document.createElement("input");n.type="button",n.value=toLanguage("Accept and play","Accepter et jouer"),n.style.fontSize=3*iScreenScale+"px",n.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),shareLink.accepted=!0,searchCourse()},o.appendChild(n),a.appendChild(o),e.appendChild(a);a=document.createElement("input");a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){e.innerHTML="",oContainers[0].removeChild(e),selectPlayerScreen(0)},e.appendChild(a),oContainers[0].appendChild(e)}function selectChallengesScreen(){var n=document.createElement("div"),e=n.style;e.width=iWidth*iScreenScale+"px",e.height=iHeight*iScreenScale+"px",e.border="solid 1px black",e.backgroundColor="black";var t=toTitle(toLanguage("Challenges","Défis"),0);t.style.fontSize=7*iScreenScale+"px",n.appendChild(t);var a=document.createElement("div");a.style.position="absolute",a.style.left="0px",a.style.top=9*iScreenScale+"px",a.style.width=iWidth*iScreenScale+"px";var o,e=document.createElement("div");e.style.maxHeight=24*iScreenScale+"px",e.style.overflowX="hidden",e.style.overflowY="auto";t=hasChallenges();if(t){document.getElementById("comment-connect")&&((w=document.createElement("div")).style.width=(iWidth-5)*iScreenScale+"px",w.style.marginLeft="auto",w.style.marginRight="auto",w.style.marginBottom=Math.round(1.5*iScreenScale)+"px",w.style.textAlign="center",w.innerHTML=language?'You are not connected. The challenges you complete will not be saved. Click here to log in or register.':'Vous n\'êtes pas connecté. Les défis réussis ne seront pas sauvegardés. Cliquez ici pour vous connecter ou vous inscrire.',w.style.fontSize=Math.round(1.8*iScreenScale)+"px",e.appendChild(w));var i=document.createElement("table");i.style.width=(iWidth-3)*iScreenScale+"px",i.style.marginLeft="auto",i.style.marginRight="auto",i.style.borderCollapse="collapse";var r=[],l=[];for(m in challenges)for(var s in challenges[m])for(var c=(u=challenges[m][s]).list,p=0;p'+escapeSpecialChars(u.name)+"",y.style.textAlign="center",y.style.margin="0px",y.style.fontSize=Math.round(4*iScreenScale)+"px",y.style.paddingTop=Math.round(.5*iScreenScale)+"px",y.style.paddingBottom=Math.round(.5*iScreenScale)+"px",y.style.backgroundColor="#fa7c1b",y.style.color="white",C.appendChild(y),S.appendChild(C),i.appendChild(S)}var S,v="active"==h.status&&h.succeeded,b=v?"#9E9":"white";(S=document.createElement("tr")).style.border="solid 1px "+b,v&&(S.style.backgroundColor="#031"),(C=document.createElement("td")).style.padding=iScreenScale+" "+iScreenScale+"px",h.name&&((y=document.createElement("h1")).style.fontSize=3*iScreenScale+"px",y.style.marginTop="0px",y.style.marginBottom="0px",y.innerText=h.name,C.appendChild(y));var C,M=document.createElement("div");if(h.name||h.description.extra?M.style.fontSize=2*iScreenScale+"px":M.style.fontSize=Math.round(2.5*iScreenScale)+"px",M.style.color=b,M.style.fontWeight="bold",M.innerHTML=h.description.main,C.appendChild(M),h.description.extra&&((M=document.createElement("div")).style.fontSize=Math.round(1.6*iScreenScale)+"px",M.style.color=b,M.innerHTML=h.description.extra,C.appendChild(M)),"active"!=h.status){switch((M=document.createElement("div")).style.fontSize=Math.round(1.6*iScreenScale)+"px",M.style.color="#FC0",h.status){case"pending_completion":M.innerHTML=toLanguage("This challenge is pending completion. Succeed it to publish it.","Ce défi est en attente de réussite. Réussissez-le pour le publier.");break;case"pending_publication":M.innerHTML=toLanguage("This challenge is pending publication. Click on "Manage challenges" to publish it.","Ce défi est en attente de publication. Cliquez sur "Gérer les défis" pour le publier.");break;case"pending_moderation":M.innerHTML=toLanguage("This challenge is pending moderation. It will be published once a validator validates it.","Ce défi est en attente de modération. Il sera publié dès qu'un modérateur l'aura validé.")}M.style.fontWeight="bold",C.appendChild(M)}S.appendChild(C),(C=document.createElement("td")).style.padding=iScreenScale+" "+iScreenScale+"px",C.style.width=12*iScreenScale+"px",C.style.textAlign="center",h.succeeded&&((P=document.createElement("div")).innerHTML=''+toLanguage("Completed","Réussi"),P.style.whiteSpace="nowrap",P.style.fontSize=Math.round(iScreenScale*(language?2:2.2))+"px",P.style.backgroundColor="#33A033",P.style.display="inline-block",P.style.padding="0px "+Math.round(.8*iScreenScale)+"px",P.style.borderRadius=Math.round(.6*iScreenScale)+"px",P.style.color="white",P.style.marginBottom=Math.round(.5*iScreenScale)+"px",P.style.marginTop=Math.round(.5*iScreenScale)+"px",C.appendChild(P));var x,v=document.createElement("div"),b=document.createElement("img");if(b.src="images/challenges/difficulty"+h.difficulty.level+".png",b.alt="D",b.style.width=2*iScreenScale+"px",v.appendChild(b),(P=document.createElement("span")).style.color=h.difficulty.color,P.style.fontSize=Math.round(1.7*iScreenScale)+"px",P.style.position="relative",P.style.top="-1px",P.innerHTML=" "+h.difficulty.name,v.appendChild(P),C.appendChild(v),h.winners.length){(v=document.createElement("div")).style.cursor="help";var P,b=document.createElement("img");h.succeeded||(v.style.marginBottom=Math.round(.5*iScreenScale)+"px"),b.src="images/cups/cup1.png",b.alt="W",b.style.width=2*iScreenScale+"px",v.appendChild(b),(P=document.createElement("span")).style.color="white",P.style.fontSize=Math.round(1.7*iScreenScale)+"px",P.style.position="relative",P.style.top="-2px",P.innerHTML=" "+h.winners.length;for(var k=''+toLanguage("Succeeded by:","Réussi par :")+"",T=0;T'+h.winners[T].nick;v.dataset||(v.dataset={}),v.dataset.title=k,v.appendChild(P),v.onmouseover=function(e){var t;D||((D=document.createElement("div")).className="ranking_activeplayertitle",D.innerHTML=this.dataset.title,D.style.position="fixed",D.style.padding=Math.round(iScreenScale/2)+"px "+iScreenScale+"px",D.style.borderRadius=iScreenScale+"px",D.style.zIndex=10,D.style.backgroundColor="rgba(51,160,51, 0.95)",D.style.color="white",D.style.fontSize=Math.round(1.8*iScreenScale)+"px",D.style.lineHeight=Math.round(2*iScreenScale)+"px",D.style.visibility="hidden",$mkScreen.appendChild(D),t=this.getBoundingClientRect(),D.style.left=Math.round(t.left+(this.scrollWidth-D.scrollWidth)/2)+"px",D.style.top=t.top+this.scrollHeight+5+"px",D.style.visibility="visible")},v.onmouseout=function(){D&&($mkScreen.removeChild(D),D=void 0)},C.appendChild(v)}function I(e,t,a){n.innerHTML="",oContainers[0].removeChild(n),(clSelected=e).trackId=t,clSelected.trackType=a,localStorage.removeItem("itemset."+getItemMode()),xhr("challengeTry.php","challenge="+e.id,function(e){if(!e)return!1;try{e=JSON.parse(e)}catch(e){return!1}for(var t in clSelected.autoset=e,course="",e)window[t]=e[t];return course?selectPlayerScreen(0):selectMainPage(),delete window.selectedPerso,showClSelectedPopup(),!0})}h.succeeded?((L=document.createElement("a")).href="#null",L.innerHTML=toLanguage("Replay","Rejouer"),L.style.color="white",L.style.fontSize=Math.round(1.7*iScreenScale)+"px",function(e,t,a){L.onclick=function(){return I(e,t,a),!1}}(h,s,m),C.appendChild(L)):((x=document.createElement("input")).type="button",x.value=toLanguage("Take up","Relever"),x.style.width=11*iScreenScale+"px",x.style.fontSize=Math.round(2.4*iScreenScale)+"px",function(e,t,a){x.onclick=function(){I(e,t,a)}}(h,s,m),C.appendChild(x)),S.appendChild(C),i.appendChild(S)}e.appendChild(i)}else{e.style.textAlign="center",(M=document.createElement("div")).style.fontSize=3*iScreenScale+"px",M.style.marginTop=3*iScreenScale+"px",M.style.marginBottom=2*iScreenScale+"px",M.style.marginLeft="auto",M.style.marginRight="auto",M.style.width=60*iScreenScale+"px",M.style.color="white",M.innerHTML=toLanguage("This circuit has no challenges. Create some right now, it's fast and easy!","Ce circuit ne comporte aucun défi. Créez-en dès maintenant, c'est facile et rapide !"),e.appendChild(M);var w=document.createElement("input");w.type="button",w.style.fontSize=3*iScreenScale+"px",w.style.paddingLeft=2*iScreenScale+"px",w.style.paddingRight=2*iScreenScale+"px",w.value=toLanguage("Go to challenge editor","Accéder à l'éditeur de défis"),w.onclick=function(){openChallengeEditor()},e.appendChild(w)}a.appendChild(e),n.appendChild(a);a=document.createElement("input");if((a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){n.innerHTML="",oContainers[0].removeChild(n),selectMainPage()},n.appendChild(a),t)&&(myCircuit&&((a=document.createElement("input")).type="button",a.value=toLanguage("Manage challenges...","Gérer les défis..."),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.right=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){openChallengeEditor()},n.appendChild(a)),clRewards.length)){var L=document.createElement("a");o?L.href="persoLocked.php?cl="+o:"undefined"!=typeof commentType&&"undefined"!=typeof commentCircuit&&(L.href="persoLocked.php?cltype="+commentType+"&clrace="+commentCircuit),L.target="_blank",L.style.color="white",L.style.textDecoration="none",L.onclick=function(){return window.open(this.href,"persoLock","scrollbars=1, resizable=1, width=500, height=500"),!1};t=document.createElement("img");t.src="images/challenges/unlocking.png",t.alt=toLanguage("Unlocking characters","Persos à débloquer"),t.style.height=2*iScreenScale+"px",t.style.marginRight=Math.round(.55*iScreenScale)+"px",t.style.position="relative",t.style.top=Math.round(.2*iScreenScale)+"px",L.appendChild(t);var E=0;if(myCircuit)L.innerHTML+=clRewards.length;else{for(p=0;pcongratulations!","Tous les persos ont été
débloqués, félicitations !"),L.style.color="#0F8",L.style.fontWeight="bold"):L.dataset.title=E?toLanguage(a,"Plus que "+a)+" "+toLanguage("character"+t+" left to unlock","perso"+t+" à débloquer"):a+" "+toLanguage("character"+t+" to unlock","perso"+t+" à débloquer"),L.onmouseover=function(){var e;this.style.opacity=.7,D||((D=document.createElement("div")).className="ranking_activeplayertitle",D.style.textAlign="center",D.innerHTML=this.dataset.title,D.style.position="fixed",D.style.padding=Math.round(iScreenScale/2)+"px "+iScreenScale+"px",D.style.borderRadius=iScreenScale+"px",D.style.zIndex=10,D.style.backgroundColor="rgba(102,153,160, 0.95)",D.style.color="white",D.style.fontSize=Math.round(1.8*iScreenScale)+"px",D.style.lineHeight=Math.round(2*iScreenScale)+"px",D.style.visibility="hidden",$mkScreen.appendChild(D),e=this.getBoundingClientRect(),D.style.left=Math.round(e.left+(this.scrollWidth-D.scrollWidth)/2)+"px",D.style.top=e.top-D.scrollHeight-5+"px",D.style.visibility="visible")},L.onmouseout=function(){this.style.opacity="",D&&($mkScreen.removeChild(D),D=void 0)},n.appendChild(L)}oContainers[0].appendChild(n)}function searchCourse(e){e=e||{};var n=document.createElement("div"),t=n.style;t.width=iWidth*iScreenScale+"px",t.height=iHeight*iScreenScale+"px",t.border="solid 1px black",t.backgroundColor="black";var a=document.createElement("div");a.style.position="absolute",a.style.left="0px",a.style.top=4*iScreenScale+"px",a.style.width=iScreenScale*iWidth+"px",a.style.fontSize=4*iScreenScale+"",a.style.textAlign="center",a.innerHTML=toLanguage("Searching for other players
Please wait...","Recherche d'autres joueurs
Veuillez patienter..."),n.appendChild(a);t=document.createElement("label");t.style.position="absolute",t.style.left="0px",t.style.top=15*iScreenScale-9+"px",t.style.width=iScreenScale*iWidth+"px",t.style.textAlign="center";var o=document.createElement("input");o.type="checkbox",o.id="iAlert",o.style.transform=o.style.WebkitTransform=o.style.MozTransform="scale("+iScreenScale/6+") translateY(8%)",o.style.transformOrigin=o.style.WebkitTransformOrigin=o.style.MozTransformOrigin="bottom right",t.appendChild(o);a=document.createElement("span");a.setAttribute("for","iAlert"),a.style.fontSize=2*iScreenScale+"pt",a.style.marginLeft="5px",a.innerHTML=toLanguage("Notify me when opponents have been found","M'alerter lorsque des adversaires ont été trouvés"),t.appendChild(a),n.appendChild(t);var i=0,r=document.createElement("div");r.style.position="absolute",r.style.left="0px",r.style.top=21*iScreenScale+"px",r.style.width=41*iScreenScale*2+"px",r.style.height=Math.round(8.5*iScreenScale)+"px",r.style.overflow="hidden";for(var l=0;l<41;l++){var s=document.createElement("img");s.src="images/cLoading.png",s.className="pixelated",s.style.width=2*iScreenScale+"px",s.style.position="absolute",s.style.left=l*iScreenScale*2+"px",s.style.top="0px",r.appendChild(s)}n.appendChild(r);var c=document.createElement("div");c.style.position="absolute",c.style.left="0px",c.style.top=Math.round(17.5*iScreenScale)+"px",c.style.width=iScreenScale*iWidth+"px",c.style.textAlign="center",c.style.fontSize=2*iScreenScale+"px",c.style.color="#0B0",c.style.display="none",c.style.backgroundColor="rgba(0,0,0, 0.7)",c.innerHTML=toLanguage(' currently online. You\'ll join them as soon as they finish their '+(isBattle?"battle":"race"),' actuellement en ligne. Vous les rejoindrez une fois leur partie terminée'),n.appendChild(c);var p=document.createElement("div");p.style.position="absolute",p.style.left="0px",p.style.top=Math.round(17.5*iScreenScale)+"px",p.style.width=iScreenScale*iWidth+"px",p.style.textAlign="center",p.style.fontSize=2*iScreenScale+"px",p.style.color="#0B0",p.style.display="none",p.style.backgroundColor="rgba(0,0,0, 0.7)",p.innerHTML=toLanguage(' currently waiting, left before the game begins...',' actuellement en attente. Plus que pour que la partie commence'),n.appendChild(p);var d=1,u=iScreenScale/2,m=getOnlineCourseParams(e),h=m+(m?"&":"")+"nojoin",g=!!e.enableSpectatorMode;function y(){d&&(--d||xhr("getCourse.php",g?h:m,function(e){if(!e)return!1;try{e=JSON.parse(e)}catch(e){return!1}var t,a;return e.found?(t=o.checked,n.innerHTML="",oContainers[0].removeChild(n),t&&((a=document.createElement("embed")).src="musics/mkalert.wav",a.setAttribute("loop",!1),a.setAttribute("autostart",!0),a.style.position="absolute",a.style.left="-1000px",a.style.top="-1000px",document.body.appendChild(a),t=(new Date).getTime(),alert(toLanguage("Opponents have been found !\nGood luck !","Des adversaires ont été trouvés !\nBonne chance !")),e.time-=Math.round(((new Date).getTime()-t)/1e3),document.body.removeChild(a)),handleMatchmakingSuccess(e)):(d=10,e.nb_players?(e.nb_players<2&&(e.nb_players=2),document.getElementById("nb-active-players").innerHTML=e.nb_players+" "+toLanguage("players","joueurs"),p.style.display="none",c.style.display="block"):e.pending_players?((a=document.getElementById("nb-pending-players")).dataset.pendingCourse=e.pending_course,a.innerHTML=e.pending_players+" "+toLanguage("player","joueur")+(1"),t.innerHTML=e,t.style.left=Math.max(iScreenScale,Math.round(o.left+(o.width-t.scrollWidth)/2))+"px"):t.style.visibility="hidden",!0})}})}y(),f(c.querySelector("#nb-active-players"),"active_players"),f(p.querySelector("#nb-pending-players"),"pending_players"),shareLink.key||xhr("sendCourseNotifs.php",null,function(e){return!0});a=document.createElement("input");a.type="button",a.value=toLanguage("Back","Retour"),a.style.fontSize=2*iScreenScale+"px",a.style.position="absolute",a.style.left=2*iScreenScale+"px",a.style.top=35*iScreenScale+"px",a.onclick=function(){y=function(){},n.innerHTML="",oContainers[0].removeChild(n),selectPlayerScreen(0,void 0,void 0,{enableSpectatorMode:g})},n.appendChild(a),oContainers[0].appendChild(n);t=document.createElement("div");t.style.position="absolute",t.style.left=28*iScreenScale+"px",t.style.top=34*iScreenScale+"px",t.style.fontSize=Math.round(2.5*iScreenScale)+"px",t.style.display="flex",t.style.alignItems="center";e=document.createElement("label");e.style.display="inline-flex",e.style.alignItems="center",e.style.cursor="pointer",e.style.gap=Math.round(.5*iScreenScale)+"px",e.style.marginRight=iScreenScale+"px";a=document.createElement("input");a.type="checkbox",a.checked=g,a.style.transform="scale("+iScreenScale/6+")",a.style.transformOrigin="center",a.style.marginRight=Math.round(1.5*iScreenScale-6)+"px",a.onclick=function(){g=this.checked},e.appendChild(a);a=document.createElement("span");a.innerHTML=toLanguage("Spectator mode","Mode spectateur"),e.appendChild(a),t.appendChild(e);e=document.createElement("a");e.href="#null",e.style.color="#CCF",e.innerHTML="[?]",e.style.cursor="help",e.onclick=function(){return!1},e.dataset.noselect="1",t.appendChild(e),addFancyTitle({elt:e,title:toLanguage("Check this to see races
without playing on them","Cochez cette case pour voir
les courses sans y participer"),style:function(e){return{left:e.left-10*iScreenScale+"px",top:e.top-6*iScreenScale+"px",backgroundColor:"rgba(51,51,160, 0.95)"}}}),n.appendChild(t),updateMenuMusic(0)}function getOnlineCourseParams(e){var t="";return isCup?isMCups?t+="mid="+nid:isSingle?t+=(complete?"i":"id")+"="+nid+(isBattle?"&battle":""):t+=(complete?"c":"s")+"id="+nid:isBattle&&(t+="battle"),shareLink.key&&(t+=(t?"&":"")+"key="+shareLink.key),e.spectator?t+=(t?"&":"")+"spectator="+e.spectator:e.course&&(t+=(t?"&":"")+"course="+e.course),t}function handleMatchmakingSuccess(e){e.time<1&&(e.time=1),e.spectator&&(setSpectatorId(e.spectator),e.spectatorState&&(onlineSpectatorState=e.spectatorState)),selectMapScreen({racecountdown:e.time-5}),dRest(),setTimeout(setChat,1)}function addFancyTitle(t){var a,n,o=t.elt;o.onmouseover=function(){var e;a||(o.style.opacity=.9,(a=document.createElement("div")).className="ranking_activeplayertitle",a.innerHTML=t.title,a.style.position="fixed",a.style.padding=Math.round(iScreenScale/2)+"px "+iScreenScale+"px",a.style.borderRadius=iScreenScale+"px",a.style.zIndex=10,a.style.color="white",a.style.fontSize=Math.round(1.8*iScreenScale)+"px",a.style.lineHeight=Math.round(2*iScreenScale)+"px",a.style.visibility="hidden",$mkScreen.appendChild(a),t.style&&(e=o.getBoundingClientRect(),Object.assign(a.style,t.style(e))),a.style.visibility="visible",clearInterval(n),n=setInterval(function(){a&&(document.body.contains(o)||($mkScreen.removeChild(a),clearInterval(n),a=void 0))},1e3),t.onShow&&t.onShow(a))},o.onmouseout=function(){a&&(o.style.opacity="",$mkScreen.removeChild(a),clearInterval(n),a=void 0)}}function chooseRandMap(){"MK"==page?"BB"!=course?chooseWithin(0,NBCIRCUITS):chooseWithin(NBCIRCUITS,12):isSingle?choose(1):isBattle?isCup?chooseWithin(0,aAvailableMaps.length):chooseWithin(NBCIRCUITS,12):chooseWithin(0,NBCIRCUITS)}function chooseWithin(e,t){for(var a=e+t,n={},o=e+1;o<=a;o++)n[o]=1;for(o=0;o=y[T=R]&&(O=0,R++)):(I=Math.min(p,c-(v-v%p)),k=v%p,T=Math.floor(v/p)),g<=T)break;(T-=h)<0||((w=document.createElement("img")).className="pixelated",w.style.width=C*iScreenScale+"px",w.style.height=C*iScreenScale+"px",w.style.cursor="pointer",w.style.position="absolute",L=(iWidth+M+1)/2+(k-I/2)*(C+M),z=(x+P)/2+(T-u/2)*(C+x),w.style.left=Math.round(L*iScreenScale)+"px",w.style.top=Math.round(z*iScreenScale)+"px",cupOpts.icons?"number"==typeof cupOpts.icons[v]?w.src="images/cups/"+d[cupOpts.icons[v]]+".gif":function(e,t){w.onload=function(){this.naturalWidth>this.naturalHeight?(this.style.width=C*iScreenScale+"px",this.style.top=Math.round((t+C*(1-this.naturalHeight/this.naturalWidth)/2)*iScreenScale)+"px",this.style.height="auto"):(this.style.width="auto",this.style.height=C*iScreenScale+"px",this.style.left=Math.round((e+C*(1-this.naturalWidth/this.naturalHeight)/2)*iScreenScale)+"px")},w.src=cupOpts.icons[v]}(L,z):w.src="images/cups/"+d[v%d.length]+".gif","BB"==course?w.alt=v+NBCIRCUITS/4:w.alt=v,E=iScreenScale,w.onmouseover=function(){var e=new Image;e.src=getMapSelectorSrc(v),e.alt=4*this.alt+4,e.style.border="double 4px white",e.style.width="100%",e.style.height="100%",e.className="pixelated",bSelectedMirror&&(e.className+=" mirrored"),e.id="maps",document.getElementById("dMaps").appendChild(e),document.getElementById("dMaps").style.display="block",function e(t,a){var n,o;document.getElementById("maps")&&document.getElementById("maps").alt==a&&(a%4!=0?a++:a-=3,n=document.getElementById("dMaps"),o=mapNameOf(t,a-1),n.appendChild(o),document.getElementById("maps").alt=a,document.getElementById("maps").src=getMapSelectorSrc(a-1),setTimeout(function(){try{n.removeChild(o)}catch(e){return}e(t,a)},1e3))}(E,4*this.alt+4);var t,a=cupPayloads[this.alt];a&&(s.innerHTML="",(e=a.name)&&((a=a.prefix)&&((t=document.createElement("span")).innerText=a,t.style.fontSize="0.7em",s.appendChild(t)),(t=document.createElement("span")).innerText=e,s.appendChild(t),e=a?a+e:e,e=Math.min(Math.max(8/Math.sqrt(e.length),1.45),3),l.style.fontSize=Math.round(e*iScreenScale)+"px",l.style.display="flex",s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.gap="0.25em"))},w.onmouseout=function(){document.getElementById("dMaps").style.display="none",document.getElementById("dMaps").innerHTML="",l.style.display="none"},w.onclick=function(){A(),selectRaceScreen(4*this.alt)},isCup||"BB"!=course||(D=[toLanguage("SNES Stages","Arènes SNES"),toLanguage("GBA Stages","Arènes GBA"),toLanguage("DS Stages","Arènes DS")],(B=document.createElement("div")).style.position="absolute",B.style.left=Math.round((L-M/2)*iScreenScale)+"px",B.style.top=Math.round((z+.9*C)*iScreenScale)+"px",B.style.width=(C+M)*iScreenScale+"px",B.style.fontSize=3*iScreenScale+"px",B.style.color="white",B.style.textAlign="center",B.innerHTML=D[v],n.appendChild(B)),n.appendChild(w),"GP"==course?(B=+ptsGP.charAt(v))&&((H=new Image).src="images/cups/cup"+(4-B)+".png",H.style.width=Math.round(4*iScreenScale*C/7)+"px",H.style.height=Math.round(4*iScreenScale*C/7)+"px",H.style.position="absolute",H.style.left=Math.round((L+4*C/7)*iScreenScale)+"px",H.style.top=Math.round((z+4*C/7)*iScreenScale)+"px",H.className="pixelated",n.appendChild(H)):isMCups&&!isOnline&&((H=document.createElement("a")).style.position="absolute",H.style.left=Math.round((L+5*C/7)*iScreenScale)+"px",H.style.top=Math.round((z+5*C/7)*iScreenScale)+"px",H.style.backgroundColor="rgba(0,50,128, 0.5)",H.style.padding="4px",H.style.borderRadius="50%",H.href="?cid="+cupIDs[v],H.title=toLanguage("Link to this cup","Lien vers cette coupe"),H.onmouseover=function(){this.style.backgroundColor="rgba(0,102,153, 0.8)"},H.onmouseout=function(){this.style.backgroundColor="rgba(0,50,128, 0.5)"},(z=document.createElement("img")).src="images/clink.png",z.style.width=Math.round(C*iScreenScale*2/7)+"px",H.appendChild(z),n.appendChild(H)))}"VS"==course||"BB"==course?((r=document.createElement("input")).type="button",r.value=toLanguage("Random","Aléatoire"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=34*iScreenScale-10+"px",r.style.top=30*iScreenScale+"px",r.onclick=function(){i=!1,A(),chooseRandMap()},n.appendChild(r)):"GP"==course?oContainers[0].appendChild(n):"CM"==course&&((r=document.createElement("input")).type="button",r.value=toLanguage("Rankings","Classement"),r.style.fontSize=3*iScreenScale+"px",r.style.position="absolute",r.style.left=33*iScreenScale-10+"px",r.style.top=30*iScreenScale+"px",r.onclick=openRankings,n.appendChild(r)),showRaceCountIfRelevant(n),cupOpts.pages&&cupOpts.pages.length&&((r=document.createElement("input")).type="button",r.value="◄",r.style.fontSize=Math.round(2.5*iScreenScale)+"px",r.style.position="absolute",r.style.left=72*iScreenScale+"px",r.style.top=(isOnline?31:34)*iScreenScale+"px",r.className="disablable",r.onclick=function(){e.page--,A(),selectMapScreen(e)},r.disabled=e.page<=0,n.appendChild(r),(r=document.createElement("input")).type="button",r.value="►",r.style.fontSize=Math.round(2.5*iScreenScale)+"px",r.style.position="absolute",r.style.left=76*iScreenScale+"px",r.style.top=(isOnline?31:34)*iScreenScale+"px",r.className="disablable",r.onclick=function(){e.page++,A(),selectMapScreen(e)},r.disabled=e.page>=cupOpts.pages.length,n.appendChild(r)),isOnline&&(handleSpectatorLink(function(){i=!1,A()}),setTimeout(function(){i&&(A(),chooseRandMap())},1e3*document.getElementById("racecountdown").innerHTML)),updateMenuMusic(1)}else selectRaceScreen(0);function A(){document.getElementById("dMaps").style.display="none",document.getElementById("dMaps").innerHTML="",n.innerHTML="",oContainers[0].removeChild(n)}}function setMapSrc(e,t,a,n){isCup?setTimeout(function(){e.src=n},100*(a-t)):e.src=n}function rankingsLink(e){var t=getActualCc();switch(page){case"MK":return"classement.php?map="+e.map+"&cc="+t;case"CI":return"classement.php?circuit="+e.id+"&cc="+t;case"MA":return"classement.php?draw="+e.map+"&cc="+t}}function globalRankingsLink(){var e=getActualCc();if(isMCups)return"classement.php?mcup="+nid+"&cc="+e;switch(page){case"MK":return"classement.php?cc="+e;case"CI":return"classement.php"+(isSingle?"?circuit="+nid:"?scup="+nid)+"&cc="+e;case"MA":return"classement.php"+(isSingle?"?draw="+nid:"?ccup="+nid)+"&cc="+e}}function openRankings(){open(globalRankingsLink())}function exitCircuit(){var e=document.getElementById("changeRace"),t=document.getElementById("supprRace");e&&!t?e.click():document.location.href="index.php"}function showRaceCountIfRelevant(e){var t,a;"CM"!=course&&iRaceCount&&isLocalScore()&&(t=document.createElement("div"),a="BB"==course?toLanguage("Battle","Bataille"):toLanguage("Race","Course"),t.innerHTML=a+" "+(iRaceCount+1),t.style.fontSize=2*iScreenScale+"px",t.style.position="absolute",t.style.color="#ccc",t.style.right=3*iScreenScale+"px",t.style.top=(isOnline?isSingle||isMCups||!isCup?31:27:35)*iScreenScale+"px",e.appendChild(t))}function appendContainers(){for(var e=1;e=gameRules.minPlayers){for(aPlayers=new Array,aIDs=new Array,aPlaces=new Array,aPseudos=new Array,aControllers=new Array,shareLink.options&&shareLink.options.cpu&&(cpuLevel=shareLink.options.cpuLevel||0,cpuLevel=2-cpuLevel,iDificulty=4+.5*cpuLevel,isBattle&&(iDificulty=4.5)),fSelectedClass=gameRules.cc?getRelSpeedFromCc(gameRules.cc):1,bSelectedMirror=!!gameRules.mirror,0<=gameRules.raceCount&&(iRaceCount=gameRules.raceCount),aTeams=new Array,i=0;i=tThen-(new Date).getTime()&&(e=!1)}e?(trs[cCursor].style.backgroundColor="",trs[cCursor].style.color="",++cCursor==nbChoices&&(cCursor=0),trs[cCursor].style.backgroundColor="#F80",trs[cCursor].style.color="white",cTime=Math.round(1.05*cTime),setTimeout(moveCursor,cTime)):clignote(0)}function clignote(e){trs[cCursor].style.backgroundColor=e%2?"":"#F80",trs[cCursor].style.color=e%2?"":"white",e<4?setTimeout(function(){clignote(e+1)},100):setTimeout(function(){$mkScreen.removeChild(oTable),proceedOnlineRaceSelection(rCode)},500),1==e&&(trs[cCursor].getElementsByTagName("td")[0].innerHTML=dCircuits[choixJoueurs[cCursor][2]-1])}oMap=oMaps[aAvailableMaps[choixJoueurs[rCode[1]][2]-1]],onlineSpectatorState?($mkScreen.removeChild(oTable),setTimeout(function(){proceedOnlineRaceSelection(rCode)},500)):moveCursor()}else{if(onlineSpectatorState)return setSpectatorId(void 0),backToSearch(),!0;var oDiv=document.createElement("div");oDiv.style.position="absolute",oDiv.style.left=10*iScreenScale+10+"px",oDiv.style.top=20*iScreenScale+10+"px",oDiv.style.fontSize=2*iScreenScale+"pt",oDiv.innerHTML=1choixJoueurs.length&&(selectedNbTeams=choixJoueurs.length,selectedTeamOpts&&(selectedTeamOpts.length=selectedNbTeams)),t.manualTeams?(setupTeamColors(),selectOnlineTeams(e,choixJoueurs,playerIsSelecter())):resetGame(e)}function rePosSpectatorLink(){var e,t=document.getElementById("spectatormode");t&&(e=oTable.getBoundingClientRect(),t.style.top=Math.max(e.bottom+5,38*iScreenScale+15)+"px")}onlineSpectatorId?(waitHandler=setTimeout(waitForChoice,1),onlineSpectatorState||showSpectatorLink({toggled:!0,click:function(){clearTimeout(waitHandler),waitHandler=null,$mkScreen.removeChild(oTable)}})):(xhr("chooseMap.php","joueur="+strPlayer+"&map="+map+("BB"==course?"&battle":"")+(rand?"&rand":""),refreshTab),hideSpectatorLink(),window.onbeforeunload=function(){return language?"Caution, if you leave the game, you are considered loser":"Attention, si vous quittez la partie, vous êtes considéré comme perdant"});var waitHandler=0;function waitForChoice(){var e=[];onlineSpectatorId&&e.push("spectator="+onlineSpectatorId),"BB"==course&&e.push("battle"),xhr("getMap.php",e.join("&"),refreshTab)}oTable.appendChild(oTBody),$mkScreen.appendChild(oTable),document.getElementById("waitrace").style.visibility="hidden",updateMenuMusic(1),formulaire.dataset.disabled=1,bMusic&&(startMusicHandler=setInterval(function(){oMapImg&&(loadMapMusic(),clearInterval(startMusicHandler))},onlineSpectatorState?10:500))}function leaveRaceWheelScreen(){clearRaceWheenScreen(),removeMenuMusic(),removeGameMusics(),chatting=!1;var e={enableSpectatorMode:!!onlineSpectatorId};setSpectatorId(void(iRaceCount=0)),searchCourse(e)}function clearRaceWheenScreen(){clearInterval(startMusicHandler),formulaire.dataset.disabled="",hideSpectatorLink()}function setSpectatorId(e){(onlineSpectatorId=e)||(onlineSpectatorState=void 0),rtcService&&rtcService.setSpectatorId(onlineSpectatorId)}function selectOnlineTeams(s,e,t){var y=document.createElement("div"),a=y.style;a.width=iWidth*iScreenScale+"px",a.height=iHeight*iScreenScale+"px",a.border="solid 1px black",a.backgroundColor="black";var n=selectedTeamOpts&&selectedTeamOpts.some(function(e){return e.name}),a=toTitle(toLanguage("Team selection","Sélection des équipes"),.5);n?(a.style.top="0px",a.style.fontSize=Math.round(5*iScreenScale)+"px"):a.style.fontSize=Math.round(7*iScreenScale)+"px",y.appendChild(a);var c=document.createElement("div");if(c.style.display="none",c.style.position="absolute",c.style.zIndex=5e4,c.style.left=iScreenScale+"px",c.style.top=10*iScreenScale+"px",c.style.width=(iWidth-2)*iScreenScale+"px",c.style.height=iScreenScale*(iHeight-10)+"px",c.style.overflow="auto",c.style.textAlign="center",n){c.style.top=7.5*iScreenScale+"px",c.style.paddingTop=2.5*iScreenScale+"px",(C=document.createElement("div")).style.position="absolute",C.style.left=iScreenScale+"px",C.style.top="0px",C.style.width=(iWidth-2)*iScreenScale+"px",C.style.textAlign="center",C.style.fontSize=2*iScreenScale+"px",C.style.whiteSpace="nowrap",C.style.color="white";for(var o=0;ochacun pour soi."),function(){clearTimeout(h);var e="noteams";isBattle&&(e+="&battle"),isSingle&&(e+="&single"),m(),xhr("chooseTeams.php",e,function(e){if(!e)return!1;var t;try{t=JSON.parse(e)}catch(e){return!1}return l(t),!0})})},p.appendChild(n);n=document.createElement("input");function r(e,t,a){var n=document.createElement("div");n.id="online-teams-confirm",n.style.position="absolute",n.style.left=0,n.style.top=0,n.style.width=iWidth*iScreenScale+"px",n.style.height=iHeight*iScreenScale+"px",n.style.backgroundColor="rgba(0,0,0, 0.5)",n.style.zIndex=6e4;var o=document.createElement("div");o.style.position="absolute",o.style.zIndex=6e4,o.style.left=Math.round(iScreenScale*iWidth/2)+"px",o.style.top=Math.round(iScreenScale*iHeight/2)+"px",o.style.width=40*iScreenScale+"px",o.style.transform=o.style.WebkitTransform=o.style.MozTransform="translate(-50%, -50%)",o.style.backgroundColor="gray",o.style.border="solid 1px silver",o.onclick=function(e){e.stopPropagation()};var i=document.createElement("div");i.style.marginTop=iScreenScale+"px",i.style.marginBottom=Math.round(iScreenScale/2)+"px",i.style.fontSize=Math.round(2.5*iScreenScale)+"px",i.style.textAlign="center",i.style.marginLeft=2*iScreenScale+"px",i.style.marginRight=2*iScreenScale+"px",i.style.color="#FE9",i.innerHTML=e,o.appendChild(i);i=document.createElement("div");i.style.marginBottom=iScreenScale+"px",i.style.textAlign="center",i.style.marginLeft=Math.round(1.5*iScreenScale)+"px",i.style.marginRight=Math.round(1.5*iScreenScale)+"px",i.style.fontSize=Math.round(1.8*iScreenScale)+"px",i.style.color="white",i.innerHTML=t,o.appendChild(i);t=document.createElement("div");t.style.textAlign="center",t.style.marginBottom=iScreenScale+"px";var r=document.createElement("input");r.type="button",r.style.marginRight=Math.round(iScreenScale/2)+"px",r.value="Ok",r.style.fontSize=Math.round(2*iScreenScale)+"px",r.onclick=function(){return y.removeChild(n),a(),!1},t.appendChild(r);i=document.createElement("input");return i.type="button",i.value=toLanguage("Cancel","Annuler"),i.style.marginLeft=Math.round(iScreenScale/2)+"px",i.style.fontSize=Math.round(2*iScreenScale)+"px",i.onclick=n.onclick=function(){return y.removeChild(n),!1},t.appendChild(i),o.appendChild(t),n.appendChild(o),y.appendChild(n),setTimeout(function(){r.focus()},1),n}function S(e){f.innerHTML="";for(var t=v.reduce(function(e,t){return Math.max(e,t.length)},0),a=0;afor all players. Use this option if you're waiting for more players for example.",'Attention, vous êtes sur le point d\'annuler la partie pour tous les joueurs. Utilisez cette option si vous attendez plus de joueurs par exemple.'),function(){clearTimeout(h);var e="cancel";isBattle&&(e+="&battle"),m(),xhr("chooseTeams.php",e,function(e){if(!e)return!1;try{JSON.parse(e)}catch(e){return!1}return u(),!0})})},p.appendChild(n),y.appendChild(p);for(var v=new Array(selectedNbTeams),o=0;o30 seconds left to choose the next race','Il vous reste 30 secondes pour choisir la prochaine course'),team:toLanguage('There are 10 seconds left to choose the teams','Il vous reste 10 secondes pour choisir les équipes')},(a=document.createElement("div")).id="wait"+e,a.className="wait",a.innerHTML=t[e],document.getElementById("mariokartcontainer").appendChild(a)),a.style.left=2*iScreenScale+10+"px",a.style.top=35*iScreenScale+10+"px",a.style.minWidth=iScreenScale*(iWidth-4)+"px",a.style.fontSize=3*iScreenScale+"px")}function showSpectatorLink(t){hideSpectatorLink();var e=document.createElement("div");e.id="spectatormode",e.style.left=2*iScreenScale+10+"px",e.style.top=38*iScreenScale+15+"px",e.style.width=iScreenScale*(iWidth-4)+"px",e.style.fontSize=Math.round(2.25*iScreenScale)+"px";var a=document.createElement("img");a.src="images/ic_spectator.png",a.alt="Toggle",a.style.height=Math.round(1.75*iScreenScale)+"px",a.style.marginRight=Math.round(iScreenScale/4)+"px",e.appendChild(a);var a=document.createElement("a"),n=!(a.href="#null");t.toggled?(a.innerHTML=toLanguage("Exit spectator mode","Quitter le mode spectateur"),a.onclick=function(e){e.preventDefault(),n||(n=!0,t.click(),xhr("getCourse.php",getOnlineCourseParams({spectator:onlineSpectatorId}),function(e){if(!e)return!1;try{e=JSON.parse(e)}catch(e){return!1}return e.found?(clearRaceWheenScreen(),setSpectatorId(void 0),handleMatchmakingSuccess(e)):(choose(),hideSpectatorLink(),showExitSpectatorFailMessage()),!0}))}):(a.title=toLanguage("You'll see games but not play on it","Vous verrez les parties mais ne jouerez pas dedans"),a.innerHTML=toLanguage("Switch to spectator mode","Passer en mode spectateur"),a.onclick=function(e){e.preventDefault(),n||(n=!0,t.click(),xhr("spectatorMode.php","",function(e){return 0",l=0;l'+(l+1)+". "+timeStr(n[l]);oPersoLapTimes.dataset.title=r}}function multiGhosts(n){oScr.innerHTML="";var e=gID-3,t=gID+4;e<0?t-=e:t>n.length&&(e-=t-n.length),e=Math.max(e,0),t=Math.min(t,n.length),(gIDs=new Array).length=t-e;for(var a=0,o=e;o=n.length&&(gIDs[e]=0),writeTime(n[gIDs[e]][1],n[gIDs[e]][2],n[gIDs[e]][3],n[gIDs[e]][4],t,a)}}(a,p,s),i.appendChild(u),l.appendChild(s),r.appendChild(l),i.appendChild(r),oScr.appendChild(i),a++}var m=gIDs.length,h=document.createElement("div");h.style.textAlign="center",h.style.position="absolute",h.style.left=2*iScreenScale+"px",h.style.top=29*iScreenScale+"px",h.style.width=76*iScreenScale+"px",h.style.color="white";var g=document.createElement("span");g.style.fontSize=Math.round(2.5*iScreenScale)+"px",g.innerHTML=toLanguage("Number of ghosts:","Nombre de fantômes :"),g.style.marginRight=Math.round(1.2*iScreenScale)+"px",h.appendChild(g);var y=document.createElement("input");y.type="button",y.value="-",y.style.fontSize=3*iScreenScale+"px",y.onclick=function(){m--,oScr.querySelectorAll(".igScr")[m].style.visibility="hidden",b()};var f=document.createElement("span");f.style.fontSize=Math.round(2.5*iScreenScale)+"px",f.style.marginLeft=f.style.marginRight=Math.round(1.5*iScreenScale)+"px";var S=document.createElement("input");S.type="button",S.value="+",S.onclick=function(){oScr.querySelectorAll(".igScr")[m].style.visibility="visible",m++,b()},y.className=S.className="disablable",y.style.borderRadius=S.style.borderRadius="50%",y.style.fontSize=y.style.lineHeight=S.style.fontSize=S.style.lineHeight=3*iScreenScale+"px",y.style.width=y.style.height=S.style.width=S.style.height=4*iScreenScale+"px",h.appendChild(y),h.appendChild(f),h.appendChild(S),oScr.appendChild(h);h=document.createElement("input");h.type="button",h.value=toLanguage("Back","Retour"),h.style.fontSize=2*iScreenScale+"px",h.style.position="absolute",h.style.left=2*iScreenScale+"px",h.style.top=36*iScreenScale+"px",h.onclick=function(){oScr.innerHTML="",oContainers[0].removeChild(oScr),selectFantomeScreen(ghostsData,map,{times:n,id:gID})},oScr.appendChild(h);var v=document.createElement("input");function b(){f.innerHTML=m,v.value=toLanguage("Face with "+m+" ghost"+(1=gIDs.length}v.type="button",b(),v.style.fontSize=Math.round(2.5*iScreenScale)+"px",v.style.position="absolute",v.style.right=5*iScreenScale-10+"px",v.style.top=35*iScreenScale+"px",v.onclick=function(){gIDs.length=m,seeGhost(!1)},oScr.appendChild(v);h=document.createElement("input");h.type="button",h.value=toLanguage("See race","Voir la course"),h.style.fontSize=Math.round(2.5*iScreenScale)+"px",h.style.position="absolute",h.style.right=33*iScreenScale-10+"px",h.style.top=35*iScreenScale+"px",h.onclick=function(){gIDs.length=m,seeGhost(!0)},oScr.appendChild(h)}function showGhosts(){if(gTimes.length){for(i=0;i=ghostsData[3];)gID--;!gID&&1=gTimes.length&&(gID=0),writeTime(gTimes[gID][1],gTimes[gID][2],gTimes[gID][3],gTimes[gID][4]),ghostsData)&&gTimes[gID][0]===ghostsData[0];e++);},oScr.appendChild(o);var r,o=document.createElement("input");o.id="ffDroite",o.type="button",o.value="⏭",o.style.fontSize=4*iScreenScale+"px",o.style.position="absolute",o.style.left=72*iScreenScale+"px",o.style.top=a+"px",o.style.height=n+"px",o.onclick=function(){gID=gTimes.length-1,writeTime(gTimes[gID][1],gTimes[gID][2],gTimes[gID][3],gTimes[gID][4])},oScr.appendChild(o),ghostsData?oScr.style.visibility="visible":oContainers[0].appendChild(oScr),writeTime(gTimes[gID][1],gTimes[gID][2],gTimes[gID][3],gTimes[gID][4]),OPFace&&(OPFace.style.display="none"),document.body.style.cursor="default",(OPFace7=document.createElement("input")).type="button",OPFace7.value=toLanguage("7 ghosts...","7 fantômes..."),OPFace7.style.fontSize=2*iScreenScale+"px",OPFace7.style.position="absolute",OPFace7.style.right=2*iScreenScale+"px",OPFace7.style.top=36*iScreenScale+"px",OPFace7.onmouseover=function(){r||((r=document.createElement("div")).style.position="absolute",r.style.textAlign="center",r.style.fontSize=2*iScreenScale+"px",r.style.width=30*iScreenScale+"px",r.style.right=2*iScreenScale+"px",r.style.bottom=4*iScreenScale+"px",r.style.backgroundColor="rgba(204,192,178,0.95)",r.style.padding=Math.round(iScreenScale/2)+" "+iScreenScale+"px",r.style.color="#363330",r.innerHTML=toLanguage("Play with 7 ghosts with the same level as the ghost above","Affronter 7 fantômes du même niveau que le fantôme ci-dessus"),r.style.borderBottomLeftRadius=iScreenScale+"px",r.style.borderTopRightRadius=iScreenScale+"px",oScr.appendChild(r))},OPFace7.onmouseout=function(){r&&(oScr.removeChild(r),r=null)},OPFace7.onclick=function(){r&&(oScr.removeChild(r),r=null),multiGhosts(gTimes)},oScr.appendChild(OPFace7)}else if(ghostsData)alert(language?"No other record for this circuit yet":"Aucun autre record pour ce circuit"),oScr.style.visibility="visible",gID=-1,document.body.style.cursor="default";else{oScr.innerHTML="";try{oContainers[0].removeChild(oScr)}catch(e){}document.body.style.cursor="default",gPersos.length=0,resetGame(aAvailableMaps[map])}}function otherGhosts(){document.body.style.cursor="progress",ghostsData&&(oScr.style.visibility="hidden"),xhr("otherghosts.php","map="+getCreationId(oMaps[aAvailableMaps[map]])+"&type="+getCreationTable()+"&cc="+getActualCc(),function(reponse){if(reponse){try{gTimes=eval(reponse)}catch(e){return!1}return showGhosts(),!0}return!1})}function seeGhost(replay){if(replay&&(pause=!0,fInfos.replay=!0,gSelectedPerso=strPlayer[0]),-1==gID)oScr.innerHTML="",oContainers[0].removeChild(oScr),gOverwriteRecord=1,replay?(strPlayer[0]=ghostsData[1],iRecord=ghostsData[3],iLapTimes=ghostsData[4],iTrajet=ghostsData[5]):(gPersos=[ghostsData[1]],iLapTimes=ghostsData[4],jTrajets=[ghostsData[5]]),resetGame(aAvailableMaps[map]);else{var xhrUrl,xhrData;if(oScr.innerHTML="",oContainers[0].removeChild(oScr),document.body.style.cursor="progress",gIDs){xhrUrl="ghostsrace.php",xhrData="";for(var i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'"):""}function stripSpecialChars(e){return e.replace(/&[#\w]+;/g,"_").replace(/<\w+>(.+?)<\/\w+>/g,"$1")}function mapNameOf(e,t){var a=document.createElement("div"),n=isCup?Math.min(Math.max(9/Math.sqrt(stripSpecialChars(lCircuits[t]).length),1.4),4):2.1;a.style.fontSize=Math.round(e*n)+"px",a.className="mapname",a.style.textAlign="center",a.innerHTML=dCircuits[t];t=a.querySelector("small");return t&&(t.style.fontSize=2*iScreenScale+"px"),a}function addOption(e,t,a,n,o,i){document.getElementById(e).innerHTML=t.replace(/ /g," "),document.getElementById(a).innerHTML="";var r,l=document.createElement("select");l.name=n;for(var s=0;s'+e+"
")+'Edit',document.getElementById("commandes-edit").onclick=function(){editCommands()}}}function updateCommandSheet(){var a=getCommands(null,2),n=navigator.platform&&0<=navigator.platform.toUpperCase().indexOf("MAC");function e(e,t){var a=language?"P":"J";return 1==oContainers.length?e:a+"1 : "+e+"; "+a+"2 : "+t}function t(e){var t=a[e],e=t[0];return t[1]&&n&&(e=t[1]),getKeyName(e)}displayCommands(""+toLanguage("Move","Se diriger")+" : "+e(t("up")+t("left")+t("down")+t("right"),t("up_p2")+t("left_p2")+t("down_p2")+t("right_p2"))+'
'+toLanguage("Use item","Utiliser un objet")+" : "+e(t("item"),t("item_p2"))+"
"+toLanguage("Item backwards","Objet en arrière")+" : "+e(t("item_back"),t("item_back_p2"))+"
"+("BB"==course?"":""+toLanguage("Item forwards","Objet en avant")+" : "+e(t("item_fwd"),t("item_fwd_p2"))+"

")+""+toLanguage("Jump/drift","Sauter/déraper")+" : "+e(t("jump"),t("jump_p2"))+("BB"==course?"
"+toLanguage("Inflate a balloon","Gonfler un ballon")+" : "+e(t("balloon"),t("balloon_p2")):"")+"
"+toLanguage("Rear/Front view","Vue arrière/avant")+" : "+e(t("rear"),t("rear_p2"))+"
"+toLanguage("Pause","Mettre en pause")+" : "+t("pause")+"
"+toLanguage("Quit","Quitter")+" : "+t("quit"))}function editCommands(n){clearInterval(pollingGamepadsHandler);var e=!!n,a=(n=n||{}).currentTab||0,u=n.selectedPlayer||0,m=n.selectedDevice||"keyboard",t=u+1,o=document.getElementById("control-editor-mask");if(!o||(document.body.removeChild(o),e)){(o=document.createElement("div")).id="control-editor-mask",o.onclick=function(){editCommands()};var i=document.createElement("div");i.className="control-editor",i.onclick=function(e){e.stopPropagation()};var r=document.createElement("div");r.className="control-header";e=document.createElement("div");e.innerHTML=toLanguage("Game settings","Paramètres du jeu"),r.appendChild(e);e=document.createElement("button");e.className="control-close",e.innerHTML="×",e.onclick=function(){editCommands()},r.appendChild(e),i.appendChild(r);var l=document.createElement("div");l.className="control-tabs";for(var s=[toLanguage("Edit controls","Modifier les contrôles"),toLanguage("Advanced settings","Paramètres avancés")],c=0;c div")[e].classList.add("control-window-active"),a=e,n.currentTab=a},l.appendChild(t)}(c);i.appendChild(l);e=document.createElement("div");e.className="control-window";r=document.createElement("div");if(r.className="control-window-active",!n.pc&&isMobile()){var p=(p=localStorage.getItem("settings.ctrl"))?JSON.parse(p):{},d=document.createElement("div");d.className="control-main-title",d.innerHTML=toLanguage("Command interface","Interface de commandes"),r.appendChild(d);var h=document.createElement("div");h.className="control-type-values";for(var g=[{id:"keyboard",name:toLanguage("Virtual Keyboard","Clavier virtuel"),description:toLanguage("Shows buttons that behave like keys in a keyboard","Affiche des boutons pour simuler les touches d'un clavier"),dropdown:function(e){var t=document.createElement("label"),a=document.createElement("span");a.innerHTML=toLanguage("Keyboard layout:","Disposition des touches :"),t.appendChild(a);var n,o=document.createElement("select"),i={"":toLanguage("Default","Par défaut"),h_sym:toLanguage("Horizontal symmetry","Symétrie horizontale"),v_sym:toLanguage("Vertical symmetry","Symétrie verticale"),vh_sym:toLanguage("Both symmetries","Symétrie mixte"),old:toLanguage("Old version","Ancienne version")},r=p.layout||"";for(n in i){var l=document.createElement("option");(l.value=n)===r&&(l.selected="selected"),l.innerHTML=i[n],o.appendChild(l)}t.appendChild(o),o.onchange=function(){this.value?p.layout=this.value:delete p.layout,localStorage.setItem("settings.ctrl",JSON.stringify(p))},e.appendChild(t)}},{id:"gestures",name:toLanguage("Touch controls","Contrôles tactiles"),description:toLanguage("Swipe the screen to go in the desired direction. Controls similar to Mario Kart Tour","Balayez l'écran pour vous diriger dans la direction souhaitée. Contrôles similaires à Mario Kart Tour"),dropdown:function(e){var t=document.createElement("a");t.className="control-touch-help",t.href="#null",t.innerHTML=toLanguage("How touch controls work...","Aide sur les contrôles tactiles..."),t.onclick=function(){return window.open("helpTouchCtrls.php","help","scrollbars=1, resizable=1, width=500, height=500"),!1},e.appendChild(t)}},{id:"external",name:toLanguage("External controller","Contrôleur externe"),description:toLanguage("Connect an external keyboard or gamepad","Connetez un clavier ou une manette externe"),dropdown:function(e){var t=document.createElement("a");t.className="control-ext-settings",t.href="#null",t.innerHTML=toLanguage("Controller settings...","Paramètres du contrôlleur..."),t.onclick=function(){return n.pc=!0,editCommands(n),!1},e.appendChild(t)}}],y=p.mode||"keyboard",c=0;c🎮',t.innerHTML+="
"+toLanguage("Connect a gamepad and press any button to continue","Connectez une manette et appuyez sur n'importe quel bouton pour continuer")+"
",r.appendChild(t),clearInterval(pollingGamepadsHandler),pollingGamepadsHandler=setInterval(function(){for(var e=navigator.getGamepads(),t=0;t"+toLanguage("Selected:","Séléctionné :")+" "+T["_name"+P],q.appendChild(K),(W=document.createElement("a")).href="#null",W.innerHTML=toLanguage("[Reset]","[Réinitiliser]"),W.onclick=function(){if(confirm(toLanguage("Reset controller selection?","Réinitialiser la sélection de la manette ?"))){delete T["_id"+P],delete T["_name"+P];for(var e=0;e div")[a].click()}else document.querySelector("#commandes strong")&&updateCommandSheet();function $(e,t){var a=document.createElement("label"),n=document.createElement("input");n.type="checkbox",n.checked=!!B[e],a.appendChild(n);var o=document.createElement("span");o.innerHTML=t,a.appendChild(o),n.onclick=function(){this.checked?B[e]=1:delete B[e],localStorage.setItem("settings",JSON.stringify(B))},D.appendChild(a)}}function getKeyName(e,t){if("gamepad"!==t)return this.keyMatching||(this.keyMatching=["","","","Break","","","","","Backspace","Tab","","","Clear","Enter","","","Shift","Ctrl","Alt","Pause","CapsLock","Hangul","","","","Hanja","",toLanguage("Escape","Échap"),"Conversion","Non-conversion","","",toLanguage("Spacebar","Espace"),"PageUp","PageDown","End","Home","←","↑","→","↓","Select","Print","Execute",toLanguage("Print Screen","ImpEcr"),"Inser",toLanguage("Delete","Suppr"),"Help","0","1","2","3","4","5","6","7","8","9",":","=","<","=","","SS","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","Meta","Meta","Meta","","Sleep","0","1","2","3","4","5","6","7","8","9","×","+",".","-",".","/","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","F13","F14","F15","F16","F17","F18","F19","F20","F21","F22","F23","F24","","","","","","","","","NumLock","ScrollLock","","","","","","","","","","","","","","","^","!","؛","#","$","Ù","PageDown","PageUp","Refresh",")","*","~","Home","-","Vol. down","Vol. up","Next","Previous","Stop","Play/pause","@","Mute","Vol. down","Vol. up","","","Ñ","=",",","#",".","/","%","°",",","","","","","","","","","","","","","","","","","","","","","","","","","{","\\","}","'","`","Meta","AltGr","<","","","","Compose","Ç","","Forward","Back","Non-conversion","","","","","Alphanumeric","","Hiragana","Half-width","Kanji","","","","","","","Unlock Trackpad","","","","Toggle Touchpad"]),this.keyMatching[e]||"#"+e;for(var a=[],n=0;n"+t+""}function toTitle(e,t){var a=document.createElement("div");return a.style.width=iWidth*iScreenScale+"px",a.style.fontSize=Math.round(8*iScreenScale)+"px",a.style.fontWeight="normal",a.style.position="absolute",a.style.left="0px",a.style.top=Math.round(t*iScreenScale)+"px",a.style.textAlign="center",a.style.color=primaryColor,a.innerHTML=e,a.style.fontFamily="Tahoma",a}function ucwords(e){return e.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g,function(e){return e.toUpperCase()})}function toPerso(e){if(isCustomPerso(e))return customPersos[e].name;var t=e;return language?"maskass"==e?t="shy guy":"skelerex"==e?t="dry bones":"harmonie"==e?t="rosalina":"roi_boo"==e?t="king boo":"frere_marto"==e?t="hammer bro":"bowser_skelet"==e?t="dry bowser":"flora_piranha"==e&&(t="petey piranha"):"frere_marto"==e&&(t="frère marto"),t=ucwords(t=t.replace(/_/g," "))}var isMobileCache=!!(navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)),$commandes;function isMobile(){return isMobileCache}function isChatting(){return isOnline&&(document.forms[1]&&(document.forms[1].elements.rMessage&&document.activeElement==document.forms[1].elements.rMessage))}function onButtonTouch(e){e&&e.preventDefault(),this.style.backgroundColor="#603",this.dataset.pressed="1",navigator.vibrate(30);for(var t=this.dataset.key.split(","),a=0;a"+toLanguage("Message not sent (reason: "+t+")","Message non envoyé (raison : "+t+")")+"",oMessages.appendChild(e),oMessages.scrollTop=oMessages.scrollHeight-oMessages.clientHeight),!0}),rMessage.value=""),!1},oChat.appendChild(oConnectes),oChat.appendChild(oMessages),oChat.appendChild(oRepondre);var iChatLastMsg=0;rtcService=rtcService||RTCService({spectatorId:onlineSpectatorId}),refreshChat(),vConnectes.disabled=!0,rtcService.getVocChat({callback:function(e){e&&(vConnectes.style.display="none",vChatActions.style.display="inline-block"),vConnectes.disabled=!1}}),document.body.insertBefore(oChat,$mkScreen);try{handleChatPos()}catch(e){console.error(e)}}function removeBlockDialog(){return oBlockDialog&&(oChat.removeChild(oBlockDialog),oBlockDialog=null,1)}function showMemberList(title,blockedFn,onSelect){var oBlockTitle,oBlockClose,oBlockMembers;removeBlockDialog()||(oBlockDialog=document.createElement("div"),oBlockDialog.className="online-chat-blockdialog",oBlockDialog.style.position="absolute",oBlockDialog.style.left="85px",oBlockDialog.style.top="8%",oBlockDialog.style.width="200px",oBlockDialog.style.border="double 4px silver",oBlockDialog.style.backgroundColor="#222",oBlockTitle=document.createElement("h1"),oBlockTitle.innerHTML=title,oBlockDialog.appendChild(oBlockTitle),oBlockClose=document.createElement("input"),oBlockClose.type="button",oBlockClose.onclick=function(){removeBlockDialog()},oBlockClose.value="×",oBlockDialog.appendChild(oBlockClose),oBlockMembers=document.createElement("div"),oBlockMembers.className="online-chat-blockdialog-members",xhr("listCoursePlayers.php",onlineSpectatorId?"spectator="+onlineSpectatorId:"",function(reponse){if(reponse){try{var rCode=eval(reponse)}catch(e){return!1}for(var i=0;i
Spectator
Voc
',jConnectes.appendChild(sNom)),isIcon=!1,sNom.querySelector(".online-chat-playerlistname").innerText=cPlayer.name,cPlayer.spectator?(sNom.querySelector(".online-chat-spectator").style.display="",isIcon=!0):sNom.querySelector(".online-chat-spectator").style.display="none",cPlayer.peer?(isIcon=!0,sNom.querySelector(".online-chat-playerlisticonwrapper").style.display="",sNom.querySelector(".online-chat-playerlisticonwrapper img").src="images/"+(cPlayer.muted?"ic_muted":"ic_voc")+".png",cPeer=rtcService.getPeer(cPlayer.peer),cPeer&&cPeer.audio&&(cPeer.recorderHandler||function(o,i){var e,r,l;i&&(e=new AudioContext,r=e.createAnalyser(),e.createMediaStreamSource(o.audio.srcObject).connect(r),l=new Uint8Array(r.fftSize),o.recorderHandler=setInterval(function(){if(!o.audio.parentNode||!document.body.contains(i)||!cPlayerPeers[identifiant])return clearInterval(o.recorderHandler),delete o.recorderHandler,r.disconnect(),i.style.width="",i.style.height="",i.style.left="",void(i.style.top="");r.getByteTimeDomainData(l);for(var e=0,t=0;t