修改card.destroyed

This commit is contained in:
Spmario233 2023-10-28 14:27:13 +08:00
parent ce9ecf3d7b
commit 1509e50121
3 changed files with 49 additions and 54 deletions

View File

@ -696,7 +696,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
}); });
}, },
mode:['guozhan'], mode:['guozhan'],
global:['g_chiling1','g_chiling2','g_chiling3'], //global:['g_chiling1','g_chiling2','g_chiling3'],
filterTarget:function(card,player,target){ filterTarget:function(card,player,target){
return target.isUnseen(); return target.isUnseen();
}, },
@ -754,6 +754,27 @@ game.import('card',function(lib,game,ui,get,ai,_status){
} }
target.draw(); target.draw();
}, },
destroy:function(card,targetPosition,player,event){
if(event.name!='lose'||event.name!='cardsDiscard'||targetPosition!='discardPile') return false;
var evt=event.getParent().relatedEvent;
if(evt&&evt.name=='useCard') return false;
return true;
},
onDestroy:function(){
var currentPhase=_status.currentPhase;
if(currentPhase){
_status.chiling=true;
currentPhase.addTempSkill('g_chiling3');
}
if(!lib.inpile.contains('zhaoshu')){
lib.inpile.push('zhaoshu');
var card=game.createCard2('zhaoshu','club',3);
game.log(card,'被置于了牌堆底');
ui.cardPile.appendChild(card);
game.updateRoundNumber();
}
},
ai:{ ai:{
order:6, order:6,
result:{ result:{
@ -1570,50 +1591,9 @@ game.import('card',function(lib,game,ui,get,ai,_status){
} }
}, },
}, },
g_chiling1:{
mode:['guozhan'],
trigger:{
player:'loseEnd',
global:'cardsDiscardEnd',
},
filter:function(event,player){
var evt=event.getParent().relatedEvent;
if(evt&&evt.name=='useCard') return false;
for(var i=0;i<event.cards.length;i++){
if(event.cards[i].name=='chiling'&&get.position(event.cards[i],true)=='d'){
return true;
}
}
return false;
},
forced:true,
popup:false,
content:function(){
var cards=[];
for(var i=0;i<trigger.cards.length;i++){
if(trigger.cards[i].name=='chiling'&&get.position(trigger.cards[i],true)=='d'){
cards.push(trigger.cards[i]);
}
}
if(cards.length){
game.cardsGotoSpecial(cards);
game.log(cards,'已被移出游戏');
_status.chiling=true;
if(player&&player.popup) player.popup('敕令');
}
if(!lib.inpile.contains('zhaoshu')){
lib.inpile.push('zhaoshu');
var card=game.createCard2('zhaoshu','club',3);
game.log(card,'被置于了牌堆底');
ui.cardPile.appendChild(card);
game.updateRoundNumber();
}
},
},
g_chiling2:{},
g_chiling3:{ g_chiling3:{
mode:['guozhan'], mode:['guozhan'],
trigger:{player:'phaseAfter'}, trigger:{player:'phaseEnd'},
forced:true, forced:true,
popup:false, popup:false,
filter:function(){ filter:function(){

View File

@ -77,7 +77,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(typeof count!='number') count=1; if(typeof count!='number') count=1;
while(count--){ while(count--){
let card=game.createCard('ying','spade',1); let card=game.createCard('ying','spade',1);
card.destroyed='discardPile';
cards.push(card); cards.push(card);
} }
return cards; return cards;

View File

@ -8395,9 +8395,10 @@
var that=this; var that=this;
this.timeout=setTimeout(function(){ this.timeout=setTimeout(function(){
if(!that.destroyed){ if(!that._selfDestroyed){
position.appendChild(that); position.appendChild(that);
} }
else that.remove();
that.classList.remove('removing'); that.classList.remove('removing');
delete that.destiny; delete that.destiny;
},time); },time);
@ -12745,6 +12746,7 @@
return; return;
} }
if(card.willBeDestroyed('equip',player,event)){ if(card.willBeDestroyed('equip',player,event)){
card.selfDestroy(event);
event.finish(); event.finish();
return; return;
} }
@ -13719,7 +13721,7 @@
var withPile=false; var withPile=false;
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
if(cards[i].willBeDestroyed('discardPile',null,event)){ if(cards[i].willBeDestroyed('discardPile',null,event)){
cards[i].remove(); cards[i].selfDestroy(event);
continue; continue;
} }
if(get.position(cards[i],true)=='c') withPile=true; if(get.position(cards[i],true)=='c') withPile=true;
@ -13739,7 +13741,7 @@
var withPile=false; var withPile=false;
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
if(cards[i].willBeDestroyed('ordering',null,event)){ if(cards[i].willBeDestroyed('ordering',null,event)){
cards[i].remove(); cards[i].selfDestroy(event);
continue; continue;
} }
if(get.position(cards[i],true)=='c') withPile=true; if(get.position(cards[i],true)=='c') withPile=true;
@ -13762,7 +13764,7 @@
var withPile=false; var withPile=false;
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
if(cards[i].willBeDestroyed('special',null,event)){ if(cards[i].willBeDestroyed('special',null,event)){
cards[i].remove(); cards[i].selfDestroy(event);
continue; continue;
} }
if(get.position(cards[i],true)=='c') withPile=true; if(get.position(cards[i],true)=='c') withPile=true;
@ -19264,6 +19266,7 @@
"step 1" "step 1"
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
if(cards[i].willBeDestroyed('handcard',player,event)){ if(cards[i].willBeDestroyed('handcard',player,event)){
cards[i].selfDestroy(event);
cards.splice(i--,1); cards.splice(i--,1);
} }
else if(event.losing_map){ else if(event.losing_map){
@ -19458,6 +19461,7 @@
"step 1" "step 1"
for(var i=0;i<cards.length;i++){ for(var i=0;i<cards.length;i++){
if(cards[i].willBeDestroyed('expansion',player,event)){ if(cards[i].willBeDestroyed('expansion',player,event)){
cards[i].selfDestroy(event);
cards.splice(i--,1); cards.splice(i--,1);
} }
else if(event.losing_map){ else if(event.losing_map){
@ -19680,8 +19684,7 @@
} }
else if(cards[i].hasOwnProperty('destroyed')){ else if(cards[i].hasOwnProperty('destroyed')){
if(event.getlx!==false&&event.position&&cards[i].willBeDestroyed(event.position.id,null,event)){ if(event.getlx!==false&&event.position&&cards[i].willBeDestroyed(event.position.id,null,event)){
cards[i].delete(); cards[i].selfDestroy(event);
continue;
} }
} }
else if(info.destroy){ else if(info.destroy){
@ -20348,6 +20351,7 @@
} }
"step 1" "step 1"
if(cards[0].willBeDestroyed('judge',player,event)){ if(cards[0].willBeDestroyed('judge',player,event)){
cards[0].selfDestroy(event);
event.finish(); event.finish();
return; return;
} }
@ -29980,6 +29984,17 @@
buildIntro(noclick){ buildIntro(noclick){
if(!noclick) lib.setIntro(this); if(!noclick) lib.setIntro(this);
} }
//执行销毁一张牌的钩子函数
selfDestroy(event){
if(this._selfDestroyed) return;
this._selfDestroyed=true;
this.fix();
this.delete();
const info=get.info(this,false);
if(!info) return;
if(info.destroyLog!==false) game.log(this,'被销毁了');
if(info.onDestroy) info.onDestroy(this,event);
}
//判断一张牌进入某个区域后是否会被销毁 //判断一张牌进入某个区域后是否会被销毁
willBeDestroyed(targetPosition,player,event){ willBeDestroyed(targetPosition,player,event){
const destroyed=this.destroyed; const destroyed=this.destroyed;
@ -30142,6 +30157,10 @@
this.number=parseInt(card[1])||0; this.number=parseInt(card[1])||0;
this.name=card[2]; this.name=card[2];
if(info.destroy&&(typeof info.destroy!='boolean'&&!lib.skill[info.destroy])){
this.destroyed=info.destroy;
}
if(_status.connectMode&&!game.online&&lib.cardOL&&!this.cardid){ if(_status.connectMode&&!game.online&&lib.cardOL&&!this.cardid){
this.cardid=get.id(); this.cardid=get.id();
lib.cardOL[this.cardid]=this; lib.cardOL[this.cardid]=this;
@ -30608,9 +30627,6 @@
if(this._uncheck.length==0) this.classList.remove('uncheck'); if(this._uncheck.length==0) this.classList.remove('uncheck');
} }
discard(bool){ discard(bool){
if(!this.willBeDestroyed('discardPile',null,event)){
ui.discardPile.appendChild(this);
}
this.fix(); this.fix();
this.classList.remove('glow'); this.classList.remove('glow');
if(bool===false){ if(bool===false){
@ -36384,7 +36400,7 @@
const pile=ui.cardPile; const pile=ui.cardPile;
for(let i=0;i<cards.length;i++){ for(let i=0;i<cards.length;i++){
if(cards[i].willBeDestroyed('cardPile',null,event)){ if(cards[i].willBeDestroyed('cardPile',null,event)){
cards[i].remove(); cards[i].selfDestroy(event);
continue; continue;
} }
if(event.insert_index){ if(event.insert_index){