Merge branch 'PR-Branch' of https://github.com/libccy/noname into PR-Branch

This commit is contained in:
Spmario233 2023-10-03 00:32:17 +08:00
commit 83ef7e7033
1 changed files with 175 additions and 132 deletions

View File

@ -26153,72 +26153,60 @@
return list; return list;
}, },
addSkillTrigger:function(skill,hidden,triggeronly){ addSkillTrigger:function(skill,hidden,triggeronly){
var info=lib.skill[skill]; let skills=game.expandSkills([skill]);
if(!info) return; for(let skill of skills){
if(typeof info.group=='string'){ let info=lib.skill[skill];
this.addSkillTrigger(info.group,hidden); if(!info){
} console.trace(`Cannot find skill: ${skill}\nPlease check if game.expandSkills is overwritten`);
else if(Array.isArray(info.group)){ continue;
for(var i=0;i<info.group.length;i++){
this.addSkillTrigger(info.group[i],hidden);
} }
} if(!triggeronly){
if(!triggeronly){ if(info.global&&(!hidden||info.globalSilent)){
if(info.global&&(!hidden||info.globalSilent)){ if(typeof info.global=='string'){
if(typeof info.global=='string'){ game.addGlobalSkill(info.global,this);
game.addGlobalSkill(info.global,this); }
else{
for(let j=0;j<info.global.length;j++){
game.addGlobalSkill(info.global[j],this);
}
}
} }
else{ if(this.initedSkills.contains(skill)) return this;
for(var j=0;j<info.global.length;j++){ this.initedSkills.push(skill);
game.addGlobalSkill(info.global[j],this); if(info.init&&!_status.video) info.init(this,skill);
}
if(info.trigger&&this.playerid){
let playerid=this.playerid;
let setTrigger=function(i,evt){
if(i=='global'){
if(!lib.hook.globaltrigger[evt]){
lib.hook.globaltrigger[evt]={};
}
if(!lib.hook.globaltrigger[evt][playerid]){
lib.hook.globaltrigger[evt][playerid]=[];
}
lib.hook.globaltrigger[evt][playerid].add(skill);
}
else{
let name=playerid+'_'+i+'_'+evt;
if(!lib.hook[name]) lib.hook[name]=[];
lib.hook[name].add(skill);
}
lib.hookmap[evt]=true;
}
for(let i in info.trigger){
if(typeof info.trigger[i]=='string') setTrigger(i,info.trigger[i]);
else if(Array.isArray(info.trigger[i])){
for(let trigger of info.trigger[i]) setTrigger(i,trigger);
} }
} }
} }
if(this.initedSkills.contains(skill)) return this; if(info.hookTrigger){
this.initedSkills.push(skill); if(!this._hookTrigger) this._hookTrigger=[];
if(info.init&&!_status.video){ this._hookTrigger.add(skill);
info.init(this,skill);
} }
if(_status.event&&_status.event.addTrigger) _status.event.addTrigger(skill,this);
} }
if(info.trigger&&this.playerid){
var playerid=this.playerid;
var setTrigger=function(i,evt){
if(i=='global'){
if(!lib.hook.globaltrigger[evt]){
lib.hook.globaltrigger[evt]={};
}
if(!lib.hook.globaltrigger[evt][playerid]){
lib.hook.globaltrigger[evt][playerid]=[];
}
lib.hook.globaltrigger[evt][playerid].add(skill);
}
else{
var name=playerid+'_'+i+'_'+evt;
if(!lib.hook[name]){
lib.hook[name]=[];
}
lib.hook[name].add(skill);
}
lib.hookmap[evt]=true;
}
for(var i in info.trigger){
if(typeof info.trigger[i]=='string'){
setTrigger(i,info.trigger[i]);
}
else if(Array.isArray(info.trigger[i])){
for(var j=0;j<info.trigger[i].length;j++){
setTrigger(i,info.trigger[i][j]);
}
}
}
}
if(info.hookTrigger){
if(!this._hookTrigger){
this._hookTrigger=[];
}
this._hookTrigger.add(skill);
}
if(_status.event&&_status.event.addTrigger) _status.event.addTrigger(skill,this);
return this; return this;
}, },
addSkillLog:function(skill){ addSkillLog:function(skill){
@ -26506,59 +26494,49 @@
return this; return this;
}, },
removeSkillTrigger:function(skill,triggeronly){ removeSkillTrigger:function(skill,triggeronly){
var info=lib.skill[skill]; let skills=game.expandSkills([skill]);
if(!info) return; for(let skill of skills){
if(typeof info.group=='string'){ let info=lib.skill[skill];
this.removeSkillTrigger(info.group); if(!info){
} console.trace(`Cannot find skill: ${skill}\nPlease check if game.expandSkills is overwritten`);
else if(Array.isArray(info.group)){ continue;
for(var i=0;i<info.group.length;i++){
this.removeSkillTrigger(info.group[i]);
} }
} if(!triggeronly) this.initedSkills.remove(skill);
if(!triggeronly) this.initedSkills.remove(skill); if(info.trigger){
if(info.trigger){ let playerid=this.playerid;
var playerid=this.playerid; let removeTrigger=function(i,evt){
var removeTrigger=function(i,evt){ if(i=='global'){
if(i=='global'){ for(let j in lib.hook.globaltrigger){
for(var j in lib.hook.globaltrigger){ if(lib.hook.globaltrigger[j][playerid]){
if(lib.hook.globaltrigger[j][playerid]){ lib.hook.globaltrigger[j][playerid].remove(skill);
lib.hook.globaltrigger[j][playerid].remove(skill); if(lib.hook.globaltrigger[j][playerid].length==0){
if(lib.hook.globaltrigger[j][playerid].length==0){ delete lib.hook.globaltrigger[j][playerid];
delete lib.hook.globaltrigger[j][playerid]; }
} if(get.is.empty(lib.hook.globaltrigger[j])){
if(get.is.empty(lib.hook.globaltrigger[j])){ delete lib.hook.globaltrigger[j];
delete lib.hook.globaltrigger[j]; }
} }
} }
} }
} else{
else{ let name=playerid+'_'+i+'_'+evt;
var name=playerid+'_'+i+'_'+evt; if(lib.hook[name]){
if(lib.hook[name]){ lib.hook[name].remove(skill);
lib.hook[name].remove(skill); if(lib.hook[name].length==0) delete lib.hook[name];
if(lib.hook[name].length==0){
delete lib.hook[name];
} }
} }
} }
} for(let i in info.trigger){
for(var i in info.trigger){ if(typeof info.trigger[i]=='string') removeTrigger(i,info.trigger[i]);
if(typeof info.trigger[i]=='string'){ else if(Array.isArray(info.trigger[i])){
removeTrigger(i,info.trigger[i]); for(let trigger of info.trigger[i]) removeTrigger(i,trigger);
}
else if(Array.isArray(info.trigger[i])){
for(var j=0;j<info.trigger[i].length;j++){
removeTrigger(i,info.trigger[i][j]);
} }
} }
} }
} if(info.hookTrigger){
if(info.hookTrigger){ if(this._hookTrigger){
if(this._hookTrigger){ this._hookTrigger.remove(skill);
this._hookTrigger.remove(skill); if(!this._hookTrigger.length) delete this._hookTrigger;
if(!this._hookTrigger.length){
delete this._hookTrigger;
} }
} }
} }
@ -27528,9 +27506,43 @@
if(this.hasSkillTag('respondShan',true,null,true)) return true; if(this.hasSkillTag('respondShan',true,null,true)) return true;
return this.hasUsableCard('shan'); return this.hasUsableCard('shan');
}, },
mayHaveShan:function(){ mayHaveSha:function(viewer,type){
return this.hasShan(); if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondSha',true,type,true)) return true;
// modify: After AngelBeats! -2nd Beat- if(get.itemtype(viewer)!=='player') viewer=_status.event.player;
let cards;
if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h');
else cards=this.getShownCards();
if(cards.some(card=>{
let name=get.name(card,this);
if(name=='sha'||name=='hufu'||name=='yuchanqian'){
if(type==='use') return lib.filter.cardEnabled(card,this);
if(type==='respond') return lib.filter.cardRespondable(card,this);
return true;
}
return false;
})) return true;
let hs=this.getCards('hs').removeArray(cards).length;
if(hs===0) return false;
return Math.pow(hs+(this.isPhaseUsing()?6:4),2)>100*_status.event.getRand('mayHaveSha');
},
mayHaveShan:function(viewer,type){
if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondShan',true,type,true)) return true;
if(get.itemtype(viewer)!=='player') viewer=_status.event.player;
let cards;
if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h');
else cards=this.getShownCards();
if(cards.some(card=>{
let name=get.name(card,this);
if(name==='shan'||name==='hufu'){
if(type==='use') return lib.filter.cardEnabled(card,this);
if(type==='respond') return lib.filter.cardRespondable(card,this);
return true;
}
return false;
})) return true;
let hs=this.getCards('hs').removeArray(cards).length;
if(hs===0) return false;
return Math.pow(hs+(this.isPhaseUsing()?3:5),2)>100*_status.event.getRand('mayHaveShan');
}, },
hasCard:function(name,position){ hasCard:function(name,position){
if(typeof name=='function'){ if(typeof name=='function'){
@ -40214,7 +40226,7 @@
if(drawDeck&&drawDeck.drawDeck) players[0].draw(num2,drawDeck); if(drawDeck&&drawDeck.drawDeck) players[0].draw(num2,drawDeck);
else players[0].draw(num2); else players[0].draw(num2);
}, },
finishSkill:(i,sub)=>{ finishSkill:(i,history)=>{
const mode=get.mode(),info=lib.skill[i],iInfo=`${i}_info`; const mode=get.mode(),info=lib.skill[i],iInfo=`${i}_info`;
if(info.alter){ if(info.alter){
lib.translate[`${iInfo}_origin`]=lib.translate[iInfo]; lib.translate[`${iInfo}_origin`]=lib.translate[iInfo];
@ -40257,14 +40269,25 @@
}); });
} }
if(info.inherit){ if(info.inherit){
const skill=lib.skill[info.inherit]; var inheritHistory=[];
if(skill) Object.keys(skill).forEach(value=>{ while(true){
if(info[value]!=undefined) return; if(!info.inherit) break;
if(value=='audio'&&(typeof info[value]=='number'||typeof info[value]=='boolean')) info[value]=info.inherit; if(inheritHistory.includes(info.inherit)){
else info[value]=skill[value]; console.trace(`Inherit Error: ${info.inherit} in ${i}'s inherit forms a deadlock`);
}); break;
if(lib.translate[i]==undefined) lib.translate[i]=lib.translate[info.inherit]; }
if(lib.translate[iInfo]==undefined) lib.translate[iInfo]=lib.translate[`${info.inherit}_info`]; inheritHistory.push(info.inherit);
const inheritInfo=lib.skill[info.inherit];
if(inheritInfo) Object.keys(inheritInfo).forEach(value=>{
if(info[value]!=undefined) return;
if(value=='audio'&&(typeof info[value]=='number'||typeof info[value]=='boolean')) info[value]=info.inherit;
else info[value]=inheritInfo[value];
});
if(lib.translate[i]==undefined) lib.translate[i]=lib.translate[info.inherit];
if(lib.translate[`${i}_info`]==undefined) lib.translate[`${i}_info`]=lib.translate[`${info.inherit}_info`];
if(!inheritInfo||!inheritInfo.inherit) info.inherit=void 0;
}
} }
if(info.limited){ if(info.limited){
if(info.mark===undefined) info.mark=true; if(info.mark===undefined) info.mark=true;
@ -40273,16 +40296,26 @@
if(info.skillAnimation===undefined) info.skillAnimation=true; if(info.skillAnimation===undefined) info.skillAnimation=true;
if(info.init===undefined) info.init=(player,skill)=>player.storage[skill]=false; if(info.init===undefined) info.init=(player,skill)=>player.storage[skill]=false;
} }
if(info.subSkill&&!sub) Object.keys(info.subSkill).forEach(value=>{ if(info.subSkill){
const iValue=`${i}_${value}`; let subSkillHistory=Array.isArray(history)?history:[];
lib.skill[iValue]=info.subSkill[value]; for(let value in info.subSkill){
lib.skill[iValue].sub=true; if(subSkillHistory.includes(value)){
if(info.subSkill[value].name) lib.translate[iValue]=info.subSkill[value].name; console.trace(`SubSkill Error: ${value} in ${i} forms a deadlock`);
else lib.translate[iValue]=lib.translate[iValue]||lib.translate[i]; continue;
if(info.subSkill[value].description) lib.translate[`${iValue}_info`]=info.subSkill[value].description; }
if(info.subSkill[value].marktext) lib.translate[`${iValue}_bg`]=info.subSkill[value].marktext; let history=subSkillHistory.slice(0);
game.finishSkill(iValue,true); history.push(value);
});
const iValue=`${i}_${value}`;
lib.skill[iValue]=info.subSkill[value];
lib.skill[iValue].sub=true;
if(info.subSkill[value].name) lib.translate[iValue]=info.subSkill[value].name;
else lib.translate[iValue]=lib.translate[iValue]||lib.translate[i];
if(info.subSkill[value].description) lib.translate[`${iValue}_info`]=info.subSkill[value].description;
if(info.subSkill[value].marktext) lib.translate[`${iValue}_bg`]=info.subSkill[value].marktext;
game.finishSkill(iValue,history);
}
}
if(info.round){ if(info.round){
const k=`${i}_roundcount`; const k=`${i}_roundcount`;
if(typeof info.group=='string') info.group=[info.group,k]; if(typeof info.group=='string') info.group=[info.group,k];
@ -41185,15 +41218,25 @@
if(!player.storage.skill_blocker||!player.storage.skill_blocker.length) return out; if(!player.storage.skill_blocker||!player.storage.skill_blocker.length) return out;
return out.filter(value=>exclude&&exclude.includes(value)||!get.is.blocked(value,player)); return out.filter(value=>exclude&&exclude.includes(value)||!get.is.blocked(value,player));
}, },
expandSkills:skills=>skills.addArray(skills.reduce((previousValue,currentValue)=>{ expandSkills:(skill,oldHistory)=>{
const info=get.info(currentValue); let history=[];
if(info){ if(oldHistory) history.addArray(oldHistory);
if(Array.isArray(info.group)) previousValue.push(...info.group); if(Array.isArray(skill)){
else if(info.group) previousValue.push(info.group); return skill.reduce((previous,current)=>previous.addArray(game.expandSkills(current,history)),[]);
} }
else console.log(currentValue);
return previousValue; let info=get.info(skill);
},[])), if(!info){
console.trace(`Cannot find skill: ${skill}`);
return history;
}
history.add(skill);
if(info.group){
let group=Array.isArray(info.group)?info.group:[info.group];
history.addArray(game.expandSkills([].addArray(group.filter(skill=>!history.includes(skill))),history));
}
return history;
},
css:style=>Object.keys(style).forEach(value=>{ css:style=>Object.keys(style).forEach(value=>{
let uiStyle=ui.style[value]; let uiStyle=ui.style[value];
if(!uiStyle){ if(!uiStyle){