Add lib.element.player.executeDelayCardEffect.

This commit is contained in:
Tipx-L 2023-09-04 04:43:51 -07:00
parent 65463a0b62
commit 8a785b89c6
5 changed files with 104 additions and 71 deletions

View File

@ -932,7 +932,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},
translate:{
jiu:'酒',
jiu_info:'①每回合限一次。出牌阶段,对你自己使用。目标角色使用的下一张【杀】的伤害值基数+1。②当你处于濒死状态时对你自己使用。目标角色回复1点体力。',
jiu_info:'①每回合限一次。出牌阶段,对你自己使用。本回合目标角色使用的下一张【杀】的伤害值基数+1。②当你处于濒死状态时对你自己使用。目标角色回复1点体力。',
huogong:'火攻',
tiesuo:'铁索连环',
tiesuo_info:'此牌可被重铸。出牌阶段,对至多两名角色使用。目标角色横置。',

View File

@ -285,7 +285,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var info=get.info(skill);
if(info.charlotte) return false;
var translation=get.skillInfoTranslation(skill,event.player);
if(!translation||!(/(?<!“)出牌阶段限一次/.test(translation))) return false;
if(!translation||translation.match(/“?出牌阶段限一次/g).every(value=>value!='出牌阶段限一次')) return false;
return event.player.countCards('h')>0;
},
check:function(event,player){
@ -1727,34 +1727,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return true;
},
content:function(){
'step 0'
event.judgestr=get.translation('shandian');
player.judge(lib.card.shandian.judge,event.judgestr).judge2=lib.card.shandian.judge2;
game.delayx(1.5);
'step 1'
var name='shandian';
if(event.cancelled&&!event.direct){
if(lib.card[name].cancel){
var next=game.createEvent(name+'Cancel');
next.setContent(lib.card[name].cancel);
next.cards=[];
next.card=get.autoViewAs({name:name});
next.player=player;
}
}
else{
var next=game.createEvent(name);
next.setContent(function(){
if(result.bool==false){
player.damage(3,'thunder','nosource');
}
});
next._result=result;
next.cards=[];
next.card=get.autoViewAs({name:name});
next.player=player;
}
'step 2'
player.executeDelayCardEffect('shandian');
trigger.player.drawTo(4);
},
ai:{expose:0.25}
@ -2366,7 +2339,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
clanyunshen:'熨身',
clanyunshen_info:'出牌阶段限一次。你可以令一名其他角色回复1点体力然后选择一项1.你视为对其使用一张冰【杀】2.其视为对你使用一张冰【杀】。',
clanshangshen:'伤神',
clanshangshen_info:'当一名角色受到属性伤害后,若本回合此前没有角色或已死亡的角色受到过属性伤害,你可以进行目标角色为你的【闪电】的特殊的使用流程,然后其将手牌摸至四张。',
clanshangshen_info:'当一名角色受到属性伤害后,若本回合此前没有角色或已死亡的角色受到过属性伤害,你可以执行目标角色为你的【闪电】效果,然后其将手牌摸至四张。',
clanfenchai:'分钗',
clanfenchai_info:'锁定技。若你首次发动技能指定的异性目标角色中:存在存活角色,你的判定牌视为♥;不存在存活角色,你的判定牌视为♠。',
clan_hanshao:'族韩韶',

View File

@ -1249,7 +1249,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
(used.length?('(你不能以此法令其'+reason+get.translation(used)+''):'')+'?若如此做,你摸一张牌并令〖称贤〗此阶段可发动次数上限+1。';
event.str=str;
if(!listx.length) event.finish();
if(listx.length==1) event._result={bool:true,links:listx};
else if(listx.length==1) event._result={bool:true,links:listx};
else{
event.asked=true;
player.chooseButton([
@ -4019,6 +4019,13 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
jsrglinghua:{
audio:2,
locked:false,
mod:{
judge:(player,result)=>{
const parent=_status.event.getParent(2);
if(parent.name=='jsrglinghua'&&parent.triggername=='phaseJieshuBegin') result.bool=!result.bool;
}
},
trigger:{
player:['phaseZhunbeiBegin','phaseJieshuBegin'],
},
@ -4041,39 +4048,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
content:function(){
'step 0'
var judge=trigger.name=='phaseZhunbei'?lib.card.shandian.judge:function(card){
if(get.suit(card)!='spade'||get.number(card)<=1||get.number(card)>=10) return -5;
return 1;
}
player.judge(judge,get.translation('shandian')).set('judge2',lib.card.shandian.judge2);
game.delayx(1.5);
event.executeDelayCardEffect=player.executeDelayCardEffect('shandian');
'step 1'
var name='shandian';
if(event.cancelled&&!event.direct){
if(lib.card[name].cancel){
var next=game.createEvent(name+'Cancel');
next.setContent(lib.card[name].cancel);
next.cards=[];
next.card=get.autoViewAs({name:name});
next.player=player;
}
}
else{
var next=game.createEvent(name);
next.setContent(function(){
if(result.bool==false){
player.damage(3,'thunder','nosource');
}
});
next._result=result;
next.cards=[];
next.card=get.autoViewAs({name:name});
next.player=player;
}
'step 2'
if(!player.hasHistory('damage',evt=>{
return evt.card&&evt.card.name=='shandian'&&evt.getParent(2)==event;
})){
var executeDelayCardEffect=event.executeDelayCardEffect;
if(!player.hasHistory('damage',evt=>evt.getParent(2)==executeDelayCardEffect)){
if(trigger.name=='phaseZhunbei'){
player.chooseTarget('灵化是否令一名角色回复1点体力').set('ai',target=>{
var player=_status.event.player;
@ -4088,7 +4066,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
}
else event.finish();
'step 3'
'step 2'
if(result.bool){
var target=result.targets[0];
player.line(target);
@ -4214,7 +4192,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
jsrgxundao:'寻道',
jsrgxundao_info:'当你的判定牌生效前,你可以令至多两名角色依次弃置一张牌,然后你选择一张以此法弃置且位于弃牌堆中的牌代替此判定牌。',
jsrglinghua:'灵化',
jsrglinghua_info:'①准备阶段,你可以进行目标角色为你的【闪电】的特殊的使用流程。若你未因此受到伤害你可以令一名角色回复1点体力。②结束阶段你可以进行目标角色为你且判定效果反转的【闪电】的特殊的使用流程。若你未因此受到伤害你可以对一名角色造成1点雷电伤害。',
jsrglinghua_info:'①准备阶段,你可以执行目标角色为你的【闪电】效果。若你未因此受到伤害你可以令一名角色回复1点体力。②结束阶段你可以执行目标角色为你且判定效果反转的【闪电】效果。若你未因此受到伤害你可以对一名角色造成1点雷电伤害。',
sbyingmen:'盈门',
sbyingmen_info:'锁定技。①游戏开始时你将武将牌堆中随机四张武将牌置于你的武将牌上称为“访客”。②回合开始时若你的“访客”数小于4你随机从武将牌堆中将“访客”补至四张。',
sbpingjian:'评鉴',

View File

@ -386,8 +386,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
audio:2,
trigger:{global:'phaseEnd'},
filter:function(event,player){
var zhu=game.filterPlayer(i=>i.getSeatNum()==1)[0];
return player.hasSkill('shiming_round')&&(game.getGlobalHistory('changeHp',evt=>{
var zhu=game.findPlayer(i=>i.getSeatNum()==1);
return zhu&&player.hasSkill('shiming_round')&&(game.getGlobalHistory('changeHp',evt=>{
return evt.player==zhu&&evt._dyinged;
}).length>0||zhu.getHistory('damage').length==0)||!game.hasPlayer2(current=>current.getHistory('damage').length>0);
},
@ -395,7 +395,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
content:function(){
'step 0'
if(player.hasSkill('shiming_round')){
var zhu=game.filterPlayer(i=>i.getSeatNum()==1)[0];
var zhu=game.findPlayer(i=>i.getSeatNum()==1);
if(game.getGlobalHistory('changeHp',evt=>{
return evt.player==zhu&&evt._dyinged;
}).length>0||zhu.getHistory('damage').length==0){

View File

@ -9955,7 +9955,7 @@
parsex:function(func){
//Remove all comments
//移除所有注释
var str=func.toString().replace(/((?:(?:^[ \t]*)?(?:\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/(?:[ \t]*\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/)))?|\/\/(?:[^\\]|\\(?:\r?\n)?)*?(?:\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/))|(?=\r?\n))))+)|("(?:\\[\S\s]|[^"\\])*"|'(?:\\[\S\s]|[^'\\])*'|(?:\r?\n|[\S\s])[^\/"'\\\s]*)/mg,'$2').trim();
var str=func.toString().replace(/((?:(?:^[ \t]*)?(?:\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/(?:[ \t]*\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/)))?|\/\/(?:[^\\]|\\(?:\r?\n)?)*?(?:\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/))|(?=\r?\n))))+)|("(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|(?:\r?\n|[\s\S])[^\/"'\\\s]*)/mg,'$2').trim();
//获取第一个 { 后的所有字符
str=str.slice(str.indexOf('{')+1);
//func中要写步骤的话必须要写step 0
@ -10937,6 +10937,69 @@
emptyEvent:function(){
event.trigger(event.name);
},
//Execute the delay card effect
//执行延时锦囊牌效果
executeDelayCardEffect:()=>{
'step 0'
target.$phaseJudge(card);
event.cancelled=false;
event.trigger('executeDelayCardEffect');
event.cardName=card.viewAs||card.name;
target.popup(event.cardName,'thunder');
if(!lib.card[event.cardName].effect){
game.delay();
event.finish();
}
else if(!lib.card[event.cardName].judge){
game.delay();
event.nojudge=true;
}
'step 1'
if(!event.cancelled&&!event.nojudge) player.judge(card);
'step 2'
if(event.excluded) delete event.excluded;
else{
const cardName=event.cardName;
if(event.cancelled&&!event.direct){
const cardCancel=lib.card[cardName].cancel;
if(cardCancel){
const next=game.createEvent(`${cardName}Cancel`);
next.setContent(cardCancel);
next.cards=[card];
if(!card.viewAs){
const autoViewAs=next.card=get.autoViewAs(card);
autoViewAs.expired=card.expired;
}
else{
const autoViewAs=next.card=get.autoViewAs({
name:cardName
},next.cards);
autoViewAs.expired=card.expired;
}
next.player=player;
}
}
else{
const next=game.createEvent(cardName);
next.setContent(lib.card[cardName].effect);
next._result=result;
next.cards=[card];
if(!card.viewAs){
const autoViewAs=next.card=get.autoViewAs(card);
autoViewAs.expired=card.expired;
}
else{
const autoViewAs=next.card=get.autoViewAs({
name:cardName
},next.cards);
autoViewAs.expired=card.expired;
}
next.player=player;
}
}
ui.clear();
card.delete();
},
//Gift
//赠予
gift:()=>{
@ -18709,6 +18772,25 @@
},
player:{
//新函数
//Execute the delay card effect
//执行延时锦囊牌效果
executeDelayCardEffect:function(card,target){
const executeDelayCardEffect=game.createEvent('executeDelayCardEffect');
executeDelayCardEffect.player=this;
executeDelayCardEffect.target=target||this;
if(typeof card=='string'){
const virtualCard=executeDelayCardEffect.card=ui.create.card();
virtualCard._destroy=true;
virtualCard.expired=true;
const info=lib.card[card];
virtualCard.init(['','',card,info&&info.cardnature]);
}
else if(get.itemtype(card)=='card') executeDelayCardEffect.card=card;
else _status.event.next.remove(executeDelayCardEffect);
executeDelayCardEffect.setContent('executeDelayCardEffect');
executeDelayCardEffect._args=Array.from(arguments);
return executeDelayCardEffect;
},
//Check if the card does not count toward hand limit
//检测此牌是否不计入手牌上限
canIgnoreHandcard:function(card){
@ -27863,7 +27945,6 @@
return this._tempCache[key1][key2];
},
cancel:function(arg1,arg2,notrigger){
if(typeof arg1=='undefined') arg1=true;
this.untrigger(arg1,arg2);
this.finish();
if(notrigger!='notrigger'){
@ -28426,6 +28507,7 @@
}
},
untrigger:function(all,player){
if(typeof all=='undefined') all=true;
var evt=this._triggering;
if(all){
if(evt&&evt.map){