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;
},
addSkillTrigger:function(skill,hidden,triggeronly){
var info=lib.skill[skill];
if(!info) return;
if(typeof info.group=='string'){
this.addSkillTrigger(info.group,hidden);
}
else if(Array.isArray(info.group)){
for(var i=0;i<info.group.length;i++){
this.addSkillTrigger(info.group[i],hidden);
let skills=game.expandSkills([skill]);
for(let skill of skills){
let info=lib.skill[skill];
if(!info){
console.trace(`Cannot find skill: ${skill}\nPlease check if game.expandSkills is overwritten`);
continue;
}
}
if(!triggeronly){
if(info.global&&(!hidden||info.globalSilent)){
if(typeof info.global=='string'){
game.addGlobalSkill(info.global,this);
if(!triggeronly){
if(info.global&&(!hidden||info.globalSilent)){
if(typeof info.global=='string'){
game.addGlobalSkill(info.global,this);
}
else{
for(let j=0;j<info.global.length;j++){
game.addGlobalSkill(info.global[j],this);
}
}
}
else{
for(var j=0;j<info.global.length;j++){
game.addGlobalSkill(info.global[j],this);
if(this.initedSkills.contains(skill)) return this;
this.initedSkills.push(skill);
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;
this.initedSkills.push(skill);
if(info.init&&!_status.video){
info.init(this,skill);
if(info.hookTrigger){
if(!this._hookTrigger) this._hookTrigger=[];
this._hookTrigger.add(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;
},
addSkillLog:function(skill){
@ -26506,59 +26494,49 @@
return this;
},
removeSkillTrigger:function(skill,triggeronly){
var info=lib.skill[skill];
if(!info) return;
if(typeof info.group=='string'){
this.removeSkillTrigger(info.group);
}
else if(Array.isArray(info.group)){
for(var i=0;i<info.group.length;i++){
this.removeSkillTrigger(info.group[i]);
let skills=game.expandSkills([skill]);
for(let skill of skills){
let info=lib.skill[skill];
if(!info){
console.trace(`Cannot find skill: ${skill}\nPlease check if game.expandSkills is overwritten`);
continue;
}
}
if(!triggeronly) this.initedSkills.remove(skill);
if(info.trigger){
var playerid=this.playerid;
var removeTrigger=function(i,evt){
if(i=='global'){
for(var j in lib.hook.globaltrigger){
if(lib.hook.globaltrigger[j][playerid]){
lib.hook.globaltrigger[j][playerid].remove(skill);
if(lib.hook.globaltrigger[j][playerid].length==0){
delete lib.hook.globaltrigger[j][playerid];
}
if(get.is.empty(lib.hook.globaltrigger[j])){
delete lib.hook.globaltrigger[j];
if(!triggeronly) this.initedSkills.remove(skill);
if(info.trigger){
let playerid=this.playerid;
let removeTrigger=function(i,evt){
if(i=='global'){
for(let j in lib.hook.globaltrigger){
if(lib.hook.globaltrigger[j][playerid]){
lib.hook.globaltrigger[j][playerid].remove(skill);
if(lib.hook.globaltrigger[j][playerid].length==0){
delete lib.hook.globaltrigger[j][playerid];
}
if(get.is.empty(lib.hook.globaltrigger[j])){
delete lib.hook.globaltrigger[j];
}
}
}
}
}
else{
var name=playerid+'_'+i+'_'+evt;
if(lib.hook[name]){
lib.hook[name].remove(skill);
if(lib.hook[name].length==0){
delete lib.hook[name];
else{
let name=playerid+'_'+i+'_'+evt;
if(lib.hook[name]){
lib.hook[name].remove(skill);
if(lib.hook[name].length==0) delete lib.hook[name];
}
}
}
}
for(var i in info.trigger){
if(typeof info.trigger[i]=='string'){
removeTrigger(i,info.trigger[i]);
}
else if(Array.isArray(info.trigger[i])){
for(var j=0;j<info.trigger[i].length;j++){
removeTrigger(i,info.trigger[i][j]);
for(let i in info.trigger){
if(typeof info.trigger[i]=='string') removeTrigger(i,info.trigger[i]);
else if(Array.isArray(info.trigger[i])){
for(let trigger of info.trigger[i]) removeTrigger(i,trigger);
}
}
}
}
if(info.hookTrigger){
if(this._hookTrigger){
this._hookTrigger.remove(skill);
if(!this._hookTrigger.length){
delete this._hookTrigger;
if(info.hookTrigger){
if(this._hookTrigger){
this._hookTrigger.remove(skill);
if(!this._hookTrigger.length) delete this._hookTrigger;
}
}
}
@ -27528,9 +27506,43 @@
if(this.hasSkillTag('respondShan',true,null,true)) return true;
return this.hasUsableCard('shan');
},
mayHaveShan:function(){
return this.hasShan();
// modify: After AngelBeats! -2nd Beat-
mayHaveSha:function(viewer,type){
if((this.hp>2||!this.isZhu&&this.hp>1)&&this.hasSkillTag('respondSha',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=='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){
if(typeof name=='function'){
@ -40214,7 +40226,7 @@
if(drawDeck&&drawDeck.drawDeck) players[0].draw(num2,drawDeck);
else players[0].draw(num2);
},
finishSkill:(i,sub)=>{
finishSkill:(i,history)=>{
const mode=get.mode(),info=lib.skill[i],iInfo=`${i}_info`;
if(info.alter){
lib.translate[`${iInfo}_origin`]=lib.translate[iInfo];
@ -40257,14 +40269,25 @@
});
}
if(info.inherit){
const skill=lib.skill[info.inherit];
if(skill) Object.keys(skill).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]=skill[value];
});
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`];
var inheritHistory=[];
while(true){
if(!info.inherit) break;
if(inheritHistory.includes(info.inherit)){
console.trace(`Inherit Error: ${info.inherit} in ${i}'s inherit forms a deadlock`);
break;
}
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.mark===undefined) info.mark=true;
@ -40273,16 +40296,26 @@
if(info.skillAnimation===undefined) info.skillAnimation=true;
if(info.init===undefined) info.init=(player,skill)=>player.storage[skill]=false;
}
if(info.subSkill&&!sub) Object.keys(info.subSkill).forEach(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,true);
});
if(info.subSkill){
let subSkillHistory=Array.isArray(history)?history:[];
for(let value in info.subSkill){
if(subSkillHistory.includes(value)){
console.trace(`SubSkill Error: ${value} in ${i} forms a deadlock`);
continue;
}
let history=subSkillHistory.slice(0);
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){
const k=`${i}_roundcount`;
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;
return out.filter(value=>exclude&&exclude.includes(value)||!get.is.blocked(value,player));
},
expandSkills:skills=>skills.addArray(skills.reduce((previousValue,currentValue)=>{
const info=get.info(currentValue);
if(info){
if(Array.isArray(info.group)) previousValue.push(...info.group);
else if(info.group) previousValue.push(info.group);
expandSkills:(skill,oldHistory)=>{
let history=[];
if(oldHistory) history.addArray(oldHistory);
if(Array.isArray(skill)){
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=>{
let uiStyle=ui.style[value];
if(!uiStyle){