function control(){this.init()}control.prototype.init=function(){};control.prototype.setRequestAnimationFrame=function(){(function(){var c=0;var d=["webkit","moz"];for(var e=0;ecore.animateFrame.speed&&core.isset(core.status.globalAnimateObjs)){for(var c=0;ccore.animateFrame.speed&&core.isset(core.status.boxAnimateObjs)&&core.status.boxAnimateObjs.length>0){core.drawBoxAnimate();core.animateFrame.boxTime=g}if(g-core.animateFrame.moveTime>16&&core.isset(core.status.heroMoving)&&core.status.heroMoving>0){var h=core.getHeroLoc("x"),i=core.getHeroLoc("y"),e=core.getHeroLoc("direction");if(core.status.heroMoving<=4){core.drawHero(e,h,i,"leftFoot",4*core.status.heroMoving*b[e].x,4*core.status.heroMoving*b[e].y)}else{if(core.status.heroMoving<=8){core.drawHero(e,h,i,"rightFoot",4*core.status.heroMoving*b[e].x,4*core.status.heroMoving*b[e].y)}}core.animateFrame.moveTime=g}if(core.isPlaying()&&g-core.animateFrame.weather.time>30){if(core.animateFrame.weather.type=="rain"&&core.animateFrame.weather.level>0){core.clearMap("weather",0,0,416,416);core.canvas.weather.strokeStyle="rgba(174,194,224,0.8)";core.canvas.weather.lineWidth=1;core.canvas.weather.lineCap="round";core.animateFrame.weather.nodes.forEach(function(j){core.canvas.weather.beginPath();core.canvas.weather.moveTo(j.x,j.y);core.canvas.weather.lineTo(j.x+j.l*j.xs,j.y+j.l*j.ys);core.canvas.weather.stroke();j.x+=j.xs;j.y+=j.ys;if(j.x>416||j.y>416){j.x=Math.random()*416;j.y=-10}});core.canvas.weather.fill()}else{if(core.animateFrame.weather.type=="snow"&&core.animateFrame.weather.level>0){core.clearMap("weather",0,0,416,416);core.canvas.weather.fillStyle="rgba(255, 255, 255, 0.8)";core.canvas.weather.beginPath();if(!core.isset(core.animateFrame.weather.data)){core.animateFrame.weather.data=0}core.animateFrame.weather.data+=0.01;var d=core.animateFrame.weather.data;core.animateFrame.weather.nodes.forEach(function(j){core.canvas.weather.moveTo(j.x,j.y);core.canvas.weather.arc(j.x,j.y,j.r,0,Math.PI*2,true);j.x+=Math.sin(d)*2;j.y+=Math.cos(d+j.d)+1+j.r/2;if(j.x>416+5||j.x<-5||j.y>416){if(Math.random()>1/3){j.x=Math.random()*416;j.y=-10}else{if(Math.sin(d)>0){j.x=-5;j.y=Math.random()*416}else{j.x=416+5;j.y=Math.random()*416}}}});core.canvas.weather.fill()}}core.animateFrame.weather.time=g}window.requestAnimationFrame(a)};window.requestAnimationFrame(a)};control.prototype.showStartAnimate=function(a){core.dom.startPanel.style.opacity=1;core.dom.startPanel.style.display="block";core.dom.startTop.style.opacity=1;core.dom.startTop.style.display="block";core.dom.startButtonGroup.style.display="none";core.dom.startButtons.style.display="block";core.dom.levelChooseButtons.style.display="none";core.dom.curtain.style.background="#000000";core.dom.curtain.style.opacity=0;core.status.played=false;core.clearStatus();core.clearMap("all");var b=1;var c=window.setInterval(function(){b-=0.03;if(b<0){clearInterval(c);core.dom.startTop.style.display="none";core.dom.startButtonGroup.style.display="block";if(core.isset(a)){a()}}core.dom.startTop.style.opacity=b},20)};control.prototype.hideStartAnimate=function(a){var b=1;var c=window.setInterval(function(){b-=0.03;if(b<0){clearInterval(c);core.dom.startPanel.style.display="none";if(core.isset(a)){a()}}core.dom.startPanel.style.opacity=b},20)};control.prototype.isPlaying=function(){return core.isset(core.status.played)&&core.status.played};control.prototype.clearStatus=function(){for(var a in core.timeout){clearTimeout(core.timeout[a]);core.timeout[a]=null}for(var a in core.interval){clearInterval(core.interval[a]);core.interval[a]=null}core.status={};core.clearStatusBar();core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};control.prototype.resetStatus=function(c,b,a,e,d){var f=0;if(core.isset(core.status)&&core.isset(core.status.hero)&&core.isset(core.status.hero.statistics)&&core.isset(e)){f=core.status.hero.statistics.totalTime}this.clearStatus();core.status=core.clone(core.initStatus);core.status.played=true;core.status.floorId=a;core.status.maps=core.clone(d);core.material.enemys=core.clone(core.enemys.getEnemys());core.status.hero=core.clone(c);if(!core.isset(core.status.hero.statistics)){core.status.hero.statistics={totalTime:f,currTime:0,hp:0,battleDamage:0,poisonDamage:0,extraDamage:0,moveDirectly:0,ignoreSteps:0,}}core.status.hero.statistics.totalTime=Math.max(core.status.hero.statistics.totalTime,f);core.status.hero.statistics.start=null;core.status.hard=b;if(core.isset(e)){core.status.route=e}core.status.saveIndex=core.getLocalStorage("saveIndex2",1)};control.prototype.startGame=function(b,a){console.log("开始游戏");this.resetStatus(core.firstData.hero,b,core.firstData.floorId,null,core.initStatus.maps);core.changeFloor(core.status.floorId,null,core.firstData.hero.loc,null,function(){if(core.isset(a)){a()}},true);setTimeout(function(){var c=new FormData();c.append("type","people");c.append("name",core.firstData.name);c.append("version",core.firstData.version);c.append("platform",core.platform.isPC?"PC":core.platform.isAndroid?"Android":core.platform.isIOS?"iOS":"");c.append("hard",b);c.append("hardCode",core.getFlag("hard",0));core.utils.http("POST","/games/upload.php",c)})};control.prototype.restart=function(){this.showStartAnimate();if(core.bgms.length>0){core.playBgm(core.bgms[0])}};control.prototype.clearAutomaticRouteNode=function(a,b){if(core.status.event.id==null){core.canvas.ui.clearRect(a*32+5,b*32+5,27,27)}};control.prototype.stopAutomaticRoute=function(){if(!core.status.played){return}core.status.automaticRoute.autoHeroMove=false;core.status.automaticRoute.autoStep=0;core.status.automaticRoute.destStep=0;core.status.automaticRoute.movedStep=0;core.status.automaticRoute.autoStepRoutes=[];core.status.automaticRoute.destX=null;core.status.automaticRoute.destY=null;core.status.automaticRoute.lastDirection=null;core.stopHero();if(core.status.automaticRoute.moveStepBeforeStop.length==0){core.canvas.ui.clearRect(0,0,416,416)}};control.prototype.continueAutomaticRoute=function(){var a=core.status.automaticRoute.moveStepBeforeStop;if(a.length===0||(a.length===1&&a[0].step===1)){core.status.automaticRoute.moveStepBeforeStop=[]}else{core.setAutoHeroMove(a)}};control.prototype.clearContinueAutomaticRoute=function(){core.canvas.ui.clearRect(0,0,416,416);core.status.automaticRoute.moveStepBeforeStop=[]};control.prototype.setAutomaticRoute=function(a,b,h){if(!core.status.played||core.status.lockControl){return}if(core.status.automaticRoute.autoHeroMove){var c=core.status.automaticRoute.destX,d=core.status.automaticRoute.destY;core.stopAutomaticRoute();if(c==a&&d==b){core.status.automaticRoute.moveDirectly=true;setTimeout(function(){if(core.status.automaticRoute.moveDirectly&&core.status.heroMoving==0){var j=core.canMoveDirectly(a,b);if(j>0){core.clearMap("hero",0,0,416,416);core.setHeroLoc("x",a);core.setHeroLoc("y",b);core.drawHero();core.status.route.push("move:"+a+":"+b);core.status.hero.statistics.moveDirectly++;core.status.hero.statistics.ignoreSteps+=j}}core.status.automaticRoute.moveDirectly=false},100)}return}if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y&&h.length==0){if(core.timeout.turnHeroTimeout==null){core.timeout.turnHeroTimeout=setTimeout(function(){core.turnHero();clearTimeout(core.timeout.turnHeroTimeout);core.timeout.turnHeroTimeout=null},250)}else{clearTimeout(core.timeout.turnHeroTimeout);core.timeout.turnHeroTimeout=null;core.getNextItem()}return}var g=0;var i=null;var f;if(!(f=core.automaticRoute(a,b))){if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y){f=[]}else{core.canvas.ui.clearRect(0,0,416,416);return}}f=f.concat(h);core.status.automaticRoute.destX=a;core.status.automaticRoute.destY=b;core.canvas.ui.save();core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.fillStyle="#bfbfbf";core.canvas.ui.strokeStyle="#bfbfbf";core.canvas.ui.lineWidth=8;for(var e=0;e12||t<0||t>12){continue}var l=13*s+t;if(core.isset(v[l])){continue}var c=1;var k,j=core.getBlock(s,t);if(j!=null){k=j.block.event.id;if(k=="light"){c=100}if(k.substring(k.length-3)=="Net"){c=core.values.lavaDamage}if(!core.flags.potionWhileRouting&&k.substring(k.length-6)=="Potion"){c=20}if(j.block.event.trigger=="changeFloor"){c=10}}if(core.status.checkBlock.damage[l]>0){c=core.status.checkBlock.damage[l]}if(s==d&&t==e){v[l]=h;break}if(core.noPassExists(s,t)){continue}v[l]=h;u.push(169*(n+c)+l)}if(core.isset(v[13*d+e])){break}}if(!core.isset(v[13*d+e])){return false}var q=d,r=e;while(q!=x||r!=y){var g=v[13*q+r];a.push({direction:g,x:q,y:r});q-=w[g].x;r-=w[g].y}a.reverse();return a};control.prototype.fillPosWithPoint=function(a){core.fillRect("ui",a.x*32+12,a.y*32+12,8,8,"#bfbfbf")};control.prototype.setAutoHeroMove=function(a){a=a||core.status.automaticRoute.autoStepRoutes;if(a.length==0){return}core.status.automaticRoute.autoStepRoutes=a;core.status.automaticRoute.autoHeroMove=true;core.status.automaticRoute.autoStep=1;core.status.automaticRoute.destStep=a[0].step;core.moveHero(a[0].direction)};control.prototype.setHeroMoveInterval=function(b,e,f,a){if(core.status.heroMoving>0){return}core.status.heroMoving=1;var c={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};var d=1;if(core.status.replay.speed>3){d=2}core.interval.heroMoveInterval=window.setInterval(function(){core.status.heroMoving+=d;if(core.status.heroMoving>=8){core.setHeroLoc("x",e+c[b].x);core.setHeroLoc("y",f+c[b].y);core.moveOneStep();core.clearMap("hero",0,0,416,416);core.drawHero(b);clearInterval(core.interval.heroMoveInterval);core.status.heroMoving=0;if(core.isset(a)){a()}}},12.5*d/core.status.replay.speed)};control.prototype.moveAction=function(a){if(core.interval.openDoorAnimate!=null){return}if(core.status.heroMoving>0){return}var e={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};var c=core.getHeroLoc("direction");var f=core.getHeroLoc("x");var g=core.getHeroLoc("y");var d=core.noPass(f+e[c].x,g+e[c].y),b=core.canMoveHero();if(d||!b){if(core.status.event.id!="ski"){core.status.route.push(c)}core.status.automaticRoute.moveStepBeforeStop=[];core.status.automaticRoute.lastDirection=core.getHeroLoc("direction");if(b){core.trigger(f+e[c].x,g+e[c].y)}core.drawHero(c,f,g);if(core.status.automaticRoute.moveStepBeforeStop.length==0){core.clearContinueAutomaticRoute();core.stopAutomaticRoute()}if(core.isset(a)){a()}}else{core.setHeroMoveInterval(c,f,g,function(){if(core.status.automaticRoute.autoHeroMove){core.status.automaticRoute.movedStep++;core.status.automaticRoute.lastDirection=core.getHeroLoc("direction");if(core.status.automaticRoute.destStep==core.status.automaticRoute.movedStep){if(core.status.automaticRoute.autoStep==core.status.automaticRoute.autoStepRoutes.length){core.clearContinueAutomaticRoute();core.stopAutomaticRoute()}else{core.status.automaticRoute.movedStep=0;core.status.automaticRoute.destStep=core.status.automaticRoute.autoStepRoutes[core.status.automaticRoute.autoStep].step;core.setHeroLoc("direction",core.status.automaticRoute.autoStepRoutes[core.status.automaticRoute.autoStep].direction);core.status.automaticRoute.autoStep++}}}else{if(core.status.heroStop){core.drawHero()}}if(core.status.event.id!="ski"){core.status.route.push(c)}core.trigger(core.getHeroLoc("x"),core.getHeroLoc("y"));core.checkBlock();if(core.isset(a)){a()}})}};control.prototype.turnHero=function(){if(core.status.hero.loc.direction=="up"){core.status.hero.loc.direction="right"}else{if(core.status.hero.loc.direction=="right"){core.status.hero.loc.direction="down"}else{if(core.status.hero.loc.direction=="down"){core.status.hero.loc.direction="left"}else{if(core.status.hero.loc.direction=="left"){core.status.hero.loc.direction="up"}}}}core.drawHero();core.canvas.ui.clearRect(0,0,416,416);core.status.route.push("turn")};control.prototype.moveHero=function(b,a){if(core.status.heroMoving!=0){return}if(core.isset(b)){core.setHeroLoc("direction",b)}if(!core.isset(a)){core.status.heroStop=false;core.status.automaticRoute.moveDirectly=false;var c=function(){if(!core.status.heroStop){if(core.hasFlag("debug")&&core.status.ctrlDown){if(core.status.heroMoving!=0){return}core.status.heroMoving=-1;core.eventMoveHero([core.getHeroLoc("direction")],100,function(){core.status.heroMoving=0;c()})}else{core.moveAction();setTimeout(c,50)}}else{core.stopHero()}};c()}else{core.moveAction(function(){a()})}};control.prototype.eventMoveHero=function(f,g,b){g=g||100;core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);var c=[];f.forEach(function(h){if(typeof h=="string"){c.push(h)}else{if(!core.isset(h.value)){c.push(h.direction)}else{for(var j=0;j12||m<0||m>12){continue}if(!r&&Math.abs(c)+Math.abs(d)>o){continue}core.status.checkBlock.damage[13*l+m]+=e.value}}}if(core.enemys.hasSpecial(e.special,18)){for(var c=-1;c<=1;c++){for(var d=-1;d<=1;d++){if(c==0&&d==0){continue}var l=p+c,m=q+d;if(l<0||l>12||m<0||m>12||Math.abs(c)+Math.abs(d)>1){continue}core.status.checkBlock.damage[13*l+m]+=e.value}}}}}}core.status.checkBlock.betweenAttack=[];for(var p=0;p<13;p++){for(var q=0;q<13;q++){var f=false;if(p>0&&p<12){var h=core.status.checkBlock.map[13*(p-1)+q],i=core.status.checkBlock.map[13*(p+1)+q];if(core.isset(h)&&core.isset(i)&&h==i){var e=core.material.enemys[h];if(core.isset(e)&&core.enemys.hasSpecial(e.special,16)){f=true}}}if(q>0&&q<12){var h=core.status.checkBlock.map[13*p+q-1],i=core.status.checkBlock.map[13*p+q+1];if(core.isset(h)&&core.isset(i)&&h==i){var e=core.material.enemys[h];if(core.isset(e)&&core.enemys.hasSpecial(e.special,16)){f=true}}}if(f){core.status.checkBlock.betweenAttack[13*p+q]=true;var j=core.status.hero.hp-core.status.checkBlock.damage[13*p+q];if(j>1){core.status.checkBlock.damage[13*p+q]+=Math.floor((j+(core.flags.betweenAttackCeil?0:1))/2)}}}}};control.prototype.checkBlock=function(){var i=core.getHeroLoc("x"),j=core.getHeroLoc("y");var a=core.status.checkBlock.damage[13*i+j];if(a>0){core.status.hero.hp-=a;var h=[];var g={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};for(var b in g){var e=i+g[b].x,f=j+g[b].y;if(e<0||e>12||f<0||f>12){continue}var d=core.status.checkBlock.map[13*e+f];if(core.isset(d)){var c=core.material.enemys[d];if(core.isset(c)&&core.enemys.hasSpecial(c.special,18)){h.push({direction:b,x:e,y:f})}}}if(core.status.checkBlock.betweenAttack[13*i+j]&&a>0){core.drawTip("受到夹击,生命变成一半")}else{if(core.status.checkBlock.map[13*i+j]=="lavaNet"){core.drawTip("受到血网伤害"+a+"点")}else{if(h.length>0&&a>0){core.drawTip("受到阻击伤害"+a+"点")}else{if(a>0){core.drawTip("受到领域伤害"+a+"点")}}}}if(a>0){core.playSound("zone.mp3");core.drawAnimate("zone",i,j)}core.status.hero.statistics.extraDamage+=a;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose();return}h=h.filter(function(n){var o=n.x,p=n.y,k=n.direction;var l=o+g[k].x,m=p+g[k].y;return l>=0&&l<=12&&m>=0&&m<=12&&core.getBlock(l,m,core.status.floorId,false)==null});core.updateStatusBar();if(h.length>0){core.snipe(h)}}};control.prototype.snipe=function(c){var b={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};c.forEach(function(j){var k=j.x,l=j.y,h=j.direction;j.nx=k+b[j.direction].x;j.ny=l+b[j.direction].y;core.removeGlobalAnimate(k,l);var d=core.getBlock(k,l).block;var e=d.event.cls;var i=d.event.height||32;j.animate=d.event.animate||1;j.blockIcon=core.material.icons[e][d.event.id];j.blockImage=core.material.images[e];j.height=i;var g=core.enemys.getDamage(d.event.id);var f="#000000";if(g==null){g="???";f="#FF0000"}else{if(g<=0){f="#00FF00"}else{if(g=core.values.animateSpeed){e++;f=0}c.forEach(function(n){var o=n.x,p=n.y,i=n.direction;var j=b[i].x*2*g,k=b[i].y*2*g;var l=32*o+j,m=32*p+k;core.clearMap("fg",l-2*b[i].x,m-2*b[i].y,32,32);core.canvas.event.clearRect(l-2*b[i].x,m-2*b[i].y,32,32);core.canvas.event2.clearRect(l-2*b[i].x,m-2*b[i].y-32,32,32);core.drawBlock(n.block,e,j,k);if(core.hasItem("book")){core.setFillStyle("fg","#000000");core.canvas.fg.fillText(n.damage,l+2,m+30);core.canvas.fg.fillText(n.damage,l,m+30);core.canvas.fg.fillText(n.damage,l+2,m+32);core.canvas.fg.fillText(n.damage,l,m+32);core.setFillStyle("fg",n.color);core.canvas.fg.fillText(n.damage,l+1,m+31)}});if(g==16){clearInterval(d);a();if(core.status.event.id==null){core.unLockControl()}}},h/16)})}};control.prototype.setWeather=function(d,c){if(d!="rain"&&d!="snow"){core.clearMap("weather",0,0,416,416);core.animateFrame.weather.type=null;core.animateFrame.weather.level=0;core.animateFrame.weather.nodes=[];return}c=parseInt(c);if(d==core.animateFrame.weather.type&&(!core.isset(c)||20*c==core.animateFrame.weather.level)){return}if(!core.isset(c)){c=5}if(c<1){c=1}if(c>10){c=10}c*=20;core.clearMap("weather",0,0,416,416);core.animateFrame.weather.type=d;core.animateFrame.weather.level=c;core.animateFrame.weather.nodes=[];if(d=="rain"){for(var b=0;b1){c[3]=1}if(f==0){core.dom.curtain.style.background=core.arrayToRGB(c);core.dom.curtain.style.opacity=c[3];core.status.curtainColor=c;if(core.isset(a)){a()}return}var e=0;core.status.replay.animate=true;var b=setInterval(function(){e++;var g=d[3]+(c[3]-d[3])*e/25;var j=parseInt(d[0]+(c[0]-d[0])*e/25);var i=parseInt(d[1]+(c[1]-d[1])*e/25);var h=parseInt(d[2]+(c[2]-d[2])*e/25);core.dom.curtain.style.background=core.arrayToRGB([j,i,h]);core.dom.curtain.style.opacity=g;if(e>=25){clearInterval(b);core.status.curtainColor=c;core.status.replay.animate=false;if(core.isset(a)){a()}}},f/25)};control.prototype.updateFg=function(){if(!core.isset(core.status.thisMap)||!core.isset(core.status.thisMap.blocks)){return}var i=core.status.thisMap.blocks;core.clearMap("fg",0,0,416,416);if(!core.hasItem("book")){return}core.setFont("fg","bold 11px Arial");var g=core.status.hero.hp;if(core.flags.displayEnemyDamage||core.flags.displayCritical){core.canvas.fg.textAlign="left";for(var a=0;a0){d=d[0]}d=core.formatBigNumber(d[0]);if(d=="???"){d="?"}core.setFillStyle("fg","#000000");core.canvas.fg.fillText(d,32*j+2,32*(k+1)-2-10);core.canvas.fg.fillText(d,32*j,32*(k+1)-2-10);core.canvas.fg.fillText(d,32*j+2,32*(k+1)-10);core.canvas.fg.fillText(d,32*j,32*(k+1)-10);core.setFillStyle("fg","#FFFFFF");core.canvas.fg.fillText(d,32*j+1,32*(k+1)-1-10)}}}}if(core.flags.displayExtraDamage){core.canvas.fg.textAlign="center";for(var j=0;j<13;j++){for(var k=0;k<13;k++){var e=core.status.checkBlock.damage[13*j+k];if(e>0){e=core.formatBigNumber(e);core.setFillStyle("fg","#000000");core.canvas.fg.fillText(e,32*j+17,32*(k+1)-13);core.canvas.fg.fillText(e,32*j+15,32*(k+1)-15);core.canvas.fg.fillText(e,32*j+17,32*(k+1)-15);core.canvas.fg.fillText(e,32*j+15,32*(k+1)-13);core.setFillStyle("fg","#FF7F00");core.canvas.fg.fillText(e,32*j+16,32*(k+1)-14)}}}}};control.prototype.doEffect=function(b){var a=b.split("+=");if(a.length!=2){return}var d=a[0],f=core.calValue(a[1]);if(d.indexOf("status:")==0){var e=d.substring(7);core.setStatus(e,core.getStatus(e)+f)}else{if(d.indexOf("item:")==0){var c=d.substring(5);core.setItem(c,core.itemCount(c)+f)}}};control.prototype.debug=function(){core.setFlag("debug",true);core.insertAction(["\t[调试模式开启]此模式下按住Ctrl键可以穿墙并忽略一切事件。\n同时,录像将失效,也无法上传成绩。"])};control.prototype.startReplay=function(a){core.status.replay.replaying=true;core.status.replay.pausing=false;core.status.replay.speed=1;core.status.replay.toReplay=core.clone(a);core.status.replay.totalList=core.clone(a);core.status.replay.steps=0;core.status.replay.save=[];core.updateStatusBar();core.drawTip("开始播放");this.replay();return};control.prototype.triggerReplay=function(){if(core.status.event.id=="save"){return}if(core.status.replay.pausing){this.resumeReplay()}else{this.pauseReplay()}};control.prototype.pauseReplay=function(){if(core.status.event.id=="save"){return}if(!core.status.replay.replaying){return}core.status.replay.pausing=true;core.updateStatusBar();core.drawTip("暂停播放")};control.prototype.resumeReplay=function(){if(core.status.event.id=="save"){return}if(!core.status.replay.replaying){return}core.status.replay.pausing=false;core.updateStatusBar();core.drawTip("恢复播放");core.replay()};control.prototype.speedUpReplay=function(){if(core.status.event.id=="save"){return}if(!core.status.replay.replaying){return}var a=core.status.replay.speed>=3?3:core.status.replay.speed>=2?2:1;core.status.replay.speed=parseInt(10*core.status.replay.speed+a)/10;if(core.status.replay.speed>6){core.status.replay.speed=6}core.drawTip("x"+core.status.replay.speed+"倍")};control.prototype.speedDownReplay=function(){if(core.status.event.id=="save"){return}if(!core.status.replay.replaying){return}var a=core.status.replay.speed>3?3:core.status.replay.speed>2?2:1;core.status.replay.speed=parseInt(10*core.status.replay.speed-a)/10;if(core.status.replay.speed<0.3){core.status.replay.speed=0.3}core.drawTip("x"+core.status.replay.speed+"倍")};control.prototype.stopReplay=function(){if(core.status.event.id=="save"){return}if(!core.status.replay.replaying){return}core.status.replay.toReplay=[];core.status.replay.totalList=[];core.status.replay.replaying=false;core.status.replay.pausing=false;core.status.replay.speed=1;core.status.replay.steps=0;core.status.replay.save=[];core.updateStatusBar();core.drawTip("停止播放并恢复游戏")};control.prototype.rewindReplay=function(){if(core.status.event.id=="save"){return}if(!core.status.replay.replaying){return}if(!core.status.replay.pausing){core.drawTip("请先暂停录像");return}if(core.status.replay.animate){core.drawTip("请等待当前事件的处理结束");return}if(core.status.replay.save.length==0){core.drawTip("无法再回到上一个节点");return}var b=core.status.replay.save;var a=b.pop();core.loadData(a.data,function(){core.status.replay={replaying:true,pausing:true,animate:false,toReplay:a.replay.toReplay,totalList:a.replay.totalList,speed:a.replay.speed,steps:a.replay.steps,save:b};core.updateStatusBar();core.drawTip("成功回退到上一个节点")})};control.prototype.saveReplay=function(){if(!core.status.replay.replaying){return}if(!core.status.replay.pausing){core.drawTip("请先暂停录像");return}if(core.status.replay.animate||core.isset(core.status.event.id)){core.drawTip("请等待当前事件的处理结束");return}core.lockControl();core.status.event.id="save";var c=core.status.saveIndex;var b=parseInt((c-1)/5),a=c-5*b;core.ui.drawSLPanel(10*b+a)};control.prototype.bookReplay=function(){if(!core.status.replay.replaying){return}if(!core.status.replay.pausing){core.drawTip("请先暂停录像");return}if(core.status.replay.animate||core.isset(core.status.event.id)){core.drawTip("请等待当前事件的处理结束");return}core.lockControl();core.status.event.id="book";core.useItem("book")};control.prototype.replay=function(){if(!core.status.replay.replaying){return}if(core.status.replay.pausing){return}if(core.status.replay.animate){return}if(core.status.replay.toReplay.length==0){core.stopReplay();core.insertAction("录像回放完毕!");return}core.status.replay.steps++;if(core.status.replay.steps%50==0){core.status.replay.save.push({data:core.saveData(),replay:{totalList:core.clone(core.status.replay.totalList),toReplay:core.clone(core.status.replay.toReplay),speed:core.status.replay.speed,steps:core.status.replay.steps}})}var a=core.status.replay.toReplay.shift();if(a=="up"||a=="down"||a=="left"||a=="right"){core.moveHero(a,function(){setTimeout(function(){core.replay()})});return}else{if(a.indexOf("item:")==0){var h=a.substring(5);if(core.canUseItem(h)){var s=Object.keys(core.status.hero.items.tools).sort();var d=Object.keys(core.status.hero.items.constants).sort();var g;if((g=s.indexOf(h))>=0||(g=d.indexOf(h)+100)>=100){core.ui.drawToolbox(g);setTimeout(function(){core.ui.closePanel();core.useItem(h,function(){core.replay()})},750/core.status.replay.speed)}return}}else{if(a.indexOf("fly:")==0){var e=a.substring(4);var r=core.status.hero.flyRange.indexOf(e);var k=core.status.hero.flyRange.indexOf(core.status.floorId);if(core.hasItem("fly")&&r>=0&&k>=0){core.ui.drawFly(r);setTimeout(function(){core.ui.closePanel();var w=r0){var n=core.status.shops[o];if(core.isset(n)&&n.visited){var c=n.choices;var t=6-parseInt(c.length/2);core.status.event.selection=parseInt(m.shift());core.events.openShop(o,false);var p=setInterval(function(){if(!core.actions.clickShop(6,t+core.status.event.selection)){clearInterval(p);core.stopReplay();core.drawTip("录像文件出错");return}if(m.length==0){clearInterval(p);core.actions.clickShop(6,t+c.length);core.replay();return}core.status.event.selection=parseInt(m.shift());core.events.openShop(o,false)},750/core.status.replay.speed);return}}}else{if(a=="turn"){core.turnHero();core.replay();return}else{if(a=="getNext"){if(core.flags.enableGentleClick&&core.getBlock(core.nextX(),core.nextY())!=null){var i=core.nextX(),j=core.nextY();var b=core.getBlock(i,j);if(b!=null&&b.block.event.trigger=="getItem"){core.getItem(b.block.event.id,1,i,j);core.status.route.push("getNext");core.replay();return}}}else{if(a.indexOf("move:")==0){var l=a.substring(5).split(":");var u=parseInt(l[0]),v=parseInt(l[1]);var f=core.canMoveDirectly(u,v);if(f>0){core.clearMap("hero",0,0,416,416);core.setHeroLoc("x",u);core.setHeroLoc("y",v);core.drawHero();core.status.route.push("move:"+u+":"+v);core.status.hero.statistics.moveDirectly++;core.status.hero.statistics.ignoreSteps+=f;core.replay();return}}else{if(a.indexOf("key:")==0){core.actions.keyUp(parseInt(a.substring(4)),true);core.replay();return}}}}}}}}core.stopReplay();core.insertAction("录像文件出错")};control.prototype.checkStatus=function(b,c,a){if(c&&core.status.event.id==b){core.ui.closePanel();return false}if(c&&core.status.lockControl){return false}if(core.isset(a)&&a&&!core.hasItem(b)){core.drawTip("你没有"+core.material.items[b].name);return false}if(!core.status.heroStop){core.drawTip("请先停止勇士行动");return false}core.lockControl();core.status.event.id=b;return true};control.prototype.openBook=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}if(core.status.event.id=="book"&&core.isset(core.status.event.selection)){core.status.boxAnimateObjs=[];core.ui.drawMaps(core.status.event.selection);return}if(core.status.event.id=="viewMaps"){a=false;core.status.event.selection=core.status.event.data}if(!core.checkStatus("book",a,true)){return}core.useItem("book")};control.prototype.useFly=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}if(!core.checkStatus("fly",a,true)){return}if(core.flags.flyNearStair&&!core.nearStair()){core.drawTip("只有在楼梯边才能使用传送器");core.unLockControl();core.status.event.data=null;core.status.event.id=null;return}if(!core.canUseItem("fly")){core.drawTip("楼层传送器好像失效了");core.unLockControl();core.status.event.data=null;core.status.event.id=null;return}core.useItem("fly");return};control.prototype.openToolbox=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}if(!core.checkStatus("toolbox",a)){return}core.ui.drawToolbox()};control.prototype.openQuickShop=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}if(!core.checkStatus("selectShop",a)){return}core.ui.drawQuickShop()};control.prototype.save=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}if(!core.checkStatus("save",a)){return}var d=core.status.saveIndex;var c=parseInt((d-1)/5),b=d-5*c;core.ui.drawSLPanel(10*c+b)};control.prototype.load=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}var d=core.getLocalStorage("saveIndex2",1);var c=parseInt((d-1)/5),b=d-5*c;if(!core.isPlaying()){core.status.event={id:"load",data:null};core.status.lockControl=true;core.dom.startPanel.style.display="none";core.ui.drawSLPanel(10*c+b);return}if(!core.checkStatus("load",a)){return}core.ui.drawSLPanel(10*c+b)};control.prototype.openSettings=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying){return}if(!core.checkStatus("settings",a)){return}core.ui.drawSettings()};control.prototype.autosave=function(a){if(core.status.event.id!=null){return}var b=null;if(a){b=core.status.route.pop()}core.setLocalStorage("autoSave",core.saveData());if(a&&core.isset(b)){core.status.route.push(b)}};control.prototype.doSL=function(b,e){if(e=="save"){if(b=="autoSave"){core.drawTip("不能覆盖自动存档!");return}if(core.setLocalStorage("save"+b,core.saveData())){core.ui.closePanel();core.drawTip("存档成功!");if(b!="autoSave"){core.status.saveIndex=b;core.setLocalStorage("saveIndex2",core.status.saveIndex)}}else{core.drawTip("存储空间不足,请覆盖已有的存档或在菜单栏中进行清理")}return}else{if(e=="load"){var a=core.getLocalStorage(b=="autoSave"?b:"save"+b,null);if(!core.isset(a)){core.drawTip("无效的存档");return}if(a.version!=core.firstData.version){if(confirm("存档版本不匹配!\n你想回放此存档的录像吗?")){core.dom.startPanel.style.display="none";var d=a.hero.flags.seed;core.resetStatus(core.firstData.hero,a.hard,core.firstData.floorId,null,core.initStatus.maps);core.events.setInitData(a.hard);core.setFlag("seed",d);core.setFlag("rand",d);core.changeFloor(core.status.floorId,null,core.firstData.hero.loc,null,function(){core.startReplay(core.decodeRoute(a.route))},true)}return}core.ui.closePanel();core.loadData(a,function(){core.drawTip("读档成功");if(b!="autoSave"){core.status.saveIndex=b;core.setLocalStorage("saveIndex2",core.status.saveIndex)}});return}else{if(e=="replayLoad"){var a=core.getLocalStorage(b=="autoSave"?b:"save"+b,null);if(!core.isset(a)){core.drawTip("无效的存档");return}if(a.version!=core.firstData.version){core.drawTip("存档版本不匹配");return}if(a.hard!=core.status.hard){core.drawTip("游戏难度不匹配!");return}var c=core.subarray(core.status.route,core.decodeRoute(a.route));if(!core.isset(c)||a.hero.flags.seed!=core.getFlag("seed")){core.drawTip("无法从此存档回放录像");return}core.loadData(a,function(){core.startReplay(c);core.drawTip("回退到存档节点")})}}}};control.prototype.syncSave=function(f){var e=null;if(f=="all"){e=[];for(var c=1;c<=5*(main.savePages||30);c++){var a=core.getLocalStorage("save"+c,null);if(core.isset(a)){e.push(a)}}}else{for(var c=5*(main.savePages||30);c>=1;c--){e=core.getLocalStorage("save"+c,null);if(core.isset(e)){break}}}if(!core.isset(e)){core.drawText("没有要同步的存档");return}core.ui.drawWaiting("正在同步,请稍后...");var b=new FormData();b.append("type","save");b.append("name",core.firstData.name);var d=JSON.stringify(e);b.append("data",d);core.http("POST","/games/sync.php",b,function(g){var h=JSON.parse(g);if(h.code<0){core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:"+h.msg)}else{core.drawText("同步成功!\n\n您的存档编号: "+h.code+"\n您的存档密码: "+h.msg+"\n\n请牢记以上两个信息(如截图等),在从服务器\n同步存档时使用。")}},function(g){core.drawText("出错啦!\n无法同步存档到服务器。\n错误原因:"+g)})};control.prototype.syncLoad=function(){var b=prompt("请输入存档编号:");if(b==null||b==""){core.ui.drawSyncSave();return}var c=prompt("请输入存档密码:");if(c==null||c==""){core.ui.drawSyncSave();return}core.ui.drawWaiting("正在同步,请稍后...");var a=new FormData();a.append("type","load");a.append("name",core.firstData.name);a.append("id",b);a.append("password",c);core.http("POST","/games/sync.php",a,function(d){var g=JSON.parse(d);switch(g.code){case 0:var d=JSON.parse(g.msg);if(d instanceof Array){core.status.event.selection=1;core.ui.drawConfirmBox("所有本地存档都将被覆盖,确认?",function(){for(var h=1;h<=5*(main.savePages||30);h++){if(h<=d.length){core.setLocalStorage("save"+h,d[h-1])}else{core.removeLocalStorage("save"+h)}}core.drawText("同步成功!\n你的本地所有存档均已被覆盖。")},function(){core.status.event.selection=0;core.ui.drawSyncSave()})}else{var f=5*(main.savePages||30);for(var e=5*(main.savePages||30);e>=1;e--){if(core.getLocalStorage("save"+e,null)==null){f=e}else{break}}core.setLocalStorage("save"+f,d);core.drawText("同步成功!\n单存档已覆盖至存档"+f)}break;case -1:core.drawText("出错啦!\n存档编号"+b+"不存在!");break;case -2:core.drawText("出错啦!\n存档密码错误!");break;default:core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:"+g.msg);break}},function(d){core.drawText("出错啦!\n无法从服务器同步存档。\n错误原因:"+d)})};control.prototype.saveData=function(){var a={floorId:core.status.floorId,hero:core.clone(core.status.hero),hard:core.status.hard,maps:core.maps.save(core.status.maps),route:core.encodeRoute(core.status.route),shops:{},version:core.firstData.version,time:new Date().getTime()};for(var b in core.status.shops){a.shops[b]={times:core.status.shops[b].times||0,visited:core.status.shops[b].visited||false}}core.events.beforeSaveData(a);return a};control.prototype.loadData=function(b,a){core.resetStatus(b.hero,b.hard,b.floorId,core.decodeRoute(b.route),core.maps.load(b.maps));for(var d in core.status.shops){if(core.isset(b.shops[d])){core.status.shops[d].times=b.shops[d].times;core.status.shops[d].visited=b.shops[d].visited}}var c=core.getFlag("heroIcon","hero.png");if(core.isset(core.material.images.images[c])){core.material.images.hero.src=core.material.images.images[c].src;core.material.icons.hero.height=core.material.images.images[c].height/4}core.events.afterLoadData(b);core.changeFloor(b.floorId,null,b.hero.loc,0,function(){if(core.isset(a)){a()}},true)};control.prototype.setStatus=function(a,b){if(core.isset(core.status.hero.loc[a])){core.status.hero.loc[a]=b}else{core.status.hero[a]=b}};control.prototype.getStatus=function(a){if(core.isset(core.status.hero.loc[a])){return core.status.hero.loc[a]}return core.status.hero[a]};control.prototype.getLvName=function(){if(core.status.hero.lv>core.firstData.levelUp.length){return core.status.hero.lv}return core.firstData.levelUp[core.status.hero.lv-1].name||core.status.hero.lv};control.prototype.setFlag=function(a,b){if(!core.isset(core.status.hero)){return}core.status.hero.flags[a]=b};control.prototype.getFlag=function(b,a){if(!core.isset(core.status.hero)){return a}var c=core.status.hero.flags[b];if(core.isset(c)){return c}return a};control.prototype.hasFlag=function(a){if(core.getFlag(a)){return true}return false};control.prototype.lockControl=function(){core.status.lockControl=true};control.prototype.unLockControl=function(){core.status.lockControl=false};control.prototype.playBgm=function(a){if(main.mode!="play"){return}if(!core.musicStatus.bgmStatus){return}if(!core.isset(core.material.bgms[a])){return}if(core.material.bgms[a]=="loading"){core.material.bgms[a]="starting";return}try{if(core.musicStatus.playingBgm==a&&core.musicStatus.isPlaying){return}if(core.isset(core.musicStatus.playingBgm)&&core.musicStatus.isPlaying){core.material.bgms[core.musicStatus.playingBgm].pause()}core.material.bgms[a].volume=core.musicStatus.volume;core.material.bgms[a].play();core.musicStatus.playingBgm=a;core.musicStatus.isPlaying=true}catch(b){console.log("无法播放BGM "+a);console.log(b);core.musicStatus.playingBgm=null}};control.prototype.pauseBgm=function(){try{if(core.isset(core.musicStatus.playingBgm)){core.material.bgms[core.musicStatus.playingBgm].pause()}core.musicStatus.isPlaying=false}catch(a){console.log("无法暂停BGM "+bgm);console.log(a)}};control.prototype.resumeBgm=function(){if(main.mode!="play"){return}if(!core.musicStatus.bgmStatus){return}try{if(core.isset(core.musicStatus.playingBgm)){core.material.bgms[core.musicStatus.playingBgm].play();core.musicStatus.isPlaying=true}else{if(core.bgms.length>0){if(core.isset(core.floors[core.status.floorId].bgm)){core.playBgm(core.floors[core.status.floorId].bgm)}else{core.playBgm(core.bgms[0])}core.musicStatus.isPlaying=true}}}catch(a){console.log("无法恢复BGM "+bgm);console.log(a)}};control.prototype.playSound=function(d){if(main.mode!="play"){return}if(!core.musicStatus.soundStatus){return}if(!core.isset(core.material.sounds[d])){return}try{if(core.musicStatus.audioContext!=null){var f=core.musicStatus.audioContext.createBufferSource();f.buffer=core.material.sounds[d];f.connect(core.musicStatus.gainNode);try{f.start(0)}catch(a){try{f.noteOn(0)}catch(b){}}}else{core.material.sounds[d].volume=core.musicStatus.volume;core.material.sounds[d].play()}}catch(c){console.log("无法播放SE "+d);console.log(c)}};control.prototype.clearStatusBar=function(){var a=["floor","lv","hp","atk","def","mdef","money","experience","up","yellowKey","blueKey","redKey","poison","weak","curse","hard"];a.forEach(function(b){core.statusBar[b].innerHTML=" "});core.statusBar.image.book.style.opacity=0.3;core.statusBar.image.fly.style.opacity=0.3};control.prototype.updateStatusBar=function(){core.events.checkLvUp();if(core.flags.enableHPMax){core.setStatus("hp",Math.min(core.getStatus("hpmax"),core.getStatus("hp")))}core.updateCheckBlock();var b=core.getLvName();core.statusBar.lv.innerHTML=b;if(/^[+-]?\d+$/.test(b)){core.statusBar.lv.style.fontStyle="italic"}else{core.statusBar.lv.style.fontStyle="normal"}var c=["hpmax","hp","atk","def","mdef","money","experience"];c.forEach(function(d){if(core.isset(core.status.hero[d])){core.status.hero[d]=Math.floor(core.status.hero[d])}core.statusBar[d].innerHTML=core.formatBigNumber(core.getStatus(d))});if(core.flags.enableLevelUp&&core.status.hero.lvh&&h9){C=C*9/k}var u;x="3px #fff solid";J="3px #fff solid";var V=(a-U)/4.22;var b=1-V/100;if(U