buttonPresets, 神典韦 update

This commit is contained in:
Spmario233 2023-09-27 13:37:20 +08:00
parent 39a126b64d
commit 0ad723d2db
2 changed files with 244 additions and 168 deletions

View File

@ -109,27 +109,30 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(!_status.characterlist){ if(!_status.characterlist){
lib.skill.pingjian.initList(); lib.skill.pingjian.initList();
} }
var list=_status.characterlist.randomGets(5); _status.characterlist.randomSort();
var list=[];
for(var name of _status.characterlist){
var info=lib.character[name];
if(info[3].some(function(skill){
var info=get.skillInfoTranslation(skill);
if(!info.includes('【杀】')) return false;
var list=get.skillCategoriesOf(skill);
list.remove('锁定技');
return list.length==0;
})){
list.push(name);
if(list.length>=5) break;
}
}
if(!list.length) event.finish(); if(!list.length) event.finish();
else{ else{
var num=player.countEquipableSlot(1); var num=player.countEquipableSlot(1);
player.chooseButton([ player.chooseButton([
'挈挟:选择至多'+get.cnNumber(num)+'张武将置入武器栏', '挈挟:选择至多'+get.cnNumber(num)+'张武将置入武器栏',
[list,'character'], [list,function(item,type,position,noclick,node){
],[1,num],true).set('filterButton',function(button){ return lib.skill.qiexie.$createButton(item,type,position,noclick,node);
var name=button.link; }],
var info=lib.character[name]; ],[1,num],true).set('ai',function(button){
if(info[3].some(function(skill){
var info=get.skillInfoTranslation(skill);
if(!info.includes('【杀】')) return false;
var list=get.skillCategoriesOf(skill);
list.remove('锁定技');
return list.length==0;
})){
button.classList.add('glow2');
}
return true;
}).set('ai',function(button){
var name=button.link; var name=button.link;
var info=lib.character[name]; var info=lib.character[name];
var skills=info[3].filter(function(skill){ var skills=info[3].filter(function(skill){
@ -164,6 +167,58 @@ game.import('character',function(lib,game,ui,get,ai,_status){
for(var card of cards) player.equip(card); for(var card of cards) player.equip(card);
} }
}, },
$createButton:function(item,type,position,noclick,node){
node=ui.create.buttonPresets.character(item,'character',position,noclick);
const info=lib.character[item];
const skills=info[3].filter(function(skill){
var info=get.skillInfoTranslation(skill);
if(!info.includes('【杀】')) return false;
var list=get.skillCategoriesOf(skill);
list.remove('锁定技');
return list.length==0;
});
if(skills.length){
const skillstr=skills.map(i=>`[${get.translation(i)}]`).join('<br>');
const skillnode=ui.create.caption(`<div class="text" data-nature=${get.groupnature(info[1])}>${skillstr}</div>`,node);
skillnode.style.left='2px';
skillnode.style.bottom='2px';
}
node._customintro=function(uiintro,evt){
const character=node.link,characterInfo=get.character(node.link);
let capt=get.translation(character);
if(characterInfo){
const infoSex=characterInfo[0];
if(infoSex) capt+=`&nbsp;&nbsp;${infoSex=='none'?'无':lib.translate[infoSex]}`;
const infoGroup=characterInfo[1];
if(infoGroup){
const group=get.is.double(character,true);
if(group) capt+=`&nbsp;&nbsp;${group.map(value=>get.translation(value)).join('/')}`;
else capt+=`&nbsp;&nbsp;${lib.translate[infoGroup]}`;
}
}
uiintro.add(capt);
if(lib.characterTitle[node.link]){
uiintro.addText(get.colorspan(lib.characterTitle[node.link]));
}
for(let i=0;i<skills.length;i++){
if(lib.translate[skills[i]+'_info']){
let translation=lib.translate[skills[i]+'_ab']||get.translation(skills[i]).slice(0,2);
if(lib.skill[skills[i]]&&lib.skill[skills[i]].nobracket){
uiintro.add('<div><div class="skilln">'+get.translation(skills[i])+'</div><div>'+get.skillInfoTranslation(skills[i])+'</div></div>');
}
else{
uiintro.add('<div><div class="skill">【'+translation+'】</div><div>'+get.skillInfoTranslation(skills[i])+'</div></div>');
}
if(lib.translate[skills[i]+'_append']){
uiintro._place_text=uiintro.add('<div class="text">'+lib.translate[skills[i]+'_append']+'</div>')
}
}
}
}
return node;
},
video:function(player,info){ video:function(player,info){
for(var name of info[0]){ for(var name of info[0]){
lib.skill.qiexie.createCard(name); lib.skill.qiexie.createCard(name);

View File

@ -50267,9 +50267,8 @@
_status.prebutton.push(node); _status.prebutton.push(node);
return node; return node;
}, },
button:function(item,type,position,noclick,node){ buttonPresets:{
switch(type){ tdnodes:(item,type,position,noclick,node)=>{
case 'tdnodes':
node=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode.tdnodes',position); node=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode.tdnodes',position);
if(Array.isArray(item)){ if(Array.isArray(item)){
node.innerHTML='<span>'+(item[1])+'</span>'; node.innerHTML='<span>'+(item[1])+'</span>';
@ -50279,14 +50278,14 @@
node.innerHTML='<span>'+(item)+'</span>'; node.innerHTML='<span>'+(item)+'</span>';
node.link=item; node.link=item;
} }
break; return node;
},
case 'blank': blank:(item,type,position,noclick,node)=>{
node=ui.create.div('.button.card',position); node=ui.create.div('.button.card',position);
node.link=item; node.link=item;
break; return node;
},
case 'card': card:(item,type,position,noclick,node)=>{
if(typeof item.copy=='function'){ if(typeof item.copy=='function'){
node=item.copy(false); node=item.copy(false);
} }
@ -50313,9 +50312,9 @@
if(get.position(item)=='j'&&item.viewAs&&item.viewAs!=item.name&&lib.config.cardtempname!='off'){ if(get.position(item)=='j'&&item.viewAs&&item.viewAs!=item.name&&lib.config.cardtempname!='off'){
ui.create.cardTempName(item,node); ui.create.cardTempName(item,node);
} }
break; return node;
},
case 'vcard': vcard:(item,type,position,noclick,node)=>{
if(typeof item=='string'){ if(typeof item=='string'){
item=[get.type(item),'',item]; item=[get.type(item),'',item];
} }
@ -50323,9 +50322,9 @@
node.classList.add('button'); node.classList.add('button');
node.init(item); node.init(item);
node.link=item; node.link=item;
break; return node;
},
case 'character':case 'player':case 'characterx': character:(item,type,position,noclick,node)=>{
if(node){ if(node){
node.classList.add('button'); node.classList.add('button');
node.classList.add('character'); node.classList.add('character');
@ -50340,152 +50339,174 @@
if(lib.characterReplace[item]&&lib.characterReplace[item].length) item=lib.characterReplace[item].randomGet(); if(lib.characterReplace[item]&&lib.characterReplace[item].length) item=lib.characterReplace[item].randomGet();
} }
node.link=item; node.link=item;
if(type=='character'||type=='characterx'){
var double=get.is.double(node._link,true); var double=get.is.double(node._link,true);
if(double) node._changeGroup=true; if(double) node._changeGroup=true;
if(type=='characterx'&&lib.characterReplace[node._link]&&lib.characterReplace[node._link].length>1) node._replaceButton=true; if(type=='characterx'&&lib.characterReplace[node._link]&&lib.characterReplace[node._link].length>1) node._replaceButton=true;
var func=function(node,item){ var func=function(node,item){
node.setBackground(item,'character'); node.setBackground(item,'character');
if(node.node){ if(node.node){
node.node.name.remove(); node.node.name.remove();
node.node.hp.remove(); node.node.hp.remove();
node.node.group.remove(); node.node.group.remove();
node.node.intro.remove(); node.node.intro.remove();
if(node.node.replaceButton) node.node.replaceButton.remove(); if(node.node.replaceButton) node.node.replaceButton.remove();
} }
node.node={
name:ui.create.div('.name',node),
hp:ui.create.div('.hp',node),
group:ui.create.div('.identity',node),
intro:ui.create.div('.intro',node),
};
var infoitem=lib.character[item];
if(!infoitem){
for(var itemx in lib.characterPack){
if(lib.characterPack[itemx][item]){
infoitem=lib.characterPack[itemx][item];break;
}
}
}
node.node.name.innerHTML=get.slimName(item);
if(lib.config.buttoncharacter_style=='default'||lib.config.buttoncharacter_style=='simple'){
if(lib.config.buttoncharacter_style=='simple'){
node.node.group.style.display='none';
}
node.classList.add('newstyle');
node.node.name.dataset.nature=get.groupnature(get.bordergroup(infoitem));
node.node.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw');
ui.create.div(node.node.hp);
var hp=get.infoHp(infoitem[2]),maxHp=get.infoMaxHp(infoitem[2]),hujia=get.infoHujia(infoitem[2]);
var str=get.numStr(hp);
if(hp!=maxHp){
str+='/';
str+=get.numStr(maxHp);
}
var textnode=ui.create.div('.text',str,node.node.hp);
if(infoitem[2]==0){
node.node.hp.hide();
}
else if(get.infoHp(infoitem[2])<=3){
node.node.hp.dataset.condition='mid';
}
else{
node.node.hp.dataset.condition='high';
}
if(hujia>0){
ui.create.div(node.node.hp,'.shield');
ui.create.div('.text',get.numStr(hujia),node.node.hp);
}
}
else{
var hp=get.infoHp(infoitem[2]);
var maxHp=get.infoMaxHp(infoitem[2]);
var shield=get.infoHujia(infoitem[2]);
if(maxHp>14){
if(typeof infoitem[2]=='string') node.node.hp.innerHTML=infoitem[2];
else node.node.hp.innerHTML=get.numStr(infoitem[2]);
node.node.hp.classList.add('text');
}
else{
for(var i=0;i<maxHp;i++){
var next=ui.create.div('',node.node.hp);
if(i>=hp) next.classList.add('exclude');
}
for(var i=0;i<shield;i++){
ui.create.div(node.node.hp,'.shield');
}
}
}
if(node.node.hp.childNodes.length==0){
node.node.name.style.top='8px';
}
if(node.node.name.querySelectorAll('br').length>=4){
node.node.name.classList.add('long');
if(lib.config.buttoncharacter_style=='old'){
node.addEventListener('mouseenter',ui.click.buttonnameenter);
node.addEventListener('mouseleave',ui.click.buttonnameleave);
}
}
node.node.intro.innerHTML=lib.config.intro;
if(!noclick){
lib.setIntro(node);
}
if(infoitem[1]){
if(double){
node.node.group.innerHTML=double.reduce((previousValue,currentValue)=>`${previousValue}<div data-nature="${get.groupnature(currentValue)}">${get.translation(currentValue)}</div>`,'');
if(double.length>4) if(new Set([5,6,9]).has(double.length)) node.node.group.style.height='48px';
else node.node.group.style.height='64px';
}
else node.node.group.innerHTML=`<div>${get.translation(infoitem[1])}</div>`;
node.node.group.style.backgroundColor=get.translation(`${get.bordergroup(infoitem)}Color`);
}
else{
node.node.group.style.display='none';
}
if(node._replaceButton){
var intro=ui.create.div('.button.replaceButton',node);
node.node.replaceButton=intro;
intro.innerHTML='切换';
intro._node=node;
intro.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
_status.tempNoButton=true;
var node=this._node;
var list=lib.characterReplace[node._link];
var link=node.link;
var index=list.indexOf(link);
if(index==list.length-1) index=0;
else index++;
link=list[index];
node.link=link;
node.refresh(node,link);
setTimeout(function(){
delete _status.tempNoButton;
},200);
});
}
};
node.refresh=func;
node.refresh(node,item);
}
else{
node.node={ node.node={
name:ui.create.div('.name',node), name:ui.create.div('.name',node),
intro:ui.create.div('.intro',node) hp:ui.create.div('.hp',node),
group:ui.create.div('.identity',node),
intro:ui.create.div('.intro',node),
};
var infoitem=lib.character[item];
if(!infoitem){
for(var itemx in lib.characterPack){
if(lib.characterPack[itemx][item]){
infoitem=lib.characterPack[itemx][item];break;
}
}
} }
if(item.name&&item.name.indexOf('unknown')==0){ node.node.name.innerHTML=get.slimName(item);
if(item.node&&item.node.name_seat){ if(lib.config.buttoncharacter_style=='default'||lib.config.buttoncharacter_style=='simple'){
node.classList.add('cardbg'); if(lib.config.buttoncharacter_style=='simple'){
ui.create.div('.avatar_name',node,get.translation(item.name)); node.node.group.style.display='none';
}
node.classList.add('newstyle');
node.node.name.dataset.nature=get.groupnature(get.bordergroup(infoitem));
node.node.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw');
ui.create.div(node.node.hp);
var hp=get.infoHp(infoitem[2]),maxHp=get.infoMaxHp(infoitem[2]),hujia=get.infoHujia(infoitem[2]);
var str=get.numStr(hp);
if(hp!=maxHp){
str+='/';
str+=get.numStr(maxHp);
}
var textnode=ui.create.div('.text',str,node.node.hp);
if(infoitem[2]==0){
node.node.hp.hide();
}
else if(get.infoHp(infoitem[2])<=3){
node.node.hp.dataset.condition='mid';
} }
else{ else{
node.setBackground(item.name1,'character'); node.node.hp.dataset.condition='high';
}
if(hujia>0){
ui.create.div(node.node.hp,'.shield');
ui.create.div('.text',get.numStr(hujia),node.node.hp);
} }
} }
else{ else{
node.setBackground(item.name,'character'); var hp=get.infoHp(infoitem[2]);
var maxHp=get.infoMaxHp(infoitem[2]);
var shield=get.infoHujia(infoitem[2]);
if(maxHp>14){
if(typeof infoitem[2]=='string') node.node.hp.innerHTML=infoitem[2];
else node.node.hp.innerHTML=get.numStr(infoitem[2]);
node.node.hp.classList.add('text');
}
else{
for(var i=0;i<maxHp;i++){
var next=ui.create.div('',node.node.hp);
if(i>=hp) next.classList.add('exclude');
}
for(var i=0;i<shield;i++){
ui.create.div(node.node.hp,'.shield');
}
}
}
if(node.node.hp.childNodes.length==0){
node.node.name.style.top='8px';
}
if(node.node.name.querySelectorAll('br').length>=4){
node.node.name.classList.add('long');
if(lib.config.buttoncharacter_style=='old'){
node.addEventListener('mouseenter',ui.click.buttonnameenter);
node.addEventListener('mouseleave',ui.click.buttonnameleave);
}
}
node.node.intro.innerHTML=lib.config.intro;
if(!noclick){
lib.setIntro(node);
}
if(infoitem[1]){
if(double){
node.node.group.innerHTML=double.reduce((previousValue,currentValue)=>`${previousValue}<div data-nature="${get.groupnature(currentValue)}">${get.translation(currentValue)}</div>`,'');
if(double.length>4) if(new Set([5,6,9]).has(double.length)) node.node.group.style.height='48px';
else node.node.group.style.height='64px';
}
else node.node.group.innerHTML=`<div>${get.translation(infoitem[1])}</div>`;
node.node.group.style.backgroundColor=get.translation(`${get.bordergroup(infoitem)}Color`);
}
else{
node.node.group.style.display='none';
}
if(node._replaceButton){
var intro=ui.create.div('.button.replaceButton',node);
node.node.replaceButton=intro;
intro.innerHTML='切换';
intro._node=node;
intro.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
_status.tempNoButton=true;
var node=this._node;
var list=lib.characterReplace[node._link];
var link=node.link;
var index=list.indexOf(link);
if(index==list.length-1) index=0;
else index++;
link=list[index];
node.link=link;
node.refresh(node,link);
setTimeout(function(){
delete _status.tempNoButton;
},200);
});
}
};
node.refresh=func;
node.refresh(node,item);
return node;
},
characterx:(item,type,position,noclick,node)=>{
return ui.create.buttonPresets.character(item,type,position,noclick,node);
},
player:(item,type,position,noclick,node)=>{
if(node){
node.classList.add('button');
node.classList.add('character');
node.style.display='';
}
else{
node=ui.create.div('.button.character',position);
}
node._link=item;
node.link=item;
node.node={
name:ui.create.div('.name',node),
intro:ui.create.div('.intro',node)
}
if(item.name&&item.name.indexOf('unknown')==0){
if(item.node&&item.node.name_seat){
node.classList.add('cardbg');
ui.create.div('.avatar_name',node,get.translation(item.name));
}
else{
node.setBackground(item.name1,'character');
} }
} }
break; else{
node.setBackground(item.name,'character');
}
return node;
}
},
button:function(item,type,position,noclick,node){
if(ui.create.buttonPresets[type]){
node=ui.create.buttonPresets[type](item,type,position,noclick,node);
}
else if(typeof type=='function'){
node=type(item,type,position,noclick,node);
} }
if(!noclick){ if(!noclick){
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button); node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
@ -50503,7 +50524,7 @@
}, },
buttons:function(list,type,position,noclick,zoom){ buttons:function(list,type,position,noclick,zoom){
var buttons=[]; var buttons=[];
var pre=(type.slice(0,3)=='pre'); var pre=(typeof type=='string'&&type.slice(0,3)=='pre');
if(pre){ if(pre){
if(!_status.prebutton){ if(!_status.prebutton){
_status.prebutton=[]; _status.prebutton=[];