消灭lib.element遍历

This commit is contained in:
Spmario233 2023-10-18 12:07:33 +08:00
parent 638ac38f21
commit 9123425a7c
12 changed files with 90 additions and 341 deletions

View File

@ -4483,37 +4483,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(list.length>=result.score) list=list.randomGets(result.score);
else list.addArray(list2.randomGets(result.score-list.length));
list.sort();
event.videoId=lib.status.videoId++;
var func=function(id,list){
var choiceList=ui.create.dialog('控物:请选择一项','forcebutton');
choiceList.videoId=id;
for(var ii=0;ii<list.length;ii++){
var i=list[ii];
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
var bool=lib.skill.yukito_kongwu.moves[i].filter(player);
if(!bool) str+='<div style="opacity:0.5">';
str+=lib.skill.yukito_kongwu.moves[i].prompt;
if(!bool) str+='</div>';
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
return choiceList;
};
if(player.isOnline2()){
player.send(func,event.videoId,list);
}
event.dialog=func(event.videoId,list);
if(player!=game.me||_status.auto){
event.dialog.style.display='none';
}
var next=player.chooseButton();
next.set('dialog',event.videoId);
var next=player.chooseButton([
'控物:请选择一项',
[list.map(i=>{
return [i,lib.skill.yukito_kongwu.moves[i].prompt];
}),'textbutton'],
]);
next.set('forced',true);
next.set('filterButton',function(button){
return lib.skill.yukito_kongwu.moves[button.link].filter(_status.event.player);
@ -4523,10 +4498,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return Math.random();
});
"step 2"
if(player.isOnline2()){
player.send('closeDialog',event.videoId);
}
event.dialog.close();
var num=result.links[0];
switch(num){
case 0:event.goto(3);break;
@ -4944,35 +4915,23 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
chooseButton:{
dialog:function(event,player){
var dialog=ui.create.dialog('游凤','hidden');
const dialog=ui.create.dialog('游凤','hidden');
const equips=[];
if(player.storage.chihaya_youfeng){
var table=document.createElement('div');
table.classList.add('add-setting');
table.style.margin='0';
table.style.width='100%';
table.style.position='relative';
for(var i=1;i<6;i++){
for(let i=1;i<6;i++){
if(!player.hasEnabledSlot(i)) continue;
var td=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
td.innerHTML='<span>'+get.translation('equip'+i)+'</span>';
td.link=i;
td.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
for(var j in lib.element.button){
td[j]=lib.element.button[i];
}
table.appendChild(td);
dialog.buttons.add(td);
equips.push([i,get.translation('equip'+i)]);
}
dialog.content.appendChild(table);
if(equips.length>0) dialog.add([equips,'tdnodes'])
}
var type=player.storage.chihaya_youfeng?'basic':'trick';
var list=[];
for(var name of lib.inpile){
const type=player.storage.chihaya_youfeng?'basic':'trick';
const list=[];
for(const name of lib.inpile){
if(get.type(name)!=type) continue;
if(event.filterCard({name:name,isCard:true},player,event)){
list.push([type,'',name]);
if(name=='sha'){
for(var j of lib.inpile_nature) list.push([type,'',name,j]);
for(let j of lib.inpile_nature) list.push([type,'',name,j]);
}
}
}

View File

@ -4481,7 +4481,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
};
"step 3"
if(!result.bool){
lib.element.player.die.apply(target,[]);
lib.element.Player.prototype.die.apply(target,[]);
}
},
sub:true,

View File

@ -4863,23 +4863,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
(player.isDisabledJudge()?list2:list1).push(-1);
var addTable=function(list,bool){
var table=document.createElement('div');
table.classList.add('add-setting');
table.style.margin='0';
table.style.width='100%';
table.style.position='relative';
const adds=[];
for(var i of list){
var td=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
td.innerHTML='<span>'+(i>0?get.translation('equip'+i)+'栏':'判定区')+'</span>';
td.link=[i,bool];
td.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
for(var j in lib.element.button){
td[j]=lib.element.button[j];
}
table.appendChild(td);
dialog.buttons.add(td);
adds.push([[i,bool],(i>0?get.translation('equip'+i)+'栏':'判定区')]);
}
dialog.content.appendChild(table);
dialog.add([adds,'tdnodes'])
}
if(list1.length){
dialog.addText('未废除');
@ -6061,38 +6049,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
event.cardname=player.storage.dunshi_damage;
player.removeSkill('dunshi_damage');
event.target=trigger.source;
event.videoId=lib.status.videoId++;
var func=function(card,id,card2,card3){
var list=[
'防止即将对'+card3+'造成的伤害,并令'+card+'获得一个技能名中包含“仁/义/礼/智/信”的技能',
'从〖遁世〗中删除【'+card2+'】并获得一枚“席”',
'减1点体力上限然后摸等同于“席”数的牌',
];
var choiceList=ui.create.dialog('遁世:请选择两项');
choiceList.videoId=id;
for(var i=0;i<list.length;i++){
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
str+=list[i];
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
return choiceList;
};
if(player.isOnline2()){
player.send(func,get.translation(trigger.source),event.videoId,get.translation(event.cardname),get.translation(trigger.player));
}
event.dialog=func(get.translation(trigger.source),event.videoId,get.translation(event.cardname),get.translation(trigger.player));
if(player!=game.me||_status.auto){
event.dialog.style.display='none';
}
var next=player.chooseButton();
next.set('dialog',event.videoId);
var card=get.translation(trigger.source),card2=get.translation(event.cardname),card3=get.translation(trigger.player);
var list=[
'防止即将对'+card3+'造成的伤害,并令'+card+'获得一个技能名中包含“仁/义/礼/智/信”的技能',
'从〖遁世〗中删除【'+card2+'】并获得一枚“席”',
'减1点体力上限然后摸等同于“席”数的牌',
];
var next=player.chooseButton([
'遁世:请选择两项',
[list.map((item,i)=>{
return [i,item];
}),'textbutton']
]);
next.set('forced',true);
next.set('selectButton',2);
next.set('ai',function(button){
@ -6113,10 +6081,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
});
'step 1'
if(player.isOnline2()){
player.send('closeDialog',event.videoId);
}
event.dialog.close();
event.links=result.links.sort();
for(var i of event.links){
game.log(player,'选择了','#g【遁世】','的','#y选项'+get.cnNumber(i+1,true));
@ -10076,7 +10040,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
str+=strx;
if(i!='jiu') str+='/';
}
str+=',然后当前回合角色于本回合内下一次造成伤害时,你选择两项:⒈防止此伤害。系统从技能名中包含“仁/义/礼/智/信”字样的技能中随机选择三个其未拥有的技能,然后你令当前回合角色获得其中一个技能。⒉从〖遁世〗中删除你本次使用或打出的牌并获得一个“赂”。⒊减1点体力上限并摸X张牌X为你的“赂”数)。';
str+=',然后当前回合角色于本回合内下一次造成伤害时,你选择两项:⒈防止此伤害。系统从技能名中包含“仁/义/礼/智/信”字样的技能中随机选择三个其未拥有的技能,然后你令当前回合角色获得其中一个技能。⒉从〖遁世〗中删除你本次使用或打出的牌并获得一个“席”。⒊减1点体力上限并摸X张牌X为你的“席”数)。';
return str;
},
dcporui:function(player){

View File

@ -5511,24 +5511,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var dialog=ui.create.dialog('集兵','hidden');
if(event.filterCard({name:'sha'},player,event)&&event.filterCard({name:'shan'},player,event)){
dialog._chooseButton=2;
var table=document.createElement('div');
table.classList.add('add-setting');
table.style.margin='0';
table.style.width='100%';
table.style.position='relative';
var list=['sha','shan'];
for(var i of list){
var td=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
td.innerHTML='<span>'+get.translation(i)+'</span>';
td.link=i;
td.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
for(var j in lib.element.button){
td[j]=lib.element.button[j];
}
table.appendChild(td);
dialog.buttons.add(td);
}
dialog.content.appendChild(table);
dialog.add([list.map(i=>{
return [i,get.translation(i)];
}),'tdnodes']);
}
else dialog._cardName=event.filterCard({name:'sha'},player,event)?'sha':'shan';
dialog.add(player.getExpansions('jibing'));
@ -13953,21 +13939,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'摸一张牌并视为使用一张【杀】',
];
var choiceList=ui.create.dialog('知略失去1点体力并...','forcebutton','hidden');
for(var i=0;i<list.length;i++){
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
var bool=lib.skill.xinzhilve.chooseButton.filter({link:i},player);
if(!bool) str+='<div style="opacity:0.5">';
str+=list[i];
if(!bool) str+='</div>';
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[i];
}
choiceList.buttons.add(next.firstChild);
}
choiceList.add([list.map((item,i)=>{
return [i,item];
}),'textbutton']);
return choiceList;
},
filter:function(button,player){

View File

@ -5523,19 +5523,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
table.style.width='100%';
table.style.position='relative';
var list=['摸牌','造成伤害'];
for(var i=0;i<list.length;i++){
if(player.hasSkill('xinpaiyi_'+i)) continue;
var td=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
td.innerHTML='<span>'+(list[i])+'</span>';
td.link=i;
td.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
for(var j in lib.element.button){
td[j]=lib.element.button[j];
}
table.appendChild(td);
dialog.buttons.add(td);
}
dialog.content.appendChild(table);
dialog.add([list.map((item,i)=>{
return [i,item];
}),'tdnodes']);
dialog.add(player.getExpansions('xinquanji'));
return dialog;
},

View File

@ -4765,21 +4765,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'将两张牌交给一名其他角色并获得其装备区内的一张牌',
];
var choiceList=ui.create.dialog('睦阵:请选择一项','hidden');
for(var i=0;i<list.length;i++){
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
var bool=lib.skill.muzhen.chooseButton.filter({link:i},player);
if(!bool) str+='<div style="opacity:0.5">';
str+=list[i];
if(!bool) str+='</div>';
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
choiceList.add([list.map((item,i)=>{
return [i,item];
}),'textbutton']);
return choiceList;
},
filter:function(button,player){

View File

@ -12350,24 +12350,12 @@ game.import('character',function(lib,game,ui,get,ai,_status){
chooseButton:{
dialog:function(event,player){
var dialog=ui.create.dialog('游龙','hidden');
var table=document.createElement('div');
table.classList.add('add-setting');
table.style.margin='0';
table.style.width='100%';
table.style.position='relative';
for(var i=1;i<6;i++){
const equips=[];
for(let i=1;i<6;i++){
if(!player.hasEnabledSlot(i)) continue;
var td=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
td.innerHTML='<span>'+get.translation('equip'+i)+'</span>';
td.link=i;
td.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
for(var j in lib.element.button){
td[j]=lib.element.button[j];
}
table.appendChild(td);
dialog.buttons.add(td);
equips.push([i,get.translation('equip'+i)]);
}
dialog.content.appendChild(table);
if(equips.length>0) dialog.add([equips,'tdnodes'])
var type=player.storage.youlong?'basic':'trick';
var list=[];
for(var name of lib.inpile){
@ -20405,40 +20393,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
event._result={bool:true,links:[0]};
return;
}
event.videoId=lib.status.videoId++;
var func=function(card,id,bool){
var list=[
'令自己摸一张牌',
'令XXX摸两张牌',
'令XXX回复1点体力',
];
var choiceList=ui.create.dialog('【礼下】:请选择一至两项','forcebutton');
choiceList.videoId=id;
for(var i=0;i<list.length;i++){
list[i]=list[i].replace(/XXX/g,card);
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
if(i==2&&!bool) str+='<div style="opacity:0.5">';
str+=list[i];
if(i==2&&!bool) str+='</div>';
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
return choiceList;
};
if(player.isOnline2()){
player.send(func,get.translation(trigger.player),event.videoId,trigger.player.isDamaged());
}
event.dialog=func(get.translation(trigger.player),event.videoId,trigger.player.isDamaged());
if(player!=game.me||_status.auto){
event.dialog.style.display='none';
}
var next=player.chooseButton(true,[1,2]);
var list=[
'令自己摸一张牌',
'令XXX摸两张牌',
'令XXX回复1点体力',
];
var card=get.translation(trigger.player);
var next=player.chooseButton([
'【礼下】:请选择一至两项',
[list.map((item,index)=>{
return [index,item.replace(/XXX/g,card)]
}),'textbutton']
],true,[1,2]);
next.set('dialog',event.videoId);
next.set('filterButton',function(button){
if(button.link==2){
@ -20454,12 +20420,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return button.link*Math.random();
});
"step 1"
if(event.videoId!=undefined){
if(player.isOnline2()){
player.send('closeDialog',event.videoId);
}
event.dialog.close();
}
var map=[
function(trigger,player,event){
player.draw();

View File

@ -7816,34 +7816,8 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(result.control=="手动分配"){
event.goto(8);
}
else if(!_status.connectMode){
var choiceList=ui.create.dialog('请选择一种方案','hidden','forcebutton');
for(var i=0;i<event.getedResult.length;i++){
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">方案'+get.cnNumber(i+1,true);
str+='<br>第一组:';
var current=event.getedResult[i];
str+=get.translation(current[0]);
str+='<br>第二组:';
str+=get.translation(current[1]);
if(current[2].length){
str+='<br>剩余:';
str+=get.translation(current[2]);
}
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
event.choiceList=choiceList;
target.chooseButton(choiceList,true);
}
"step 4"
if(result.bool&&result.links) event.index=result.links[0];
else event.index=0;
event.index=0;
event.togain=event.getedResult[event.index];
target.showCards(event.togain[0],get.translation(target)+'分出的第一份牌');
"step 5"

View File

@ -9218,39 +9218,19 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(result.index==1) player.loseMaxHp();
else player.loseHp();
'step 2'
event.videoId=lib.status.videoId++;
var func=function(player,id){
var list=[
'选项一:摸两张牌',
'选项二对一名其他角色造成1点伤害且本回合对其使用【杀】无距离和次数限制',
'选项三:本回合手牌上限视为无限',
'选项四:获得一名其他角色区域内的一张牌',
'选项五:令一名其他角色将手牌数摸至体力上限(至多摸至五张)',
];
var choiceList=ui.create.dialog('玉陨:请选择一'+(player.getDamagedHp()>0?('至'+get.cnNumber(player.getDamagedHp()+1)):'')+'项');
choiceList.videoId=id;
for(var i=0;i<list.length;i++){
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
str+=list[i];
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
return choiceList;
};
if(player.isOnline2()){
player.send(func,player,event.videoId);
}
event.dialog=func(player,event.videoId);
if(player!=game.me||_status.auto){
event.dialog.style.display='none';
}
var next=player.chooseButton();
var list=[
'选项一:摸两张牌',
'选项二对一名其他角色造成1点伤害且本回合对其使用【杀】无距离和次数限制',
'选项三:本回合手牌上限视为无限',
'选项四:获得一名其他角色区域内的一张牌',
'选项五:令一名其他角色将手牌数摸至体力上限(至多摸至五张)',
];
var next=player.chooseButton([
'玉陨:请选择一'+(player.getDamagedHp()>0?('至'+get.cnNumber(player.getDamagedHp()+1)):'')+'项',
[list.map((item,i)=>{
return [i,item];
}),'textbutton']
]);
next.set('dialog',event.videoId);
next.set('forced',true);
next.set('ai',function(button){
@ -9293,10 +9273,6 @@ game.import('character',function(lib,game,ui,get,ai,_status){
});
if(player.getDamagedHp()>0) next.set('selectButton',[1,1+player.getDamagedHp()]);
'step 3'
if(player.isOnline2()){
player.send('closeDialog',event.videoId);
}
event.dialog.close();
result.links.sort();
for(var i of result.links) game.log(player,'选择了','#g【玉陨】','的','#y选项'+get.cnNumber(1+i,true))
event.links=result.links;
@ -10246,26 +10222,10 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'选择手牌数大于你的一名角色',
'选择装备数大于你的一名角色',
];
var choiceList=ui.create.dialog('尊位:清选择一项','forcebutton','hidden');
for(var i=0;i<list.length;i++){
if(player.storage.zunwei&&player.storage.zunwei.contains(i)) continue;
var bool=game.hasPlayer(function(current){
return current!=player&&lib.skill.zunwei.backups[i].filterTarget(null,player,current);
});
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
if(!bool) str+='<div style="opacity:0.5">';
str+=list[i];
if(!bool) str+='</div>';
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
next.firstChild._filterButton=bool;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
var choiceList=ui.create.dialog('尊位:请选择一项','forcebutton','hidden');
choiceList.add([list.map((item,i)=>{
return [i,item];
}),'textbutton'])
return choiceList;
},
filter:function(button){

View File

@ -10094,21 +10094,9 @@ game.import('character',function(lib,game,ui,get,ai,_status){
'选择体力值最大的一名角色',
];
var choiceList=ui.create.dialog('散谣:请选择一项','forcebutton','hidden');
for(var i=0;i<list.length;i++){
var str='<div class="popup text" style="width:calc(100% - 10px);display:inline-block">';
var bool=lib.skill.olsanyao.chooseButton.filter({link:i},player);
if(!bool) str+='<div style="opacity:0.5">';
str+=list[i];
if(!bool) str+='</div>';
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
choiceList.buttons.add(next.firstChild);
}
choiceList.add([list.map((item,i)=>{
return [i,item];
}),'textbutton']);
return choiceList;
},
filter:function(button,player){

View File

@ -8991,7 +8991,7 @@
}
}
if(lib.assetURL.includes('com.widget.noname.qingyao')){
if(lib.assetURL.includes('com.widget.noname.qingyao')||lib.assetURL.includes('online.nonamekill.android')){
alert('您正在一个不受信任的闭源客户端上运行《无名杀》。建议您更换为其他开源的无名杀客户端,避免给您带来不必要的损失。');
}
@ -60048,7 +60048,8 @@
}
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=`${node.countCards('h')}/${node.getHandcardLimit()}`;
let handcardLimit=node.getHandcardLimit();
td.innerHTML=`${node.countCards('h')}/${handcardLimit>=114514?'∞':handcardLimit}`;
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=node.phaseNumber;

View File

@ -3786,21 +3786,12 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
ui.arena.classList.add('choose-character');
var list=game.liangjunduilei;
var id=lib.status.videoId++;
var choiceList=ui.create.dialog('请选择要游玩的剧情','forcebutton');
choiceList.videoId=id;
for(var i=0;i<list.length;i++){
var str='<div class="popup text center" style="width:calc(100% - 10px);display:inline-block">';
str+=list[i].name;
str+='</div>';
var next=choiceList.add(str);
next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=i;
for(var j in lib.element.button){
next[j]=lib.element.button[i];
}
choiceList.buttons.add(next.firstChild);
}
game.me.chooseButton(true).set('dialog',id).set('onfree',true);
var choiceList=ui.create.dialog('请选择要游玩的剧情','forcebutton');
choiceList.videoId=id;
choiceList.add([list.map((item,i)=>{
return [i,`<div class="popup text center" style="width:calc(100% - 10px);display:inline-block">${item.name}</div>`];
}),'textbutton'])
game.me.chooseButton(true).set('dialog',id).set('onfree',true);
'step 1'
var pack=game.liangjunduilei[result.links[0]];
game.versusVideoName=pack.name;