'use strict'; mode.chess={ canvasUpdates2:[], element:{ card:{ moveTo:function(player,method){ this.fixed=true; if(this.parentNode==ui.arena){ var rect=player.getBoundingClientRect(); this.style.left=(rect.left+8)+'px'; this.style.top=(rect.top+8)+'px'; } else{ this.style.left=''; this.style.top=''; this.dataset.position=player.dataset.position; } if(method=='flip'){ this.style.transition='all 0.5s'; this.style.webkitTransform='rotate'+(Math.random()<0.5?'X':'Y')+'(180deg) perspective(1000px)'; } else if(method=='rotate'){ this.style.transition='all 0.5s'; this.style.webkitTransform='rotate(180deg)'; } return this; }, }, player:{ createRangeShadow:function(num,move){ num++; var shadows=this.parentNode.getElementsByClassName('playergrid'); while(shadows.length){ shadows[0].remove(); } for(var i=1-num;i=ui.chesswidth){ x=ui.chesswidth-1; } if(y>=ui.chessheight){ y=ui.chessheight-1; } // console.log(x,y); var pos=y*ui.chesswidth+x; if(!lib.posmap[pos]){ delete lib.posmap[this.dataset.position]; this.dataset.position=pos; lib.posmap[pos]=this; this.chessFocus(); } return this; }, chessFocus:function(){ if(ui.chess._chessdrag) return; if(_status.chessscrolling) return; var player=this; var dx=0,dy=0; if(player.offsetLeft-ui.chessContainer.scrollLeft<14){ dx=player.offsetLeft-ui.chessContainer.scrollLeft-14; } else if(player.offsetLeft-ui.chessContainer.scrollLeft>ui.chessContainer.offsetWidth-134){ dx=player.offsetLeft-ui.chessContainer.scrollLeft-ui.chessContainer.offsetWidth+134; } if(player.offsetTop-ui.chessContainer.scrollTop<14){ dy=player.offsetTop-ui.chessContainer.scrollTop-14; } else if(player.offsetTop+ui.chess.offsetTop-ui.chessContainer.scrollTop>ui.chessContainer.offsetHeight-134){ dy=player.offsetTop+ui.chess.offsetTop-ui.chessContainer.scrollTop-ui.chessContainer.offsetHeight+134; } if(_status.currentChessFocus){ clearInterval(_status.currentChessFocus); } var count=12; var ddx=Math.floor(dx/12); var ddy=Math.floor(dy/12); if(dx||dy){ _status.currentChessFocus=setInterval(function(){ if(count--){ ui.chessContainer.scrollLeft+=ddx; ui.chessContainer.scrollTop+=ddy; } else{ ui.chessContainer.scrollLeft+=dx%12; ui.chessContainer.scrollTop+=dy%12; clearInterval(_status.currentChessFocus); delete _status.currentChessFocus; } },16); } }, getXY:function(){ var pos=parseInt(this.dataset.position); var x=pos%ui.chesswidth; var y=Math.floor(pos/ui.chesswidth); return [x,y]; }, getDataPos:function(x,y){ var xy=this.getXY(); if(typeof x!='number') x=0; if(typeof y!='number') y=0; x+=xy[0]; y+=xy[1]; return x+y*ui.chesswidth; }, getNeighbour:function(x,y){ return lib.posmap[this.getDataPos(x,y)]||null; }, movable:function(x,y){ var xy=this.getXY(); if(xy[0]+x<0) return false; if(xy[1]+y<0) return false; if(xy[0]+x>=ui.chesswidth) return false; if(xy[1]+y>=ui.chessheight) return false; return !this.getNeighbour(x,y); }, moveRight:function(){ if(this.movable(1,0)){ this.move(1,0); return true; } return false; }, moveLeft:function(){ if(this.movable(-1,0)){ this.move(-1,0); return true; } return false; }, moveUp:function(){ if(this.movable(0,-1)){ this.move(0,-1); return true; } return false; }, moveDown:function(){ if(this.movable(0,1)){ this.move(0,1); return true; } return false; }, dieAfter:function(source){ var player=this; delete lib.posmap[player.dataset.position]; setTimeout(function(){ player.delete(); },500); for(var i=0;i1){ if(cards){ that.$draw(cards) } else{ that.$draw(num-1) } } }, $gainmod:function(num){ var cards,node; if(get.itemtype(num)=='cards'){ cards=num; num=cards.length; } else if(get.itemtype(num)=='card'){ cards=[num]; num=1; } if(cards){ cards=cards.slice(0); node=cards.shift().copy('thrown','hidden'); } else{ node=ui.create.div('.card.thrown.hidden'); } node.fixed=true; game.$randomMove(this,node,100,30); var ot=node.style.webkitTransform; node.style.webkitTransform+='scale(0.6)'; node.dataset.position=this.dataset.position; this.parentNode.appendChild(node); ui.refresh(node); node.show(); node.style.webkitTransform=ot; setTimeout(function(){ node.style.webkitTransform=''; node.delete(); },500); var that=this; if(num&&num>1){ if(cards){ that.$gain(cards) } else{ that.$gain(num-1) } } }, $throw:function(card,time){ this.chessFocus(); if(get.itemtype(card)=='cards'){ for(var i=0;i=0){ for(var i=0;ipxy[0]&&randomMove.contains('moveRight')){ if(player.moveRight()){ event.moved=true;break; } } else if(txy[0]pxy[1]&&randomMove.contains('moveDown')){ if(player.moveDown()){ event.moved=true;break; } } else if(txy[1]pxy[1]&&randomMove.contains('moveDown')){ if(player.moveDown()){ event.moved=true;break; } } else if(txy[1]pxy[0]&&randomMove.contains('moveRight')){ if(player.moveRight()){ event.moved=true;break; } } else if(txy[0]=ui.chessContainer.offsetWidth){ tx=-Math.abs(tx); } if(rect.top<=80){ ty=Math.abs(ty); } else if(rect.top+rect.height+80>=ui.chessContainer.offsetHeight){ ty=-Math.abs(ty); } node.style.webkitTransform='translate('+tx+'px,'+ty+'px)'; }, draw2:function(func){ lib.canvasUpdates2.push(func); if(!lib.status.canvas2){ lib.status.canvas2=true; game.update(game.updateCanvas2); } }, updateCanvas2:function(time){ if(lib.canvasUpdates2.length===0){ lib.status.canvas2=false; return false; } ui.canvas2.width=ui.chess.offsetWidth; ui.canvas2.height=ui.chess.offsetHeight; ui.canvas2.style.left=0; ui.canvas2.style.top=0; var ctx=ui.ctx2; ctx.shadowBlur=5; ctx.shadowColor='rgba(0,0,0,0.3)'; ctx.fillStyle='white'; ctx.strokeStyle='white'; ctx.lineWidth=3; ctx.save(); 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;i7?'thunder':''; game.players[i].popup('距离:'+dist2+'/'+dist,nature); } } },true); ui.create.me(); ui.create.fakeme(); ui.chessinfo=ui.create.div('.fakeme.player',ui.me); ui.chessinfo.ontouchmove = ui.click.touchScroll; ui.chessinfo.style.WebkitOverflowScrolling='touch'; game.arrangePlayers(); "step 2" ui.control.style.display=''; var p; for(var i=0;i=4&&!bosses.childNodes[i].classList.contains('glow')){ bosses.childNodes[i].classList.add('forbidden'); } else{ bosses.childNodes[i].classList.remove('forbidden'); } } if(num){ if(!event.asboss){ event.asboss=ui.create.control('应战',function(){ _status.boss=true; ui.click.ok(); }); } } else{ if(event.asboss){ event.asboss.close(); delete event.asboss; } } addToButton(); }; for(var i=0;i=4) return true; } return false; }, filterCard:function(card){ var suit=get.suit(card); for(var i=0;i1) break; } } if(num<=1) return; if(_status.currentPhase==player&&player.num('h')=6){ if(typeof card=='string') return; if(card.name=='wuzhong') return; if(card.name=='shunshou') return; if(card.name=='yuanjiao') return; if(card.name=='yiyi') return; if(!player.skills.contains('cangming2')) return [0,0,0,0]; } } }, result:{ target:function(player){ var num=0; for(var i=0;i1) break; } } if(num<=1) return 0; return -10; } } }, }, cangming2:{ trigger:{player:'phaseBegin'}, forced:true, popup:false, content:function(){ for(var i=0;i0; }, check:function(event,player){ var targets=lib.skill.guanchuan.getTargets(player,event.targets[0]); var eff=0; for(var i=0;i0; }, content:function(){ var targets=lib.skill.guanchuan.getTargets(player,trigger.targets[0]); for(var i=0;i1&&lib.filter.filterCard({name:'sha'},player); }, filterCard:{name:'sha'}, selectCard:2, check:function(card){ var num=0; var player=_status.event.player; for(var i=0;i0){ num++; if(num>1) return 8-ai.get.value(card); } } return 0; }, selectTarget:[1,Infinity], discard:false, prepare:function(cards,player,targets){ player.$throw(cards); player.line(targets); }, filterTarget:function(card,player,target){ return lib.filter.targetEnabled({name:'sha'},player,target)&& get.distance(player,target,'pure')<=5; }, content:function(){ targets.sort(lib.sort.seat); player.useCard({name:'sha'},cards,targets,'luanjian').animate=false; }, multitarget:true, ai:{ order:function(){ return lib.card.sha.ai.order+0.1; }, result:{ target:function(player,target){ var added=false; if(!player.skills.contains('unequip')){ added=true; player.skills.push('unequip'); } var eff=ai.get.effect(target,{name:'sha'},player,target); if(added){ player.skills.remove('unequip'); } return eff; } }, effect:{ player:function(card,player){ if(_status.currentPhase!=player) return; if(card.name=='sha'&&player.num('h','sha')<2&&player.num('h')<=player.hp){ var num=0; var player=_status.event.player; for(var i=0;i1) return [0,0,0,0]; } } } } }, } }, zhiming:{ trigger:{source:'damageBegin'}, filter:function(event,player){ return get.distance(event.player,player,'attack')>1&&event.card&&event.card.name=='sha'; }, forced:true, content:function(){ trigger.num++; } }, lianshe:{ mod:{ cardUsable:function(card,player,num){ if(card.name=='sha'){ return num+get.cardCount(true,player)-get.cardCount('sha',player); } }, attackFrom:function(from,to,distance){ return distance-1; } }, }, pianyi:{ trigger:{player:'phaseEnd'}, direct:true, filter:function(event,player){ return !player.getStat('damage'); }, content:function(){ "step 0" player.chooseToMove(1,'是否发动【翩仪】?'); "step 1" if(result.bool){ player.logSkill('pianyi'); } } }, lingdong:{ trigger:{player:'phaseEnd'}, direct:true, filter:function(event,player){ return get.cardCount('sha',player)>0; }, content:function(){ "step 0" player.chooseToMove(get.cardCount('sha',player),'是否发动【移动射击】?'); "step 1" if(result.bool){ player.logSkill('lingdong'); } } }, _noactpunish:{ trigger:{player:'useCard'}, filter:function(event,player){ return _status.currentPhase==player&&event.targets&&(event.targets.length>1||event.targets[0]!=player); }, forced:true, popup:false, content:function(){ player.addTempSkill('noactpunish','phaseAfter'); } }, noactpunish:{}, _phasequeue:{ trigger:{player:'phaseBegin'}, forced:true, popup:false, content:function(){ var current=ui.chessinfo.querySelector('.glow2'); if(current){ current.classList.remove('glow2'); } for(var i=0;i0; }, content:function(){ "step 0" var move=player.skills.contains('noactpunish')?2:1; move=game.checkMod(player,move,'chessMove',player.get('s')); player.chooseToMove(move).phasing=true; "step 1" if(!result.bool){ player.getStat().skill._chessmove--; } }, ai:{ order:5, result:{ playerx:function(player){ var nh=player.num('h'); if(!player.num('h','sha')&& !player.num('h','shunshou')&& !player.num('h','bingliang')){ if(nh<=Math.min(3,player.hp)) return Math.random()-0.3; else if(nh<=Math.min(2,player.hp)) return Math.random()-0.4; return Math.random()-0.5; } var neighbour; neighbour=player.getNeighbour(0,1); if(neighbour&&neighbour.side!=player.side){ if(get.distance(player,neighbour,'attack')<1) return 1; return 0; } neighbour=player.getNeighbour(0,-1); if(neighbour&&neighbour.side!=player.side){ if(get.distance(player,neighbour,'attack')<1) return 1; return 0; } neighbour=player.getNeighbour(1,0); if(neighbour&&neighbour.side!=player.side){ if(get.distance(player,neighbour,'attack')<1) return 1; return 0; } neighbour=player.getNeighbour(-1,0); if(neighbour&&neighbour.side!=player.side){ if(get.distance(player,neighbour,'attack')<1) return 1; return 0; } return 1; }, player:function(player){ var x=lib.skill._chessmove.ai.result.playerx(player); if(player.isMad()) return -x; return x; } } } }, _chessswap:{ trigger:{player:['phaseBegin','chooseToUseBegin','chooseToRespondBegin','chooseToDiscardBegin','chooseToCompareBegin', 'chooseButtonBegin','chooseCardBegin','chooseTargetBegin','chooseCardTargetBegin','chooseControlBegin', 'chooseBoolBegin','choosePlayerCardBegin','discardPlayerCardBegin','gainPlayerCardBegin']}, forced:true, priority:100, popup:false, filter:function(event,player){ if(event.autochoose&&event.autochoose()) return false; return player.isUnderControl(); }, content:function(){ game.modeSwapPlayer(player); }, }, _chesscenter:{ trigger:{player:['phaseBegin','useCardBegin','useSkillBegin','respondBegin','damageBegin','loseHpBegin'], target:'useCardToBegin'}, forced:true, priority:100, popup:false, content:function(){ player.chessFocus(); }, }, boss_fengxing:{ mod:{ chessMove:function(player,current){ return current+2; }, attackFrom:function(from,to,current){ return current-2; }, }, trigger:{player:'phaseDrawBegin'}, forced:true, content:function(){ trigger.num+=2; } }, boss_chiyu:{ enable:'phaseUse', usable:1, filterCard:{color:'red'}, nodelay:true, check:function(card){return 8-ai.get.value(card);}, filterTarget:function(card,player,target){ return get.distance(player,target)<=5&&player!=target; }, filter:function(event,player){ return player.num('h',{color:'red'})>0; }, selectTarget:-1, content:function(){ target.damage('fire'); }, line:'fire', ai:{ order:1, result:{ target:function(player,target){ return ai.get.damageEffect(target,player,target,'fire'); } } } }, boss_tenglong:{ enable:'phaseUse', usable:1, position:'he', filterCard:{type:'equip'}, init:function(player){ player.forcemin=true; }, check:function(card){ var player=_status.currentPhase; if(player.num('he',{subtype:get.subtype(card)})>1){ return 12-ai.get.equipValue(card); } return 8-ai.get.equipValue(card); }, filter:function(event,player){ return player.num('he',{type:'equip'}); }, filterTarget:function(card,player,target){ return player!=target&&get.distance(player,target)<=2; }, content:function(){ target.damage(3,'fire'); }, ai:{ order:9, result:{ target:function(player,target){ return ai.get.damageEffect(target,player,target,'fire'); } } } }, boss_wuying:{ mod:{ globalTo:function(from,to,distance){ return distance+2; }, chessMove:function(player,current){ return current-1; } } }, boss_wushang:{ trigger:{player:'phaseBegin'}, forced:true, filter:function(event,player){ for(var i=0;i
  • n人对战n人的模式,由单人控制,开始游戏后随机分配位置与出牌顺序
  • '+ '每人在出牌阶段有一次移动的机会,若一名角色在移动之前使用过指定其他角色为目标的牌,该回合可移动的最大距离为2,否则最大距离为1
  • '+ '任何卡牌或技能无法指定位置相隔8个格以上的角色为目标
  • '+ '杀死对方阵营的角色可摸一张牌,杀死本方阵营无惩罚' }, config:['battle_number','ban_weak','free_choose','change_choice', function(game,lib,get,ui){ var current=get.config('chess_character'); if(typeof current!=='boolean'){ game.saveConfig('chess_character',true,true); current=true; } return ui.create.switcher('chess_character',current,ui.click.sidebar.local2); },function(game,lib,get,ui){ var current=get.config('chessscroll_speed'); if(typeof current!=='number'){ game.saveConfig('chessscroll_speed',20,true); current=20; } return ui.create.switcher('chessscroll_speed',[0,10,20,30],current,ui.click.sidebar.local); }], }