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,45 +1303,46 @@ mode.chess={
if(tafangmoved){ if(tafangmoved){
event.moved=true; event.moved=true;
} }
continue;
} }
for(var i=0;i<game.players.length;i++){ else{
if(game.players[i].side!=player.side){ var targets=[];
targets.push(game.players[i]); for(var i=0;i<game.players.length;i++){
if(game.players[i].side!=player.side){
targets.push(game.players[i]);
}
} }
} targets.sort(function(a,b){
targets.sort(function(a,b){ return get.distance(player,a)-get.distance(player,b);
return get.distance(player,a)-get.distance(player,b); });
}); while(targets.length){
while(targets.length){ var target=targets.shift();
var target=targets.shift(); var moveTowards=player.moveTowards(target,[dontMove]);
if(player.moveTowards(target)){ if(moveTowards){
event.moved=true;break; dontMove=getMove(moveTowards);
} randomMove.remove(dontMove);
if(targets.length==0){ event.moved=true;break;
if(randomMove.length){ }
var list=randomMove.slice(0); if(targets.length==0){
while(list.length){ if(randomMove.length){
var thismove=list.randomRemove(); var list=randomMove.slice(0);
if(player[thismove]()){ while(true){
event.moved=true; var thismove=list.randomRemove();
switch(thismove){ if(player[thismove]()){
case 'moveUp':randomMove.remove('moveDown');break; event.moved=true;
case 'moveDown':randomMove.remove('moveUp');break; dontMove=getMove(thismove);
case 'moveLeft':randomMove.remove('moveRight');break; randomMove.remove(dontMove);
case 'moveRight':randomMove.remove('moveLeft');break; break;
} }
break; if(list.length==0) return;
} }
} }
if(!event.moved) return; else{
} return;
else{ }
return;
} }
} }
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()){