function events(){}events.prototype.init=function(){this.events={battle:function(b,a,c){a.battle(b.event.id,b.x,b.y);if(a.isset(c)){c()}},changeFloor:function(b,a,c){a.changeFloor(b.event.data.floorId,b.event.data.stair,b.event.data.heroLoc,c)},getItem:function(b,a,c){a.getItem(b.event.id,1,b.x,b.y);if(a.isset(c)){c()}},openDoor:function(b,a,c){a.openDoor(b.event.id,b.x,b.y,true);if(a.isset(c)){c()}},visitNpc:function(b,a,c){a.visitNpc(b.event.npcid,b.x,b.y);if(a.isset(c)){c()}},openShop:function(b,a,c){a.ui.drawShop(b.event.shopid);if(a.isset(c)){c()}},passNet:function(b,a,c){a.events.passNet(b);if(a.isset(c)){c()}},blockEvent:function(b,a,c){a.events.blockEvent(b);if(a.isset(c)){c()}}}};events.prototype.getEvents=function(a){if(a==undefined){return this.events}return this.events[a]};main.instance.events=new events();events.prototype.startGame=function(a){core.hideStartAnimate(function(){core.drawText(["我是一位勇士。\n不,应该说,我曾经是一位勇士。","我奉国王之命,冲进魔塔。\n杀死魔王,拯救被抓走的公主。","但是,我杀死了魔王并没有选择离开。\n而是选择跟随仙子,集齐灵杖消灭了塔顶的血影。","最终,虽然我成功杀死了血影。\n但是我根本就找不到回来的路。","原来,血影根本就不在塔顶。\n而是,位于....异空间。","只可惜,异空间的入口只能进不能出。\n我深陷在这狭长的异空间内无法逃离。","我杀死血影以后的不久,\n魔塔失去了重心倒塌了。","在我的身边,烧起了熊熊大火。","而我,注定要被埋葬在这一片烈火之中吗?","我倒在地上,意识已经渐渐地模糊了。","公主,不知道你现在怎样了。\n已经离开魔塔了吗?","不管怎样,我再也见不到你了。","就这样吧,也许,这里,就是我的终点。","就这样...不知道过了多久..."],function(){core.startGame(10)})})};events.prototype.blockEvent=function(a){if(core.status.floorId=="MT16"&&a.x==6&&a.y==2){core.waitHeroToStop(function(){core.drawText([{content:"冥灵魔王?你不是已经被我杀了吗?\n为什么会出现在这里??",id:"hero"},{content:"因为...这里位于魔塔的另一个位面。\n大多数情况下,塔内死亡的生物都会回归这里。",id:"vampire"},{content:"你的意思是说,我现在已经死了?",id:"hero"},{content:"是的,能到达这里的,\n除了可以掌控位面的高智慧生物以外,只有\n亡灵。",id:"vampire"},{content:"呵,既然,我的生命已经不复存在。\n我已经没有什么好怕的了。\n大魔头,我们冤家路窄,居然又见面了,\n决斗吧!",id:"hero"},{content:"你似乎还没明白。。。",id:"vampire"},{content:"明白什么?",id:"hero"},{content:"诶,算了,决一死战吧。",id:"vampire"}],function(){core.removeBlock("data",a.x,a.y)})});return}};events.prototype.clickSettings=function(a,b){if(b==3){if(core.musicStatus.isIOS){core.drawTip("iOS设备不支持播放音乐");return}core.changeSoundStatus();core.ui.openSettings(false)}if(b==4){core.ui.selectShop()}if(b==5){this.decreaseHard()}if(b==6){core.ui.syncSave()}if(b==7){core.showConfirmBox("你确定要重新开始吗?",function(){core.ui.closePanel();core.restart()},function(){core.ui.openSettings(false)})}if(b==8){core.ui.drawAbout()}if(b==9){core.ui.closePanel()}return};events.prototype.afterChangeFloor=function(a){core.status.hero.flags.passLava=false;if(!core.isset(core.status.hero.flags.visitFloors[a])){core.status.hero.flags.visitFloors[a]=true;if(a=="MT1"){core.drawText([{content:"这里...是哪里?",id:"hero"},{content:"难道?我还活着?",id:"hero"},{content:"一股似曾相识的感觉,\n但我又不知道在哪里见过。",id:"hero"},{content:"魔塔已经被大火烧成了灰烬,\n这里为什么安然无恙?这到底是什么地方?",id:"hero"},{content:"这里,我感觉到不像是我生活的地方。\n难道我已经到了异世界吗?",id:"hero"},{content:"算了,不管这么多了。\n只要我还活着,一切都好。",id:"hero"},{content:"我先四处看看要怎么出去吧。",id:"hero"},{content:"(系统提示)本塔快捷键如下:\n\n[↑][↓][←][→] 移动\n[X] 怪物手册\n[G] 楼层传送器\n[T] 工具栏\n[K] 快捷商店\n[S/L] 存/读档\n[ESC] 菜单栏\n同时也可以点击状态栏中的图标进行操作。"},{content:"(系统提示)\n在菜单栏里可以同步存档,这样可以很方便的让你\n在多设备(例如手机/电脑)之间接档游戏。"}])}if(a=="MT2"){core.drawText([{content:"奇怪,我明明杀死了血影。\n为什么这里又出现了一个。",id:"hero"},{content:"不过我的力量似乎都被冻结了。\n目前肯定是无法杀死血影,\n等我变强以后再回来吧。",id:"hero"}])}if(a=="MT11"){core.drawText([{content:"诶,奇怪,我明明只是上了一层楼而已。\n为什么,这里变得如此的寒冷...",id:"hero"},{content:"诶,毕竟我已经不在我生活的世界了。\n很多事情都是预料不到的。",id:"hero"},{content:"不管怎么说,我要继续上去看个究竟。",id:"hero"}])}if(a=="MT20"){core.drawText([{content:"这...这里就是塔顶了吗。\n仙子,你怎么也在这里。\n魔塔倒塌了,你也死掉了所以到达这里了吗?",id:"hero"},{content:"呵,怎么可能。我怎么会这么容易死。\n这里就是位面的交界处了,\n我就是这个位面的操纵者。",id:"fairy"},{content:"你居然有这样强大的能力!\n跟我第一次遇见你差距太大了吧!",id:"hero"},{content:"是的,一开始,我弱不禁风。\n但是你帮我集齐了十字架和三个灵杖,\n让我的能力得到了巨幅度的提高。",id:"fairy"},{content:"估计你自己也想不到这些东西有这么大的威力。\n不过还要感谢你的无私奉献成就了我的现在。",id:"fairy"},{content:"......",id:"hero"},{content:"其实,魔塔倒塌是我一手策划的,\n就是为了把所有的生物都驱逐进这个亡灵位面。",id:"fairy"},{content:"我一直策划着等我有一天变强了,\n我要一人统治世界,消灭掉所有的其他生物。\n如今我的目标达成了。",id:"fairy"},{content:"消灭其他所有生物?也就是说也包括我?",id:"hero"},{content:"没错。愚蠢的人类终于觉悟了。",id:"fairy"},{content:"呵呵,想当初,我就应该一刀把你杀了。\n真没想到我会轻信你的鬼话。",id:"hero"},{content:"现在说这些还有什么用呢,\n你和我的力量根本就不是一个级别的。\n劝你放弃抵抗吧。",id:"fairy"},{content:"(仙子有来源于高维度的力量支持,\n所以目前强大无比。我是不可能战胜的。)",id:"hero"},{content:"(不过,这个位面力量非常不稳定,\n如果我能成功的封印她,切断外界的支持,\n也许还能有机会求胜。)",id:"hero"},{content:"(仙子目前的位置正好被八个小怪包围,\n如果按照当年封印Zeno的方法去封印她,\n能否成功呢?这是我唯一的希望。)",id:"hero"},{content:"系统提示:(专门给没玩过TSW的玩家看的)\n击杀仙子周围的四个怪,保留四个角的怪。\n如果还看不懂的,看一眼你的小键盘,\n仙子在5的位置,击杀2468。"}])}}};events.prototype.decreaseHard=function(){if(core.status.hard==0){core.drawTip("当前已是难度0,不能再降低难度了");return}var b=100,a=core.status.hard;while(a<10){a++;b*=2}core.showConfirmBox("本次操作可生命+"+b+",确定吗?",function(){core.status.hero.hp+=b;core.status.hard--;core.updateStatusBar();core.ui.closePanel();core.drawTip("降低难度成功,生命+"+b)},function(){core.openSettings(false)})};events.prototype.canUseQuickShop=function(a){if(core.status.floorId=="MT20"){return"当前不能使用快捷商店。"}if(core.status.hero.flags.passLava){return"由于你刚刚经过岩浆,此时不得使用快捷商店。\n切换楼层后恢复。"}return null};events.prototype.useItem=function(a){console.log("使用道具:"+core.material.items[a].name);core.ui.closePanel(false);if(a=="book"){core.openBook(false);return}if(a=="fly"){core.useFly(false);return}if(core.canUseItem(a)){core.useItem(a)}else{core.drawTip("当前无法使用"+core.material.items[a].name)}};events.prototype.afterBattle=function(a){if(core.status.floorId=="MT14"&&!core.enemyExists(5,9)&&!core.enemyExists(7,9)){core.openDoor("specialDoor",6,8,false)}if(core.status.floorId=="MT20"){if(!core.status.hero.flags.seal20F){if(core.enemyExists(5,5)&&core.enemyExists(5,7)&&core.enemyExists(7,7)&&core.enemyExists(7,5)&&!core.enemyExists(5,6)&&!core.enemyExists(7,6)&&!core.enemyExists(6,5)&&!core.enemyExists(6,7)){core.status.hero.flags.seal20F=true;core.material.enemys.fairy.hp/=10;core.material.enemys.fairy.atk/=10;core.material.enemys.fairy.def/=10;core.updateFg();core.drawText([{content:"啊,我怎么被封印了!\n能量只剩下一成了!",id:"fairy"}]);core.clearContinueAutomaticRoute();return}}if(a=="fairy"){core.events.win();core.clearContinueAutomaticRoute();return}}core.continueAutomaticRoute()};events.prototype.afterOpenDoor=function(a){core.continueAutomaticRoute()};events.prototype.passNet=function(a){if(a.event.id=="lavaNet"){core.status.hero.hp-=100;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose();return}core.status.hero.flags.passLava=true;core.updateStatusBar();core.drawTip("经过熔岩,生命-100")}};events.prototype.clickBook=function(a,b){if((a==3||a==4)&&b==12){core.ui.drawEnemyBook(core.status.event.data-1)}if((a==8||a==9)&&b==12){core.ui.drawEnemyBook(core.status.event.data+1)}if(a>=10&&a<=12&&b==12){core.ui.closePanel(true)}return};events.prototype.clickFly=function(a,e){if((a==10||a==11)&&e==9){core.ui.drawFly(core.status.event.data-1)}if((a==10||a==11)&&e==5){core.ui.drawFly(core.status.event.data+1)}if(a>=5&&a<=7&&e==12){core.ui.closePanel()}if(a>=0&&a<=9&&e>=3&&e<=11){var b=core.status.hero.flyRange.indexOf(core.status.floorId);var d=core.status.event.data=5&&x<=7){if(y>=5&&y<=8){if(y>=5+core.status.event.data.choices.length){return}var money=core.getStatus("money"),experience=core.getStatus("experience");var shop=core.status.event.data;var times=shop.times,need=eval(shop.need);var use=shop.use;var use_text=use=="money"?"金币":"经验";var choice=shop.choices[y-5];if(core.isset(choice.need)){need=eval(choice.need)}if(need>eval(use)){core.drawTip("你的"+use_text+"不足");return}eval(use+"-="+need);core.setStatus("money",money);core.setStatus("experience",experience);core.updateStatusBar();core.npcEffect(choice.effect);core.status.event.data.times++;core.ui.openShop(core.status.event.data.id);return}if(y==9){core.status.event.data=null;core.ui.closePanel();return}}};events.prototype.clickSelectShop=function(a,h){if(a>=5&&a<=7){var c=core.status.shops,e=Object.keys(c);var d=6-parseInt((e.length+1)/2);var b=6+parseInt((e.length+1)/2);if(h>=d&&h-d=10&&a<=12&&e==12){core.ui.closePanel(false);return}var d=null;var b=null;if(e>=4&&e<=7&&a!=12){b=Object.keys(core.status.hero.items.tools).sort()}if(e>=9&&e<=12&&a!=12){b=Object.keys(core.status.hero.items.constants).sort()}if(b==null){return}var c=0;if(e==4||e==5||e==9||e==10){c=parseInt(a/2)}else{c=6+parseInt(a/2)}if(c>=b.length){return}d=b[c];if(d==core.status.event.data){core.events.useItem(d)}else{core.ui.drawToolbox(d)}};events.prototype.clickSL=function(a,c){if((a==3||a==4)&&c==12){core.ui.drawSLPanel(core.status.event.data-1)}if((a==8||a==9)&&c==12){core.ui.drawSLPanel(core.status.event.data+1)}if(a>=10&&a<=12&&c==12){core.ui.closePanel(false);if(!core.isPlaying()){core.showStartAnimate()}return}var b=6*core.status.event.data+1;if(c>=1&&c<=4){if(a>=1&&a<=3){core.doSL(b,core.status.event.id)}if(a>=5&&a<=7){core.doSL(b+1,core.status.event.id)}if(a>=9&&a<=11){core.doSL(b+2,core.status.event.id)}}if(c>=7&&c<=10){if(a>=1&&a<=3){core.doSL(b+3,core.status.event.id)}if(a>=5&&a<=7){core.doSL(b+4,core.status.event.id)}if(a>=9&&a<=11){core.doSL(b+5,core.status.event.id)}}};events.prototype.clickSettings=function(a,b){if(a<5||a>7){return}if(b==3){if(core.musicStatus.isIOS){core.drawTip("iOS设备不支持播放音乐");return}core.changeSoundStatus();core.ui.openSettings(false)}if(b==4){core.ui.drawSelectShop()}if(b==5){this.decreaseHard()}if(b==6){core.ui.syncSave()}if(b==7){core.ui.showConfirmBox("你确定要重新开始吗?",function(){core.ui.closePanel();core.restart()},function(){core.ui.openSettings(false)})}if(b==8){core.ui.drawAbout()}if(b==9){core.ui.closePanel()}return};events.prototype.clickNPC=function(a,e){var d=core.status.event.data.current;if(core.isset(d)){if(d.action=="text"){core.npcAction();return}if(d.action=="choices"){if(a>=5&&a<=7){if(e>=5&&e<=8){if(e>=5+d.choices.length){return}var b=d.choices[e-5];if(core.isset(b.need)){var c=true;b.need.split(";").forEach(function(j){var h=j.split(",");var g=h[0],f=h[1],i=h[2];if(g=="status"){if(core.getStatus(f)