function core(){this.dom={};this.statusBar={};this.canvas={};this.images=[];this.sounds={};this.floorIds=[];this.floors={};this.firstData={};this.material={images:{},sounds:{},ground:null,items:{},enemys:{},icons:{},events:{}};this.timeout={getItemTipTimeout:null};this.interval={twoAnimate:null,fourAnimate:null,boxAnimate:null,heroMoveTriggerInterval:null,heroMoveInterval:null,heroAutoMoveScan:null,tipAnimate:null,openDoorAnimate:null};this.musicStatus={isIOS:false,loaded:false,bgmStatus:false,soundStatus:true,playedSound:null,playedBgm:null,};this.position={gameGroup:{},canvas:{},statusBar:{},toolBar:{},items:{},scale:1,screenMode:"bigScreen",};this.initStatus={played:false,hero:{},floorId:null,thisMap:null,maps:null,heroMoving:false,heroStop:true,lockControl:false,autoHeroMove:false,automaticRouting:false,automaticRouted:false,autoStep:0,movedStep:0,destStep:0,automaticRoutingTemp:{destX:0,destY:0,moveStep:[]},autoStepRoutes:[],holdingPath:0,stepPostfix:[],mouseOutCheck:1,moveStepBeforeStop:[],savePage:null,shops:{},event:{id:null,data:null},openingDoor:null,twoAnimateObjs:[],fourAnimateObjs:[],boxAnimateObjs:[],};this.status={};this.flags={}}core.prototype.init=function(c,i,a,f,h,d,e,b){core.dom=c;core.statusBar=i;core.canvas=a;core.images=f;core.sounds=h;core.floorIds=d;core.floors=e;for(var g in b){core[g]=b[g]}core.flags=core.data.flags;core.values=core.clone(core.data.values);core.firstData=core.data.getFirstData();core.initStatus.shops=core.firstData.shops;core.dom.versionLabel.innerHTML=core.firstData.version;core.dom.logoLabel.innerHTML=core.firstData.title;core.material.items=core.items.getItems();core.initStatus.maps=core.maps.initMaps(d);core.material.enemys=core.clone(core.enemys.getEnemys());core.material.icons=core.icons.getIcons();core.material.events=core.events.getEvents();core.musicStatus.soundStatus=core.getLocalStorage("soundStatus",true);var j=navigator.userAgent;if(j.indexOf("iPhone")>-1||j.indexOf("iPad")>-1){console.log("你的设备为iphone,不自动播放音乐!");core.musicStatus.isIOS=true;core.musicStatus.soundStatus=false}core.material.ground=new Image();core.material.ground.src="images/ground.png";core.loader(function(){console.log(core.material);core.showStartAnimate()})};core.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.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)};core.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)};core.prototype.setStartProgressVal=function(a){core.dom.startTopProgress.style.width=a+"%"};core.prototype.setStartLoadTipText=function(a){core.dom.startTopLoadTips.innerHTML=a};core.prototype.loader=function(c){var f=0,a=0,b=0;a=core.images.length;for(var e in core.sounds){b+=core.sounds[e].length}for(var d=0;d0){return}core.musicStatus.bgmStatus=1;if(core.musicStatus.soundStatus){core.playBgm("bgm","mp3")}return}var a=b.shift();a.oncanplay=function(){core.loadSoundItem(b)};a.load()};core.prototype.isPlaying=function(){if(core.isset(core.status.played)&&core.status.played){return true}return false};core.prototype.clearStatus=function(){for(var a in core.interval){clearInterval(core.interval[a])}core.status={};core.clearStatusBar();core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};core.prototype.resetStatus=function(c,b,a,e){for(var d in core.interval){clearInterval(core.interval[d])}core.status=core.clone(core.initStatus);core.status.played=true;core.status.floorId=a;core.status.maps=core.clone(e);core.material.enemys=core.clone(core.enemys.getEnemys());core.status.hero=core.clone(c);core.status.hard=b;core.status.savePage=core.getLocalStorage("savePage",0);core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};core.prototype.startGame=function(b,a){console.log("开始游戏");core.resetStatus(core.firstData.hero,b,core.firstData.floorId,core.initStatus.maps);core.changeFloor(core.status.floorId,null,core.firstData.hero.loc,null,function(){core.setHeroMoveTriggerInterval();if(core.isset(a)){a()}})};core.prototype.restart=function(){core.showStartAnimate()};core.prototype.onkeyDown=function(a){if(!core.isset(core.status.holdingKeys)){core.status.holdingKeys=[]}var c={37:true,38:true,39:true,40:true}[a.keyCode];if(c){for(var b=0;bd){c=b;d=a[b]}}e=[{x:0,y:1},{x:-1,y:0},{x:0,y:-1},{x:1,y:0},false][c];if(e){e.x+=f.x;e.y+=f.y;core.status.stepPostfix.push(e);core.fillPosWithPoint(e)}};core.prototype.onup=function(){core.status.holdingPath=0;if(core.status.stepPostfix.length>0){var g=[];var a={"0":{"1":"down","-1":"up"},"-1":{"0":"left"},"1":{"0":"right"}};for(var b=1;b12||c>12){return}if(!core.status.lockControl){core.setAutomaticRoute(b,c,a);return}if(core.status.event.id=="book"){core.events.clickBook(b,c);return}if(core.status.event.id=="fly"){core.events.clickFly(b,c);return}if(core.status.event.id=="settings"){core.events.clickSettings(b,c);return}if(core.status.event.id=="shop"){core.events.clickShop(b,c);return}if(core.status.event.id=="selectShop"){core.events.clickSelectShop(b,c);return}if(core.status.event.id=="toolbox"){core.events.clickToolbox(b,c);return}if(core.status.event.id=="save"||core.status.event.id=="load"){core.events.clickSL(b,c);return}if(core.status.event.id=="confirmBox"){if((b==4||b==5)&&c==7&&core.isset(core.status.event.data.yes)){core.status.event.data.yes()}if((b==7||b==8)&&c==7&&core.isset(core.status.event.data.no)){core.status.event.data.no()}return}if(core.status.event.id=="about"){if(core.isPlaying()){core.ui.closePanel(false)}else{core.showStartAnimate()}return}if(core.status.event.id=="action"){core.events.clickAction(b,c);return}if(core.status.event.id=="text"){core.drawText();return}if(core.status.event.id=="syncSave"){if(b>=4&&b<=8){if(c==5){core.ui.drawConfirmBox("你确定要将本地存档同步到服务器吗?",function(){core.ui.drawWaiting("正在同步,请稍后...");var e=new FormData();e.append("type","save");e.append("name",core.firstData.name);var h=[];for(var f=1;f<=180;f++){var d=core.getLocalStorage("save"+f,null);if(core.isset(d)){h.push(d)}}var g=JSON.stringify(h);e.append("data",g);var j=new XMLHttpRequest();j.open("POST","../sync.php");j.timeout=1000;j.onload=function(i){if(j.status==200){var k=JSON.parse(j.response);if(k.code<0){core.drawText("出错啦!\n无法同步存档到服务器。")}else{core.drawText("同步成功!\n\n您的存档编号: "+k.code+"\n您的存档密码: "+k.msg+"\n\n请牢记以上两个信息(如截图等),在从服务器\n同步存档时使用。")}}else{core.drawText("出错啦!\n无法同步存档到服务器。")}};j.ontimeout=function(i){console.log(i);core.drawText("出错啦!\n无法同步存档到服务器。")};j.onerror=function(i){console.log(i);core.drawText("出错啦!\n无法同步存档到服务器。")};j.send(e)},function(){core.ui.drawSyncSave()})}if(c==6){core.ui.drawConfirmBox("你确定要从服务器加载存档吗?\n该操作将覆盖所有本地存档且不可逆!",function(){var e=prompt("请输入存档编号:");if(e==null||e==""){core.ui.drawSyncSave();return}var f=prompt("请输入存档密码:");if(f==null||f==""){core.ui.drawSyncSave();return}core.ui.drawWaiting("正在同步,请稍后...");var d=new FormData();d.append("type","load");d.append("name",core.firstData.name);d.append("id",e);d.append("password",f);var g=new XMLHttpRequest();g.open("POST","../sync.php");g.timeout=1000;g.onload=function(j){if(g.status==200){var l=JSON.parse(g.response);switch(l.code){case 0:var h=JSON.parse(l.msg);for(var k=1;k<=180;k++){if(k<=h.length){core.setLocalStorage("save"+k,h[k-1])}else{core.removeLocalStorage("save"+k)}}core.drawText("同步成功!\n你的本地所有存档均已被覆盖。");break;case -1:core.drawText("出错啦!\n存档编号"+e+"不存在!");break;case -2:core.drawText("出错啦!\n存档密码错误!");break;default:core.drawText("出错啦!\n无法从服务器同步存档。");break}}else{core.drawText("出错啦!\n无法从服务器同步存档。")}};g.ontimeout=function(h){console.log(h);core.drawText("出错啦!\n无法从服务器同步存档。")};g.onerror=function(h){console.log(h);core.drawText("出错啦!\n无法从服务器同步存档。")};g.send(d)},function(){core.ui.drawSyncSave()})}}if(b>=5&&b<=7&&c==7){core.ui.drawSettings(false)}}};core.prototype.onmousewheel=function(a){if(core.status.lockControl&&core.status.event.id=="fly"){if(a==-1){core.ui.drawFly(core.status.event.data-1)}if(a==1){core.ui.drawFly(core.status.event.data+1)}return}};core.prototype.clearAutomaticRouteNode=function(a,b){core.canvas.ui.clearRect(a*32+5,b*32+5,27,27)};core.prototype.stopAutomaticRoute=function(){if(!core.status.played){return}core.stopAutoHeroMove();core.status.automaticRouting=false;core.status.automaticRouted=false;core.status.autoStepRoutes=[];core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};if(core.status.moveStepBeforeStop.length==0){core.canvas.ui.clearRect(0,0,416,416)}};core.prototype.continueAutomaticRoute=function(){var a=core.status.moveStepBeforeStop;core.status.moveStepBeforeStop=[];if(a.length===0){return}if(a.length===1&&a[0].step===1){return}core.status.automaticRouting=true;core.setAutoHeroMove(a)};core.prototype.clearContinueAutomaticRoute=function(){core.canvas.ui.clearRect(0,0,416,416);core.status.moveStepBeforeStop=[]};core.prototype.setAutomaticRoute=function(a,b,f){if(!core.status.played||core.status.lockControl){return}else{if(core.status.automaticRouting){core.stopAutomaticRoute();return}}if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y&&f.length==0){core.turnHero();return}var e=0;var g=null;var d;core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};if(!(d=core.automaticRoute(a,b))){if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y){d=[]}else{core.canvas.ui.clearRect(0,0,416,416);return}}d=d.concat(f);core.status.automaticRoutingTemp.destX=a;core.status.automaticRoutingTemp.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 c=0;c12||q<0||q>12){continue}var l=13*p+q;if(core.isset(s[l])){continue}if(p==e&&q==g){s[l]=i;break}if(core.noPassExists(p,q)){continue}var d=1;var b=core.getBlock(p,q);if(b!=null){var k=b.block.event.id;if(k.substring(k.length-3)=="Net"){d=100}if(!core.flags.potionWhileRouting&&k.substring(k.length-6)=="Potion"){d=20}if(b.block.event.trigger=="checkBlock"){d=200}}s[l]=i;r.push(169*(m+d)+l)}if(core.isset(s[13*e+g])){break}}if(!core.isset(s[13*e+g])){return false}var n=e,o=g;while(n!=u||o!=v){var h=s[13*n+o];a.push({direction:h,x:n,y:o});n-=t[h].x;o-=t[h].y}a.reverse();return a};core.prototype.fillPosWithPoint=function(a){core.fillRect("ui",a.x*32+12,a.y*32+12,8,8,"#bfbfbf")};core.prototype.clearStepPostfix=function(){if(core.status.mouseOutCheck>0){core.status.mouseOutCheck--;window.setTimeout(core.clearStepPostfix,1000);return}core.status.holdingPath=0;if(core.status.stepPostfix.length>0){core.status.stepPostfix=[];core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.restore()}};core.prototype.stopAutoHeroMove=function(){core.status.autoHeroMove=false;core.status.automaticRouting=false;core.status.automaticRouted=false;core.status.autoStep=0;core.status.destStep=0;core.status.movedStep=0;core.status.autoStepRoutes=[];core.stopHero();clearInterval(core.interval.heroAutoMoveScan)};core.prototype.setAutoHeroMove=function(b,a){if(b.length==0){return}core.status.autoStepRoutes=b;core.status.autoStep=0;clearInterval(core.interval.heroAutoMoveScan);core.interval.heroAutoMoveScan=window.setInterval(function(){if(!core.status.autoHeroMove){if(core.status.autoStep==core.status.autoStepRoutes.length){core.stopAutoHeroMove();return}core.autoHeroMove(core.status.autoStepRoutes[core.status.autoStep].direction,core.status.autoStepRoutes[core.status.autoStep].step);core.status.autoStep++}},80)};core.prototype.autoHeroMove=function(a,b){core.status.autoHeroMove=true;core.status.destStep=b;core.moveHero(a)};core.prototype.setHeroMoveInterval=function(b,d,e,a){if(core.status.heroMoving){return}core.status.heroMoving=true;var c=0;core.interval.heroMoveInterval=window.setInterval(function(){switch(b){case"up":c-=4;if(c==-4||c==-8||c==-12||c==-16){core.drawHero(b,d,e,"leftFoot",0,c)}else{if(c==-20||c==-24||c==-28||c==-32){core.drawHero(b,d,e,"rightFoot",0,c)}}if(c==-32){core.setHeroLoc("y","--");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d,e-1,"stop")}if(core.isset(a)){a()}}break;case"left":c-=4;if(c==-4||c==-8||c==-12||c==-16){core.drawHero(b,d,e,"leftFoot",c)}else{if(c==-20||c==-24||c==-28||c==-32){core.drawHero(b,d,e,"rightFoot",c)}}if(c==-32){core.setHeroLoc("x","--");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d-1,e,"stop")}if(core.isset(a)){a()}}break;case"down":c+=4;if(c==4||c==8||c==12||c==16){core.drawHero(b,d,e,"leftFoot",0,c)}else{if(c==20||c==24||c==28||c==32){core.drawHero(b,d,e,"rightFoot",0,c)}}if(c==32){core.setHeroLoc("y","++");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d,e+1,"stop")}if(core.isset(a)){a()}}break;case"right":c+=4;if(c==4||c==8||c==12||c==16){core.drawHero(b,d,e,"leftFoot",c)}else{if(c==20||c==24||c==28||c==32){core.drawHero(b,d,e,"rightFoot",c)}}if(c==32){core.setHeroLoc("x","++");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d+1,e,"stop")}if(core.isset(a)){a()}}break}},10)};core.prototype.setHeroMoveTriggerInterval=function(){var a,c,d;var b={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};core.interval.heroMoveTriggerInterval=window.setInterval(function(){if(!core.status.heroStop){a=core.getHeroLoc("direction");c=core.getHeroLoc("x");d=core.getHeroLoc("y");var e;e=core.noPass(c+b[a].x,d+b[a].y);if(e){core.trigger(c+b[a].x,d+b[a].y);core.drawHero(a,c,d,"stop");if(core.status.autoHeroMove){core.status.movedStep++;if(core.status.destStep==core.status.movedStep){core.status.autoHeroMove=false;core.status.destStep=0;core.status.movedStep=0;core.status.moveStepBeforeStop=[];core.stopAutomaticRoute()}}else{core.status.heroStop=true}return}core.setHeroMoveInterval(a,c,d,function(){if(core.status.autoHeroMove){core.status.movedStep++;if(core.status.destStep==core.status.movedStep){core.status.autoHeroMove=false;core.status.destStep=0;core.status.movedStep=0;core.stopHero();core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop")}}else{if(core.status.heroStop){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop")}}core.trigger(core.getHeroLoc("x"),core.getHeroLoc("y"));clearInterval(core.interval.heroMoveInterval);core.status.heroMoving=false})}},50)};core.prototype.turnHero=function(a){if(core.isset(a)){core.status.hero.loc.direction=a}else{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.status.hero.loc.direction,core.status.hero.loc.x,core.status.hero.loc.y,"stop",0,0);core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};core.canvas.ui.clearRect(0,0,416,416)};core.prototype.moveHero=function(a){core.setHeroLoc("direction",a);core.status.heroStop=false};core.prototype.moveOneStep=function(){if(core.hasFlag("poison")){core.status.hero.hp-=core.values.poisonDamage;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("poison");return}core.updateStatusBar()}};core.prototype.waitHeroToStop=function(a){core.stopAutomaticRoute();core.clearContinueAutomaticRoute();if(core.isset(a)){core.lockControl();setTimeout(function(){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");a()},30)}};core.prototype.stopHero=function(){core.status.heroStop=true};core.prototype.drawHero=function(a,f,g,e,c,d){c=c||0;d=d||0;core.clearAutomaticRouteNode(f,g);var b=core.material.icons.heros[core.status.hero.id][a];f=f*32;g=g*32;core.canvas.hero.clearRect(f-32,g-32,96,96);core.canvas.hero.drawImage(core.material.images.heros,b[e]*32,b.loc*32,32,32,f+c,g+d,32,32)};core.prototype.openDoor=function(d,i,j,f,a){if(!core.terrainExists(i,j,d)){if(core.isset(a)){a()}return}if(core.status.moveStepBeforeStop.length==0){core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);if(core.status.moveStepBeforeStop.length>=1){core.status.moveStepBeforeStop[0].step-=core.status.movedStep}}core.stopHero();core.stopAutomaticRoute();var g=30;if(f){var e=d.replace("Door","Key");if(!core.rmItem(e)){if(e!="specialKey"){core.drawTip("你没有"+core.material.items[e].name)}else{core.drawTip("无法开启此门")}core.clearContinueAutomaticRoute();if(core.isset(a)){a()}return}}core.playSound("door","ogg");var h=0;var c=d;if(!(c.substring(c.length-4)=="Door")){c=c+"Door";g=100}var b=core.material.icons.animates[c];core.interval.openDoorAnimate=window.setInterval(function(){h++;if(h==4){clearInterval(core.interval.openDoorAnimate);core.removeBlock(i,j);core.events.afterOpenDoor(d,i,j,a);return}core.canvas.event.clearRect(32*i,32*j,32,32);core.canvas.event.drawImage(core.material.images.animates,32*h,32*b,32,32,32*i,32*j,32,32)},g)};core.prototype.battle=function(f,h,i,d,a){if(core.status.moveStepBeforeStop.length==0){core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);if(core.status.moveStepBeforeStop.length>=1){core.status.moveStepBeforeStop[0].step-=core.status.movedStep}}core.stopHero();core.stopAutomaticRoute();var b=core.enemys.getDamage(f);if(b>=core.status.hero.hp&&!d){core.drawTip("你打不过此怪物!");core.clearContinueAutomaticRoute();return}core.playSound("attack","ogg");core.status.hero.hp-=b;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("battle");return}var g=core.material.enemys[f].money;if(core.hasItem("coin")){g*=2}if(core.hasFlag("curse")){g=0}core.status.hero.money+=g;var c=core.material.enemys[f].experience;if(core.hasFlag("curse")){c=0}core.status.hero.experience+=c;core.updateStatusBar();if(core.isset(h)&&core.isset(i)){core.removeBlock(h,i);core.canvas.event.clearRect(32*h,32*i,32,32)}core.updateFg();var e="打败 "+core.material.enemys[f].name+",金币+"+g;if(core.flags.enableExperience){e+=",经验+"+core.material.enemys[f].experience}core.drawTip(e);core.events.afterBattle(f,h,i,a)};core.prototype.changeFloor=function(c,f,d,g,b){g=g||50;core.lockControl();core.stopHero();core.stopAutomaticRoute();core.clearContinueAutomaticRoute();core.dom.floorNameLabel.innerHTML=core.status.maps[c].title;if(core.isset(f)){d=core.status.hero.loc;var a=core.status.maps[c].blocks;for(var e in a){if(core.isset(a[e].event)&&!(core.isset(a[e].enable)&&!a[e].enable)&&a[e].event.id===f){d.x=a[e].x;d.y=a[e].y}}}if(core.status.maps[c].canFlyTo&&core.status.hero.flyRange.indexOf(c)<0){if(core.floorIds.indexOf(c)>core.floorIds.indexOf(core.status.floorId)){core.status.hero.flyRange.push(c)}else{core.status.hero.flyRange.unshift(c)}}window.setTimeout(function(){core.playSound("floor","mp3");core.mapChangeAnimate("show",g/2,function(){core.statusBar.floor.innerHTML=core.status.maps[c].name;core.updateStatusBar();core.drawMap(c,function(){setTimeout(function(){core.mapChangeAnimate("hide",g/4,function(){core.unLockControl();core.events.afterChangeFloor(c);if(core.isset(b)){b()}});if(core.isset(d.direction)){core.setHeroLoc("direction",d.direction)}core.setHeroLoc("x",d.x);core.setHeroLoc("y",d.y);core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");core.updateFg()},15)})})},50)};core.prototype.mapChangeAnimate=function(b,c,a){if(b=="show"){core.show(core.dom.floorMsgGroup,c,function(){a()})}else{core.hide(core.dom.floorMsgGroup,c,function(){a()})}};core.prototype.clearMap=function(c,e,f,d,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].clearRect(0,0,416,416)}}else{core.canvas[c].clearRect(e,f,d,a)}};core.prototype.fillText=function(b,d,e,f,c,a){if(core.isset(c)){core.setFillStyle(b,c)}if(core.isset(a)){core.setFont(b,a)}core.canvas[b].fillText(d,e,f)};core.prototype.fillRect=function(b,e,f,d,a,c){if(core.isset(c)){core.setFillStyle(b,c)}core.canvas[b].fillRect(e,f,d,a)};core.prototype.strokeRect=function(c,f,g,e,a,d,b){if(core.isset(d)){core.setStrokeStyle(c,d)}if(core.isset(b)){core.setLineWidth(c,b)}core.canvas[c].strokeRect(f,g,e,a)};core.prototype.setFont=function(b,a){core.canvas[b].font=a};core.prototype.setLineWidth=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].lineWidth=a}}core.canvas[c].lineWidth=a};core.prototype.saveCanvas=function(a){core.canvas[a].save()};core.prototype.loadCanvas=function(a){core.canvas[a].restore()};core.prototype.setAlpha=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].globalAlpha=a}}core.canvas[c].globalAlpha=a};core.prototype.setStrokeStyle=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].strokeStyle=c}}else{core.canvas[b].strokeStyle=c}};core.prototype.setAlpha=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].globalAlpha=a}}else{core.canvas[c].globalAlpha=a}};core.prototype.setOpacity=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].canvas.style.opacity=c}}else{core.canvas[b].canvas.style.opacity=c}};core.prototype.setFillStyle=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].fillStyle=c}}else{core.canvas[b].fillStyle=c}};core.prototype.drawMap=function(h,e){var g=core.status.maps[h];var f=g.blocks;core.status.floorId=h;core.status.thisMap=g;var c,d;core.clearMap("all");core.rmGlobalAnimate(null,null,true);for(var i=0;i<13;i++){for(var j=0;j<13;j++){c=core.material.icons.terrains.ground;d=core.material.images.terrains;core.canvas.bg.drawImage(d,0,c*32,32,32,i*32,j*32,32,32)}}for(var a=0;a=0){a[d]={x:e,y:f,event:{cls:"terrains",id:"ground",noPass:false,trigger:"checkBlock"}};return}var b=core.floors[c].events[e+","+f];if(!core.isset(b)){b=core.floors[c].changeFloor[e+","+f]}if(!core.isset(b)){a.splice(d,1);return}a[d].enable=false};core.prototype.moveBlock=function(m,n,k,l,d,c){l=l||500;clearInterval(core.interval.tipAnimate);core.saveCanvas("data");core.clearMap("data",0,0,416,416);var b=core.getBlock(m,n,core.status.floorId,false);if(b==null){if(core.isset(c)){c()}return}core.removeBlock(m,n);core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);b=b.block;blockIcon=core.material.icons[b.event.cls][b.event.id];blockImage=core.material.images[b.event.cls];var h=1;core.setOpacity("data",h);core.canvas.data.drawImage(blockImage,0,blockIcon*32,32,32,b.x*32,b.y*32,32,32);var e=[];k.forEach(function(o){if(typeof o=="string"){e.push(o)}else{if(!core.isset(o.value)){e.push(o.direction)}else{for(var p=0;p=1||d<=0){clearInterval(a);core.loadCanvas("data");core.clearMap("data",0,0,416,416);core.setOpacity("data",1);if(core.isset(c)){c()}}},e/10)};core.prototype.addBlock=function(c,d,b){b=b||core.status.floorId;var a=core.getBlock(c,d,b,false);if(a==null){return}a=a.block;if(core.isset(a.enable)&&!a.enable){a.enable=true;if(b==core.status.floorId&&core.isset(a.event)){blockIcon=core.material.icons[a.event.cls][a.event.id];blockImage=core.material.images[a.event.cls];core.canvas.event.drawImage(core.material.images[a.event.cls],0,blockIcon*32,32,32,a.x*32,a.y*32,32,32);core.addGlobalAnimate(a.event.animate,a.x*32,a.y*32,blockIcon,blockImage);core.setGlobalAnimate(core.values.animateSpeed)}}};core.prototype.removeBlock=function(d,e,b){b=b||core.status.floorId;var a=core.getBlock(d,e,b,false);if(a==null){return}var c=a.index;if(b==core.status.floorId){core.rmGlobalAnimate(d,e);core.canvas.event.clearRect(d*32,e*32,32,32)}core.removeBlockById(c,b);core.updateFg()};core.prototype.removeBlockByIds=function(a,b){b.sort(function(c,d){return d-c}).forEach(function(c){core.removeBlockById(c,a)})};core.prototype.noPass=function(a,b){return a<0||a>12||b<0||b>12||core.noPassExists(a,b)};core.prototype.trigger=function(g,h){var d=core.status.thisMap.blocks;var e;for(var a=0;a0){var a=core.canvas.ui.createPattern(core.material.ground,"repeat");core.drawBoxAnimate(a);core.interval.boxAnimate=setInterval(function(){core.drawBoxAnimate(a)},core.values.animateSpeed)}};core.prototype.drawBoxAnimate=function(c){for(var b=0;b=999999999){d="???"}else{if(d>100000){d=(d/10000).toFixed(1)+"w"}}core.setFillStyle("fg","#000000");core.canvas.fg.fillText(d,32*h+2,32*(i+1)-2);core.canvas.fg.fillText(d,32*h,32*(i+1)-2);core.canvas.fg.fillText(d,32*h+2,32*(i+1));core.canvas.fg.fillText(d,32*h,32*(i+1));core.setFillStyle("fg",c);core.canvas.fg.fillText(d,32*h+1,32*(i+1)-1)}}};core.prototype.itemCount=function(b){if(!core.isset(b)||!core.isset(core.material.items[b])){return 0}var a=core.material.items[b].cls;if(a=="items"){return 0}return core.isset(core.status.hero.items[a][b])?core.status.hero.items[a][b]:0};core.prototype.hasItem=function(a){return core.itemCount(a)>0};core.prototype.setItem=function(b,c){var a=core.material.items[b].cls;if(a=="items"){return}if(!core.isset(core.status.hero.items[a])){core.status.hero.items[a]={}}core.status.hero.items[a][b]=c};core.prototype.rmItem=function(b){if(!core.hasItem(b)){return false}var a=core.material.items[b].cls;core.status.hero.items[a][b]--;core.updateStatusBar();if(a=="tools"&&core.status.hero.items[a][b]==0){delete core.status.hero.items[a][b]}return true};core.prototype.useItem=function(a){core.items.useItem(a);return};core.prototype.canUseItem=function(a){return core.items.canUseItem(a)};core.prototype.addItem=function(c,d){var b=core.material.items[c];var a=b.cls;if(a=="items"){return}if(!core.isset(core.status.hero.items[a])){core.status.hero.items[a]={};core.status.hero.items[a][c]=0}else{if(!core.isset(core.status.hero.items[a][c])){core.status.hero.items[a][c]=0}}core.status.hero.items[a][c]+=d};core.prototype.getItem=function(d,e,f,g,a){core.playSound("item","ogg");var c=core.material.items[d].cls;core.items.getItemEffect(d,e);core.removeBlock(f,g);var h="获得 "+core.material.items[d].name;if(e>1){h+="x"+e}if(c==="items"){h+=core.items.getItemEffectTip(d)}core.drawTip(h,core.material.icons.items[d]);core.canvas.event.clearRect(f*32,g*32,32,32);core.updateStatusBar();var b=core.floors[core.status.floorId].afterGetItem[f+","+g];if(core.isset(b)){core.events.doEvents(b,f,g,a)}else{if(core.isset(a)){a()}}};core.prototype.drawTip=function(e,c){var f,g,h,a,b=false,d=0;clearInterval(core.interval.tipAnimate);core.setFont("data","16px Arial");core.saveCanvas("data");core.setOpacity("data",0);if(!core.isset(c)){f=16;g=18;h=f+core.canvas.data.measureText(e).width+16;a=42}else{f=44;g=18;h=f+core.canvas.data.measureText(e).width+8;a=42}core.interval.tipAnimate=window.setInterval(function(){if(b){d-=0.1}else{d+=0.1}core.setOpacity("data",d);core.clearMap("data",5,5,400,a);core.fillRect("data",5,5,h,a,"#000");if(core.isset(c)){core.canvas.data.drawImage(core.material.images.items,0,c*32,32,32,10,8,32,32)}core.fillText("data",e,f+5,g+15,"#fff");if(d>0.6||d<0){if(b){core.loadCanvas("data");core.clearMap("data",5,5,400,a);core.setOpacity("data",1);clearInterval(core.interval.tipAnimate);return}else{if(!core.timeout.getItemTipTimeout){core.timeout.getItemTipTimeout=window.setTimeout(function(){b=true;core.timeout.getItemTipTimeout=null},750)}d=0.6;core.setOpacity("data",d)}}},30)};core.prototype.drawText=function(b,a){if(core.isset(b)){if(typeof b=="string"){b=[{content:b}]}else{if(b instanceof Object&&core.isset(b.content)){b=[b]}else{if(!(b instanceof Array)){core.drawTip("出错了");console.log(b);return}}}core.status.event={id:"text",data:{list:b,callback:a}};core.lockControl();core.stopAutomaticRoute();setTimeout(function(){core.drawText()},30);return}if(core.status.event.data.list.length==0){var a=core.status.event.data.callback;core.ui.closePanel(false);if(core.isset(a)){a()}return}var c=core.status.event.data.list.shift();if(typeof c=="string"){core.ui.drawTextBox(c)}else{core.ui.drawTextBox(c.content,c.id)}};core.prototype.replaceText=function(a){return a.replace(/\${([^}]+)}/g,function(c,b){return core.calValue(b)})};core.prototype.calValue=function(value){value=value.replace(/status:([\w\d_]+)/g,"core.getStatus('$1')");value=value.replace(/item:([\w\d_]+)/g,"core.itemCount('$1')");value=value.replace(/flag:([\w\d_]+)/g,"core.getFlag('$1', false)");return eval(value)};core.prototype.unshift=function(c,d){if(!(c instanceof Array)||!core.isset(d)){return}if(d instanceof Array){core.clone(d).reverse().forEach(function(a){c.unshift(a)})}else{c.unshift(d)}return c};core.prototype.setLocalStorage=function(b,c){try{localStorage.setItem(core.firstData.name+"_"+b,JSON.stringify(c));return true}catch(a){console.log(a);return false}};core.prototype.getLocalStorage=function(b,a){var c=localStorage.getItem(core.firstData.name+"_"+b);if(core.isset(c)){return JSON.parse(c)}return a};core.prototype.removeLocalStorage=function(a){localStorage.removeItem(core.firstData.name+"_"+a)};core.prototype.clone=function(b){if(!core.isset(b)){return b}if(b instanceof Date){var a=new Date();a.setTime(b.getTime());return a}if(b instanceof Array){var a=[];for(var c in b){a[c]=core.clone(b[c])}return a}if(b instanceof Function){return b}if(b instanceof Object){var a={};for(var c in b){if(b.hasOwnProperty(c)){a[c]=core.clone(b[c])}}return a}return b};core.prototype.formatDate=function(a){if(!core.isset(a)){return""}return a.getFullYear()+"-"+core.setTwoDigits(a.getMonth()+1)+"-"+core.setTwoDigits(a.getDate())+" "+core.setTwoDigits(a.getHours())+":"+core.setTwoDigits(a.getMinutes())+":"+core.setTwoDigits(a.getSeconds())};core.prototype.setTwoDigits=function(a){return parseInt(a)<10?"0"+a:a};core.prototype.lose=function(){core.stopAutomaticRoute();if(!core.status.heroStop){setTimeout(function(){core.lose()},30);return}core.events.lose()};core.prototype.debug=function(){core.setStatus("hp",999999);core.setStatus("atk",10000);core.setStatus("def",10000);core.setStatus("mdef",10000);core.setStatus("money",10000);core.setStatus("experience",10000);core.setItem("yellowKey",50);core.setItem("blueKey",50);core.setItem("redKey",50);core.setItem("book",1);core.setItem("fly",1);for(var a in core.status.maps){if(core.status.maps[a].canFlyTo&&core.status.hero.flyRange.indexOf(a)<0){core.status.hero.flyRange.push(a)}}core.updateStatusBar();core.drawTip("作弊成功")};core.prototype.checkStatus=function(c,d,b,a){if(d&&core.status.event.id==c){core.ui.closePanel(a);return false}if(d&&core.status.lockControl){return false}if(core.isset(b)&&b&&!core.hasItem(c)){core.drawTip("你没有"+core.material.items[c].name);return false}if(!core.status.heroStop){core.drawTip("请先停止勇士行动");return false}core.lockControl();core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};core.status.event.id=c;return true};core.prototype.openBook=function(a){if(!core.checkStatus("book",a,true,true)){return}core.useItem("book")};core.prototype.useFly=function(a){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};core.prototype.openToolbox=function(a){if(!core.checkStatus("toolbox",a)){return}core.ui.drawToolbox()};core.prototype.save=function(a){if(!core.checkStatus("save",a)){return}core.ui.drawSLPanel(core.status.savePage)};core.prototype.load=function(a){if(!core.isPlaying()){core.status.event={id:"load",data:null};core.status.lockControl=true;core.dom.startPanel.style.display="none";var b=core.getLocalStorage("savePage",0);core.ui.drawSLPanel(b);return}if(!core.checkStatus("load",a)){return}core.ui.drawSLPanel(core.status.savePage)};core.prototype.doSL=function(b,c){if(c=="save"){if(core.saveData("save"+b)){core.ui.closePanel();core.drawTip("存档成功!");core.setLocalStorage("savePage",core.status.savePage)}else{core.drawTip("存储空间不足,请覆盖已有的存档或在菜单栏中进行清理")}return}else{if(c=="load"){var a=core.getLocalStorage("save"+b,null);if(!core.isset(a)){core.drawTip("无效的存档");return}if(a.version!=core.firstData.version){core.drawTip("存档版本不匹配");return}core.ui.closePanel();core.loadData(a,function(){core.setLocalStorage("savePage",core.status.savePage);core.drawTip("读档成功")});return}}};core.prototype.saveData=function(b){var a={floorId:core.status.floorId,hero:core.clone(core.status.hero),hard:core.status.hard,maps:core.maps.save(core.status.maps),shops:{},version:core.firstData.version,time:new Date().getTime()};for(var c in core.status.shops){a.shops[c]={times:core.status.shops[c].times||0,visited:core.status.shops[c].visited||false}}core.events.beforeSaveData(a);return core.setLocalStorage(b,a)};core.prototype.loadData=function(b,a){core.resetStatus(b.hero,b.hard,b.floorId,core.maps.load(b.maps));for(var c in core.status.shops){core.status.shops[c].times=b.shops[c].times;core.status.shops[c].visited=b.shops[c].visited}core.events.afterLoadData(b);core.changeFloor(b.floorId,null,b.hero.loc,null,function(){core.setHeroMoveTriggerInterval();if(core.isset(a)){a()}})};core.prototype.setStatus=function(a,b){core.status.hero[a]=b};core.prototype.getStatus=function(a){return core.status.hero[a]};core.prototype.setFlag=function(a,b){if(!core.isset(core.status.hero)){return}core.status.hero.flags[a]=b};core.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};core.prototype.hasFlag=function(a){if(core.getFlag(a)){return true}return false};core.prototype.lockControl=function(){core.status.lockControl=true};core.prototype.unLockControl=function(){core.status.lockControl=false};core.prototype.isset=function(a){if(a==undefined||a==null){return false}return true};core.prototype.playSound=function(a,b){if(!core.musicStatus.soundStatus||!core.musicStatus.loaded){return}if(!core.isset(core.material.sounds[b][a])){return}core.musicStatus.playedSound=core.material.sounds[b][a];core.musicStatus.playedSound.play()};core.prototype.playBgm=function(a,b){if(core.musicStatus.isIOS||!core.musicStatus.loaded){return}if(core.isset(core.musicStatus.playedBgm)){core.musicStatus.playedBgm.pause()}core.musicStatus.playedBgm=core.material.sounds[b][a];if(core.musicStatus.soundStatus){core.musicStatus.playedBgm.play()}};core.prototype.changeSoundStatus=function(){if(core.musicStatus.soundStatus){main.core.disabledSound()}else{main.core.enabledSound()}};core.prototype.enabledSound=function(){core.musicStatus.soundStatus=true;core.playBgm("bgm","mp3");core.setLocalStorage("soundStatus",true)};core.prototype.disabledSound=function(){core.musicStatus.playedBgm.pause();core.musicStatus.soundStatus=false;core.setLocalStorage("soundStatus",false)};core.prototype.show=function(b,e,a){if(!core.isset(e)){b.style.display="block";return}b.style.display="block";b.style.opacity=0;var c=0;var d=window.setInterval(function(){c+=0.03;b.style.opacity=c;if(c>1){clearInterval(d);if(core.isset(a)){a()}}},e)};core.prototype.hide=function(c,e,a){if(!core.isset(e)){c.style.display="none";return}var d=1;var b=window.setInterval(function(){d-=0.03;c.style.opacity=d;if(d<0){c.style.display="none";clearInterval(b);if(core.isset(a)){a()}}},e)};core.prototype.clearStatusBar=function(){var a=["floor","hp","atk","def","mdef","money","experience","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};core.prototype.updateStatusBar=function(){if(core.values.HPMAX>0){core.setStatus("hp",Math.min(core.values.HPMAX,core.getStatus("hp")))}var b=["hp","atk","def","mdef","money","experience"];b.forEach(function(c){core.statusBar[c].innerHTML=core.getStatus(c)});var a=["yellowKey","blueKey","redKey"];a.forEach(function(c){core.statusBar[c].innerHTML=core.setTwoDigits(core.status.hero.items.keys[c])});core.statusBar.poison.innerHTML=core.hasFlag("poison")?"毒":"";core.statusBar.weak.innerHTML=core.hasFlag("weak")?"衰":"";core.statusBar.curse.innerHTML=core.hasFlag("curse")?"咒":"";core.statusBar.hard.innerHTML=core.status.hard;if(core.hasItem("book")){core.statusBar.image.book.style.opacity=1}else{core.statusBar.image.book.style.opacity=0.3}if(core.hasItem("fly")){core.statusBar.image.fly.style.opacity=1}else{core.statusBar.image.fly.style.opacity=0.3}core.updateFg()};core.prototype.resize=function(d,c){var b=416;var k=83;var q=49;var l=132;var a=b+6;var s=d;var i=false;if(d>c&&c<422){i=true;s=c}if(s