-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATESolo.min.js
1 lines (1 loc) · 60.2 KB
/
ATESolo.min.js
1
"use strict";(function(l,c,e){const t=0;const s=1;const i=2;const H=3;const O=4;const a=14;const h=23;const r=24;const o=34;const n=44;const d=48;const v=65;const u={A:"red",B:"green",C:"brown",D:"aqua"};const m=["猜猜这里一共有几条Tips呢~","你说的对,但是Extend Air Chicket是由SW0RDNEWNEW.EXE自主研发的一款文字剧情选择游戏","本视频使用由Zes M Young编写程序的Extend Air Ticket录制","设置中启用“有名的骰子”可以加速你的战斗进程!","啊哈哈哈哈哈,规则炸弹来咯!","正在为您载入存档","首先来2400行给我截个图","您希望我们的游玩率上升吗?A.希望,B.希望,C.希望,D.希望","有名,你又在打COSH哦,休息一下吧","养成亲社会行为","长期共存互相监督肝胆相照荣辱与共","啥是“特殊餐饮服务”","@小念同学 我的棉花糖工厂","敌人的攻击字母和翻转地板桥都是随机的","ATT=attack=攻击 DEF=defence=防御","有星空玑沐噩梦Zero自由组合,不考虑攻受,问一共多少种cp"];function f(e,t){return e+Math.floor(Math.random()*(t-e+1))}function g(t){if(t.startsWith("[")&&t.endsWith("]")){let e=t.slice(1,-1).split(",");return f(parseInt(e[0]),parseInt(e[1]))}else{return parseInt(t)}}function p(t,s){let i=[];for(let e of t){i.push(s(e))}return i}function b(t,s){let i=[];for(let e=0;e<t;e++){i.push(s(e))}return i}class w{constructor(e,t,s,i){this.$element=e.$input;this.checkFn=s;this.$input=l("<input/>").attr("type","text").appendTo(this.$element).on("input",e=>{const t=this.getValue();this.check(t);if(this.disabled){return}if(e.which===13){i(t,this)}});this.disabled=true;this.$shoot=_.button("走你").appendTo(this.$element).addClass("ate-button-disabled").on("click",()=>{const e=this.getValue();if(this.disabled){return}if(!s(e)){return}i(e,this)});this.$element.append("<br>");const a=s===R.check5Capitals;if(a){this.$input.attr("placeholder","输入五个大写字母")}for(let e of t){_.button(e,{margin:"10px",padding:"16px",color:a?u[e]:null}).appendTo(this.$element).on("click",()=>this.setValue(this.getValue()+e))}this.$element.append("<br>");this.$clear=_.button("清除",{cls:"negative"}).appendTo(this.$element).on("click",()=>this.setValue(""))}check(e){const t=this.checkFn(e);if(t&&this.disabled){this.disabled=false;this.$shoot.removeClass("ate-button-disabled")}else if(!t&&!this.disabled){this.disabled=true;this.$shoot.addClass("ate-button-disabled")}}setValue(e){this.$input.val(e);this.check(e);return this}getValue(){return this.$input.val()}remove(){this.$element.html("")}}class k{constructor(e,t,s,i){this.name=e;this.full=i;this.$title=l("<td/>").html(e).appendTo(t.$tr);this.$valCell=l("<td/>").appendTo(t.$tr);this.$val=l("<span/>").appendTo(this.$valCell);if(s&&i){this.$rate=l("<div/>").addClass("ate-info-rate").insertAfter(this.$val);if(s.startsWith("linear-gradient")){this.$rate.css("backgroundImage",s)}else{this.$rate.css("backgroundColor",s)}}}show(){this.$valCell.fadeIn();this.$title.fadeIn()}hide(){this.$valCell.hide();this.$title.hide()}set(s){if(this.val&&this.val!=s){let e=s-this.val;let t=l("<span/>").html((e>0?"+":"")+e+"");t.appendTo(this.$valCell).addClass("ate-val-rise").css("color",e<0?"red":"green").animate({opacity:0,top:"-3em"},2e3,()=>{t.remove()})}this.val=s;this.$val.html(s+"");if(this.full){this.$rate.css("height",s/this.full*100+"%")}}}class ${constructor(e,t){this.$outer=l("<div/>").addClass(e);var s=l("<table/>").addClass("ate-info").appendTo(this.$outer);var i=l("<tbody/>").appendTo(s);this.$tr=l("<tr/>").appendTo(i);this.$th=l("<th/>").html(t).appendTo(this.$tr);this.health=null;this.magic=null;this.attack=null;this.defence=null;this.cm=null;this.gunHealth=null;this.chaos=null;this.rules=null;this.shield=null;this.catch=null;this.feet=null}add(e,t,s,i,a){var h=new k(t,this,i,s);if(a){h.hide()}this[e]=h;return this}appendTo(e){this.$outer.appendTo(e);return this}remove(){this.$outer.remove();return this}}class C{constructor(e){this.game=e;this.values=localStorage.ateSettings?JSON.parse(localStorage.ateSettings):{speed:1500,pass:false,random:false,playwhenhidden:false};this.opened=false;this.hidden=true;this.$element=l(".ate-settings").hide();this.$tags=l(".ate-settings-tag");this.$pages=l(".ate-settings-page");this.index=0;console.log(1);this.$tags.each((e,t)=>{let s=l(t);s.on("click",()=>{if(e===this.index){return}this.$tags.eq(this.index).removeClass("ate-settings-tag-show");this.$pages.eq(this.index).removeClass("ate-settings-page-show");this.index=e;this.$tags.eq(e).addClass("ate-settings-tag-show");this.$pages.eq(e).addClass("ate-settings-page-show")})});for(let s of["pass","random","playwhenhidden"]){let e=l("#ate-settings-"+s);let t=this.get(s);if(t){e.addClass("ate-button-on")}e.html(t?"是":"否").on("click",()=>{t=!t;this.toggle(s);e.html(t?"是":"否").toggleClass("ate-button-on")})}console.log(2);l("#ate-settings-clear").on("click",()=>{delete localStorage.gameData;this.game.notify("存档已清除!")});this.$export=l("#ate-export");this.$doneButton=l(".ate-settings-done");this.$speed=l("#ate-settings-speed").val(this.get("speed"))}get(e){return this.values[e]}set(e,t){this.values[e]=t;localStorage.ateSettings=JSON.stringify(this.values)}toggle(e){this.set(e,!this.get(e))}open(){if(!this.hidden){return}this.opened=true;this.hidden=false;var s=btoa(localStorage.gameData||"");this.$export.val(s);this.$doneButton.one("click",()=>{if(!this.opened){return}this.opened=false;const e=this.$speed.val();if(typeof e!=="string"){throw new Error("$speed.val() is a str")}if(e.match(/^\-?\d+$/)){this.set("speed",parseInt(e))}const t=this.$export.val();if(typeof t!=="string"){throw new Error("$sxport.val() is a str")}if(t!==s){try{localStorage.gameData=atob(t)}catch(e){this.game.notify("存档不合法!")}}this.$element.animate({left:"-100%"},3e3,()=>{this.$element.hide();this.hidden=true});this.game.hideCover()});if(this.game.chapterGame&&this.game.chapterGame.history){var t=l(".ate-history").html("");for(let e of this.game.chapterGame.history){l("<li/>").html(e).appendTo(t)}}this.game.cover();this.$element.css("left","").show()}}class E{constructor(){this.taskTracks=[];this.processing=false;this.stack=[];this.ownerChangeCallbacks=[]}push(e,t){if(t.dead||!this.stack.includes(t)){return}this.taskTracks[this.stack.indexOf(t)].push(e);if(!this.processing){this.process()}}process(){if(this.processing){return}var i=this.owner;var e=this.ownerIndex;var a=this.taskTracks[e];this.processing=true;const h=()=>{if(this.processing==false){return}if(i!==this.owner){this.processing=false;return this.process()}if(a.length===0){this.processing=false;return}let e=a.shift();let t=e.toString().match(/\/\/ (.+)/);console.log(`Process: ${this.owner.constructor.name},Task ${t?t[1]:"ANON"} Started.`);let s=e.call(undefined);if(s&&s.done instanceof Function){s.done(()=>{console.log("Task finished.");h()})}else{console.log("Task finished immediately.");h()}};h()}give(e){if(e.dead){return}this.stack.push(e);console.log(`Entered Process ${e.constructor.name}, stack height ${this.ownerIndex}`);this.taskTracks.push([]);this.ownerChangeCallbacks.forEach(e=>e(this));if(!this.processing){this.process()}}kill(e){while(this.stack.includes(e)){this.stack.pop();this.taskTracks.pop()}this.ownerChangeCallbacks.forEach(e=>e(this));this.process()}get owner(){return this.stack[this.ownerIndex]}get ownerIndex(){return this.stack.length-1}onOwnerChange(e){this.ownerChangeCallbacks.push(e)}}class y{constructor(e){this.queue=e;this.dieCallbacks=[];this.dead=false}wait(t){if(typeof t==="function"){this.queue.push(t,this)}else{this.queue.push(()=>{var e=l.Deferred();setTimeout(()=>e.resolve(),t);return e},this)}return this}die(){this.dead=true;this.queue.kill(this);console.log(`Process ${this.constructor.name} died.`);this.dieCallbacks.forEach(e=>e())}killChildren(){if(this.queue.owner===this){return}for(let e=this.queue.ownerIndex;e>0;e--){if(this.queue.stack[e-1]===this){this.queue.stack[e].die()}}}waitDie(){this.wait(()=>this.die())}waitTriggerEvent(e,t,s){var i=l.Deferred();if(s){e.one(t,()=>i.resolve())}else{e.on(t,()=>i.resolve())}this.wait(()=>i);return this}waitFadeOutEle(e){var t=l.Deferred();this.wait(()=>e.fadeOut(()=>t.resolve()));this.wait(()=>t);return this}whenDie(e){this.dieCallbacks.push(e)}}class A extends y{constructor(e){super(e)}attachTo(e){this.chapterGame=e}choose(i,a,h,r,o){this.wait(()=>{this.chapterGame.$choices.children().hide();var s=l("<div/>").addClass("ate-choices-inner").appendTo(this.chapterGame.$choices);setTimeout(()=>s.css("height","10em"));for(let t in i){let e=l("<div/>").addClass("ate-choice").html(i[t]).appendTo(s);if(o&&o[t]){e.css("backgroundImage",`url(${o[t]})`)}if(r&&r.includes(parseInt(t))){e.addClass("ate-choice-disabled");continue}e.on("click",()=>{s.css("height","0");s.fadeOut(200,()=>{l(".ate-choices > *").show();a.call(i,parseInt(t));s.remove()})});if(h&&h.includes(parseInt(t))){e.css("opacity","0.05")}}})}log(r){this.wait(()=>{var s=l("<span/>");var t=l.Deferred();let e=this.chapterGame.root.settings.get("speed");if(e===0){s.html(r).css("display","none");s.show();this.chapterGame.$message.one("click",()=>{this.chapterGame.scrollMessage(24);t.resolve()})}else if(e===-1){let e=0;const i=Array.from(r);const a=[];for(let t of i){let e=l("<span/>").html(t).css("display","none");s.append(e);a.push(e)}const h=()=>{if(e===a.length){return t.resolve()}a[e].show();e++;requestAnimationFrame(h)};requestAnimationFrame(h);this.chapterGame.scrollMessage(2)}else{s.html(r).css("display","none");this.chapterGame.scrollMessage(e/1e3*30);s.fadeIn(e,()=>t.resolve())}this.chapterGame.$message.append(s).append("<br>");this.chapterGame.history.push(r);return t})}goProcess(e){return new T(e,this.chapterGame).go()}waitProcess(e){this.wait(()=>this.goProcess(e))}waitChoose(e,a,t){this.waitProcess(s=>{const i=()=>{s.choose(e,e=>{let t=a(e,s,i);if(t!==true){s.die()}},t&&t.fade,t&&t.disabled,t&&t.images);return true};i()})}}class T extends A{constructor(e,t){super(t.queue);this.attachTo(t);this.func=e}go(){this.chapterGame.queue.give(this);this.func(this)}}class x{constructor(e,t,s){this.game=t;var i=c.items[e];this.$element=l("<div/>").addClass("ate-item");this.id=e;this.name=i.name;this.description=i.description;this.stackable=i.stackable;this.throwable=i.throwable;if("battle"in i&&i.battle){this.battle=true;this.use=i.use;if("cd"in i){this.cd=i.cd}this.type=x.BATTLE}else if("attack"in i){this.attack=i.attack;if("magic"in i){this.magic=i.magic}this.type=x.WEAPON}else if("defence"in i){this.defence=i.defence;if("dodgeRate"in i){this.dodgeRate=i.dodgeRate}this.type=x.ARMOR}else{this.type=x.NORMAL}this.loadUI();if(this.stackable){this.amount=s}}get amount(){return this._amount}set amount(e){if(this.id===d){this.game.defence+=e-this._amount}if(e===0){this.game.removeItem(this);return}this.$descriptionAmount.html(e+"");this.$amount.html(e===1?"":e+"");this._amount=e}loadUI(){this.$inner=l("<div/>").addClass("ate-item-inner").appendTo(this.$element);if(this.battle){this.$inner.css("z-index","191981")}this.game.addImage(this.$inner,this);var e=l("<span/>").addClass("ate-item-description").appendTo(this.$inner);var t=l("<div/>").append(l("<b/>").html(this.name)).append("<br>").append(this.description).appendTo(e);if(this.stackable){this.$amount=l("<span/>").addClass("ate-item-amount").appendTo(this.$inner);this.$descriptionAmount=l("<span/>");t.append("<br>你有").append(this.$descriptionAmount).append("个")}if(this.type==x.ARMOR&&this.game.armor!==this||this.type==x.WEAPON&&this.game.weapon!==this){var s=_.button("装备").appendTo(t);s.on("click",()=>{this.game.equip(this)})}if(this.throwable!=false){this.disabled=false;this.$throw=_.button("丢弃").appendTo(t).on("click",()=>{if(this.disabled){return}if(this.game.armor!==this&&this.game.weapon!==this){this.game.removeItem(this)}});this.game.queue.onOwnerChange(e=>{if(e.owner!==this.game!==this.disabled){this.disabled=!this.disabled;this.$throw.toggleClass("ate-button-disabled")}})}}}x.NORMAL=0;x.BATTLE=1;x.WEAPON=2;x.ARMOR=3;class R extends A{constructor(e,t,s){super(t.queue);this.attachTo(t instanceof D?t:t.realGame);this.model=t;console.log(this);t.queue.give(this);this.tutorial=e.tutorial;this.withXk=e.withXk;this.withNc=e.withNc;this.withSo=e.withSo;this.octahedron=e.octahedron;this.cureMagicCost=this.chapterGame.has(a)?50:30;this.cureMagicPlus=this.chapterGame.has(a)?80:40;this.$element=t.$battle;this.after=s;this.deferredCommands={};this.won=false;this.afterWin=e.win;this.$element.children().fadeOut();var i=e.enemy;if(Array.isArray(i)){this.multiEnemy=true}else{i=[i]}this.aliveEnemyAmount=i.length;this.enemy=[];for(let s of i){let e=c.enemy[s];let t=new M(e,this);this.enemy.push(t)}this.zeroTable=new $("ate-zero-table","Zero").appendTo(this.$element);this.zeroTable.add("magic","魔法值",100,"purple");this.zeroTable.add("shield","力场盾",100,"darkblue",true);this.chapterGame.toggleExpand(true);this.magic=0;this.rounds=0;this.intenseFight=null;this.shield=0;for(let e of this.enemy){e.init()}if(t instanceof G){t.init(this);this.log(`模拟战斗开始!模拟对手${this.enemy[0].name}`)}}win(){if(this.won){return}this.won=true;this.killChildren();console.log(this.queue.owner);this.chapterGame.goProcess(e=>{e.log("您获胜了!");if(this.afterWin){for(let e of this.afterWin){this.model.execute(e)}}if(!(this.after instanceof R)){this.chapterGame.toggleExpand(false)}setTimeout(()=>{this.zeroTable.remove()},2e3);this.$element.children().fadeIn();e.wait(()=>{this.die()});console.log(this.queue.taskTracks[this.queue.ownerIndex])})}run(){if(this.tutorial){this.roundEndCallbacks=[];this.log("星空说:“让我描述详细一点吧,在魔法系统下,战斗就是我们的【魔法核心】相互接触的过程,每个人都有一个【魔法核心】,只不过大多数人都不会用罢了,我来教你怎么使用。");this.log("星空跟你详细说明了使用魔法核心的方法,你试了一下,突然你感觉世界一下就改变了!");this.log("星空:现在我们进入了战斗界面!当你听完我的这些话后,就可以加入战斗了。战斗分为准备阶段和对战阶段,在准备阶段时,你可以尝试A【物品】、B【防御】、C【魔法】、D【跳过】。物品指的是消耗品或带冷却的道具;跳过是指直接进入攻击环节。不过你现在没有魔法值,没有物品,选择【防御】吧。虽然我们无法造成伤害,也没有防具,但防御可以增加魔法值!");this.waitChoose(["物品","防御","魔法","跳过"],(e,t)=>this.prepare(e,t),{disabled:[0,2]});this.waitFightInput()}else{this.round()}}round(){this.log("回合"+(this.rounds+1));this.defend=false;this.battleMagic=false;this.ncChipMagic=0;this.soSweaterMagic=0;this.heavyAttack=false;this.breakHarm=false;this.frozenBreadUsed=false;this.escapeCatchUsed=false;this.roundEndCallbacks=[];if(this.deferredCommands[this.rounds]){for(let e of this.deferredCommands[this.rounds]){this.model.execute(e,this)}}if(this.model.armor&&this.model.armor.id===h){this.model.execute("health + [3,20]")}for(let t of this.enemy){t.round();if(t.message){let e=t.message;if(typeof e[0]!=="string"){e=this.chapterGame.judgeArr(e)}let s=Math.floor(Math.random()*(e.length+1));if(s<e.length){let t=e[s].split(";");for(let e of t){if(e.startsWith("/")){this.model.execute(e.slice(1),this)}else{this.log(e)}}}}}this.prepareChoose();if(this.enemy[0].id===M.JOKER12132){this.jokerPrepare()}this.waitFightInput()}prepareChoose(){let e=[];if(this.magicNotEnough()){e.push(2)}this.waitChoose(["物品","防御","魔法","跳过"],(e,t,s)=>this.prepare(e,t,s),{disabled:e})}magicNotEnough(){return this.magic===0||!this.octahedron&&this.magic<this.cureMagicCost}prepare(e,t,s){if(this.tutorial){if(e===1){this.defend=true;t.log("星空:很好,让我们试一下战斗吧!")}else if(e===3){t.log("星空:你……不选防御吗?不行的啊。")}else{throw new Error("Invalid Input.")}t.log("星空:总之,现在是进入【战斗】的时间了!");t.log("敌人会利用A、B、C、D四种方式攻击你,每回合攻击五次,其中,D克A克B克C克D,每多一次克制被克制方就会受到克制方的一次伤害。这个木马接下来会使用AABBB攻击,回复DDAAA来阻止它吧!");t.waitDie();return true}switch(e){case 0:this.itemSelect(t,s);break;case 1:t.log("你选择了防御。");this.defend=true;this.magic+=40;t.waitDie();break;case 2:if(this.enemy[0].id===M.LORCE){this.magicChooseForLorce(t,s);break}this.magicChoose(t,s);break;case 3:t.log("你选择了跳过。");t.waitDie()}return true}jokerPrepare(){this.waitProcess(s=>{if(!this.defend){if(this.chaoAttacked==false&&(this.chaos>=85||this.enemy[0].health<=1400)){s.log("混沌持续上升!战斗已经进入白热化!");s.log("现在,你需要独自一人面对考验");s.log("J12132正在释放一次“混沌冲击!”");s.waitDie();this.withXk=false;this.octahedron=false;this.chaoAttacked=true;this.enemy[0].attack+=5;this.chapterGame.virtually(12133);this.roundEnd(()=>{this.enemy[0].attack-=5})}else{switch(Math.floor(Math.random()*4)){case 0:s.log("小丑使用了“红心治疗”!");s.waitChoose(["进攻","诅咒"],(e,t)=>{if(e==0){this.chaos+=f(3,5);this.enemy[0].health+=f(10,50)}else{t.log("你诅咒小丑的治疗法术,小丑的法术失效了!");this.chaos+=1}s.die()});break;case 1:s.log("小丑使用了“草花守护”!");s.waitChoose(["进攻","打散"],(e,t)=>{if(e==0){this.chaos+=f(3,4);let e=this.chapterGame.attack;this.chapterGame.attack=0;this.roundEnd(()=>this.chapterGame.attack=e)}else{t.log("你用力向草花打去");this.chaos+=2}s.die()});break;case 2:s.log("小丑使用了“方块箭矢”!");s.waitChoose(["进攻","格挡"],(e,t)=>{if(e==0){this.chaos+=2;this.model.health-=f(5,35)}else{t.log("你尽可能地格挡箭矢的进攻");this.chaos+=f(1,5);this.model.attack-=10;this.roundEnd(()=>this.model.attack+=10)}s.die()});break;case 3:s.log("小丑使用了“黑桃炸弹”!");s.waitChoose(["进攻","闪躲"],(e,t)=>{if(e==0){this.chaos+=f(2,3);this.enemy[0].attack+=5;this.roundEnd(()=>this.enemy[0].attack-=5)}else{t.log("你拼命闪躲着炸弹,你的防御增加了!同时攻击减少了");this.chaos+=f(3,5);this.model.defence+=10;this.model.attack-=10;this.roundEnd(()=>this.model.defence-=10);this.roundEnd(()=>this.model.attack+=10)}s.die()});break}}}else{s.die()}})}itemSelect(i,t){if(this.enemy[0].id===6&&Math.random()<.5){i.log("四面体向你的背包里发射了一颗能量球,你受到了15点伤害!");this.model.health-=15}let a=[];for(let t in this.model.items){let e=this.model.items[t];if(e.battle){a.push(parseInt(t))}}if(a.length===0){i.log("你没有可用的物品。");return t()}i.log("选择一项物品。");i.waitProcess(e=>{let s=l("<div/>").addClass("ate-cover").appendTo(this.chapterGame.$itemsShow);_.button("取消",{cls:"negative"}).css({position:"absolute",right:"0",top:"10em"}).on("click",()=>{l(".ate-item-inner").off("click");s.remove();t();e.die()}).appendTo(s);for(let t of a){let e=this.model.items[t];e.$inner.on("click",()=>{if(this.enemy[0].id===8&&e.id===n){this.chapterGame.achieve(4)}this.chapterGame.use(t,this);l(".ate-item-inner").off("click");s.remove();i.die()})}});if(this.enemy[0].id===M.LORCE){this.rules+=f(2,5)}}magicChoose(i,a){i.log("你选择了魔法。");i.wait(200);let h=[`治疗魔法(${this.cureMagicCost})`,"战斗魔法(70)",this.darkMagicEnabled?"黑暗魔法(100)":"l͓̩̫̘͙͔̯͖̟̤̓͊̑̌́̂̆̚ò̥̪̭̱̰̝̒͂̄͋̿̏͆́̚c͍̲͇͚̖̬͈̪͙̳͌̉́̃k̪̥̱̝̱̑̈́̏̽͗̊̈́͂̀̍e̞͎̩̜̱̩͚̤̊͌̀̀d̠̖̞̝̙̪̟̞̐͛̈̊̀͂̄͌̓̏͌̓ͅ"];let r=[this.cureMagicCost,70,this.darkMagicEnabled?100:101];let o=[];if(this.octahedron){h.push(`几何八面体(${this.magic})`);o.push(this.useOctahedron);r.push(0)}if(this.withNc){h.push(`${this.chapterGame.ncChip===1?"万能":"喵叫"}芯片(40)`);o.push(this.useNcChip);r.push(40)}if(this.withSo){h.push(`${this.chapterGame.soSweater===1?"暗蓝":"高科技"}卫衣(30-50)`);o.push(this.useSoSweater);r.push(50)}let e=Array.from(new Set(p(this.enemy,e=>e.id)));for(let a of e){let e=M.magic(a);if(!e){continue}let[t,s,i]=e;o.push(this[t]);h.push(s);r.push(i)}let t=[];for(let e in r){if(r[e]>this.magic){t.push(parseInt(e))}}const l=h.length;h.push("取消");i.waitChoose(h,(e,t,s)=>{if(e!==l){t.whenDie(()=>i.die())}switch(e){case l:a();break;case 0:this.useCureMagic(t,s);break;case 1:this.useBattleMagic(t,s);break;case 2:this.useDarkMagic(t,s);break;case 3:case 4:o[e-3].call(this,t,s);break;default:throw new Error("非法输入")}return false},{disabled:t})}magicChooseForLorce(i,a){i.log("你选择了魔法。");i.wait(200);if(!this.talked){i.log("星空对你说:“罗尔斯的规则法术……好像对我们也有作用!”");this.talked=true}let e=["超级治疗(60)","规则防御(30)"];let h=2;if(this.octahedron){e.push(`几何八面体(${this.magic})`);h=3}let t=[];if(this.magic<60){t.push(0)}if(this.magic<30){t.push(1)}e.push("取消");i.waitChoose(e,(t,s,e)=>{if(t!==h){s.whenDie(()=>i.die())}switch(t){case h:a();break;case 0:s.log("你试着用尽全力使出治疗法术……你的血量和攻击力增加了!");this.model.health+=80;this.model.attack+=5;this.roundEnd(()=>this.model.attack-=5);this.battleMagic=true;this.magic-=60;break;case 1:s.log("你使用了规则防御,罗尔斯的攻击降低了!罗尔斯的防御略微降低了!");this.magic-=30;this.enemy[0].attack-=10;this.roundEnd(()=>this.enemy[0].attack+=10);this.enemy[0].defence-=5;this.roundEnd(()=>this.enemy[0].defence+=5);break;case 2:let e=this.magic;this.magic=0;this.enemy[0].health-=e/2;s.log(`你选择了几何八面体,对【罗尔斯】造成${e/2}点伤害!`);break;default:throw new Error("非法输入")}this.rules+=f(3,7);return false},{disabled:t})}useCureMagic(e,t){e.log(`你选择了治疗魔法,HP恢复${this.cureMagicPlus}`);this.magic-=this.cureMagicCost;this.model.health+=this.cureMagicPlus}useBattleMagic(e,t){e.log(`你选择了战斗魔法,Att提高5,持续一回合。`);this.battleMagic=true;this.magic-=70;this.model.attack+=5;this.roundEnd(()=>this.model.attack-=5)}useDarkMagic(e,t){e.log("水晶被黑暗笼罩住了!黑暗法术增强了!");this.magic=0;this.enemy[0].health=0}useOctahedron(e,t){if(this.enemy[0].id===9){this.chapterGame.virtually(200)}let s=this.magic;this.magic=0;this.enemy[0].health-=s/2;e.log(`你选择了几何八面体,对【${this.enemy[0].name}】造成${s/2}点伤害!`)}useNcChip(e,t){this.magic-=40;if(this.chapterGame.ncChip===0){e.log("你使用了猫叫芯片!敌人发出了喵喵叫的声音");if(Math.random()<.2){e.log("喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵(")}this.ncChipMagic=1;this.enemy.forEach(e=>{let t=e.attack;e.attack=Math.floor(e.attack/2);this.roundEnd(()=>e.attack=t)})}else if(this.chapterGame.ncChip===1){e.log("你使用了万能芯片!请选择它的效果");this.waitChoose(["使对方本回合ATT变为原来的五分之一","使对方本回合受到伤害增加","使对方本回合只能打出相同的字母"],e=>{if(e===0){this.enemy.forEach(e=>{let t=e.attack;e.attack=Math.floor(e.attack/5);this.roundEnd(()=>e.attack=t)})}this.ncChipMagic=e+2})}}useSoSweater(e,t){this.magic-=f(30,50);if(this.chapterGame.soSweater==0){e.log("你使用了暗蓝卫衣!你的闪避率提高了10%,持续一回合!");this.model.dodgeRate+=.1;this.roundEnd(()=>this.model.dodgeRate-=.1)}else{e.log("你使用了高科技卫衣!卫衣创造了一个力场盾,你的周围闪起了蓝色的光芒!");this.shield=100}}escapeCatch(e,t){this.log("你尝试逃脱机械臂的抓捕!");this.escapeCatchUsed=true;this.magic-=30}waitFightInput(e=0){this.wait(()=>this.fightInput(e))}fightInput(t=0){if(this.tutorial){this.choose(["DDAAA","你在教我做事?"],e=>this.fight(e));return}if(t>=this.enemy.length){return this.finishRound()}if(this.enemy[t].dead){return this.fightInput(t+1)}var s=new w(this.chapterGame,["A","B","C","D"],R.check5Capitals,e=>{s.remove();this.fight(e,t)});if(this.chapterGame.root.settings.get("random")){let e=b(5,()=>f(65,68));s.setValue(String.fromCharCode(...e))}}static check5Capitals(t){if(t.length!==5){return false}for(let e=0;e<5;e++){if(!(65<=t.charCodeAt(e)&&t.charCodeAt(e)<=68)){return false}}return true}static computeHurtHarm(h,r,s,o,l,n,c,d,u){if(s<0){s=0}var m;if(u&&(u.enemy[0].id===4&&u.rounds%4==3||u.ncChipMagic==4)){m=Math.floor(Math.random()*4)}let f=0,g=0,p="",b=0,w=0;const k=c.root.$interface;for(let a=0;a<5;a++){let e=h.charCodeAt(a)-65,t=m||Math.floor(Math.random()*4),i=String.fromCharCode(t+65);if(e==t-1||e==3&&t==0){b++;let e=r;let t=c.weapon;let s=n;if(!o&&t&&t.magic){if(u.magic>=c.weapon.magic){u.magic-=c.weapon.magic;if(t.id===v){s=0}}else{e-=c.weapon.attack}}e-=s;if(e<0||o){e=0}console.log("sigatt",e,"att",e,"sigedef",s,"bthis",r,"g.att",c.attack,"edef",n);g+=e;R.charWithColor(h.charAt(a),k,o?0:1,false,a*10+30+"%");R.charWithColor(i,k,-1,true,a*10+30+"%")}else if(t==e-1||t==3&&e==0){w++;let e=false;if(d&&Math.random()<d){l=0;e=true}if(!o){l=0}if(l<s){f+=s-l}console.log(a,e,o);R.charWithColor(h.charAt(a),k,o?0:1,true,a*10+30+"%",o&&e);R.charWithColor(i,k,-1,false,a*10+30+"%")}else{R.charWithColor(h.charAt(a),k,o?0:1,true,a*10+30+"%");R.charWithColor(i,k,-1,true,a*10+30+"%")}p+=i}return[f,p,g,b,w]}static charWithColor(e,t,s,i,a,h){var r=l("<span/>").html(e).css("color",u[e]).appendTo(t);r.css({fontSize:"3em",position:"fixed",display:"block",left:a,fontWeight:"bold",userSelect:"none"});let o;if(s===1){o="self-"}else if(s===0){o="self-defend-"}else if(s===-1){o="enemy-"}if(h){o+="broken"}else if(i){o+="failed"}else{o+="success"}r.css("animation",`ate-char-${o} 4s linear`);r.css("--char-color",u[e]);window.setTimeout(()=>r.remove(),3800);return r}fight(o,l=0){let n=this.enemy[l];if(this.tutorial&&typeof o==="number"){if(o===0){this.magic+=40;this.log("星空:太棒了,现在我们有足够的魔法值来使用魔法了,试一下【魔法】吧,它会给你带来增益效果!剩下的你就自己摸索吧")}else{this.log("星空:呃……你没有听我的,看来你是想自己对战了,那我就不打扰你了!我先给你个治疗法术吧!");this.model.execute("health + 240")}this.log("星空:对了,刚刚我对训练木马攻击的预测是木马的本身设定,往后可就是随机的,没法预测咯!祝你好运!");this.tutorial=false}else if(typeof o==="string"){let e=Math.random()<n.defendRate;let t=e?n.defence:0;const c={13:this.heavyAttack?.3:0,17:.6};let[s,i,a,h,r]=R.computeHurtHarm(o,this.model.attack,n.attack,this.defend,this.model.defence,t,this.chapterGame,c[n.id]||0,this);if(this.frozenBreadUsed||this.model.dodgeRate&&Math.random()<=this.model.dodgeRate){s=0}if(this.ncChipMagic===3){a*=2}this.log(`你的攻击是${o},对方的攻击是${i}`);if(e){this.log(`${n.name}选择了防御。`)}this.log(`你受到${s}点伤害`);if(this.shield){this.shield-=s}else{this.model.health-=s}this.log(`你造成了${a}点伤害`);if(n.id==M.HEXAGRAM&&n.shield>0){n.shield-=a}else{n.health-=a}if(n.id==M.MECHANIC_ARM){if(this.escapeCatchUsed){let e=this.catch;this.catch-=h*10;this.log(`你的[${e-this.catch}%]逃脱了机械臂的追捕!`)}else{this.catch+=r*10;this.log(`机械臂捕捉了你的[${r*10}%]!`)}}if(this.withXk){let e=t<20?20-t:0;this.log(`星空造成了${e}点伤害`);if(n.id==M.HEXAGRAM&&n.shield>0){n.shield-=e}else{n.health-=e}}n.fightTimes--;if(n.fightTimes>0){this.log("攻击仍在袭来,请再输入一次!");return this.waitFightInput(l)}if(this.multiEnemy&&l+1!==this.enemy.length){return this.waitFightInput(l+1)}if(n.fixed&&this.heavyAttack&&a>0){this.log("你朝炮筒攻打过去,机械木马开始松动了");n.gunHealth--}}this.finishRound()}finishRound(){for(let e=this.roundEndCallbacks.length-1;e>=0;e--){this.roundEndCallbacks[e].call(this.chapterGame)}if(!this.won){this.rounds++;this.round()}}get magic(){return this._magic}set magic(e){if(e>100){e=100}this._magic=e;this.zeroTable.magic.set(e)}get chaos(){return this._chaos}set chaos(e){this._chaos=e;this.enemy[0].table.chaos.set(e);if(this.chaos>=100){this.log("混沌盘旋着毁灭了战场,你胜利了。");this.chapterGame.virtually(12132);this.enemy[0].die()}}get rules(){return this._rules}set rules(e){this._rules=e;this.enemy[0].table.rules.set(e);if(e>=100){this.log("战斗的规则摇晃着崩塌了");this.win()}}get catch(){return this._catch}set catch(e){this._catch=e;this.enemy[0].table.catch.set(e);if(e>=100){this.log("机械臂捕捉了你!你的HP减少了150!");this.model.health-=150;this.catch=0}}get shield(){return this._shield}set shield(e){if(this._shield<=0&&e>0){this.zeroTable.shield.show()}if(e>0){this._shield=e;this.zeroTable.shield.set(e)}else{this._shield=0;this.zeroTable.shield.hide()}}roundEnd(e){this.roundEndCallbacks.push(e)}get darkMagicEnabled(){return this.chapterGame.judge(1024)&&this.enemy[0].id===9}}class S extends R{constructor(e,t,s){super(e,t,s);this.chess=true;this.maxFeet=e.maxFeet;this.zeroTable.add("feet","步数",this.maxFeet,"blue");this.feet=0;this.enemyFeet=0}round(){super.round();this.roundFeet=0}talk(){if(this.talked){return}this.log("机器人说:“哈哈哈!不行动你就加不了步数咯!”");this.talked=true}magicNotEnough(){return this.magic<10}prepare(e,t,s){switch(e){case 0:this.talk();this.itemSelect(t,s);break;case 1:this.talk();t.log("你选择了防御。");this.defend=true;this.magic+=40;t.waitDie();break;case 2:this.magicChoose(t,s);break;case 3:this.talk();t.log("你选择了跳过。");t.waitDie()}return true}magicChoose(i,a){let e=[];if(this.magic<20){e.push(1)}if(this.magic<30){e.push(2)}this.waitChoose(["走一步(10)","走两步(20)","走三步(30)","取消"],(e,t,s)=>{if(e!==3){t.whenDie(()=>i.die())}switch(e){case 0:this.roundFeet=1;this.magic-=10;t.log("你为赛车充了一部分能量");break;case 1:this.magic-=20;t.log("你使用了一节虚拟的五号电池,赛车的能量回复了一半!");this.roundFeet=2;break;case 2:this.magic-=30;t.log("你擦动着一块充能水晶,赛车的能量被充满了!");this.roundFeet=3;break;case 3:a();default:throw new Error("Invalid input")}},{disabled:e})}fight(e,t=0){let[s,i,a,h,r]=R.computeHurtHarm(e,0,0,false,0,0,this.chapterGame);this.log(`你的行动是${e},机器人的行动是${i}`);console.log(r,h);if(r>h){let e=Math.floor(3*(Math.pow(2,Math.random())-1))+1;this.log(`机器人前进了${e}/10步!`);this.enemyFeet+=e}else if(this.roundFeet>0&&h>r){this.log(`您前进了${this.roundFeet}/10步!`);this.feet+=this.roundFeet}else{this.log("你们俩都没有前进!")}this.finishRound()}get feet(){return this._feet}set feet(e){this._feet=e;if(e>=this.maxFeet){this.enemy[0].table.remove();if(this.enemyFeet){this.log("机器人说:“啊哈哈!恭喜你赢了!咱们结束吧!”")}this.win()}this.zeroTable.feet.set(e)}get enemyFeet(){return this._enemyFeet}set enemyFeet(e){this._enemyFeet=e;this.enemy[0].table.feet.set(e);if(e>=10){this.log("机器人说:“啊啊啊!你居然输啦!咱们再试一次吧!”");this.rounds=0;this.feet=0;this.enemyFeet=0;this.magic=50}}}class I extends S{constructor(e,t,s){super(e,t,s);this.esnakeRounds=e.esnakeRounds;this.talked=true}round(){super.round();if(this.esnakeRounds.includes(this.rounds)){let e;if(this.maxFeet>=40){e=Math.random()>.5?R.ESNAKE:R.SENIOR_ESNAKE}else{e=R.ESNAKE}this.chapterGame.waitBattle(e,this)}if(this.maxFeet>=40&&this.rounds==11&&this.feet<6){this.log("“你有没有觉得我们的速度好像太慢了点?”So问。");if(this.magic<40){this.log("在激烈的战斗中,你已经无暇顾及他们在说什么了")}else{this.waitChoose(["是的","并没有"],(e,t)=>{if(e===0){t.log("“这样啊...让我来整个大的”So答道");t.log("“我们好像飞起来了诶!”昵称兴奋的说");t.log("So耗费40魔法值使用了卫衣!你们向前飞行了5格");this.magic-=40;this.feet+=5}})}}}magicChoose(i,a){let t={1:20,2:30,3:this.cureMagicCost,4:70,5:40,6:30};let s=[];for(let e in t){if(t[e]>this.magic){s.push(parseInt(e))}}this.waitChoose(["走一步(10)","走两步(20)","走三步(30)",`治疗魔法(${this.cureMagicCost})`,"战斗魔法(70)",`${this.chapterGame.ncChip==1?"万能":"猫叫"}芯片(40)`,`${this.chapterGame.soSweater==1?"高科技":"暗蓝"}卫衣(30-50)`,"离开"],(e,t,s)=>{if(e!==7){t.whenDie(()=>i.die())}switch(e){case 0:this.roundFeet=1;t.log("你尝试向前移动一小步");break;case 1:if(this.magic<20){t.log("你的魔法值不够!");return s()}t.log("你使用了魔法为你的鞋子充能!你的速度变快了!");this.roundFeet=2;break;case 2:if(this.magic<30){t.log("你的魔法值不够!");return s()}t.log("你施展了一次速度魔法!你的移动速度大幅提升!");this.roundFeet=3;break;case 3:this.useCureMagic(t,s);break;case 4:this.useBattleMagic(t,s);break;case 5:this.useNcChip(t,s);break;case 6:this.useSoSweater(t,s);break;case 7:a();break;default:throw new Error("Invalid input")}},{disabled:s})}fight(e){let t=this.enemy[0];let s=Math.random()<t.defendRate;let i=s?t.defence:0;const a={13:.3,17:.6};let[h,r,o,l,n]=R.computeHurtHarm(e,this.chapterGame.attack,t.attack,this.defend,this.chapterGame.defence,i,this.chapterGame,a[t.id]||0,this);if(this.frozenBreadUsed||this.chapterGame.dodgeRate&&Math.random()<=this.chapterGame.dodgeRate){h=0}this.log(`你的攻击是${e},对方的攻击是${r}`);if(s){this.log(`${t.name}选择了防御。`)}this.log(`你受到${h}点伤害`);if(this.shield){this.shield-=h}else{this.chapterGame.health-=h}if(this.roundFeet>0&&n>=l){this.log("你前进时被电子蛇击退了!你只得留在原地")}else if(this.roundFeet>0&&l<n){this.log(`你行走了${this.roundFeet}步!`);this.feet+=this.roundFeet}this.finishRound()}get enemyFeet(){return null}set enemyFeet(e){}}class M{constructor(e,t){this.id=e.id;this.battle=t;this.game=t.chapterGame;this.table=new $("ate-enemy-table",e.name).appendTo(this.battle.$element);if(e.health){this.table.add("health","HP",e.health,"red");this.full=e.health;this.health=e.health}this.name=e.name;this.attack=e.attack;this.defence=e.defence;this.defendRate=e.defendRate;this.message=e.message;this.dead=false}init(){switch(this.id){case M.MECHANIC_HORSE:this.table.add("gunHealth","炮筒",5,"orange",true);this.gunHealth=5;this.fixed=false;break;case M.JOKER12132:this.table.add("chaos","混沌",120,"linear-gradient(red, grey)",true);this.table.chaos.show();this.battle.chaos=0;this.battle.chaoAttacked=false;break;case M.LORCE:this.table.add("rules","规则度",100,"linear-gradient(orange, grey)");this.battle.rules=0;this.battle.talked=false;this.battle.intenseFight=false;break;case M.HEXAGRAM:this.table.add("shield","护盾",100,"orange");this.shield=100;this.shieldRecovery=0;break;case M.CHESS_ROBOT:this.table.add("feet","步数",10,"red");this.battle.talked=false;this.battle.magic=50;this.battle.log("突然进入战斗界面的你有点懵。");this.battle.log("“我知道你在想什么!这游戏的规则很简单!每人都有两艘赛车,对战之前可以自选步数,谁先到终点谁就赢啦!”");this.battle.log("请点击魔法栏");break;case M.MECHANIC_ARM:this.table.add("catch","捕捉度",100,"orange");this.battle.catch=0;break;default:break}}get health(){return this._health}set health(e){if(this.dead){return}this._setHealth(e);if(this.id===M.MECHANIC_HORSE){if(e<=0){this.battle.log("木马的血条似乎空了……但不要以为【自我修复】的力量就这点!");this.game.achieve(3);this._setHealth(this._health+200)}return}else if(this.id===M.JOKER12132){if(e<=0){this.die()}}console.log(e,this);if(e<=0){this.die()}}die(){this.table.remove();this.battle.aliveEnemyAmount--;this.dead=true;if(this.battle.aliveEnemyAmount===0){this.battle.win()}}_setHealth(e){this._health=e;this.table.health.set(e)}get gunHealth(){return this._gunHealth}set gunHealth(e){if(e<=0){this.battle.log("机械木马剧烈地抖动!你胜利了!");this.die()}this._gunHealth=e;this.table.gunHealth.set(e)}get shield(){return this._shield}set shield(e){if(e<=0){this.battle.log("飞行器的护盾失效了!");this.table.shield.hide();this.shieldRecovery=8}this._shield=e}round(){this.fightTimes=1;switch(this.id){case M.WHEEL:if(Math.random()<.25){this.battle.log("滚轮扬起的烟尘让你睁不开双眼!你的攻击力降低了!");this.game.attack-=10;this.battle.roundEnd(()=>this.game.attack+=10)}break;case M.CRD:if(this.battle.rounds===9){this.battle.log("CRD:“什么?!你们居然还能挺得住,看来我要动用增援了!”");this.battle.log("第一个短矛向你袭来");this.game.waitBattle(R.SHORT_SPEAR,this.battle);this.battle.log("第二个短矛向你袭来");this.game.waitBattle(R.SHORT_SPEAR,this.battle);this.battle.log("你转过头来,继续对战CRD。")}break;case M.SHORT_SPEAR:if(this.battle.rounds===6){this.game.achieve(2)}break;case M.DEER_FALSE:case M.DEER_TRUE:if(this.battle.rounds%5===4){this.battle.log("鹿法师使用了火魔法!ATT暂时提升5点");this.attack+=5;this.battle.roundEnd(()=>this.attack-=5)}break;case M.MECHANIC_HORSE:if(this.health<400){this.battle.log("机械木马的HP降低了!");this.battle.log("机械木马使用了【自我修复】!机械木马的HP回升了70点!");if(this.fixed==false){this.battle.log("“呃……这样真的能击败它吗?”水晶说道。");this.battle.log("“Zero就不能用点什么手段吗……”一个骷髅抱怨道。");this.battle.log("“呃……对了!我看到这个木马的炮管,在平常的时候好像都是掩着的,说不定这就是它的弱点!Zero,它等下发动炮弹攻击的时候,你向炮管打去,看看会怎么样!”水晶说。");this.table.gunHealth.show();this.fixed=true}this.health+=70}if(this.battle.heavyAttack=this.battle.rounds%5===4){this.battle.log("机械木马正在准备一发重型火力攻击。");this.attack+=20;this.battle.roundEnd(()=>this.attack-=20)}else if(this.battle.rounds%5===0&&this.battle.rounds>0){this.battle.log("机械木马正在准备一发散弹攻击!");this.fightTimes=2}break;case M.POKER_GUARD:case M.POKER_GUARD_NONXK:if(this.battle.rounds%6===2){this.battle.log("扑克守卫加强了剑阵的魔法指数!");this.attack+=3;this.battle.roundEnd(()=>this.attack-=3)}break;case M.LORCE:if(this.battle.rounds%4==1&&!this.withXk){this.withXk=true;this.octahedron=true;this.battle.log("星空恢复了过来。")}let e=.1;if(this.battle.intenseFight==true){e*=2}if(this.battle.defend){e*=2}if(this.battle.breakHarm=Math.random()<e){this.battle.log("罗尔斯举起了重剑!罗尔斯的攻击力提高了!");this.attack+=10;this.battle.roundEnd(()=>this.attack-=10);this.breakHarm=true}if(Math.random()<e){let e=f(10,35);this.game.health-=e;this.battle.log(`罗尔斯使用了一发扑克散弹,你受到了${e}点伤害!`)}if(Math.random()<e){this.battle.log("罗尔斯使用重剑劈晕了星空!");this.withXk=false;this.octahedron=false}this.attack+=5;this.battle.roundEnd(()=>this.attack-=5);break;case M.HEXAGRAM:if(this.shieldRecovery>0){this.shieldRecovery--;if(this.shieldRecovery===0){this.battle.log("飞行器重新制造了一个护盾!");this.table.shield.show();this.shield=100}}break;default:break}}static magic(e){switch(e){case M.MECHANIC_ARM:return["escapeCatch","逃脱(30)",30];default:return}}}M.WHEEL=5;M.CRD=7;M.SHORT_SPEAR=8;R.SHORT_SPEAR=8;M.DEER_FALSE=10;M.DEER_TRUE=11;M.MECHANIC_HORSE=13;M.JOKER12132=14;M.POKER_GUARD=15;M.POKER_GUARD_NONXK=16;M.LORCE=17;M.HEXAGRAM=19;R.HEXAGRAM=103;M.CHESS_ROBOT=20;M.MECHANIC_ARM=21;R.MECHANIC_ARM=104;M.ESNAKE=114514;R.ESNAKE=2048;M.SENIOR_ESNAKE=1919810;R.SENIOR_ESNAKE=4096;class G{constructor(e){this.realGame=e;this.queue=this.realGame.queue;this.items=this.realGame.items;this.$battle=this.realGame.$battle}init(e){this.battle=e;this.maxHealth=c[this.realGame.chapter].maxHealth;e.zeroTable.add("health","HP",this.maxHealth,"#66EEFF");this.health=this.maxHealth}execute(e,t){var s=e.split(" ");if(s[0]=="health"){let e=g(s[2]);if(s[1]=="+"){this.health+=e}else if(s[1]=="-"){this.health-=e}}else{this.realGame.execute(e,t)}}get attack(){return this.realGame.attack}set attack(e){this.realGame.attack=e}get defence(){return this.realGame.defence}set defence(e){this.realGame.defence=e}get dodgeRate(){return this.realGame.dodgeRate}set dodgeRate(e){this.realGame.dodgeRate=e}get health(){return this._health}set health(e){if(e<=0){this.realGame.goProcess(e=>{e.log("模拟结束!");this.realGame.toggleExpand();setTimeout(()=>{this.battle.zeroTable.remove();this.battle.enemy[0].table.remove()},2e3);this.battle.$element.children().fadeIn();e.wait(()=>{this.battle.die()})})}else if(e>this.maxHealth){e=this.maxHealth}this._health=e;this.battle.zeroTable.health.set(e)}get weapon(){return this.realGame.weapon}get armor(){return this.realGame.armor}}class D extends A{constructor(e,t,s){super(e);this.attachTo(this);e.give(this);this.root=t;this.chapter=s;this.$grid=l("<div/>").addClass("ate-grid").appendTo(this.root.$interface);this.$status=l("<div/>").addClass("ate-status").appendTo(this.$grid);this.$save=_.button("保存").on("click",()=>this.save()).appendTo(this.root.$buttons);this.$shopMagic=_.button("商店").on("click",()=>this.shopMagic()).appendTo(this.root.$buttons).hide();l(document).on("keypress",e=>{e.which===89&&this.shopMagic()});this.table=new $("ate-vals","状态栏").appendTo(this.$status);this.$items=l("<div/>").addClass("ate-items").appendTo(this.$status);this.$equipments=l("<div/>").addClass("ate-equipments").appendTo(this.$status);this.$message=l("<div/>").addClass("ate-messages").appendTo(this.$grid);this.$battle=l("<div/>").addClass("ate-battle").appendTo(this.$grid);this.$input=l("<div/>").addClass("ate-input").appendTo(this.$grid);this.$choices=l("<div/>").addClass("ate-choices").appendTo(this.$grid);this.$weapon=l("<div/>").addClass("ate-item-cell").appendTo(this.$equipments);this.$armor=l("<div/>").addClass("ate-item-cell").appendTo(this.$equipments);this.$weapon.append(l("<span/>").addClass("ate-item-name"));this.$armor.append(l("<span/>").addClass("ate-item-name"));this.table.add("health","HP",c[this.chapter].maxHealth,"green");this.table.add("attack","Att");this.table.add("defence","Def");this.table.add("cm","CM币");this.max=c[this.chapter].maxItems;for(let t=0;t<10;t++){let e=l("<div/>");if(t==0){this.$itemForward=l("<div/>").addClass("ate-item-forward").on("click",()=>{if(!this.forwardDisabled){this.switchForward()}}).appendTo(e)}else if(t==9){this.$itemBackward=l("<div/>").addClass("ate-item-backward").on("click",()=>{if(!this.backwardDisabled){this.switchBackward()}}).appendTo(e)}e.addClass("ate-item-cell").appendTo(this.$items)}this.$itemsShow=l("<div/>").addClass("ate-items-show").insertBefore(this.$items);this.$hiddenItems=[];this.dead=false;this.attack=15;this.defence=0;this.dodgeRate=0;var i=window.localStorage;if(i.gameData){this.storage=JSON.parse(i.gameData);this.health=this.storage.health;this.items=[];this.experience=this.storage.experience;this.stackables=this.storage.stackables;var a=this.storage.items;if(this.storage.weapon){this.weapon=new x(this.storage.weapon,this,1);a.splice(a.indexOf(this.storage.weapon),1)}if(this.storage.armor){this.armor=new x(this.storage.armor,this,1);a.splice(a.indexOf(this.storage.armor),1)}for(let e of a){this.add(e,this.stackables[e])}this.cm=this.storage.cm;this.shops=this.storage.shops||[];this.virtualExperience=this.storage.virtual||[];this.ncChip=this.storage.ncChip||0;this.soSweater=this.storage.soSweater||0}else{this.storage={};this.health=c[this.chapter].maxHealth;this.cm=0;this.experience=[];this.stackables={};this.items=[];this.shops=[];this.virtualExperience=[];this.ncChip=0;this.soSweater=0}if(this.shops.length>0){this.$shopMagic.show()}this.R=Math.round(Math.random()*100)+1;this.history=[];this.checkSwitch();this.exp(this.experience.length?this.experience.pop():0)}die(){[this.$grid,this.$shopMagic,this.$save].forEach(e=>e.remove());super.die();delete this.chapterGame}showItems(s){var i=[],a=[];var h=this.items;for(let t in h){let e=h[t];if(e.throwable!==false||!s){i.push(e.name);a.push(parseInt(t))}}return[i,a]}equip(e){this.items.splice(this.items.indexOf(e),1);if(e.type===x.WEAPON){this.weapon=e}else if(e.type===x.ARMOR){this.armor=e}else{throw new Error("不可佩戴")}}get attack(){return this._attack}set attack(e){this._attack=e;if(this.weapon&&this.weapon.id===r){this.table.attack.$val.html("?");return}this.table.attack.set(e)}get defence(){return this._defence}set defence(e){this._defence=e;this.table.defence.set(e)}get cm(){return this._cm}set cm(e){this._cm=e;this.table.cm.set(e)}get health(){return this._health}set health(e){if(this._health<0&&e<0){return}if(e>c[this.chapter].maxHealth){e=c[this.chapter].maxHealth}else if(e<=0){this.deadInterface()}this._health=e;this.table.health.set(e)}get weapon(){return this._weapon}set weapon(e){if(!e||e===this.weapon){return}var t=this.weapon;this._weapon=e;if(t){if(t.id===r){window.clearInterval(this.timer.id);this.attack-=this.timer.lastAdd}else{this.attack-=t.attack}this.items.push(t)}e.$element.appendTo(this.$weapon);if(e.id===r){this.timer={};this.timer.lastAdd=0;this.timer.id=window.setInterval(()=>{this.attack-=this.timer.lastAdd;this.timer.lastAdd=f(5,50);this.attack+=this.timer.lastAdd},5e3)}else{this.attack+=e.attack}}get armor(){return this._armor}set armor(e){if(!e||e===this.armor){return}var t=this._armor;this._armor=e;if(t){this.defence-=t.defence;if(t.dodgeRate){this.dodgeRate-=t.dodgeRate}this.items.push(t)}e.$element.appendTo(this.$armor);this.defence+=e.defence;if(e.dodgeRate){this.dodgeRate+=e.dodgeRate}}findItem(t){if(t===undefined){return undefined}for(let e of this.items){if(e.id===t){return e}}}waitGet(i,a=1,e=this){const t=()=>{if(this.itemsFull(i)){this.wait(()=>{var[e,s]=this.showItems(true);e.push("放弃拾取");this.goProcess(t=>{t.log("已满,请丢弃一项");t.choose(e,e=>{if(e===this.max){return t.die()}this.remove(s[e]);this.add(i,a);t.die()})})})}else{var t=this.add(i,a);e.waitProcess(e=>{e.log(`已将${t.name}加入您的背包。`);e.waitDie()})}};var s=this.findItem(i);if(s&&s.stackable){s.amount+=a}else{t()}}itemsFull(e){var t;if(e!==undefined){t=c.items[e].stackable}return this.items.length===this.max&&!(t&&this.has(e))}add(e,t){var s=new x(e,this,t);return this.addItem(s)}addItem(e){this.items.push(e);this.$itemsShow.append(e.$element);this.checkSwitch();return e}has(e){return!!this.findItem(e)}remove(e){var t=this.items.splice(e,1)[0];t.$element.remove();this.checkSwitch();return t}waitRemove(e,t=this){t.wait(()=>void this.remove(e))}removeItem(e){return this.remove(this.items.indexOf(e))}waitRemoveItem(e,t=this){t.wait(()=>void this.removeItem(e))}get forwardDisabled(){return this._forwardDisabled}set forwardDisabled(e){if(e!==this._forwardDisabled){this._forwardDisabled=e;this.$itemForward.toggleClass("ate-item-forward-disabled")}}get backwardDisabled(){return this._backwardDisabled}set backwardDisabled(e){if(e!==this._backwardDisabled){this._backwardDisabled=e;this.$itemBackward.toggleClass("ate-item-backward-disabled")}}switchForward(){for(let e=0;e<10;e++){this.$hiddenItems.pop().prependTo(this.$itemsShow)}this.checkSwitch()}switchBackward(){for(let e=0;e<10;e++){this.$hiddenItems.push(this.$itemsShow.children().eq(0).remove())}this.checkSwitch()}checkSwitch(){this.forwardDisabled=this.$hiddenItems.length<10;this.backwardDisabled=this.$itemsShow.children().length<=10}use(e,t){var s=this.items[e];if(s.stackable){s.amount-=1}else{this.remove(e)}t.log(`你使用了${s.name}。`);if(s.id===o){t.frozenBreadUsed=true}for(let e of s.use){this.execute(e,t)}}exp(e){this.cache();this.$message.html("");this.experience.push(e);const t=c[this.chapter].story[e];if(Array.isArray(t)){this.story(this.judgeArr(t))}else{this.story(t)}}story(h){for(let t of h.message){let e;if(typeof t==="string"){e=t}else if(Array.isArray(t)){e=this.judgeArr(t);if(!e){continue}}if(e.startsWith("/")){this.execute(e.slice(1));continue}else if(e.endsWith("/")){e=e.slice(0,-1)}e.replace(/\$\{(.+?)\}/,(e,t)=>{return this[t]});this.log(e)}if("battle"in h){this.waitBattle(h.battle,this)}if("choice"in h){if("to"in h){let t=h.choice.length;let i=[];let a=[];for(let e=0;e<t;e++){let t=h.choice[e];let s=h.to[e];if(typeof t==="string"){i.push(t);a.push(s)}else if(Array.isArray(t)){let e=this.judgeArr(t);if(e){i.push(e);a.push(s)}}}this.choose(i,e=>{const t=a[e];if(typeof t==="number"){this.exp(t)}else if(Array.isArray(t)){this.exp(this.judgeArr(t))}},h.fadeChoice)}else{this.wait(()=>{this.toggleExpand();let s=new w(this,[],e=>"#pattern"in h.choice?new RegExp(h.choice["#pattern"]).test(e):true,e=>{if(!("#default"in h.choice)){if(e in h.choice){const t=h.choice[e];if(typeof t==="number"){this.exp(t)}else if(Array.isArray(t)){this.exp(this.judgeArr(t))}}else{return}}else{const t=h.choice[e in h.choice?e:"#default"];if(typeof t==="number"){this.exp(t)}else if(Array.isArray(t)){this.exp(this.judgeArr(t))}}s.remove();this.toggleExpand()})})}}else{const e=h.to;const t=()=>{if(typeof e==="number"){this.exp(e)}else if(Array.isArray(e)){this.exp(this.judgeArr(e))}};if(!this.root.settings.get("pass")){this.wait(()=>{this.$message.append(l("<span/>").html("点按以继续").addClass("ate-click-to-continue"));this.scrollMessage(24);this.$message.one("click",()=>{t()})})}else{t()}if(e===true){this.experience=[];this.chapter++;this.root.chapter++;this.health=c[this.chapter].maxHealth;this.cache();this.save();this.wait(()=>this.root.chooseChapter());this.waitDie()}else if(e===null){this.log("敬请期待!")}}}execute(e,a){var h=e.split(" "),r;switch(h[0]){case"get":this.waitGet(parseInt(h[1]),h[2]&&parseInt(h[2]));break;case"remove":this.removeItem(this.findItem(parseInt(h[1])));break;case"health":case"cm":r=g(h[2]);if(h[1]=="+"){this[h[0]]+=r}else if(h[1]=="-"){this[h[0]]-=r}break;case"attack":case"defence":case"dodgeRate":r=g(h[2]);let e=h[3]==="true"||h[3]==="1";if(a&&e){if(h[1]=="+"){this[h[0]]+=r;a.after.wait(()=>this[h[0]]-=r)}else if(h[1]=="-"){this[h[0]]-=r;a.after.wait(()=>this[h[0]]+=r)}}else if(a){if(h[1]=="+"){this[h[0]]+=r;a.roundEnd(()=>this[h[0]]-=r)}else if(h[1]=="-"){this[h[0]]-=r;a.roundEnd(()=>this[h[0]]+=r)}}else{if(e){console.warn("No battle. Don't use the third argument [untilEnd].")}if(h[1]=="+"){this[h[0]]+=r}else if(h[1]=="-"){this[h[0]]-=r}}break;case"harm":if(h[2]=="1"&&a.aliveEnemyAmount>1){this.goProcess(t=>{t.log("选择一个使用对象。");for(let e of a.enemy){e.table.$outer.on("click",()=>{e.health-=parseInt(h[1]);l(".ate-enemy-table").off("click");t.die()})}})}else{a.enemy.forEach(e=>!e.dead&&(e.health-=parseInt(h[1])))}break;case"dodge":this.dodge(parseInt(h[1]),h[2]);break;case"bridge":this.bridge();break;case"floor":this.floor();break;case"door":this.door(parseInt(h[1]),parseInt(h[2]));break;case"shop":this.waitShop(parseInt(h[1]));break;case"achieve":this.achieve(parseInt(h[1]));break;case"edefence":case"eattack":let t=h[0].slice(1);r=g(h[2]);if(h[1]=="+"){a.enemy[t]+=r;a.roundEnd(()=>a.enemy[t]-=r)}else if(h[1]=="-"){a.enemy[t]-=r;a.roundEnd(()=>a.enemy[t]+=r)}break;case"experience":this.virtually(parseInt(h[1]));break;case"defer":let s=a.rounds+parseInt(h[1]);let i=a.deferredCommands;i[s]=s in i?i[s]:[];i[s].push(h.slice(2).join(" "));break;case"addshop":this.shops.push(parseInt(h[1]));if(this.$shopMagic.css("display")==="none"){this.$shopMagic.show()}break;case"sleep":this.wait(parseInt(h[1])*1e3);break;default:throw new Error("Unknown Command")}}judge(t){if(typeof t==="number"){return this.experience.includes(t)}else if(typeof t==="string"){if(/^[0-9]+$/.test(t)){return this.experience.includes(parseInt(t))}let e;if(e=/^([\w\!\&\|]+?)\|([\w\!\&\|]+)$/.exec(t)){return this.judge(e[1])||this.judge(e[2])}if(e=/^([\w\!\&\|]+?)&([\w\!\&\|]+)$/.exec(t)){return this.judge(e[1])&&this.judge(e[2])}if(t.startsWith("!")){return!this.judge(t.slice(1))}if(e=/^([a-z]+)(\d+)$/.exec(t)){let s=e[1];let i=parseInt(e[2]);switch(s){case"r":return this.R===i;case"health":case"h":return this.health===i;case"item":case"i":return this.has(i);case"armor":case"a":let e=this.armor;return e!==undefined&&e.id===i;case"weapon":case"w":let t=this.weapon;return t!==undefined&&t.id===i;case"cm":case"c":return this.cm>=i;case"virtual":case"v":return this.virtualExperience.includes(i);case"attack":case"att":return this.attack>=i;case"defence":case"def":return this.defence>=i;default:throw new Error(`Illegal condition prefix '${s}'.`)}}}}static isValidCondition(e){return typeof e==="number"||/^[a-z0-9&\|!]+$/.test(e)}judgeArr(t){var s=t.length;if(!D.isValidCondition(t[1])){return t[f(0,s-1)]}var i;for(let e=0;e<s;e++){if(e===s-1){i=t[e];break}if(this.judge(t[e+1])){i=t[e];break}e++}return i}cache(){var t=[];var s={};for(let e of this.items){t.push(e.id);if(e.stackable){s[e.id]=e.amount}}if(this.weapon){t.push(this.weapon.id)}if(this.armor){t.push(this.armor.id)}this.storage={health:this.health,items:t,experience:this.experience,weapon:this.weapon?this.weapon.id:null,armor:this.armor?this.armor.id:null,cm:this.cm,stackables:s,virtual:this.virtualExperience,chapter:this.chapter,ncChip:this.ncChip,soSweater:this.soSweater};this.saved=false}save(){this.saved=true;localStorage.gameData=JSON.stringify(this.storage);this.root.notify("保存成功")}waitBattle(t,s){s.wait(()=>{var e;if(typeof t==="string"){if(t.startsWith("C")){e=new S(c.battle[t],this,s)}else if(t.startsWith("S")){e=new R(c.battle[t],new G(this),s)}else if(t.startsWith("T")){e=new R(c.battle[t],this,s)}else if(t.startsWith("E")){e=new I(c.battle[t],this,s)}}else{e=new R(c.battle[t],this,s)}e.run()})}dodge(r,o){this.waitProcess(a=>{this.toggleExpand(true);var h=new w(this,["A","B","C","D"],R.check5Capitals,e=>{h.remove();let[t,s,i]=R.computeHurtHarm(e,0,r,true,0,0,this);a.log(`你的攻击是${e},${o}的攻击是${s}。`);a.log(`你被扣血${t}`);this.health-=t;a.wait(()=>this.toggleExpand(false));a.waitDie()});if(this.root.settings.get("random")){let e=b(5,()=>f(65,68));h.setValue(String.fromCharCode(...e))}})}bridge(e=false){var t=e?4:3;var h=e?"地板":"桥";this.log(`选择一${e?"条路线":"座桥"}以通过`);var r=[];for(let e=0;e<t;e++){r.push(String.fromCharCode(65+e))}this.waitChoose(r,(e,t,s)=>{var i=Math.floor(Math.random()*3);var a=Array.from(r);if(e===i){a.splice(i,1);t.log(`翻转地板组成了${h+a.join()},你没通过${h}![HP-2]`);this.health-=2;return s()}else{t.log(`你通过了${h}!`)}})}floor(){return this.bridge(true)}door(o,l){this.waitProcess(e=>{this.toggleExpand();var a=0;const h=()=>{if(o==5&&l==5&&a%3===0){return"00000"}else if(o==10&&l==10&&a%3===0){return Math.random()>.5?"1111111111":"0000000000"}let t="";for(let e=0;e<o;e++){t+=Math.random()>.5?"1":"0"}return t};var r=new w(this,["0","1"],e=>e.length===o&&!/[^01]/.test(e),t=>{let s=h();let i=0;for(let e=0;e<o;e++){if(s[e]!==t[e]){i++}}if(i>=l){e.log("你通过了升降门!");e.waitDie();r.remove();this.toggleExpand()}else{e.log(`升降门的升降形式是${s},你只通过了${i}道门,请重新来过[HP-5]`);r.setValue("");this.health-=5}a++});e.log(`请输入您的通过方式,由${o}个二进制字符组成`);if(o!=l){e.log(`至少通过${l}/${o}道`)}})}shopMagic(){if(this.queue.ownerIndex!==1){return this.root.notify("现在不能使用商店魔法")}var s=[];if(this.shops.length<=0){this.log("你没有商店。");return}for(let t of this.shops){let e=c.shop[t];console.log(c.shop,c.shop[t],e);s.push(e.name)}this.goProcess(t=>{t.choose(s,e=>{this.waitShop(this.shops[e],t);t.waitDie()})})}waitShop(e,t=this){var s=c.shop[e];var l=s.price;this.$message.html("");t.log(`欢迎来到${"name"in s?s["name"]:"商店"}!`);const n=()=>this.goProcess(s=>{var i={},a=[],h=[],r=[];for(let t in l){let e=l[t];if(Array.isArray(e)){e=this.judgeArr(e);if(!e){continue}}i[t]=e;h.push(t);a.push(`${c.items[t].name} [${e}]`);r.push(this.root.itemImages[t])}console.log(i);var o=a.length;a.push("离开");s.choose(a,e=>{if(e===o){return s.die()}var t=parseInt(h[e]);console.log(t);if(this.itemsFull(t)){s.log("背包空间不够,你离开了商店");return s.waitDie()}if(i[t]>this.cm){s.log("你的CM币不够!")}else{this.cm-=i[t];this.waitGet(t,1,s)}s.waitDie();n()},null,null,r)});t.wait(()=>n())}virtually(e){this.virtualExperience.push(e)}deadInterface(){this.goProcess(t=>{t.log("黑暗再次降临。");if(this.has(i)){t.log("使用复活爱心吗?");t.choose(["是","否"],e=>{if(!e){this.findItem(i).amount--;this.health=100;t.log("那么,你将再次驱散黑暗");t.waitDie()}else{t.log("看来,黑暗将会再度笼罩你");t.log("You died.");delete localStorage.gameData;delete this.queue}})}else{t.log("希望似乎保佑不了你");t.log("看来,黑暗将会再度笼罩你");t.log("You died.");delete localStorage.gameData;delete this.queue}})}addImage(e,t){if(t instanceof x){t=t.id}if(t<this.root.itemImages.length){e.css("backgroundImage",`url(${this.root.itemImages[t]})`)}}achieve(e){if(this.achievements.includes(e)){return}var t=c.achievement[e];var s=l("<div/>").addClass("ate-achievement");this.root.$interface.append(s);l("<div/>").addClass("ate-achievement-title").html("成就:"+t.name).appendTo(s);l("<span/>").addClass("ate-achievement-content").html(t.description).appendTo(s);s.animate({opacity:1,left:0},2e3);setTimeout(()=>s.fadeOut(3e3),12e3);this.achievements.push(e)}get achievements(){var t=localStorage.ateAchievements?JSON.parse(localStorage.ateAchievements):[];return{push(e){t.push(e);localStorage.ateAchievements=JSON.stringify(t)},includes(e){return t.includes(e)},get length(){return t.length}}}toggleExpand(e){let t=this.root.$interface.hasClass("ate-interface-expanded");if(e===undefined?t:!e){this.root.$interface.removeClass("ate-interface-expanded")}else{this.root.$interface.addClass("ate-interface-expanded")}}scrollMessage(e){const t=this.$message[0];const s=t.scrollTop;const i=t.scrollHeight-t.clientHeight;t.scrollTop=i}}class _ extends y{constructor(e){super(e);this.queue=e;e.give(this);this.$interface=l(".ate-interface");this.$cover=l("<div/>").addClass("ate-cover").insertAfter(this.$interface).hide();this.$buttons=l("<div/>").addClass("ate-buttons").appendTo(this.$interface);this.settings=new C(this);this.$settings=_.button("设置").on("click",()=>this.settings.open()).appendTo(this.$buttons);if(Element.prototype.requestFullscreen){let e=false;l(document).on("fullscreenchange",()=>{e=!e;this.$fullscreen.html(e?"退出全屏":"全屏模式")});this.$fullscreen=_.button("退出全屏").on("click",()=>{if(!e){document.documentElement.requestFullscreen({navigationUI:"hide"})}else{document.exitFullscreen()}}).appendTo(this.$buttons)}var t=l("<div/>").addClass("ate-white").insertAfter(this.$interface);var s=l("<div/>").addClass("ate-sw0rd").insertAfter(this.$interface).hide().fadeIn(1e3);this.wait(4e3).wait(()=>{t.remove();s.fadeOut(1e3)});var i=l("<div/>").addClass("ate-enter").html("Extend Air Ticket").insertAfter(this.$interface);l("<div/>").html("Click to Start").appendTo(i);l("<div/>").addClass("ate-tips").html("Tips:").append(m[f(0,m.length-1)]).appendTo(i);this.waitTriggerEvent(i,"click",true).wait(()=>i.fadeOut(1e3)).wait(1e3).wait(()=>i.remove());var a=l("#author");a.on("click",()=>{a.hide()});l(document).one("click",()=>{const e=document.getElementById("music");if(e instanceof HTMLAudioElement){l(document).on("visibilitychange",()=>{if(document.visibilityState!=="visible"){if(!this.settings.get("playwhenhidden")){e.pause()}}else{e.play()}});e.play()}else{console.warn("未找到<audio>,无法播放。")}if(Element.prototype.requestFullscreen){document.documentElement.requestFullscreen({navigationUI:"hide"})}else if(Element.prototype.webkitRequestFullScreen){document.documentElement.webkitRequestFullScreen({navigationUI:"hide"})}});this.itemImages=p(c.items,e=>"./images/"+e.id+".png");window.addEventListener("beforeunload",e=>{if(!this.chapterGame.saved){e.preventDefault();e.returnValue="";return""}});this.noData=false;if(localStorage.gameData){this.storage=JSON.parse(localStorage.gameData);this.chapter=this.storage.chapter||1}else{this.chapter=1;this.noData=true}this.chooseChapter()}static button(e,t){var s=l("<div/>").addClass("ate-button").html(e);if(t){if(t.cls){s.addClass("ate-button-"+t.cls)}if(t.title){s.attr("title",t.title)}if(t.margin){s.css("marginLeft",t.margin)}if(t.padding){s.css("paddingLeft",t.padding).css("paddingRight",t.padding)}if(t.color){s.css("backgroundColor",t.color)}}return s}chooseChapter(){if(this.noData){this.settings.open()}var s=l("<div/>").addClass("ate-chapters").appendTo(this.$interface);for(let t=1;t<=5;t++){if(!c[t]){continue}let e=l("<div/>").addClass("ate-chapter").appendTo(s);if(t==this.chapter){e.html("Chapter "+t);this.waitTriggerEvent(e,"click");this.waitFadeOutEle(e);this.wait(()=>{s.remove();this.chapterGame=new D(this.queue,this,this.chapter)})}else if(c[t]&&t<this.chapter){e.addClass("ate-chapter-passed").html("passed")}else{e.addClass("ate-chapter-locked").html("locked")}}}notify(e){var t=l("<div/>").addClass("ate-notification").appendTo(this.$interface).html(e);t.fadeIn(1500);t.fadeOut(3e3,()=>t.remove())}cover(){this.$cover.show()}hideCover(){this.$cover.hide()}}var F=new _(new E);document.title="游玩 Extend Air Ticket";l("#version").html(e)})(jQuery,ateData,"2.15.1");