tempSkills参数归一化

This commit is contained in:
kuangshen04 2023-11-14 16:50:26 +08:00
parent 42147bc131
commit 943c0a3b7c
2 changed files with 25 additions and 45 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
ehthumbs.db
Thumbs.db
localStorage.json
.vscode

View File

@ -27725,39 +27725,16 @@
if(this.hasSkill(skill)&&this.tempSkills[skill]==undefined) return;
this.addSkill(skill,checkConflict,true,true);
if(!expire){
expire=['phaseAfter','phaseBeforeStart'];
}
if(!expire) expire={global:['phaseAfter','phaseBeforeStart']};
else if(typeof expire=='string'||Array.isArray(expire)) expire={global:expire};
this.tempSkills[skill]=expire;
if(typeof expire=='string'){
lib.hookmap[expire]=true;
}
else if(Array.isArray(expire)){
for(var i=0;i<expire.length;i++){
lib.hookmap[expire[i]]=true;
}
}
else if(get.objtype(expire)=='object'){
var roles=['player','source','target'];
for(var i=0;i<roles.length;i++){
if(typeof expire[roles[i]]=='string'){
lib.hookmap[expire[roles[i]]]=true;
}
else if(Array.isArray(expire[roles[i]])){
for(var j=0;j<expire[roles[i]].length;j++){
lib.hookmap[expire[roles[i]][j]]=true;
}
}
}
if(expire.global){
if(typeof expire.global=='string'){
lib.hookmap[expire.global]=true;
}
else if(Array.isArray(expire.global)){
for(var i=0;i<expire.global.length;i++){
lib.hookmap[expire.global[i]]=true;
}
if(get.objtype(expire)=='object'){
const roles=['player','source','target','global'];
for(const i of roles){
if(typeof expire[i]=='string') lib.hookmap[expire[i]]=true;
else if(Array.isArray(expire[i])){
expire[i].forEach(trigger=>lib.hookmap[trigger]=true);
}
}
}
@ -31841,21 +31818,23 @@
for(var j in player.additionalSkills){
if(!j.startsWith('hidden:')) notemp.addArray(player.additionalSkills[j]);
}
for(var j in player.tempSkills){
if(notemp.contains(j)) continue;
var expire=player.tempSkills[j];
if(expire===name||
(Array.isArray(expire)&&expire.contains(name))||
(typeof expire==='function'&&expire(event,player,name))){
delete player.tempSkills[j];
player.removeSkill(j);
for(const skill in player.tempSkills){
if(notemp.contains(skill)) continue;
const expire=player.tempSkills[skill];
if(typeof expire==='function'&&expire(event,player,name)){
delete player.tempSkills[skill];
player.removeSkill(skill);
}
else if(get.objtype(expire)==='object'){
for(var i=0;i<roles.length;i++){
if(expire[roles[i]]&&player===event[roles[i]]&&
(expire[roles[i]]===name||(Array.isArray(expire[roles[i]])&&expire[roles[i]].contains(name)))){
delete player.tempSkills[j];
player.removeSkill(j);
if(expire.global===name||(Array.isArray(expire.global)&&expire.global.contains(name))){
delete player.tempSkills[skill];
player.removeSkill(skill);
}
else for(const i of roles){
if(player!==event[i]) continue;
if(expire[i]===name||(Array.isArray(expire[i])&&expire[i].contains(name))){
delete player.tempSkills[skill];
player.removeSkill(skill);
}
}
}