This commit is contained in:
libccy 2017-01-25 12:59:12 +08:00
parent 7134ce0224
commit 2c66d5a57e
3 changed files with 62 additions and 51 deletions

View File

@ -93,6 +93,7 @@ card.swd={
shencaojie:{ shencaojie:{
fullskin:true, fullskin:true,
type:'trick', type:'trick',
nodelay:true,
content:function(){ content:function(){
event.getParent('_shencaojie')._trigger.num++; event.getParent('_shencaojie')._trigger.num++;
}, },

View File

@ -7803,7 +7803,7 @@
next.target.animate('target'); next.target.animate('target');
} }
} }
if(event.animate!=false||num>0){ if(!info.nodelay&&(event.animate!=false||num>0)){
if(num==0){ if(num==0){
if(event.delayx!==false){ if(event.delayx!==false){
if(event.waitingForTransition){ if(event.waitingForTransition){
@ -33937,7 +33937,7 @@
result:function(item,skill){ result:function(item,skill){
var result; var result;
var info=get.info(item); var info=get.info(item);
if(info.ai) result=info.ai.result; if(info.ai) result=get.copy(info.ai.result);
if(typeof(result)=='function') result=result(item); if(typeof(result)=='function') result=result(item);
if(!result) result={}; if(!result) result={};
if(skill){ if(skill){

View File

@ -629,7 +629,7 @@ mode.chess={
if(dy>0&&this.movable(0,1)) return true; if(dy>0&&this.movable(0,1)) return true;
return false; return false;
}, },
moveTowards:function(target){ moveTowards:function(target,forbid){
var fxy=this.getXY(); var fxy=this.getXY();
var txy; var txy;
if(Array.isArray(target)){ if(Array.isArray(target)){
@ -644,55 +644,56 @@ mode.chess={
} }
var dx=txy[0]-fxy[0]; var dx=txy[0]-fxy[0];
var dy=txy[1]-fxy[1]; var dy=txy[1]-fxy[1];
forbid=forbid||[];
if(Math.abs(dx)>Math.abs(dy)){ if(Math.abs(dx)>Math.abs(dy)){
if(dx<0){ if(dx<0){
if(this.movable(-1,0)){ if(!forbid.contains('moveLeft')&&this.movable(-1,0)){
this.moveLeft(); this.moveLeft();
return true; return 'moveLeft';
} }
} }
else if(dx>0){ else if(dx>0){
if(this.movable(1,0)){ if(!forbid.contains('moveRight')&&this.movable(1,0)){
this.moveRight(); this.moveRight();
return true; return 'moveRight';
} }
} }
if(dy<0){ if(dy<0){
if(this.movable(0,-1)){ if(!forbid.contains('moveUp')&&this.movable(0,-1)){
this.moveUp(); this.moveUp();
return true; return 'moveUp';
} }
} }
else if(dy>0){ else if(dy>0){
if(this.movable(0,1)){ if(!forbid.contains('moveDown')&&this.movable(0,1)){
this.moveDown(); this.moveDown();
return true; return 'moveDown';
} }
} }
} }
else{ else{
if(dy<0){ if(dy<0){
if(this.movable(0,-1)){ if(!forbid.contains('moveUp')&&this.movable(0,-1)){
this.moveUp(); this.moveUp();
return true; return 'moveUp';
} }
} }
else if(dy>0){ else if(dy>0){
if(this.movable(0,1)){ if(!forbid.contains('moveDown')&&this.movable(0,1)){
this.moveDown(); this.moveDown();
return true; return 'moveDown';
} }
} }
if(dx<0){ if(dx<0){
if(this.movable(-1,0)){ if(!forbid.contains('moveLeft')&&this.movable(-1,0)){
this.moveLeft(); this.moveLeft();
return true; return 'moveLeft';
} }
} }
else if(dx>0){ else if(dx>0){
if(this.movable(1,0)){ if(!forbid.contains('moveRight')&&this.movable(1,0)){
this.moveRight(); this.moveRight();
return true; return 'moveRight';
} }
} }
} }
@ -1271,8 +1272,16 @@ mode.chess={
} }
var list=[]; var list=[];
var randomMove=['moveUp','moveDown','moveLeft','moveRight']; var randomMove=['moveUp','moveDown','moveLeft','moveRight'];
var getMove=function(move){
switch(move){
case 'moveUp':return 'moveDown';
case 'moveDown':return 'moveUp';
case 'moveLeft':return 'moveRight';
case 'moveRight':return 'moveLeft';
}
}
var dontMove=null;
for(var iwhile=0;iwhile<num;iwhile++){ for(var iwhile=0;iwhile<num;iwhile++){
var targets=[];
if(get.mode()=='tafang'&&_status.enemies.contains(player)){ if(get.mode()=='tafang'&&_status.enemies.contains(player)){
var targets2=[]; var targets2=[];
for(var i=0;i<ui.chesswidth;i++){ for(var i=0;i<ui.chesswidth;i++){
@ -1294,8 +1303,9 @@ mode.chess={
if(tafangmoved){ if(tafangmoved){
event.moved=true; event.moved=true;
} }
continue;
} }
else{
var targets=[];
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){
if(game.players[i].side!=player.side){ if(game.players[i].side!=player.side){
targets.push(game.players[i]); targets.push(game.players[i]);
@ -1306,26 +1316,25 @@ mode.chess={
}); });
while(targets.length){ while(targets.length){
var target=targets.shift(); var target=targets.shift();
if(player.moveTowards(target)){ var moveTowards=player.moveTowards(target,[dontMove]);
if(moveTowards){
dontMove=getMove(moveTowards);
randomMove.remove(dontMove);
event.moved=true;break; event.moved=true;break;
} }
if(targets.length==0){ if(targets.length==0){
if(randomMove.length){ if(randomMove.length){
var list=randomMove.slice(0); var list=randomMove.slice(0);
while(list.length){ while(true){
var thismove=list.randomRemove(); var thismove=list.randomRemove();
if(player[thismove]()){ if(player[thismove]()){
event.moved=true; event.moved=true;
switch(thismove){ dontMove=getMove(thismove);
case 'moveUp':randomMove.remove('moveDown');break; randomMove.remove(dontMove);
case 'moveDown':randomMove.remove('moveUp');break;
case 'moveLeft':randomMove.remove('moveRight');break;
case 'moveRight':randomMove.remove('moveLeft');break;
}
break; break;
} }
if(list.length==0) return;
} }
if(!event.moved) return;
} }
else{ else{
return; return;
@ -1334,6 +1343,7 @@ mode.chess={
} }
if(lib.skill._chessmove.ai.result.player(player)<=0) break; if(lib.skill._chessmove.ai.result.player(player)<=0) break;
} }
}
}; };
if(event.isMine()){ if(event.isMine()){
if(event.prompt){ if(event.prompt){