1 line
38 KiB
JavaScript
1 line
38 KiB
JavaScript
function actions(){this.init()}actions.prototype.init=function(){};actions.prototype.onkeyDown=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}if(!core.isset(core.status.holdingKeys)){core.status.holdingKeys=[]}var c={37:true,38:true,39:true,40:true}[a.keyCode];if(c&&!core.status.lockControl){for(var b=0;b<core.status.holdingKeys.length;b++){if(core.status.holdingKeys[b]===a.keyCode){return}}core.status.holdingKeys.push(a.keyCode);this.pressKey(a.keyCode)}else{if(a.keyCode==17){core.status.ctrlDown=true}this.keyDown(a.keyCode)}};actions.prototype.onkeyUp=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){if(a.keyCode==27){core.stopReplay()}else{if(a.keyCode==90){core.speedDownReplay()}else{if(a.keyCode==88){core.speedUpReplay()}else{if(a.keyCode==32){core.triggerReplay()}else{if(a.keyCode==65){core.rewindReplay()}else{if(a.keyCode==83){core.saveReplay()}else{if(a.keyCode==67){core.bookReplay()}}}}}}}return}var c={37:true,38:true,39:true,40:true}[a.keyCode];if(c&&!core.status.lockControl){for(var b=0;b<core.status.holdingKeys.length;b++){if(core.status.holdingKeys[b]===a.keyCode){core.status.holdingKeys=core.status.holdingKeys.slice(0,b).concat(core.status.holdingKeys.slice(b+1));if(b===core.status.holdingKeys.length&&core.status.holdingKeys.length!==0){core.pressKey(core.status.holdingKeys.slice(-1)[0])}break}}this.keyUp(a.keyCode)}else{if(a.keyCode==17){core.status.ctrlDown=false}this.keyUp(a.keyCode)}};actions.prototype.pressKey=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}if(a===core.status.holdingKeys.slice(-1)[0]){this.keyDown(a);window.setTimeout(function(){core.pressKey(a)},30)}};actions.prototype.keyDown=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}if(core.status.lockControl){if(a==17){this.keyDownCtrl();return}if(core.status.event.id=="action"){this.keyDownAction(a);return}if(core.status.event.id=="book"){this.keyDownBook(a);return}if(core.status.event.id=="fly"){this.keyDownFly(a);return}if(core.status.event.id=="viewMaps"){this.keyDownViewMaps(a);return}if(core.status.event.id=="shop"){this.keyDownShop(a);return}if(core.status.event.id=="selectShop"){this.keyDownQuickShop(a);return}if(core.status.event.id=="toolbox"){this.keyDownToolbox(a);return}if(core.status.event.id=="save"||core.status.event.id=="load"||core.status.event.id=="replayLoad"){this.keyDownSL(a);return}if(core.status.event.id=="switchs"){this.keyDownSwitchs(a);return}if(core.status.event.id=="settings"){this.keyDownSettings(a);return}if(core.status.event.id=="syncSave"){this.keyDownSyncSave(a);return}if(core.status.event.id=="syncSelect"){this.keyDownSyncSelect(a);return}if(core.status.event.id=="localSaveSelect"){this.keyDownLocalSaveSelect(a);return}if(core.status.event.id=="storageRemove"){this.keyDownStorageRemove(a);return}if(core.status.event.id=="cursor"){this.keyDownCursor(a);return}if(core.status.event.id=="replay"){this.keyDownReplay(a)}return}if(!core.status.played){return}switch(a){case 37:core.moveHero("left");break;case 38:core.moveHero("up");break;case 39:core.moveHero("right");break;case 40:core.moveHero("down");break;case 13:case 32:case 67:case 51:if(core.status.heroStop&&core.hasItem("centerFly")){if(core.status.usingCenterFly){if(core.canUseItem("centerFly")){core.useItem("centerFly");core.clearMap("ui",core.getHeroLoc("x")*32,core.getHeroLoc("y")*32,32,32)}else{core.drawTip("当前不能使用中心对称飞行器");core.clearMap("ui",(12-core.getHeroLoc("x"))*32,(12-core.getHeroLoc("y"))*32,32,32)}core.status.usingCenterFly=false}else{if(a==51){core.status.usingCenterFly=true;core.setAlpha("ui",0.5);core.fillRect("ui",(12-core.getHeroLoc("x"))*32,(12-core.getHeroLoc("y"))*32,32,32,core.canUseItem("centerFly")?"#00FF00":"#FF0000");core.setAlpha("ui",1);core.drawTip("请确认当前中心对称飞行器的位置")}}}break}if(core.status.usingCenterFly&&a!=51){core.clearMap("ui",(12-core.getHeroLoc("x"))*32,(12-core.getHeroLoc("y"))*32,32,32);core.status.usingCenterFly=false}};actions.prototype.keyUp=function(b,a){if(!a&&core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}if(core.status.lockControl){core.status.holdingKeys=[];if(core.status.event.id=="text"&&(b==13||b==32||b==67)){core.drawText();return}if(core.status.event.id=="confirmBox"){this.keyUpConfirmBox(b);return}if(core.status.event.id=="action"){this.keyUpAction(b);return}if(core.status.event.id=="about"&&(b==13||b==32||b==67)){this.clickAbout();return}if(core.status.event.id=="book"){this.keyUpBook(b);return}if(core.status.event.id=="book-detail"&&(b==13||b==32||b==67)){this.clickBookDetail();return}if(core.status.event.id=="fly"){this.keyUpFly(b);return}if(core.status.event.id=="viewMaps"){this.keyUpViewMaps(b);return}if(core.status.event.id=="shop"){this.keyUpShop(b);return}if(core.status.event.id=="selectShop"){this.keyUpQuickShop(b);return}if(core.status.event.id=="toolbox"){this.keyUpToolbox(b);return}if(core.status.event.id=="save"||core.status.event.id=="load"||core.status.event.id=="replayLoad"){this.keyUpSL(b);return}if(core.status.event.id=="switchs"){this.keyUpSwitchs(b);return}if(core.status.event.id=="settings"){this.keyUpSettings(b);return}if(core.status.event.id=="syncSave"){this.keyUpSyncSave(b);return}if(core.status.event.id=="syncSelect"){this.keyUpSyncSelect(b);return}if(core.status.event.id=="localSaveSelect"){this.keyUpLocalSaveSelect(b);return}if(core.status.event.id=="storageRemove"){this.keyUpStorageRemove(b);return}if(core.status.event.id=="cursor"){this.keyUpCursor(b);return}if(core.status.event.id=="replay"){this.keyUpReplay(b);return}return}if(!core.status.played){return}switch(b){case 27:if(core.status.heroStop){core.openSettings(true)}break;case 71:if(core.status.heroStop){core.useFly(true)}break;case 88:if(core.status.heroStop){core.openBook(true)}break;case 65:if(core.status.heroStop){core.doSL("autoSave","load")}break;case 83:if(core.status.heroStop){core.save(true)}break;case 68:if(core.status.heroStop){core.load(true)}break;case 69:break;case 84:if(core.status.heroStop){core.openToolbox(true)}break;case 90:if(core.status.heroStop){core.turnHero()}break;case 75:if(core.status.heroStop){core.openQuickShop(true)}break;case 32:if(core.status.heroStop){core.getNextItem()}break;case 72:if(core.status.heroStop){core.ui.drawHelp()}break;case 82:if(core.status.heroStop){if(core.hasFlag("debug")){core.drawText("\t[系统提示]调试模式下无法回放录像")}else{core.ui.drawReplay()}}break;case 33:case 34:if(core.status.heroStop){if(core.flags.enableViewMaps){core.ui.drawMaps(core.floorIds.indexOf(core.status.floorId))}else{core.drawTip("本塔不允许浏览地图!")}}break;case 37:break;case 38:break;case 39:break;case 40:break;case 49:if(core.status.heroStop&&core.hasItem("pickaxe")){if(core.canUseItem("pickaxe")){core.useItem("pickaxe")}else{core.drawTip("当前不能使用破墙镐")}}break;case 50:if(core.status.heroStop){if(core.hasItem("bomb")){if(core.canUseItem("bomb")){core.useItem("bomb")}else{core.drawTip("当前不能使用炸弹")}}else{if(core.hasItem("hammer")){if(core.canUseItem("hammer")){core.useItem("hammer")}else{core.drawTip("当前不能使用圣锤")}}}}break}if(core.isset(core.status.automaticRoute)&&core.status.automaticRoute.autoHeroMove){core.stopAutomaticRoute()}core.stopHero()};actions.prototype.ondown=function(b,c){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}if(!core.status.played||core.status.lockControl){this.onclick(b,c,[]);if(core.timeout.onDownTimeout==null){core.timeout.onDownTimeout=setTimeout(function(){if(core.interval.onDownInterval==null){core.interval.onDownInterval=setInterval(function(){if(!core.actions.longClick(b,c,true)){clearInterval(core.interval.onDownInterval);core.interval.onDownInterval=null}},40)}},500)}return}core.status.downTime=new Date();core.clearMap("ui",0,0,416,416);var a={x:b,y:c};core.status.stepPostfix=[];core.status.stepPostfix.push(a);core.fillPosWithPoint(a)};actions.prototype.onmove=function(g,h){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}var e={x:g,y:h};var f=core.status.stepPostfix[core.status.stepPostfix.length-1];var a=[e.y-f.y,f.x-e.x,f.y-e.y,e.x-f.x];var d=0,c=4;for(var b=0;b<4;b++){if(a[b]>d){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)}};actions.prototype.onup=function(){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}clearTimeout(core.timeout.onDownTimeout);core.timeout.onDownTimeout=null;clearInterval(core.interval.onDownInterval);core.interval.onDownInterval=null;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;b<core.status.stepPostfix.length;b++){var d=core.status.stepPostfix[b-1];var c=core.status.stepPostfix[b];g.push({direction:a[c.x-d.x][c.y-d.y],x:c.x,y:c.y})}var e=core.status.stepPostfix[0].x;var f=core.status.stepPostfix[0].y;core.status.stepPostfix=[];if(!core.status.lockControl){core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.restore()}if(!core.status.lockControl&&g.length==0&&core.status.downTime!=null&&new Date()-core.status.downTime>=1000){this.longClick(e,f)}else{this.onclick(e,f,g)}core.status.downTime=null}};actions.prototype.getClickLoc=function(f,g){var d={x:0,y:0};var c=32;c=c*core.domStyle.scale;switch(core.domStyle.screenMode){case"vertical":d.x=0;d.y=core.dom.statusBar.offsetHeight+3;break;case"horizontal":case"bigScreen":d.x=core.dom.statusBar.offsetWidth+3;d.y=0;break}var a=core.dom.gameGroup.offsetLeft+d.x;var e=core.dom.gameGroup.offsetTop+d.y;var b={x:f-a,y:g-e,size:c};return b};actions.prototype.onclick=function(b,c,a){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}a=a||[];if(b<0||c<0||b>12||c>12){return}if(core.status.usingCenterFly){if(b!=12-core.getHeroLoc("x")||c!=12-core.getHeroLoc("y")){core.clearMap("ui",(12-core.getHeroLoc("x"))*32,(12-core.getHeroLoc("y"))*32,32,32)}else{if(core.canUseItem("centerFly")){core.useItem("centerFly");core.clearMap("ui",core.getHeroLoc("x")*32,core.getHeroLoc("y")*32,32,32);return}else{core.drawTip("当前不能使用中心对称飞行器");core.clearMap("ui",(12-core.getHeroLoc("x"))*32,(12-core.getHeroLoc("y"))*32,32,32)}}core.status.usingCenterFly=false}if(!core.status.lockControl){core.setAutomaticRoute(b,c,a);return}if(core.status.event.id=="book"){this.clickBook(b,c);return}if(core.status.event.id=="book-detail"){this.clickBookDetail(b,c);return}if(core.status.event.id=="fly"){this.clickFly(b,c);return}if(core.status.event.id=="viewMaps"){this.clickViewMaps(b,c);return}if(core.status.event.id=="switchs"){this.clickSwitchs(b,c);return}if(core.status.event.id=="settings"){this.clickSettings(b,c);return}if(core.status.event.id=="shop"){this.clickShop(b,c);return}if(core.status.event.id=="selectShop"){this.clickQuickShop(b,c);return}if(core.status.event.id=="toolbox"){this.clickToolbox(b,c);return}if(core.status.event.id=="save"||core.status.event.id=="load"||core.status.event.id=="replayLoad"){this.clickSL(b,c);return}if(core.status.event.id=="confirmBox"){this.clickConfirmBox(b,c);return}if(core.status.event.id=="keyBoard"){this.clickKeyBoard(b,c);return}if(core.status.event.id=="about"){this.clickAbout(b,c);return}if(core.status.event.id=="action"){this.clickAction(b,c);return}if(core.status.event.id=="text"){core.drawText();return}if(core.status.event.id=="syncSave"){this.clickSyncSave(b,c);return}if(core.status.event.id=="syncSelect"){this.clickSyncSelect(b,c);return}if(core.status.event.id=="localSaveSelect"){this.clickLocalSaveSelect(b,c);return}if(core.status.event.id=="storageRemove"){this.clickStorageRemove(b,c);return}if(core.status.event.id=="cursor"){this.clickCursor(b,c);return}if(core.status.event.id=="replay"){this.clickReplay(b,c);return}};actions.prototype.onmousewheel=function(a){if(core.isset(core.status.replay)&&core.status.replay.replaying&&core.status.event.id!="save"&&(core.status.event.id||"").indexOf("book")!=0){return}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}if(core.status.lockControl&&core.status.event.id=="book"){if(a==1){core.ui.drawBook(core.status.event.data-6)}if(a==-1){core.ui.drawBook(core.status.event.data+6)}return}if(core.status.lockControl&&(core.status.event.id=="save"||core.status.event.id=="load")){if(a==1){core.ui.drawSLPanel(core.status.event.data-10)}if(a==-1){core.ui.drawSLPanel(core.status.event.data+10)}return}if(core.status.lockControl&&core.status.event.id=="viewMaps"){if(a==1){this.clickViewMaps(6,2)}if(a==-1){this.clickViewMaps(6,10)}return}};actions.prototype.longClick=function(b,c,a){if(!core.isPlaying()){return false}if(core.status.lockControl){if(core.status.event.id=="text"){core.drawText();return true}if(core.status.event.id=="action"&&core.status.event.data.type=="text"){core.doAction();return true}}else{if(!a){core.waitHeroToStop(function(){core.ui.drawKeyBoard()})}}return false};actions.prototype.keyDownCtrl=function(){if(core.status.event.id=="text"){core.drawText();return}if(core.status.event.id=="action"&&core.status.event.data.type=="text"){core.doAction();return}};actions.prototype.clickConfirmBox=function(a,b){if((a==4||a==5)&&b==7&&core.isset(core.status.event.data.yes)){core.status.event.data.yes()}if((a==7||a==8)&&b==7&&core.isset(core.status.event.data.no)){core.status.event.data.no()}};actions.prototype.keyUpConfirmBox=function(a){if(a==37){core.status.event.selection=0;core.ui.drawConfirmBox(core.status.event.ui,core.status.event.data.yes,core.status.event.data.no)}if(a==39){core.status.event.selection=1;core.ui.drawConfirmBox(core.status.event.ui,core.status.event.data.yes,core.status.event.data.no)}if(a==13||a==32||a==67){if(core.status.event.selection==0&&core.isset(core.status.event.data.yes)){core.status.event.selection=null;core.status.event.data.yes()}if(core.status.event.selection==1&&core.isset(core.status.event.data.no)){core.status.event.selection=null;core.status.event.data.no()}}};actions.prototype.clickAction=function(d,e){if(core.status.event.data.type=="text"){core.doAction();return}if(core.status.event.data.type=="wait"){core.setFlag("type",1);core.setFlag("x",d);core.setFlag("y",e);core.status.route.push("input:"+(10000+100*d+e));core.doAction();return}if(core.status.event.data.type=="choices"){var b=core.status.event.data.current;var a=b.choices;if(a.length==0){return}if(d>=5&&d<=7){var c=6-parseInt((a.length-1)/2);if(e>=c&&e<c+a.length){core.status.route.push("choices:"+(e-c));core.insertAction(a[e-c].action);core.doAction()}}}};actions.prototype.keyDownAction=function(c){if(core.status.event.data.type=="choices"){var b=core.status.event.data.current;var a=b.choices;if(a.length>0){if(c==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(c==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}}}};actions.prototype.keyUpAction=function(c){if(core.status.event.data.type=="text"&&(c==13||c==32||c==67)){core.doAction();return}if(core.status.event.data.type=="wait"){core.setFlag("type",0);core.setFlag("keycode",c);core.status.route.push("input:"+c);core.doAction();return}if(core.status.event.data.type=="choices"){var b=core.status.event.data.current;var a=b.choices;if(a.length>0){if(c==13||c==32||c==67){core.status.route.push("choices:"+core.status.event.selection);core.insertAction(a[core.status.event.selection].action);core.doAction()}}}};actions.prototype.clickBook=function(d,e){if((d==3||d==4)&&e==12){core.ui.drawBook(core.status.event.data-6);return}if((d==8||d==9)&&e==12){core.ui.drawBook(core.status.event.data+6);return}if(d>=10&&d<=12&&e==12){if(core.status.event.selection==null){core.ui.closePanel()}else{core.status.boxAnimateObjs=[];core.ui.drawMaps(core.status.event.selection)}return}var a=core.status.event.data;if(core.isset(a)&&e<12){var c=parseInt(a/6);var b=6*c+parseInt(e/2);core.ui.drawBook(b);core.ui.drawBookDetail(b)}return};actions.prototype.keyDownBook=function(a){if(a==37){core.ui.drawBook(core.status.event.data-6)}if(a==38){core.ui.drawBook(core.status.event.data-1)}if(a==39){core.ui.drawBook(core.status.event.data+6)}if(a==40){core.ui.drawBook(core.status.event.data+1)}if(a==33){core.ui.drawBook(core.status.event.data-6)}if(a==34){core.ui.drawBook(core.status.event.data+6)}return};actions.prototype.keyUpBook=function(b){if(b==27||b==88){if(core.status.event.selection==null){core.ui.closePanel()}else{core.status.boxAnimateObjs=[];core.ui.drawMaps(core.status.event.selection)}return}if(b==13||b==32||b==67){var a=core.status.event.data;if(core.isset(a)){this.clickBook(6,2*(a%6))}return}};actions.prototype.clickBookDetail=function(){core.clearMap("data",0,0,416,416);core.status.event.id="book"};actions.prototype.clickFly=function(e,f){if((e==10||e==11)&&f==9){core.ui.drawFly(core.status.event.data-1)}if((e==10||e==11)&&f==5){core.ui.drawFly(core.status.event.data+1)}if(e>=5&&e<=7&&f==12){core.ui.closePanel()}if(e>=0&&e<=9&&f>=3&&f<=11){var b=core.status.hero.flyRange.indexOf(core.status.floorId);var c=core.status.event.data<b?"upFloor":"downFloor";var a=core.status.event.data;var d=core.status.hero.flyRange[a];core.status.route.push("fly:"+d);core.ui.closePanel();core.changeFloor(d,c)}return};actions.prototype.keyDownFly=function(a){if(a==37||a==38){core.ui.drawFly(core.status.event.data+1)}else{if(a==39||a==40){core.ui.drawFly(core.status.event.data-1)}}return};actions.prototype.keyUpFly=function(a){if(a==71||a==27||a==88){core.ui.closePanel()}if(a==13||a==32||a==67){this.clickFly(5,5)}return};actions.prototype.clickViewMaps=function(c,d){var b=core.floorIds.indexOf(core.status.floorId);var a=core.status.event.data;if(d<=4){a++;while(a<core.floorIds.length&&a!=b&&core.floors[core.floorIds[a]].cannotViewMap){a++}if(a<core.floorIds.length){core.ui.drawMaps(a)}}else{if(d>=8){a--;while(a>=0&&a!=b&&core.floors[core.floorIds[a]].cannotViewMap){a--}if(a>=0){core.ui.drawMaps(a)}}else{core.clearMap("data",0,0,416,416);core.setOpacity("data",1);core.ui.closePanel()}}};actions.prototype.keyDownViewMaps=function(a){if(a==37||a==38||a==33){this.clickViewMaps(6,2)}else{if(a==39||a==40||a==34){this.clickViewMaps(6,10)}}return};actions.prototype.keyUpViewMaps=function(a){if(a==27||a==13||a==32||a==67){core.clearMap("data",0,0,416,416);core.setOpacity("data",1);core.ui.closePanel()}if(a==88){core.openBook(false)}return};actions.prototype.clickShop=function(x,y){var shop=core.status.event.data.shop;var choices=shop.choices;if(x>=5&&x<=7){var topIndex=6-parseInt(choices.length/2);if(y>=topIndex&&y<topIndex+choices.length){core.status.event.selection=y-topIndex;var money=core.getStatus("money"),experience=core.getStatus("experience");var times=shop.times,need=eval(shop.need);var use=shop.use;var use_text=use=="money"?"金币":"经验";var choice=choices[y-topIndex];if(core.isset(choice.need)){need=eval(choice.need)}if(need>eval(use)){core.drawTip("你的"+use_text+"不足");return false}core.status.event.data.actions.push(y-topIndex);eval(use+"-="+need);core.setStatus("money",money);core.setStatus("experience",experience);choice.effect.split(";").forEach(function(t){core.doEffect(t)});core.updateStatusBar();shop.times++;core.events.openShop(core.status.event.data.id)}else{if(y==topIndex+choices.length){if(core.status.event.data.actions.length>0){core.status.route.push("shop:"+core.status.event.data.id+":"+core.status.event.data.actions.join(""))}core.status.event.data.actions=[];core.status.boxAnimateObjs=[];if(core.status.event.data.fromList){core.ui.drawQuickShop()}else{core.ui.closePanel()}}else{return false}}}return true};actions.prototype.keyDownShop=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpShop=function(b){if(b==27||b==88){if(core.status.event.data.actions.length>0){core.status.route.push("shop:"+core.status.event.data.id+":"+core.status.event.data.actions.join(""))}core.status.event.data.actions=[];core.status.boxAnimateObjs=[];if(core.status.event.data.fromList){core.ui.drawQuickShop()}else{core.ui.closePanel()}return}var c=core.status.event.data.shop;var a=c.choices;if(b==13||b==32||b==67){var d=6-parseInt(a.length/2);this.clickShop(6,d+core.status.event.selection)}return};actions.prototype.clickQuickShop=function(e,f){var c=core.status.shops,a=Object.keys(c);if(e>=5&&e<=7){var d=6-parseInt(a.length/2);if(f>=d&&f<d+a.length){var b=core.events.canUseQuickShop(a[f-d]);if(core.isset(b)){core.drawText(b);return}core.events.openShop(a[f-d],true);if(core.status.event.id=="shop"){core.status.event.data.fromList=true}}else{if(f==d+a.length){core.ui.closePanel()}}}};actions.prototype.keyDownQuickShop=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpQuickShop=function(a){if(a==27||a==75||a==88){core.ui.closePanel();return}var c=core.status.shops,b=Object.keys(c);if(a==13||a==32||a==67){var d=6-parseInt(b.length/2);this.clickQuickShop(6,d+core.status.event.selection)}return};actions.prototype.clickToolbox=function(b,c){if(b>=10&&b<=12&&c==12){core.ui.closePanel();return}if(b>=10&&b<=12&&c<=1){if(!core.isset(core.status.event.data)){return}if(!core.flags.enableDeleteItem){core.drawTip("不支持删除道具!");return}core.removeItem(core.status.event.data);core.status.event.data=null;core.ui.drawToolbox();return}var a=0;if(c==4||c==5||c==9||c==10){a=parseInt(b/2)}else{a=6+parseInt(b/2)}if(c>=9){a+=100}this.clickToolboxIndex(a)};actions.prototype.clickToolboxIndex=function(b){var d=null;var a=b;if(a<100){d=Object.keys(core.status.hero.items.tools).sort()}else{a-=100;d=Object.keys(core.status.hero.items.constants).sort()}if(d==null){return}if(a>=d.length){return}var c=d[a];if(c==core.status.event.data){core.events.useItem(c)}else{core.ui.drawToolbox(b)}};actions.prototype.keyDownToolbox=function(c){if(!core.isset(core.status.event.data)){return}var d=Object.keys(core.status.hero.items.tools).sort();var a=Object.keys(core.status.hero.items.constants).sort();var b=core.status.event.selection;if(c==37){if((b>0&&b<100)||b>100){this.clickToolboxIndex(b-1);return}if(b==100&&d.length>0){this.clickToolboxIndex(d.length-1);return}}if(c==38){if((b>5&&b<100)||b>105){this.clickToolboxIndex(b-6);return}if(b>=100&&b<=105){if(d.length>6){this.clickToolboxIndex(Math.min(d.length-1,b-100+6))}else{if(d.length>0){this.clickToolboxIndex(Math.min(d.length-1,b-100))}}return}}if(c==39){if((b<d.length-1)||(b>=100&&b<a.length+100)){this.clickToolboxIndex(b+1);return}if(b==d.length-1&&a.length>0){this.clickToolboxIndex(100);return}}if(c==40){if(b<=5){if(d.length>6){this.clickToolboxIndex(Math.min(d.length-1,b+6))}else{if(a.length>0){this.clickToolboxIndex(100+Math.min(a.length-1,b))}}return}if(b>5&&b<100&&a.length>0){this.clickToolboxIndex(100+Math.min(a.length-1,b-6));return}if(b>=100&&b<=105&&a.length>6){this.clickToolboxIndex(Math.min(100+a.length-1,b+6));return}}};actions.prototype.keyUpToolbox=function(a){if(a==84||a==27||a==88){core.ui.closePanel();return}if(!core.isset(core.status.event.data)){return}if(a==13||a==32||a==67){this.clickToolboxIndex(core.status.event.selection);return}if(a==46){if(!core.isset(core.status.event.data)){return}if(!core.flags.enableDeleteItem){core.drawTip("不支持删除道具!");return}core.removeItem(core.status.event.data);core.status.event.data=null;core.ui.drawToolbox();return}};actions.prototype.clickSL=function(e,f){var b=core.status.event.data;var d=parseInt(b/10),c=b%10;if((e==3||e==4)&&f==12){core.ui.drawSLPanel(10*(d-1)+c);return}if((e==8||e==9)&&f==12){core.ui.drawSLPanel(10*(d+1)+c);return}if(e>=10&&e<=12&&f==12){core.ui.closePanel();if(!core.isPlaying()){core.showStartAnimate()}return}if(e>=0&&e<=2&&f==12){core.status.event.selection=!core.status.event.selection;core.ui.drawSLPanel(b);return}var a=null;if(f>=1&&f<=4){if(e>=1&&e<=3){a="autoSave"}if(e>=5&&e<=7){a=5*d+1}if(e>=9&&e<=11){a=5*d+2}}if(f>=7&&f<=10){if(e>=1&&e<=3){a=5*d+3}if(e>=5&&e<=7){a=5*d+4}if(e>=9&&e<=11){a=5*d+5}}if(a!=null){if(core.status.event.selection){if(a=="autoSave"){core.drawTip("无法删除自动存档!")}else{core.removeLocalStorage("save"+a);core.ui.drawSLPanel(b)}}else{core.doSL(a,core.status.event.id)}}};actions.prototype.keyDownSL=function(b){var a=core.status.event.data;var d=parseInt(a/10),c=a%10;if(b==37){if(c==0){core.ui.drawSLPanel(10*(d-1)+5)}else{core.ui.drawSLPanel(a-1)}return}if(b==38){if(c<3){core.ui.drawSLPanel(10*(d-1)+c+3)}else{core.ui.drawSLPanel(a-3)}return}if(b==39){if(c==5){core.ui.drawSLPanel(10*(d+1)+1)}else{core.ui.drawSLPanel(a+1)}return}if(b==40){if(c>=3){core.ui.drawSLPanel(10*(d+1)+c-3)}else{core.ui.drawSLPanel(a+3)}return}if(b==33){core.ui.drawSLPanel(10*(d-1)+c);return}if(b==34){core.ui.drawSLPanel(10*(d+1)+c);return}};actions.prototype.keyUpSL=function(b){var a=core.status.event.data;var d=parseInt(a/10),c=a%10;if(b==27||b==88||(core.status.event.id=="save"&&b==83)||(core.status.event.id=="load"&&b==68)){core.ui.closePanel();if(!core.isPlaying()){core.showStartAnimate()}return}if(b==13||b==32||b==67){if(c==0){core.doSL("autoSave",core.status.event.id)}else{core.doSL(5*d+c,core.status.event.id)}return}if(b==46){if(c==0){core.drawTip("无法删除自动存档!")}else{core.removeLocalStorage("save"+(5*d+c));core.ui.drawSLPanel(a)}}};actions.prototype.clickSwitchs=function(d,e){if(d<5||d>7){return}var a=core.status.event.ui.choices;var c=6-parseInt((a.length-1)/2);if(e>=c&&e<c+a.length){var b=e-c;switch(b){case 0:core.musicStatus.bgmStatus=!core.musicStatus.bgmStatus;if(core.musicStatus.bgmStatus){core.resumeBgm()}else{core.pauseBgm();core.musicStatus.playingBgm=null}core.setLocalStorage("bgmStatus",core.musicStatus.bgmStatus);core.ui.drawSwitchs();break;case 1:core.musicStatus.soundStatus=!core.musicStatus.soundStatus;core.setLocalStorage("soundStatus",core.musicStatus.soundStatus);core.ui.drawSwitchs();break;case 2:if(!core.flags.canOpenBattleAnimate){core.drawTip("本塔不能开启战斗动画!")}else{core.flags.battleAnimate=!core.flags.battleAnimate;core.setLocalStorage("battleAnimate",core.flags.battleAnimate);core.ui.drawSwitchs()}break;case 3:core.flags.displayEnemyDamage=!core.flags.displayEnemyDamage;core.updateFg();core.setLocalStorage("enemyDamage",core.flags.displayEnemyDamage);core.ui.drawSwitchs();break;case 4:core.flags.displayCritical=!core.flags.displayCritical;core.updateFg();core.setLocalStorage("critical",core.flags.displayCritical);core.ui.drawSwitchs();break;case 5:core.flags.displayExtraDamage=!core.flags.displayExtraDamage;core.updateFg();core.setLocalStorage("extraDamage",core.flags.displayExtraDamage);core.ui.drawSwitchs();break;case 6:window.open(core.firstData.name+".zip","_blank");break;case 7:core.status.event.selection=0;core.ui.drawSettings();break}}};actions.prototype.keyDownSwitchs=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpSwitchs=function(b){if(b==27||b==88){core.status.event.selection=0;core.ui.drawSettings();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickSwitchs(6,c+core.status.event.selection)}};actions.prototype.clickSettings=function(d,e){if(d<5||d>7){return}var a=core.status.event.ui.choices;var c=6-parseInt((a.length-1)/2);if(e>=c&&e<c+a.length){var b=e-c;switch(b){case 0:core.status.event.selection=0;core.ui.drawSwitchs();break;case 1:core.status.event.selection=0;core.ui.drawQuickShop();break;case 2:if(!core.flags.enableViewMaps){core.drawTip("本塔不允许浏览地图!")}else{core.drawText("\t[系统提示]即将进入浏览地图模式。\n\n点击地图上半部分,或按[↑]键可查看前一张地图\n点击地图下半部分,或按[↓]键可查看后一张地图\n点击地图中间,或按[ESC]键可离开浏览地图模式\n此模式下可以打开怪物手册以查看某层楼的怪物属性",function(){core.ui.drawMaps(core.floorIds.indexOf(core.status.floorId))})}break;case 3:core.status.event.selection=0;core.ui.drawSyncSave();break;case 4:core.status.event.selection=1;core.ui.drawConfirmBox("你确定要返回标题页面吗?",function(){core.ui.closePanel();core.restart()},function(){core.status.event.selection=3;core.ui.drawSettings()});break;case 5:core.ui.drawStatistics();break;case 6:core.ui.drawHelp();break;case 7:core.ui.drawAbout();break;case 8:core.ui.closePanel();break}}return};actions.prototype.keyDownSettings=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpSettings=function(b){if(b==27||b==88){core.ui.closePanel();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickSettings(6,c+core.status.event.selection)}};actions.prototype.clickSyncSave=function(d,e){if(d<5||d>7){return}var a=core.status.event.ui.choices;var c=6-parseInt((a.length-1)/2);if(e>=c&&e<c+a.length){var b=e-c;switch(b){case 0:core.status.event.selection=0;core.ui.drawSyncSelect();break;case 1:core.syncLoad();break;case 2:core.status.event.selection=0;core.ui.drawLocalSaveSelect();break;case 3:core.readFile(function(j){if(j.name!=core.firstData.name){alert("存档和游戏不一致!");return}if(j.version!=core.firstData.version){alert("游戏版本不一致!");return}if(!core.isset(j.data)){alert("无效的存档!");return}var f=j.data;if(f instanceof Array){core.ui.drawConfirmBox("所有本地存档都将被覆盖,确认?",function(){for(var k=1;k<=5*(main.savePages||30);k++){if(k<=f.length){core.setLocalStorage("save"+k,f[k-1])}else{core.removeLocalStorage("save"+k)}}core.drawText("读取成功!\n你的本地所有存档均已被覆盖。")},function(){core.status.event.selection=0;core.ui.drawSyncSave()})}else{var h=5*(main.savePages||30);for(var g=5*(main.savePages||30);g>=1;g--){if(core.getLocalStorage("save"+g,null)==null){h=g}else{break}}core.setLocalStorage("save"+h,f);core.drawText("同步成功!\n单存档已覆盖至存档"+h)}},function(){});break;case 4:if(core.hasFlag("debug")){core.drawText("\t[系统提示]调试模式下无法下载录像");break}core.download(core.firstData.name+"_"+core.formatDate2(new Date())+".h5route",JSON.stringify({name:core.firstData.name,hard:core.status.hard,seed:core.getFlag("seed"),route:core.encodeRoute(core.status.route)}));break;case 5:core.status.event.selection=0;core.ui.drawStorageRemove();break;case 6:core.status.event.selection=3;core.ui.drawSettings();break}}return};actions.prototype.keyDownSyncSave=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpSyncSave=function(b){if(b==27||b==88){core.status.event.selection=2;core.ui.drawSettings();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickSyncSave(6,c+core.status.event.selection)}};actions.prototype.clickSyncSelect=function(d,e){if(d<5||d>7){return}var a=core.status.event.ui.choices;var c=6-parseInt((a.length-1)/2);if(e>=c&&e<c+a.length){var b=e-c;switch(b){case 0:core.syncSave("all");break;case 1:core.syncSave();break;case 2:core.status.event.selection=0;core.ui.drawSyncSave();break}}};actions.prototype.keyDownSyncSelect=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpSyncSelect=function(b){if(b==27||b==88){core.status.event.selection=0;core.ui.drawSettings();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickSyncSelect(6,c+core.status.event.selection)}};actions.prototype.clickLocalSaveSelect=function(h,j){if(h<5||h>7){return}var a=core.status.event.ui.choices;var g=6-parseInt((a.length-1)/2);var e=null;if(j>=g&&j<g+a.length){var f=j-g;switch(f){case 0:e=[];for(var d=1;d<=5*(main.savePages||30);d++){var c=core.getLocalStorage("save"+d,null);if(core.isset(c)){e.push(c)}}break;case 1:for(var d=5*(main.savePages||30);d>=1;d--){e=core.getLocalStorage("save"+d,null);if(core.isset(e)){break}}break;case 2:break}}if(core.isset(e)){var b={name:core.firstData.name,version:core.firstData.version,data:e};core.download(core.firstData.name+"_"+core.formatDate2(new Date())+".h5save",JSON.stringify(b))}core.status.event.selection=2;core.ui.drawSyncSave()};actions.prototype.keyDownLocalSaveSelect=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpLocalSaveSelect=function(b){if(b==27||b==88){core.status.event.selection=0;core.ui.drawSettings();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickLocalSaveSelect(6,c+core.status.event.selection)}};actions.prototype.clickStorageRemove=function(e,f){if(e<5||e>7){return}var a=core.status.event.ui.choices;var d=6-parseInt((a.length-1)/2);if(f>=d&&f<d+a.length){var c=f-d;switch(c){case 0:localStorage.clear();core.drawText("\t[操作成功]你的所有存档已被清空。");break;case 1:for(var b=1;b<=5*(main.savePages||30);b++){core.removeLocalStorage("save"+b)}core.drawText("\t[操作成功]当前塔的存档已被清空。");core.removeLocalStorage("autoSave");break;case 2:core.status.event.selection=5;core.ui.drawSyncSave();break}}};actions.prototype.keyDownStorageRemove=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpStorageRemove=function(b){if(b==27||b==88){core.status.event.selection=5;core.ui.drawSyncSave();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickStorageRemove(6,c+core.status.event.selection)}};actions.prototype.clickReplay=function(j,k){if(j<5||j>7){return}var a=core.status.event.ui.choices;var i=6-parseInt((a.length-1)/2);if(k>=i&&k<i+a.length){var h=k-i;switch(h){case 0:core.ui.closePanel();var b=core.status.hard,e=core.clone(core.status.route);var g=core.getFlag("seed");core.resetStatus(core.firstData.hero,b,core.firstData.floorId,null,core.initStatus.maps);core.events.setInitData(b);core.setFlag("seed",g);core.setFlag("rand",g);core.changeFloor(core.status.floorId,null,core.firstData.hero.loc,null,function(){core.startReplay(e)},true);break;case 1:core.status.event.id="replayLoad";core.status.event.selection=null;var f=core.status.saveIndex;var d=parseInt((f-1)/5),c=f-5*d;core.ui.drawSLPanel(10*d+c);break;case 2:core.ui.closePanel();break}}};actions.prototype.keyDownReplay=function(a){if(a==38){core.status.event.selection--;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}if(a==40){core.status.event.selection++;core.ui.drawChoices(core.status.event.ui.text,core.status.event.ui.choices)}};actions.prototype.keyUpReplay=function(b){if(b==27||b==88){core.ui.closePanel();return}var a=core.status.event.ui.choices;if(b==13||b==32||b==67){var c=6-parseInt((a.length-1)/2);this.clickReplay(6,c+core.status.event.selection)}};actions.prototype.clickKeyBoard=function(b,c){if(c==3&&b>=1&&b<=11){core.ui.closePanel();core.keyUp(112+b-1)}if(c==4&&b>=1&&b<=10){core.ui.closePanel();core.keyUp(b==10?48:48+b)}var a=[["Q","W","E","R","T","Y","U","I","O","P"],["A","S","D","F","G","H","J","K","L"],["Z","X","C","V","B","N","M"],];if(c==5&&b>=1&&b<=10){core.ui.closePanel();core.keyUp(a[0][b-1].charCodeAt(0))}if(c==6&&b>=1&&b<=9){core.ui.closePanel();core.keyUp(a[1][b-1].charCodeAt(0))}if(c==7&&b>=1&&b<=7){core.ui.closePanel();core.keyUp(a[2][b-1].charCodeAt(0))}if(c==8&&b>=1&&b<=11){core.ui.closePanel();if(b==1){core.keyUp(189)}if(b==2){core.keyUp(187)}if(b==3){core.keyUp(219)}if(b==4){core.keyUp(221)}if(b==5){core.keyUp(220)}if(b==6){core.keyUp(186)}if(b==7){core.keyUp(222)}if(b==8){core.keyUp(188)}if(b==9){core.keyUp(190)}if(b==10){core.keyUp(191)}if(b==11){core.keyUp(192)}}if(c==9&&b>=1&&b<=10){core.ui.closePanel();if(b==1){core.keyUp(27)}if(b==2){core.keyUp(9)}if(b==3){core.keyUp(20)}if(b==4){core.keyUp(16)}if(b==5){core.keyUp(17)}if(b==6){core.keyUp(18)}if(b==7){core.keyUp(32)}if(b==8){core.keyUp(8)}if(b==9){core.keyUp(13)}if(b==10){core.keyUp(46)}}if(c==10&&b>=9&&b<=11){core.ui.closePanel()}};actions.prototype.clickCursor=function(a,b){if(a==core.status.automaticRoute.cursorX&&b==core.status.automaticRoute.cursorY){core.ui.closePanel();core.onclick(a,b,[]);return}core.status.automaticRoute.cursorX=a;core.status.automaticRoute.cursorY=b;core.ui.drawCursor()};actions.prototype.keyDownCursor=function(a){if(a==37){core.status.automaticRoute.cursorX--;core.ui.drawCursor();return}if(a==38){core.status.automaticRoute.cursorY--;core.ui.drawCursor();return}if(a==39){core.status.automaticRoute.cursorX++;core.ui.drawCursor();return}if(a==40){core.status.automaticRoute.cursorY++;core.ui.drawCursor();return}};actions.prototype.keyUpCursor=function(a){if(a==27||a==88){core.ui.closePanel();return}if(a==13||a==32||a==67||a==69){core.ui.closePanel();core.onclick(core.status.automaticRoute.cursorX,core.status.automaticRoute.cursorY,[]);return}};actions.prototype.clickAbout=function(){if(core.isPlaying()){core.ui.closePanel()}else{core.restart()}}; |