This commit is contained in:
shijian 2023-09-18 13:07:46 +08:00
parent b33f84f0e5
commit 2094e90cec
1 changed files with 15 additions and 16 deletions

View File

@ -19171,8 +19171,9 @@
}, },
}, },
player:{ player:{
//新函数
/** /**
* version 1.2 * version 1.3
* *
* 链式创建一次性技能的api * 链式创建一次性技能的api
* *
@ -19186,10 +19187,13 @@
skillName='player_when_'+Math.random().toString(36).slice(-8); skillName='player_when_'+Math.random().toString(36).slice(-8);
} }
var skill={ var skill={
trigger:{player:triggerNames},
forced:true, forced:true,
charlotte:true, charlotte:true,
popup:false, popup:false,
filterFuns:[], filterFuns:[(event, player, name) => {
return !name||(triggerNames.includes(name)&&event.player==player);
}],
contentFuns:[], contentFuns:[],
get filter(){ get filter(){
return function(event, player, name){ return function(event, player, name){
@ -19201,12 +19205,9 @@
} }
}, },
}; };
skill.trigger={player:triggerNames};
skill.filterFuns.push((event, player, name) => {
return !name||(triggerNames.includes(name)&&event.player==player);
});
Object.defineProperty(lib.skill,skillName,{ Object.defineProperty(lib.skill,skillName,{
configurable:true, configurable:true,
//这类技能不需要被遍历到
enumerable:false, enumerable:false,
writable:true, writable:true,
value:skill value:skill
@ -19214,25 +19215,24 @@
this.addSkill(skillName); this.addSkill(skillName);
return{ return{
filter(fun){ filter(fun){
if(!lib.skill[skillName]) throw `This skill has been destroyed`; if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
skill.filterFuns.push(fun); skill.filterFuns.push(fun);
return this; return this;
}, },
removeFilter(fun){ removeFilter(fun){
if(!lib.skill[skillName]) throw `This skill has been destroyed`; if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
skill.filterFuns.remove(fun); skill.filterFuns.remove(fun);
return this; return this;
}, },
then(fun){ then(fun){
if(!lib.skill[skillName]) throw `This skill has been destroyed`; if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
skill.contentFuns.push(fun); skill.contentFuns.push(fun);
var str=` var str=`
function content(){ function content(){
if(event.triggername=='${skillName}After'){ if(event.triggername=='${skillName}After'){
player.removeSkill('${skillName}'); player.removeSkill('${skillName}');
delete lib.skill['${skillName}']; delete lib.skill['${skillName}'];
delete lib.translate['${skillName}'] delete lib.translate['${skillName}'];
console.log('remove ${skillName}');
return event.finish(); return event.finish();
} }
`; `;
@ -19247,23 +19247,22 @@
return this; return this;
}, },
popup(str){ popup(str){
if(!lib.skill[skillName]) throw `This skill has been destroyed`; if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
if(typeof str=='string') skill.popup=str; if(typeof str=='string') skill.popup=str;
return this; return this;
}, },
translation(translation){ translation(translation){
if(!lib.skill[skillName]) throw `This skill has been destroyed`; if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
if(typeof translation=='string') lib.translate[skillName]=translation; if(typeof translation=='string') lib.translate[skillName]=translation;
return this; return this;
}, },
assgin(obj) { assgin(obj) {
if(!lib.skill[skillName]) throw `This skill has been destroyed`; if(lib.skill[skillName]!=skill) throw `This skill has been destroyed`;
if(typeof obj=='object'&&obj!==null) Object.assign(skill,obj); if(typeof obj=='object'&&obj!==null) Object.assign(skill,obj);
return this; return this;
} }
}; };
}, },
//新函数
//让一名角色明置一些手牌 //让一名角色明置一些手牌
addShownCards:function(){ addShownCards:function(){
const cards=[]; const cards=[];
@ -19908,7 +19907,7 @@
}, },
removeGaintag:function(tag,cards){ removeGaintag:function(tag,cards){
cards=cards||this.getCards('h'); cards=cards||this.getCards('h');
game.addVideo('removeGaintag',this,[tag,cards]); game.addVideo('removeGaintag',this,[tag,get.cardsInfo(cards)]);
game.broadcastAll(function(player,tag,cards){ game.broadcastAll(function(player,tag,cards){
for(var i of cards) i.removeGaintag(tag); for(var i of cards) i.removeGaintag(tag);
},this,tag,cards); },this,tag,cards);