'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.create.cards(); ui.chessinfo=ui.create.div('.fakeme.player',ui.me); game.finishCards(); game.arrangePlayers(); "step 2" var p; 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; }, 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;i1; 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){ return range?1:0; } neighbour=player.getNeighbour(0,-1); if(neighbour&&neighbour.side!=player.side){ return range?1:0; } neighbour=player.getNeighbour(1,0); if(neighbour&&neighbour.side!=player.side){ return range?1:0; } neighbour=player.getNeighbour(-1,0); if(neighbour&&neighbour.side!=player.side){ return range?1:0; } return 1; } } } }, _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(); }, }, }, translate:{ friend:'友', enemy:'敌', trueColor:"zhu", falseColor:"wei", _chessmove:'移动', chessscroll_speed_config:'边缘滚动速度', chess_character_config:'战棋武将', only_chess_character_config:'只用战棋武将', chess_caocao:'曹操', chess_xunyu:'荀彧', chess_simayi:'司马懿', chess_xiahoudun:'夏侯惇', chess_dianwei:'典韦', chess_xuzhu:'许褚', chess_zhangliao:'张辽', chess_jiaxu:'贾诩', chess_liubei:'刘备', chess_guanyu:'关羽', chess_zhangfei:'张飞', chess_zhaoyun:'赵云', chess_machao:'马超', chess_huangzhong:'黄忠', chess_maliang:'马良', chess_zhugeliang:'诸葛亮', chess_sunquan:'孙权', chess_zhouyu:'周瑜', chess_lvmeng:'吕蒙', chess_huanggai:'黄盖', chess_lusu:'鲁肃', chess_luxun:'陆逊', chess_ganning:'甘宁', chess_taishici:'太史慈', chess_lvbu:'吕布', chess_sunshangxiang:'孙尚香', chess_diaochan:'貂蝉', chess_huatuo:'华佗', chess_zhangjiao:'张辽', chess_menghuo:'孟获', chess_dongzhuo:'董卓', chess_jinchidiao:'金翅雕', chess_beimingjukun:'北溟巨鲲', chess_wuzhaojinlong:'五爪金龙', pianyi:'翩仪', pianyi_info:'回合结束阶段,若你没有于本回合内造成伤害,你获得一次移动机会', lingdong:'灵动', lingdong_info:'回合结束阶段,你可以移动X个格,X为你回合内出杀的次数', lianshe:'连射', lianshe_info:'你的攻击范围+1;回合内,你回合内,每当你使用一张不是杀的牌,你可以额外使用一张杀', zhiming:'致命', zhiming_info:'锁定技,当你使用杀造成伤害时,若你不在目标的攻击范围内,此伤害+1', sanjiansheji:'散箭', sanjiansheji_info:'你可以将两张杀当杀使用,此杀可以指定距离你5格以内任意名目标', guanchuan:'贯穿', guanchuan_info:'当你使用杀指定惟一的目标后,可将攻击射线内的其他角色也加入目标', }, ui:{ create:{ playergrid:function(player,x,y){ var node=ui.create.div('.player.minskin.playergrid',player.parentNode); node.link=player; node.dataset.position=player.getDataPos(x,y); return node; }, fakeme:function(){ if(ui.fakeme){ ui.fakeme.delete(); } ui.fakeme=ui.create.div('.fakeme.avatar',ui.me); ui.fakeme.style.backgroundImage=game.me.node.avatar.style.backgroundImage; } }, click:{ playergrid:function(){ if(!_status.paused) return; delete lib.posmap[this.link.dataset.position]; this.link.dataset.position=this.dataset.position; lib.posmap[this.link.dataset.position]=this.link; if(ui.movegrids){ while(ui.movegrids.length){ ui.movegrids.shift().delete(); } } _status.event.result={ bool:true, move:this.link.dataset.position }; game.resume(); } } }, ai:{ get:{ attitude:function(from,to){ return (from.side==to.side?1:-1)*5; } } }, chess_character:{ // chess_caocao:['male','wei',3,['']], // chess_xunyu:['male','wei',3,['']], // chess_simayi:['male','wei',3,['']], // chess_xiahoudun:['male','wei',3,['']], // chess_dianwei:['male','wei',3,['']], // chess_xuzhu:['male','wei',3,['']], chess_zhangliao:['male','wei',4,['gongji','zhiming']], // chess_jiaxu:['male','wei',3,['']], // // chess_liubei:['male','shu',3,['']], // chess_guanyu:['male','shu',3,['']], // chess_zhangfei:['male','shu',3,['']], // chess_zhaoyun:['male','shu',3,['']], // chess_machao:['male','shu',3,['']], chess_huangzhong:['male','shu',4,['sanjiansheji','liegong']], // chess_maliang:['male','shu',3,['']], // chess_zhugeliang:['male','shu',3,['']], // // chess_sunquan:['male','wu',3,['']], // chess_zhouyu:['male','wu',3,['qinyin']], // chess_lvmeng:['male','wu',3,['']], // chess_huanggai:['male','wu',3,['']], // chess_lusu:['male','wu',3,['']], // chess_luxun:['male','wu',3,['']], // chess_ganning:['male','wu',3,['']], chess_taishici:['male','wu',4,['guanchuan','pojun']], // // chess_lvbu:['male','qun',3,['']], chess_sunshangxiang:['female','wu',3,['lingdong','lianshe']], chess_diaochan:['female','qun',3,['xingzhui','pianyi']], chess_huatuo:['male','qun',3,['zhenjiu','mazui']], // chess_zhangjiao:['male','qun',3,['']], // chess_menghuo:['male','qun',3,['']], // // chess_dongzhuo:['male','qun',3,['']], // chess_xingtian:['male','qun',3,['']], // chess_jinchidiao:['male','qun',3,['']], // chess_beimingjukun:['male','qun',3,['']], // chess_wuzhaojinlong:['male','qun',3,['']], }, posmap:{}, help:{ '战棋模式':'
  • 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); 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); }], }