'use strict'; game.import('mode',function(){ var game=window.game; var ui=window.ui; var get=window.get; var ai=window.ai; var lib=window.lib; var _status=window._status; return { name:'tafang', canvasUpdates2:[], start:function(){ "step 0" lib.init.css(lib.assetURL+'layout/mode','chess'); lib.init.css(lib.assetURL+'layout/mode','tafang'); game.loadMode('chess'); "step 1" for(var i in result.element){ for(var j in result.element[i]){ if(j!='dieAfter'){ lib.element[i][j]=lib.init.eval(result.element[i][j]); } } } for(var i in result.ui){ for(var j in result.ui[i]){ ui[i][j]=lib.init.eval(result.ui[i][j]); } } get.chessDistance=lib.init.eval(result.get.chessDistance); get.rawAttitude=lib.init.eval(result.get.rawAttitude); var toLoad=['addChessPlayer','addObstacle','removeObstacle','isChessNeighbour', 'draw2','updateCanvas2','setChessInfo','modeSwapPlayer']; for(var i=0;i.player'+pos+ '{left:'+(14+i*148)+'px;top:'+(14+j*148)+'px}',0); ui.chesssheet.sheet.insertRule('#arena.chess #chess>.card'+pos+ '{left:'+(22+i*148)+'px;top:'+(22+j*148)+'px}',0); ui.chesssheet.sheet.insertRule('#arena.chess #chess>.popup'+pos+ '{left:'+(19+i*148)+'px;top:'+(142+j*148)+'px}',0); } } var grids=[]; var gridnum=ui.chessheight*ui.chesswidth; for(var i=0;i=8&&j!=0&&j!=ui.chesswidth-1) continue; if(tafanglist.contains(j)){ var cg=i*ui.chesswidth+j; grids.remove(cg); game.addObstacle(cg.toString(),false); event.obs.push(cg.toString()); } } } for(var i=0;icount){ map[i][j].classList.add('unselectable'); map[i][j].classList.remove('pointerdiv'); } else if(i=='zhaomu'&&_status.friends.length+selectedZhaomu>=5){ map[i][j].classList.add('unselectable'); map[i][j].classList.remove('pointerdiv'); } else if(i=='bufang'){ var numbufang=0; for(var k=0;k=3){ map[i][j].classList.add('unselectable'); break; } } } } } ui.dialog.content.firstChild.innerHTML='剩余行动点:'+count; } var clickOrder=0; event.custom.replace.button=function(button){ if(!button.classList.contains('unselectable')|| button.classList.contains('selected')){ button.classList.toggle('selected'); button._clickOrder=clickOrder++; } updateSelected(); } event.custom.add.window=function(clicked){ if(clicked) return; if(event.step>1) return; for(var i in map){ for(var j=0;j=5){ event.control.childNodes[1].style.opacity=0.5; event.control.childNodes[1].disabled=true; if(_status.lastTafangCommand=='招募'){ _status.lastTafangCommand='布防'; } } _status.imchoosing=true; ui.auto.hide(); var eventdong=function(){ var selected=dialog.querySelectorAll('.button.selected'); event.bufang=[]; event.zhaomu=[]; event.xingdong=_status.friends.slice(0); // var xingdongs=[]; _status.remainingCount+=10; for(var i=0;i0){ game.pause(); } else{ eventdong(); } 'step 1' event.dialog.close(); event.control.close(); event.done.close(); delete event.dialog; delete event.control; delete event.done; 'step 2' event.chooseObstacle=false; if(event.bufang.length){ event.obstacles=game.obstacles.slice(0); for(var i=0;i=0;k--){ var pos=i+k*ui.chesswidth; if(lib.posmap[pos]){ lib.posmap[pos].moveDown(); } } } } } if(shalldelay) game.delay(); 'step 7' event.justadded=[]; if(_status.characterList.length){ if(_status.enemies.length=10&&list1.length&&difficulty>1){ // var enemy=game.addChessPlayer(_status.characterList.shift(),true,4,list1.randomRemove()); // _status.enemies.push(enemy); // event.justadded.push(enemy.name); // } // if(_status.turnCount>=20&&list1.length&&difficulty>1){ // var enemy=game.addChessPlayer(_status.characterList.shift(),true,4,list1.randomRemove()); // _status.enemies.push(enemy); // event.justadded.push(enemy.name); // } // if(list1.length&&difficulty>2){ // var enemy=game.addChessPlayer(_status.characterList.shift(),true,4,list1.randomRemove()); // _status.enemies.push(enemy); // event.justadded.push(enemy.name); // } } } else{ game.over(true); } 'step 8' if(event.xingdong.length){ var toact=event.xingdong.shift(); if(game.players.contains(toact)){ toact.phase(); } event.redo(); } else{ event.xingdong=_status.enemies.slice(0); } 'step 9' if(event.xingdong.length){ var enemy=event.xingdong.shift(); if(!event.justadded.contains(enemy.name)&&game.players.contains(enemy)){ enemy.phase(); } event.redo(); } else{ event.mechlist=game.treasures.slice(0); } 'step 10' if(event.mechlist.length){ var mech=event.mechlist.shift(); var info=lib.skill[mech.name+'_skill']; if(!info.filter||info.filter(mech)){ var next=game.createEvent('chessMech'); next.player=mech; next.setContent(info.content); mech.chessFocus(); if(lib.config.animation&&!lib.config.low_performance){ mech.$epic2(); } game.delay(); } if(--mech.hp<=0){ var next=game.createEvent('chessMechRemove'); next.player=mech; next.setContent('chessMechRemove'); } else{ mech.update(); } event.redo(); } 'step 11' delete event.xingdong; delete event.mechlist; if(_status.turnCount>=_status.turnTotal){ game.over(true); } else{ event.goto(0); game.delay(); } }); }, loadMap:function(){ var next=game.createEvent('loadMap'); next.setContent(function(){ if(!lib.storage.map){ lib.storage.map=['basic_small','basic_medium','basic_large']; } if(!lib.storage.newmap){ lib.storage.newmap=[]; } var sceneview=ui.create.div('.storyscene'); if(!lib.config.touchscreen&&lib.config.mousewheel){ sceneview._scrollspeed=30; sceneview._scrollnum=10; sceneview.onmousewheel=function(){ if(!this.classList.contains('lockscroll')){ ui.click.mousewheel.apply(this,arguments); } }; } lib.setScroll(sceneview); var switchScene=function(){ event.result=this.link; sceneview.delete(); setTimeout(game.resume,300); } var clickScene=function(e){ if(this.classList.contains('unselectable')) return; if(this._clicking) return; if(e&&e.stopPropagation) e.stopPropagation(); if(this.classList.contains('flipped')){ return; } if(this.classList.contains('glow3')){ this.classList.remove('glow3'); lib.storage.newmap.remove(this.name); game.save('newmap',lib.storage.newmap); } var sceneNode=this.parentNode; var current=document.querySelector('.flipped.scene'); if(current){ restoreScene(current,true); } this.content.innerHTML=''; ui.create.div('.menubutton.large.enter','进入',this.content,switchScene).link=this.name; sceneNode.classList.add('lockscroll'); var node=this; node._clicking=true; setTimeout(function(){ node._clicking=false; },700); sceneNode.dx=ui.window.offsetWidth/2-(-sceneNode.scrollLeft+this.offsetLeft+this.offsetWidth/2); if(Math.abs(sceneNode.dx)<20){ sceneNode.dx=0; } if(!sceneNode.sceneInterval&&sceneNode.dx){ sceneNode.sceneInterval=setInterval(function(){ var dx=sceneNode.dx; if(Math.abs(dx)<=2){ sceneNode.scrollLeft-=dx; clearInterval(sceneNode.sceneInterval); delete sceneNode.sceneInterval; } else{ var ddx=dx/Math.sqrt(Math.abs(dx))*1.5; sceneNode.scrollLeft-=ddx; sceneNode.dx-=ddx; } },16); } node.style.transition='all ease-in 0.2s'; node.style.transform='perspective(1600px) rotateY(90deg) scale(0.75)'; var onEnd=function(){ node.removeEventListener('webkitTransitionEnd',onEnd); node.classList.add('flipped'); sceneNode.classList.add('lockscroll'); node.style.transition='all ease-out 0.4s'; node.style.transform='perspective(1600px) rotateY(180deg) scale(1)' }; node.listenTransition(onEnd); } ui.click.scene=clickScene; var restoreScene=function(node,forced){ if(node._clicking&&!forced) return; if(node.transformInterval){ clearInterval(node.transformInterval); delete node.transformInterval; } var sceneNode=node.parentNode; node._clicking=true; setTimeout(function(){ node._clicking=false; },700); node.style.transition='all ease-in 0.2s'; node.style.transform='perspective(1600px) rotateY(90deg) scale(0.75)'; var onEnd=function(){ node.removeEventListener('webkitTransitionEnd',onEnd); node.classList.remove('flipped'); if(!sceneNode.querySelector('.flipped')){ sceneNode.classList.remove('lockscroll'); } node.style.transition='all ease-out 0.4s'; node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)' }; node.listenTransition(onEnd); } ui.click.scene2=restoreScene; var createScene=function(name){ var scene=lib.tafang.map[name]; var node=ui.create.div('.scene',clickScene); node.style.transform='perspective(1600px) rotateY(0deg) scale(0.7)'; node.name=name; node.bgnode=ui.create.div('.background.player',node); node.info=scene; ui.create.div('.avatar.menu',node.bgnode); node.namenode=ui.create.div('.name',node,(scene.name)); if(lib.storage.map.contains(name)){ if(lib.storage.newmap.contains(name)){ node.classList.add('glow3'); } node.namenode.dataset.nature='soilm'; } else{ node.classList.add('unselectable'); node.namenode.innerHTML=('未开启'); } var content=ui.create.div('.menu',node); lib.setScroll(content); node.content=content; sceneview.appendChild(node); return node; } event.custom.add.window=function(){ var current=document.querySelector('.flipped.scene'); if(current){ restoreScene(current); } } for(var i in lib.tafang.map){ createScene(i); } ui.window.appendChild(sceneview.animate('start')); game.pause(); }); }, }, skill:{ tafang_mech_weixingxianjing_skill:{ filter:function(player){ for(var i=0;i<_status.enemies.length;i++){ if(!_status.enemies[i].isTurnedOver()&& get.chessDistance(player,_status.enemies[i])<=2){ return true; } } return false; }, content:function(){ var list=[]; for(var i=0;i<_status.enemies.length;i++){ if(!_status.enemies[i].isTurnedOver()&& get.chessDistance(player,_status.enemies[i])<=2){ list.push(_status.enemies[i]); } } if(list.length){ game.log('小型陷阱发动'); var target=list.randomGet(); target.turnOver(); game.logv(player,'tafang_mech_weixingxianjing_skill',[target]).node.text.style.display='none'; player.line(target,'green'); } } }, tafang_mech_nengliangqiu_skill:{ filter:function(player){ for(var i=0;i<_status.friends.length;i++){ if(get.chessDistance(player,_status.friends[i])<=3){ return true; } } return false; }, content:function(){ var list1=[],list2=[]; for(var i=0;i<_status.friends.length;i++){ if(get.chessDistance(player,_status.friends[i])<=1){ list2.push(_status.friends[i]); } else if(get.chessDistance(player,_status.friends[i])<=3){ list1.push(_status.friends[i]); } // else if(get.chessDistance(player,_status.friends[i])<=4){ // list2.push(_status.friends[i]); // } } if(list2.length){ game.asyncDraw(list2,2); player.line(list2,'green'); } if(list1.length){ game.asyncDraw(list1); player.line(list1,'green'); } if(list1.length||list2.length){ game.log('能量球发动'); game.logv(player,'tafang_mech_nengliangqiu_skill',list1.concat(list2)).node.text.style.display='none'; } } }, tafang_mech_mutong_skill:{ filter:function(player){ for(var i=0;i<_status.enemies.length;i++){ if(get.chessDistance(player,_status.enemies[i])<=3){ return true; } } return false; }, content:function(){ var list=[]; for(var i=0;i<_status.enemies.length;i++){ if(get.chessDistance(player,_status.enemies[i])<=3){ list.push(_status.enemies[i]); } } if(list.length){ game.log('木桶发动'); var targets=list.randomGets(1); game.logv(player,'tafang_mech_mutong_skill',targets).node.text.style.display='none'; player.line(targets,'green'); for(var i=0;i
  • 阻上敌人到达最下方的出口,坚持到给定的回合数即获得胜利
  • '+ '每轮可获得10个行动点,用来布置机关、招募武将。场上每有一个友方武将,行动点数-1。游戏难度将影响不同操作消耗的行动点数。未用完的行动点将减半(向下取整)并累积到下一轮
  • '+ '每一轮在最上方的一个随机位置增加一名敌人,若最上方已有角色,则将其下移一格
  • '+ '战场上最多出现3个相同的机关,每个机关在置入战场3轮后消失。战场上最多招募5名友方角色。
  • '+ '敌方角色到达底部出口时游戏失败,已方角色到达底部出口,将被移出游戏', }, }; });