diff --git a/card/extra.js b/card/extra.js
index c7743a1b2..80ad18299 100644
--- a/card/extra.js
+++ b/card/extra.js
@@ -781,7 +781,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
if(card.name=='sha'){
var equip1=player.getEquip('zhuque');
if(equip1&&equip1.name=='zhuque') return 1.9;
- if(!card.hasNature()) return 'zerotarget';
+ if(!game.hasNature(card)) return 'zerotarget';
}
}
}
@@ -810,7 +810,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
effect:{
target:function(card,player,target,current){
if(card.name=='sha'){
- if(card.hasNature('fire')) return 2;
+ if(game.hasNature(card,'fire')) return 2;
if(player.hasSkill('zhuque_skill')) return 1.9;
}
if(get.tag(card,'fireDamage')&¤t<0) return 2;
@@ -830,7 +830,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
target:player,
card:event.card
})) return false;
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
return false;
},
content:function(){
@@ -906,7 +906,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
trigger:{player:'useCard1'},
//priority:7,
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
},
audio:true,
check:function(event,player){
diff --git a/card/guozhan.js b/card/guozhan.js
index 409bb4e95..51588f330 100644
--- a/card/guozhan.js
+++ b/card/guozhan.js
@@ -1211,7 +1211,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},
filter:function(event,player){
if(['huoshaolianying','huogong'].contains(event.card.name)) return true;
- if(event.card.name=='sha') return event.card.hasNature('fire');
+ if(event.card.name=='sha') return game.hasNature(event.card,'fire');
return false;
},
content:function(){
@@ -1220,7 +1220,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
ai:{
effect:{
target:function(card,player,target,current){
- if(['huoshaolianying','huogong'].contains(card.name)||(card.name=='sha'&&card.hasNature('fire'))){
+ if(['huoshaolianying','huogong'].contains(card.name)||(card.name=='sha'&&game.hasNature(card,'fire'))){
return 'zeroplayertarget';
}
},
diff --git a/card/standard.js b/card/standard.js
index c451c7651..f59f3c784 100644
--- a/card/standard.js
+++ b/card/standard.js
@@ -134,7 +134,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
if(event.shanRequired>1){
next.set('prompt2','(共需使用'+event.shanRequired+'张闪)');
}
- else if(event.card.hasNature('stab')){
+ else if(game.hasNature(event.card,'stab')){
next.set('prompt2','(在此之后仍需弃置一张手牌)');
}
next.set('ai1',function(card){
@@ -168,7 +168,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
if(event.shanRequired>0){
event.goto(1);
}
- else if(event.card.hasNature('stab')&&target.countCards('h')>0){
+ else if(game.hasNature(event.card,'stab')&&target.countCards('h')>0){
event.responded=result;
event.goto(4);
}
@@ -265,7 +265,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
},
order:function(item,player){
if(player.hasSkillTag('presha',true,null,true)) return 10;
- if(item.hasNature('linked')){
+ if(game.hasNature(item,'linked')){
if(game.hasPlayer(function(current){
return current!=player&¤t.isLinked()&&player.canUse(item,current,null,true)&&get.effect(current,item,player,player)>0&&lib.card.sha.ai.canLink(player,current,item);
})&&game.countPlayer(function(current){
@@ -306,20 +306,20 @@ game.import('card',function(lib,game,ui,get,ai,_status){
respond:1,
respondShan:1,
damage:function(card){
- if(card.hasNature('poison')) return;
+ if(game.hasNature(card,'poison')) return;
return 1;
},
natureDamage:function(card){
- if(card.hasNature()) return 1;
+ if(game.hasNature(card)) return 1;
},
fireDamage:function(card,nature){
- if(card.hasNature('fire')) return 1;
+ if(game.hasNature(card,'fire')) return 1;
},
thunderDamage:function(card,nature){
- if(card.hasNature('thunder')) return 1;
+ if(game.hasNature(card,'thunder')) return 1;
},
poisonDamage:function(card,nature){
- if(card.hasNature('poison')) return 1;
+ if(game.hasNature(card,'poison')) return 1;
}
}
}
@@ -338,20 +338,20 @@ game.import('card',function(lib,game,ui,get,ai,_status){
respond:1,
respondShan:1,
damage:function(card){
- if(card.hasNature('poison')) return;
+ if(game.hasNature(card,'poison')) return;
return 1;
},
natureDamage:function(card){
- if(card.hasNature()) return 1;
+ if(game.hasNature(card)) return 1;
},
fireDamage:function(card,nature){
- if(card.hasNature('fire')) return 1;
+ if(game.hasNature(card,'fire')) return 1;
},
thunderDamage:function(card,nature){
- if(card.hasNature('thunder')) return 1;
+ if(game.hasNature(card,'thunder')) return 1;
},
poisonDamage:function(card,nature){
- if(card.hasNature('poison')) return 1;
+ if(game.hasNature(card,'poison')) return 1;
}
}
}
diff --git a/card/yingbian.js b/card/yingbian.js
index 79eb64103..288f64211 100644
--- a/card/yingbian.js
+++ b/card/yingbian.js
@@ -307,7 +307,7 @@ game.import('card',function(lib,game,ui,get,ai,_status){
equipSkill:true,
trigger:{player:'useCard1'},
filter:function(event,player){
- return (event.card.name=='sha'&&lib.linked.some(n=>n!='kami'&&event.card.hasNature(n)));
+ return (event.card.name=='sha'&&lib.linked.some(n=>n!='kami'&&game.hasNature(event.card,n)));
},
audio:true,
direct:true,
diff --git a/character/clan.js b/character/clan.js
index 77cf6a5d1..7fe0b4bf3 100644
--- a/character/clan.js
+++ b/character/clan.js
@@ -1076,7 +1076,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
try{
var cards=player.getCards('hs',cardx=>{
if(get.name(cardx)!='sha') return false;
- return cardx.hasNature('linked');
+ return game.hasNature(cardx,'linked');
});
cards.map(i=>[i,get.effect(target,i,player,player)]);
cards.sort((a,b)=>b[1]-a[1]);
@@ -1096,7 +1096,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return get.name(card)=='jiu'&&player.hasUseTarget(card);
})&&player.countCards('hs',card=>{
if(get.name(card)!='sha') return false;
- return card.hasNature('linked');
+ return game.hasNature(card,'linked');
}));
'step 1'
if(result.bool){
diff --git a/character/ddd.js b/character/ddd.js
index cb698cca3..53dbc276e 100644
--- a/character/ddd.js
+++ b/character/ddd.js
@@ -875,7 +875,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var player=_status.event.player,target=_status.event.getParent().target;
if(get.attitude(player,target)<0) return false;
if(!_status.event.colors.contains(get.color(card,player))) return 0;
- if(card.hasNature()) return 1.2;
+ if(game.hasNature(card)) return 1.2;
return 1;
})
'step 3'
diff --git a/character/extra.js b/character/extra.js
index 10adfb6d4..86560fa03 100755
--- a/character/extra.js
+++ b/character/extra.js
@@ -6177,7 +6177,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
if(['trick','delay'].contains(lib.card[card.name].type)) return 'thunder';
},
cardUsable:function(card,player){
- if(card.name=='sha'&&card.hasNature('thunder')) return Infinity;
+ if(card.name=='sha'&&game.hasNature(card,'thunder')) return Infinity;
},
},
ai:{
diff --git a/character/huicui.js b/character/huicui.js
index c4e944b6a..fccc2bdf1 100644
--- a/character/huicui.js
+++ b/character/huicui.js
@@ -6437,7 +6437,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
prompt2:function(event,player){
var str=('令'+get.translation(event.player)+'即将受到的');
str+=(''+event.num+'点');
- if(lib.linked.some(n=>event.hasNature(n))){
+ if(event.hasNature('linked')){
str+=(get.translation(event.nature)+'属性');
}
str+='伤害+1';
@@ -7061,7 +7061,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}).length;
//var str='视为额外使用'+get.cnNumber(num)+'张'
var str='额外结算'+get.cnNumber(num)+'次'
- if(event.card.name=='sha'&&event.card.hasNature()) str+=get.translation(event.card.nature);
+ if(event.card.name=='sha'&&game.hasNature(event.card)) str+=get.translation(event.card.nature);
return (str+'【'+get.translation(event.card.name)+'】');
},
check:function(event,player){
diff --git a/character/mobile.js b/character/mobile.js
index addf138d0..069533492 100644
--- a/character/mobile.js
+++ b/character/mobile.js
@@ -9624,7 +9624,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
group:['relihuo_baigei','relihuo_damage'],
trigger:{player:'useCard1'},
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
},
check:function(event,player){
return false;
@@ -9650,7 +9650,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
forced:true,
audio:'relihuo',
filter:function(event,player){
- if(event.card.name!='sha'||!event.card.hasNature('fire')) return false;
+ if(event.card.name!='sha'||!game.hasNature(event.card,'fire')) return false;
var num=0;
player.getHistory('sourceDamage',function(evt){
if(evt.card==event.card) num+=evt.num;
diff --git a/character/offline.js b/character/offline.js
index 36559222d..c9005b9ac 100644
--- a/character/offline.js
+++ b/character/offline.js
@@ -940,7 +940,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
filter:function(event,player){
if(!player.hasEmptySlot(2)) return false;
if(event.card.name!='sha') return false;
- return event.card.hasNature();
+ return game.hasNature(event.card);
},
content:function(){
trigger.cancel();
@@ -6234,7 +6234,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
fulu:{
trigger:{player:'useCard1'},
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
},
audio:true,
check:function(event,player){
diff --git a/character/refresh.js b/character/refresh.js
index 9d806cf4f..b46bce1e2 100755
--- a/character/refresh.js
+++ b/character/refresh.js
@@ -6111,7 +6111,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
},
trigger:{player:'useCard1'},
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
return false;
},
audio:'lihuo',
@@ -6139,7 +6139,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
ollihuo2:{
trigger:{player:'useCard2'},
filter:function(event,player){
- if(event.card.name!='sha'||!event.card.hasNature('fire')) return false;
+ if(event.card.name!='sha'||!game.hasNature(event.card,'fire')) return false;
return game.hasPlayer(function(current){
return !event.targets.contains(current)&&lib.filter.targetEnabled(event.card,player,current)&&lib.filter.targetInRange(event.card,player,current);
});
@@ -7604,7 +7604,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
decadelihuo:{
trigger:{player:'useCard1'},
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
return false;
},
audio:'lihuo',
@@ -7630,7 +7630,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
decadelihuo2:{
trigger:{player:'useCard2'},
filter:function(event,player){
- if(event.card.name!='sha'||!event.card.hasNature('fire')) return false;
+ if(event.card.name!='sha'||!game.hasNature(event.card,'fire')) return false;
return game.hasPlayer(function(current){
return !event.targets.contains(current)&&player.canUse(event.card,current);
});
@@ -7660,7 +7660,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
decadelihuo3:{
trigger:{player:'useCardAfter'},
filter:function(event,player){
- return event.card.name=='sha'&&event.card.hasNature('fire')&&event.targets.length>1&&player.getHistory('sourceDamage',function(evt){
+ return event.card.name=='sha'&&game.hasNature(event.card,'fire')&&event.targets.length>1&&player.getHistory('sourceDamage',function(evt){
return evt.card==event.card;
}).length>0;
},
diff --git a/character/sp.js b/character/sp.js
index 25c9b9b4b..3d8b17a5c 100755
--- a/character/sp.js
+++ b/character/sp.js
@@ -19389,7 +19389,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
effect:{
target:function(card,player,target,current){
if(card.name=='sha'){
- if(card.hasNature('fire')||player.hasSkill('zhuque_skill')) return 2;
+ if(game.hasNature(card,'fire')||player.hasSkill('zhuque_skill')) return 2;
}
if(get.tag(card,'fireDamage')&¤t<0) return 2;
}
@@ -19415,7 +19415,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
hanyong:{
trigger:{player:'useCard'},
filter:function(event,player){
- return event.card&&(event.card.name=='nanman'||event.card.name=='wanjian'||(event.card.name=='sha'&&!event.card.hasNature()&&get.suit(event.card)=='spade'))&&player.isDamaged();
+ return event.card&&(event.card.name=='nanman'||event.card.name=='wanjian'||(event.card.name=='sha'&&!game.hasNature(event.card)&&get.suit(event.card)=='spade'))&&player.isDamaged();
},
content:function(){
trigger.baseDamage++;
diff --git a/character/sp2.js b/character/sp2.js
index e10796a8a..1a02647e6 100644
--- a/character/sp2.js
+++ b/character/sp2.js
@@ -6560,7 +6560,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
}
else{
var vcard=[get.type(trigger.card),'',trigger.card.name];
- if(trigger.card.hasNature()) vcard.push(get.nature(trigger.card));
+ if(game.hasNature(trigger.card)) vcard.push(get.nature(trigger.card));
player.storage.juanhui3.push(vcard);
player.markSkill('juanhui2');
}
@@ -7361,7 +7361,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
target:function(card,player,target,current){
if(target.hasMark('cangchu')){
if(card.name=='sha'){
- if(lib.skill.global.contains('huoshaowuchao')||card.hasNature('fire')||player.hasSkill('zhuque_skill')) return 2;
+ if(lib.skill.global.contains('huoshaowuchao')||game.hasNature(card,'fire')||player.hasSkill('zhuque_skill')) return 2;
}
if(get.tag(card,'fireDamage')&¤t<0) return 2;
}
diff --git a/character/tw.js b/character/tw.js
index e5b49951d..ea9b149ce 100644
--- a/character/tw.js
+++ b/character/tw.js
@@ -6039,7 +6039,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var list=[];
player.getHistory('useCard',function(evt){
if(get.type(evt.card)!='basic') return;
- var name=evt.card.name,nature=evt.card.hasNature()?get.nature(evt.card):'';
+ var name=evt.card.name,nature=game.hasNature(evt.card)?get.nature(evt.card):'';
if(!list.contains(name+nature)) list.push(name+nature);
});
event.addDamage=list.length>1;
@@ -10452,7 +10452,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
twlihuo:{
trigger:{player:'useCard1'},
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
return false;
},
audio:'lihuo',
@@ -10477,7 +10477,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
twlihuo2:{
trigger:{player:'useCard2'},
filter:function(event,player){
- if(event.card.name!='sha'||!event.card.hasNature('fire')) return false;
+ if(event.card.name!='sha'||!game.hasNature(event.card,'fire')) return false;
return game.hasPlayer(function(current){
return !event.targets.contains(current)&&player.canUse(event.card,current);
});
diff --git a/character/yijiang.js b/character/yijiang.js
index f0623bd4c..809963056 100755
--- a/character/yijiang.js
+++ b/character/yijiang.js
@@ -7010,7 +7010,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
lihuo:{
trigger:{player:'useCard1'},
filter:function(event,player){
- if(event.card.name=='sha'&&!event.card.hasNature()) return true;
+ if(event.card.name=='sha'&&!game.hasNature(event.card)) return true;
return false;
},
audio:2,
@@ -7038,7 +7038,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
lihuo2:{
trigger:{player:'useCard2'},
filter:function(event,player){
- if(event.card.name!='sha'||!event.card.hasNature('fire')) return false;
+ if(event.card.name!='sha'||!game.hasNature(event.card,'fire')) return false;
return game.hasPlayer(function(current){
return !event.targets.contains(current)&&player.canUse(event.card,current);
});
diff --git a/game/config.js b/game/config.js
index 6a5fb309e..d33b563fc 100644
--- a/game/config.js
+++ b/game/config.js
@@ -1,6 +1,7 @@
window.config={
extension_sources:{
- Coding:'https://raw.fgit.cf/libccy/noname-extension/master/',
+ 'GitHub Proxy':'https://ghproxy.com/https://raw.githubusercontent.com/libccy/noname-extension/master/',
+ FastGit:'https://raw.fgit.cf/libccy/noname-extension/master/',
GitHub:'https://raw.githubusercontent.com/libccy/noname-extension/master/'
},
extension_source:'Coding',
diff --git a/game/game.js b/game/game.js
index 5e7bb4239..a1df995c6 100644
--- a/game/game.js
+++ b/game/game.js
@@ -6,7 +6,7 @@
}
else{
const ua=navigator.userAgent.toLowerCase();
- const ios=ua.indexOf('iphone')!=-1||ua.indexOf('ipad')!=-1||ua.indexOf('macintosh')!=-1;
+ const ios=ua.includes('iphone')||ua.includes('ipad')||ua.includes('macintosh');
//electron
if(typeof window.process=='object'&&typeof window.require=='function'){
const versions=window.process.versions;
@@ -273,7 +273,7 @@
if(typeof order!='number') order=0;
if(typeof background!='string') background='';
if(!Array.isArray(lineColor)||lineColor.length!=3) lineColor=[];
- else if(background.indexOf('ext:')==0){
+ else if(background.startsWith('ext:')){
background=background.replace(/^ext:/,'extension/');
}
if(linked) lib.linked.add(nature);
@@ -334,6 +334,7 @@
}
}],
},
+ objectURL:new Map(),
hookmap:{},
imported:{},
layoutfixed:['chess','tafang','stone'],
@@ -1000,7 +1001,7 @@
init:'coding',
unfrequent:true,
item:{
- coding:'Github Proxy',
+ coding:'FastGit',
github:'GitHub',
},
onclick:function(item){
@@ -1010,15 +1011,10 @@
},
extension_source:{
name:'获取扩展地址',
- init:'Coding',
+ init:'GitHub Proxy',
unfrequent:true,
item:{},
- intro:function(){
- return '获取在线扩展时的地址。当前地址:
'+lib.config.extension_sources[lib.config.extension_source];
- },
- onclick:function(item){
- game.saveConfig('extension_source',item);
- },
+ intro:()=>`获取在线扩展时的地址。当前地址:${document.createElement('br').outerHTML}${lib.config.extension_sources[lib.config.extension_source]}`
},
extension_create:{
name:'添加获取扩展地址',
@@ -1571,7 +1567,7 @@
ui.create.filediv('.menubutton','添加背景',node,function(file){
if(file){
var name=file.name;
- if(name.indexOf('.')!=-1){
+ if(name.includes('.')){
name=name.slice(0,name.indexOf('.'));
}
var link=(game.writeFile?'cdv_':'custom_')+name;
@@ -1609,7 +1605,7 @@
if(link&&link!='default'){
var str;
if(this.classList.contains('active')){
- if(link.indexOf('custom_')==0||link.indexOf('cdv_')==0){
+ if(link.startsWith('custom_')||link.startsWith('cdv_')){
str='删除';
}
else{
@@ -1633,10 +1629,10 @@
if(node.firstChild){
node.firstChild.innerHTML=get.verticalStr(name);
}
- if(link=='default'||link.indexOf('custom_')==0){
+ if(link=='default'||link.startsWith('custom_')){
node.style.backgroundImage='none';
node.classList.add('dashedmenubutton');
- if(link.indexOf('custom_')==0){
+ if(link.startsWith('custom_')){
game.getDB('image',link,function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
@@ -1689,7 +1685,7 @@
menu.updateBr();
lib.config.customBackgroundPack.remove(background);
game.saveConfig('customBackgroundPack',lib.config.customBackgroundPack);
- if(background.indexOf('cdv_')==0){
+ if(background.startsWith('cdv_')){
game.removeFile('image/background/'+background+'.jpg');
}
else{
@@ -2428,7 +2424,7 @@
node.className='button character dashedmenubutton';
}
else{
- if(link.indexOf('dragon_')==0){
+ if(link.startsWith('dragon_')){
link=link.slice(7);
node.dataset.decoration=link;
}
@@ -2476,7 +2472,7 @@
}
else if(layout!='default'&&layout!='auto'){
ui.css.border_stylesheet=lib.init.sheet();
- if(layout.indexOf('dragon_')==0){
+ if(layout.startsWith('dragon_')){
layout=layout.slice(7);
ui.arena.dataset.framedecoration=layout;
}
@@ -4076,11 +4072,11 @@
style.display='flex';
style.height='60px';
style.justifyContent='center';
- style.width='200px';
+ style.width='180px';
const firstChild=node.firstChild;
firstChild.removeAttribute('class');
firstChild.style.position='initial';
- if(link=='false') return;
+ if(link=='doNotShow') return;
const ruby=document.createElement('ruby');
ruby.textContent=name;
const rt=document.createElement('rt');
@@ -4217,7 +4213,7 @@
if(confirm('是否清除已导入的所有自定义背景音乐?(该操作不可撤销!)')){
for(var i in lib.config.customBackgroundMusic){
lib.config.all.background_music.remove(i);
- if(i.indexOf('cdv_')==0){
+ if(i.startsWith('cdv_')){
game.removeFile('audio/background/'+i+'.mp3');
}
else{
@@ -4381,7 +4377,7 @@
if(!lib.db){
data={};
for(var i in localStorage){
- if(i.indexOf(lib.configprefix)==0){
+ if(i.startsWith(lib.configprefix)){
data[i]=localStorage[i];
}
}
@@ -7944,7 +7940,7 @@
//处理id和class
if(options.identity){
for(const item of options.identity){
- if (item.indexOf("#")==0) element.id = item.slice(1);
+ if (item.startsWith("#")) element.id = item.slice(1);
else element.classList.add(item);
}
}
@@ -8039,7 +8035,7 @@
}
var links=document.head.querySelectorAll('link');
for(var i=0;ipos.includes(get.position(card,true)));
}
});
+ /**
+ * @legacy Use `Array.prototype.includes(searchElement)` instead.
+ */
Object.defineProperty(Array.prototype, "contains", {
configurable:true,
enumerable:false,
writable:true,
- value:function(item){
- return this.indexOf(item)!=-1;
- }
+ value:Array.prototype.includes
});
Object.defineProperty(Array.prototype, "add", {
configurable:true,
@@ -8522,6 +8519,8 @@
return this;
}
});
+ //!!!WARNING!!!
+ //Will be deprecated in next verision
Object.defineProperty(Object.prototype,'hasNature',{
configurable:true,
enumerable:false,
@@ -8866,16 +8865,16 @@
var noname_inited=localStorage.getItem('noname_inited');
if(noname_inited&&noname_inited!=='nodejs'){
var ua=navigator.userAgent.toLowerCase();
- if(ua.indexOf('android')!=-1){
+ if(ua.includes('android')){
lib.device='android';
}
- else if(ua.indexOf('iphone')!=-1||ua.indexOf('ipad')!=-1||ua.indexOf('macintosh')!=-1){
+ else if(ua.includes('iphone')||ua.includes('ipad')||ua.includes('macintosh')){
lib.device='ios';
}
lib.assetURL=noname_inited;
}
- if(lib.assetURL.indexOf('com.widget.noname.qingyao')!='-1'){
+ if(lib.assetURL.includes('com.widget.noname.qingyao')){
alert('您正在一个不受信任的闭源客户端上运行《无名杀》。建议您更换为其他开源的无名杀客户端,避免给您带来不必要的损失。');
}
@@ -8899,7 +8898,7 @@
lib.config.defaultcards=lib.config.cards.slice(0);
}
for(var i in config2){
- if(i.indexOf('_mode_config')!=-1){
+ if(i.includes('_mode_config')){
var thismode=i.substr(i.indexOf('_mode_config')+13);
if(!lib.config.mode_config[thismode]){
lib.config.mode_config[thismode]={};
@@ -9050,7 +9049,7 @@
}
else if(confirm('是否切换到触屏模式?(触屏模式可提高触屏设备的响应速度,但无法使用鼠标)')){
game.saveConfig('touchscreen',true);
- if(ua.indexOf('iphone')!=-1||ua.indexOf('android')!=-1){
+ if(ua.includes('iphone')||ua.includes('android')){
game.saveConfig('phonelayout',true);
}
game.reload();
@@ -9060,7 +9059,7 @@
else if(lib.config.touchscreen){
game.saveConfig('touchscreen',false);
}
- if(!lib.config.toscrolled&&ua.indexOf('macintosh')!=-1){
+ if(!lib.config.toscrolled&&ua.includes('macintosh')){
game.saveConfig('toscrolled',true);
game.saveConfig('mousewheel',false);
}
@@ -9086,7 +9085,7 @@
}
}
for(var i=0;i.framebg,#window #arena.long.mobile:not(.fewplayer) .player[data-position="0"]>.framebg{display:block;background-image:url("'+lib.assetURL+'theme/style/player/'+bstyle+'1.png")}',0);
@@ -9426,7 +9425,7 @@
});
}
game.download=function(url,folder,onsuccess,onerror,dev,onprogress){
- if(url.indexOf('http')!=0){
+ if(!url.startsWith('http')){
url=get.url(dev)+url;
}
var fileTransfer = new FileTransfer();
@@ -9597,7 +9596,7 @@
};
lib.path=lib.node.path;
game.download=function(url,folder,onsuccess,onerror,dev,onprogress){
- if(url.indexOf('http')!=0){
+ if(!url.startsWith('http')){
url=get.url(dev)+url;
}
game.ensureDirectory(folder,function(){
@@ -9613,7 +9612,7 @@
if(!lib.node.https) lib.node.https=require('https');
var opts = require('url').parse(encodeURI(url));
opts.headers={'User-Agent': 'AppleWebkit'};
- var request = (url.indexOf('https')==0?lib.node.https:lib.node.http).get(opts, function(response) {
+ (url.startsWith('https')?lib.node.https:lib.node.http).get(opts, function(response) {
var stream=response.pipe(file);
stream.on('finish',function(){
lib.config.brokenFile.remove(folder);
@@ -9891,7 +9890,7 @@
ui.background=ui.create.div('.background');
ui.background.style.backgroundSize="cover";
ui.background.style.backgroundPosition='50% 50%';
- if(lib.config.image_background&&lib.config.image_background!='default'&&lib.config.image_background.indexOf('custom_')!=0){
+ if(lib.config.image_background&&lib.config.image_background!='default'&&!lib.config.image_background.startsWith('custom_')){
ui.background.setBackgroundImage('image/background/'+lib.config.image_background+'.jpg');
if(lib.config.image_background_blur){
ui.background.style.filter='blur(8px)';
@@ -9919,7 +9918,7 @@
});
}
- if(lib.config.image_background.indexOf('custom_')==0){
+ if(lib.config.image_background.startsWith('custom_')){
ui.background.style.backgroundImage="none";
game.getDB('image',lib.config.image_background,function(fileToLoad){
if(!fileToLoad) return;
@@ -10481,7 +10480,7 @@
delete lib.imported.mode;
delete lib.imported.play;
for(var i in lib.init){
- if(i.indexOf('setMode_')==0){
+ if(i.startsWith('setMode_')){
delete lib.init[i];
}
}
@@ -10620,7 +10619,7 @@
var node=ui.create.div('.hidden',splash,clickNode);
node.link=lib.config.all.mode[i];
ui.create.div(node,'.splashtext',get.verticalStr(get.translation(lib.config.all.mode[i])));
- if(lib.config.all.stockmode.indexOf(lib.config.all.mode[i])!=-1){
+ if(lib.config.all.stockmode.includes(lib.config.all.mode[i])){
// 初始启动页设置
if(lib.config.splash_style==undefined) game.saveConfig('splash_style','style1');
splash.dataset.splash_style=lib.config.splash_style;
@@ -10635,7 +10634,7 @@
else{
var avatarnode=ui.create.div(node,'.avatar');
var avatarbg=lib.mode[lib.config.all.mode[i]].splash;
- if(avatarbg.indexOf('ext:')==0){
+ if(avatarbg.startsWith('ext:')){
avatarnode.setBackgroundImage(avatarbg.replace(/^ext:/,'extension/'));
}
else{
@@ -10765,7 +10764,7 @@
if(path){
if(path[path.length-1]=='/') path=path.slice(0,path.length-1);
if(file) path=`${path}${/^db:extension-[^:]*$/.test(path)?':':'/'}${file}.css`;
- (path.indexOf('db:')==0?game.getDB('image',path.slice(3)).then(get.objectURL):new Promise(resolve=>resolve(path))).then(resolvedPath=>{
+ (path.startsWith('db:')?game.getDB('image',path.slice(3)).then(get.objectURL):new Promise(resolve=>resolve(path))).then(resolvedPath=>{
style.href=resolvedPath;
if(typeof before=='function'){
style.addEventListener('load',before);
@@ -10800,8 +10799,8 @@
return;
}
let scriptSource=file?`${path}${/^db:extension-[^:]*$/.test(path)?':':'/'}${file}.js`:path;
- if(path.indexOf('http')==0) scriptSource+=`?rand=${get.id()}`;
- else if(lib.config.fuck_sojson&&scriptSource.includes('extension')!=-1&&scriptSource.indexOf(lib.assetURL)==0){
+ if(path.startsWith('http')) scriptSource+=`?rand=${get.id()}`;
+ else if(lib.config.fuck_sojson&&scriptSource.includes('extension')!=-1&&scriptSource.startsWith(lib.assetURL)){
const pathToRead=scriptSource.slice(lib.assetURL.length);
const alertMessage=`检测到您安装了使用免费版sojson进行加密的扩展。请谨慎使用这些扩展,避免游戏数据遭到破坏。\n扩展文件:${pathToRead}`;
if(typeof game.readFileAsText=='function') game.readFileAsText(pathToRead,result=>{
@@ -10813,9 +10812,9 @@
},()=>void 0);
}
const script=document.createElement('script');
- (scriptSource.indexOf('db:')==0?game.getDB('image',scriptSource.slice(3)).then(get.objectURL):new Promise(resolve=>resolve(scriptSource))).then(resolvedScriptSource=>{
+ (scriptSource.startsWith('db:')?game.getDB('image',scriptSource.slice(3)).then(get.objectURL):new Promise(resolve=>resolve(scriptSource))).then(resolvedScriptSource=>{
script.src=resolvedScriptSource;
- if(path.indexOf('http')==0) script.addEventListener('load',()=>script.remove());
+ if(path.startsWith('http')) script.addEventListener('load',()=>script.remove());
document.head.appendChild(script);
if(typeof onLoad=='function') script.addEventListener('load',onLoad);
if(typeof onError=='function') script.addEventListener('error',onError);
@@ -10844,7 +10843,7 @@
let scriptSource;
if(!file) scriptSource=path;
else scriptSource=`${path}/${file}.js`;
- if(path.indexOf('http')==0) scriptSource+=`?rand=${get.id()}`;
+ if(path.startsWith('http')) scriptSource+=`?rand=${get.id()}`;
const xmlHttpRequest=new XMLHttpRequest();
let data;
xmlHttpRequest.addEventListener("load",()=>{
@@ -10853,7 +10852,7 @@
if(typeof onError=='function') onError(new Error(`${scriptSource}加载失败!`));
return;
}
- if(lib.config.fuck_sojson&&scriptSource.includes('extension')!=-1&&scriptSource.indexOf(lib.assetURL)==0){
+ if(lib.config.fuck_sojson&&scriptSource.includes('extension')!=-1&&scriptSource.startsWith(lib.assetURL)){
const pathToRead=scriptSource.slice(lib.assetURL.length);
if(data.includes('sojson')||data.includes('jsjiami')||data.includes('var _0x')) alert(`检测到您安装了使用免费版sojson进行加密的扩展。请谨慎使用这些扩展,避免游戏数据遭到破坏。\n扩展文件:${pathToRead}`);
}
@@ -10871,7 +10870,7 @@
},
req:(str,onload,onerror,master)=>{
let sScriptURL;
- if(str.indexOf('http')==0) sScriptURL=str;
+ if(str.startsWith('http')) sScriptURL=str;
else if(str.startsWith('local:')){
if(lib.assetURL.length==0&&location.origin=='file://'&&typeof game.readFile=='undefined'){
const e=new Error('浏览器file协议下无法使用此api,请在http/https协议下使用此api');
@@ -10897,7 +10896,7 @@
*/
reqSync:(str,onload,onerror,master)=>{
let sScriptURL;
- if(str.indexOf('http')==0) sScriptURL=str;
+ if(str.startsWith('http')) sScriptURL=str;
else if(str.startsWith('local:')){
if(lib.assetURL.length==0&&location.origin=='file://'&&typeof game.readFile=='undefined'){
const e=new Error('浏览器file协议下无法使用此api,请在http/https协议下使用此api');
@@ -11108,7 +11107,7 @@
list.remove(lib.config.image_background);
localStorage.setItem(lib.configprefix+'background',JSON.stringify(list));
}
- else if(lib.config.image_background&&lib.config.image_background!='default'&&lib.config.image_background.indexOf('custom_')!=0){
+ else if(lib.config.image_background&&lib.config.image_background!='default'&&!lib.config.image_background.startsWith('custom_')){
localStorage.setItem(lib.configprefix+'background',lib.config.image_background);
}
else if(lib.config.image_background=='default'&&lib.config.theme=='simple'){
@@ -11355,7 +11354,7 @@
gl(str,function(folders,files){
if(files.length>1){
for(var i=0;i{
+ if(!lib.config.forbidai.includes(key)&&!key.startsWith('boss_')&&!key.startsWith('tafang_')&&!list.includes(key)) console.log(get.translation(key),key);
+ });
},
h:function(player){
console.log(get.translation(player.getCards('h')));
@@ -11813,17 +11811,17 @@
var suit=null;
var suits=['club','spade','diamond','heart'];
for(var i=0;ihs.includes(card));
- var shown=player.getShownCards();
- for(var tag of event.gaintag) player.addGaintag(cards,tag);
- event.cards=cards.filter(card=>!shown.includes(card));
- if(event.cards.length>0){
- game.log(player,'明置了',event.cards);
- event.trigger('addShownCardsAfter')
- }
+ addShownCards:()=>{
+ var hs=player.getCards('h'),showingCards=event._cards.filter(showingCard=>hs.includes(showingCard)),shown=player.getShownCards();
+ event.gaintag.forEach(tag=>player.addGaintag(showingCards,tag));
+ if(!(event.cards=showingCards.filter(showingCard=>!shown.includes(showingCard))).length) return;
+ game.log(player,'明置了',event.cards);
+ if(event.animate!=false) player.$give(event.cards,player,false);
+ event.trigger('addShownCardsAfter');
},
//隐藏明置手牌
- hideShownCards:function(){
- var shown=player.getShownCards(),cards=event._cards.filter(card=>shown.includes(card));
- if(cards.length>0){
- if(!event.gaintag.length){
- var map={};
- cards.forEach(card=>{
- var tags=card.gaintag.filter(tag=>tag.indexOf('visible_')==0)
- if(tags.length){
- tags.forEach(tag=>{
- if(!map[tag]) map[tag]=[];
- map[tag].push(card);
- })
- }
+ hideShownCards:()=>{
+ var shown=player.getShownCards(),hidingCards=event._cards.filter(hidingCard=>shown.includes(hidingCard));
+ if(!hidingCards.length) return;
+ if(event.gaintag.length) event.gaintag.forEach(tag=>player.removeGaintag(tag,hidingCards));
+ else {
+ var map=hidingCards.reduce((constructingMap,hidingCard)=>{
+ hidingCard.gaintag.forEach(tag=>{
+ if(!tag.startsWith('visible_')) return;
+ if(!constructingMap[tag]) constructingMap[tag]=[];
+ constructingMap[tag].push(hidingCard);
});
- for(var i in map){
- player.removeGaintag(i,map[i])
- }
- }
- else{
- event.gaintag.forEach(tag=>{
- player.removeGaintag(tag,cards);
- })
- }
- cards.removeArray(player.getShownCards());
- if(cards.length>0){
- event.cards=cards;
- game.log(player,'取消明置了',cards);
- event.trigger('hideShownCardsAfter');
- }
+ return constructingMap;
+ },{});
+ Object.keys(map).forEach(key=>player.removeGaintag(key,map[key]));
}
+ hidingCards.removeArray(player.getShownCards());
+ if(!hidingCards.length) return;
+ game.log(player,'取消明置了',event.cards=hidingCards);
+ if(event.animate!=false) player.$give(hidingCards,player,false);
+ event.trigger('hideShownCardsAfter');
},
//Execute the delay card effect
//执行延时锦囊牌效果
@@ -12710,7 +12696,7 @@
ui.create.dialog(str).videoId=id;
if(ui.backgroundMusic) ui.backgroundMusic.pause();
if(lib.config.background_audio){
- if(beatmap.filename.indexOf('ext:')==0) game.playAudio(beatmap.filename);
+ if(beatmap.filename.startsWith('ext:')) game.playAudio(beatmap.filename);
else game.playAudio('effect',beatmap.filename);
}
},player,event.videoId,event.beatmap);
@@ -12733,7 +12719,7 @@
var custom_mapping=Array.isArray(beatmap.mapping);
var mapping=custom_mapping?beatmap.mapping.slice():beatmap.mapping;
var hitsound=beatmap.hitsound||'hitsound.wav';
- if(hitsound.indexOf('ext:')==0) hitsound=lib.assetURL+'extension/'+hitsound.slice(4);
+ if(hitsound.startsWith('ext:')) hitsound=lib.assetURL+'extension/'+hitsound.slice(4);
else hitsound=lib.assetURL+'audio/effect/'+hitsound;
var hitsound_audio=new Audio(hitsound);
hitsound_audio.volume=0.25;
@@ -12925,7 +12911,7 @@
game.countChoose();
setTimeout(()=>{
if(!lib.config.background_audio) return;
- if(beatmap.filename.indexOf('ext:')==0) game.playAudio(beatmap.filename);
+ if(beatmap.filename.startsWith('ext:')) game.playAudio(beatmap.filename);
else game.playAudio('effect',beatmap.filename);
},Math.floor(speed*100*(0.9+beatmap.judgebar_height))+beatmap.current);
setTimeout(function(){
@@ -12970,8 +12956,8 @@
var skip_timeout;
var skip=()=>{
settle();
- Array.from(ui.window.getElementsByTagName('audio')).forEach(value=>{
- if(value.currentSrc.indexOf(beatmap.filename.indexOf('ext:')==0?beatmap.name:beatmap.filename)>-1) value.remove();
+ Array.from(ui.window.getElementsByTagName('audio')).forEach(audio=>{
+ if(audio.currentSrc.includes(beatmap.filename.startsWith('ext:')?beatmap.name:beatmap.filename)) audio.remove();
});
document.removeEventListener(lib.config.touchscreen?'touchend':'click',skip);
clearTimeout(settle_timeout);
@@ -14238,7 +14224,7 @@
else{
var keep=false;
for(var i in player.additionalSkills){
- if(i.indexOf('hidden:')==0&&game.expandSkills(player.additionalSkills[i]).contains(event.skill)){
+ if(i.startsWith('hidden:')&&game.expandSkills(player.additionalSkills[i]).contains(event.skill)){
keep=true;break;
}
}
@@ -14291,7 +14277,7 @@
}
else if(typeof info.logTarget=='function'){
var logTarget=info.logTarget(trigger,player);
- if(get.itemtype(logTarget).indexOf('player')==0) str=get.prompt(event.skill,logTarget,player);
+ if(get.itemtype(logTarget).startsWith('player')) str=get.prompt(event.skill,logTarget,player);
}
else{
str=get.prompt(event.skill,null,player);
@@ -17806,8 +17792,8 @@
const audio=lib.card[card.name].audio;
if(typeof audio=='string'){
const audioInfo=audio.split(':');
- if(audio.indexOf('db:')==0) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${card.name}_${sex}.${audioInfo[3]||'mp3'}`);
- else if(audio.indexOf('ext:')==0) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`);
+ if(audio.startsWith('db:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${card.name}_${sex}.${audioInfo[3]||'mp3'}`);
+ else if(audio.startsWith('ext:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`);
else game.playAudio('card',sex,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`);
}
else game.playAudio('card',sex,card.name);
@@ -18624,8 +18610,8 @@
const sex=player.sex=='female'?'female':'male',audio=lib.card[card.name].audio;
if(typeof audio=='string'){
const audioInfo=audio.split(':');
- if(audio.indexOf('db:')==0) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${card.name}_${sex}.${audioInfo[3]||'mp3'}`);
- else if(audio.indexOf('ext:')==0) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`);
+ if(audio.startsWith('db:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${card.name}_${sex}.${audioInfo[3]||'mp3'}`);
+ else if(audio.startsWith('ext:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`);
else game.playAudio('card',sex,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`);
}
else game.playAudio('card',sex,card.name);
@@ -19766,9 +19752,9 @@
}
}
if(_status.characterlist){
- if(lib.character[player.name]&&player.name.indexOf('gz_shibing')!=0&&player.name.indexOf('gz_jun_')!=0) _status.characterlist.add(player.name);
- if(lib.character[player.name1]&&player.name1.indexOf('gz_shibing')!=0&&player.name1.indexOf('gz_jun_')!=0) _status.characterlist.add(player.name1);
- if(lib.character[player.name2]&&player.name2.indexOf('gz_shibing')!=0&&player.name2.indexOf('gz_jun_')!=0) _status.characterlist.add(player.name2);
+ if(lib.character[player.name]&&!player.name.startsWith('gz_shibing')&&!player.name.startsWith('gz_jun_')) _status.characterlist.add(player.name);
+ if(lib.character[player.name1]&&!player.name1.startsWith('gz_shibing')&&!player.name1.startsWith('gz_jun_')) _status.characterlist.add(player.name1);
+ if(lib.character[player.name2]&&!player.name2.startsWith('gz_shibing')&&!player.name2.startsWith('gz_jun_')) _status.characterlist.add(player.name2);
}
event.cards=player.getCards('hejsx');
if(event.cards.length){
@@ -20283,52 +20269,36 @@
},
//让一名角色明置一些手牌
addShownCards:function(){
- const cards=[];
- const tags=[];
- for(let i=0;i0){
+ if(subtype.startsWith('equip')&&parseInt(subtype.slice(5))>0){
break;
}
else if(lib.card[subtype]){
@@ -20554,7 +20524,7 @@
else if(Array.isArray(arguments[i])){
for(var arg of arguments[i]){
if(typeof arg=='string'){
- if(arg.indexOf('equip')==0&&parseInt(arg.slice(5))>0) next.slots.push(arg);
+ if(arg.startsWith('equip')&&parseInt(arg.slice(5))>0) next.slots.push(arg);
}
else if(typeof arg=='number'){
next.slots.push('equip'+arg);
@@ -20562,7 +20532,7 @@
}
}
else if(typeof arguments[i]=='string'){
- if(arguments[i].indexOf('equip')==0&&parseInt(arguments[i].slice(5))>0) next.slots.push(arguments[i]);
+ if(arguments[i].startsWith('equip')&&parseInt(arguments[i].slice(5))>0) next.slots.push(arguments[i]);
}
else if(typeof arguments[i]=='number'){
next.slots.push('equip'+arguments[i]);
@@ -20586,7 +20556,7 @@
else if(Array.isArray(arguments[i])){
for(var arg of arguments[i]){
if(typeof arg=='string'){
- if(arg.indexOf('equip')==0&&parseInt(arg.slice(5))>0) next.slots.push(arg);
+ if(arg.startsWith('equip')&&parseInt(arg.slice(5))>0) next.slots.push(arg);
}
else if(typeof arg=='number'){
next.slots.push('equip'+arg);
@@ -20594,7 +20564,7 @@
}
}
else if(typeof arguments[i]=='string'){
- if(arguments[i].indexOf('equip')==0&&parseInt(arguments[i].slice(5))>0) next.slots.push(arguments[i]);
+ if(arguments[i].startsWith('equip')&&parseInt(arguments[i].slice(5))>0) next.slots.push(arguments[i]);
}
else if(typeof arguments[i]=='number'){
next.slots.push('equip'+arguments[i]);
@@ -20618,7 +20588,7 @@
else if(Array.isArray(arguments[i])){
for(var arg of arguments[i]){
if(typeof arg=='string'){
- if(arg.indexOf('equip')==0&&parseInt(arg.slice(5))>0) next.slots.push(arg);
+ if(arg.startsWith('equip')&&parseInt(arg.slice(5))>0) next.slots.push(arg);
}
else if(typeof arg=='number'){
next.slots.push('equip'+arg);
@@ -20626,7 +20596,7 @@
}
}
else if(typeof arguments[i]=='string'){
- if(arguments[i].indexOf('equip')==0&&parseInt(arguments[i].slice(5))>0) next.slots.push(arguments[i]);
+ if(arguments[i].startsWith('equip')&&parseInt(arguments[i].slice(5))>0) next.slots.push(arguments[i]);
}
else if(typeof arguments[i]=='number'){
next.slots.push('equip'+arguments[i]);
@@ -20671,14 +20641,14 @@
var map2=get.copy(map);
var cards=Array.from(player.node.equips.childNodes);
for(var card of cards){
- if(card.name.indexOf('feichu_')==0){
+ if(card.name.startsWith('feichu_')){
var index=card.name.slice(7);
if(!map2[index]) map2[index]=0;
map2[index]--;
}
}
for(var index in map2){
- if(index.indexOf('equip')!=0||!(parseInt(index.slice(5))>0)) continue;
+ if(!index.startsWith('equip')||!(parseInt(index.slice(5))>0)) continue;
var num=map2[index];
if(num>0){
for(var i=0;i0;
- if(nature=='linked') return natures.some(n=>lib.linked.includes(n));
- return get.is.sameNature(natures,nature);
+ return game.hasNature(this,nature,player);
},
//只针对【杀】起效果
addNature:function(nature){
@@ -29208,7 +29175,7 @@
card[3]=prefix;
}
}
- if(card[2].indexOf('sha_')==0){
+ if(card[2].startsWith('sha_')){
let suffix=card[2].slice(4);
let natureList=suffix.split('_');
card[2]='sha';
@@ -29268,10 +29235,10 @@
}
var img=lib.card[bg].image;
if(img){
- if(img.indexOf('db:')==0){
+ if(img.startsWith('db:')){
img=img.slice(3);
}
- else if(img.indexOf('ext:')!=0){
+ else if(!img.startsWith('ext:')){
img=null;
}
}
@@ -29287,7 +29254,7 @@
if(!lib.config.hide_card_image&&lib.card[bg].fullskin){
this.classList.add('fullskin');
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
this.node.image.setBackgroundImage(img.replace(/^ext:/,'extension/'));
}
else{
@@ -29322,7 +29289,7 @@
else if(lib.card[bg].fullimage){
this.classList.add('fullimage');
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
this.setBackgroundImage(img.replace(/^ext:/,'extension/'));
this.style.backgroundSize='cover';
}
@@ -29331,7 +29298,7 @@
}
}
else if(lib.card[bg].image){
- if(lib.card[bg].image.indexOf('character:')==0){
+ if(lib.card[bg].image.startsWith('character:')){
this.setBackground(lib.card[bg].image.slice(10),'character');
}
else{
@@ -29366,7 +29333,7 @@
this.insertBefore(this.node.framebg,this.firstChild);
}
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
this.node.avatar.setBackgroundImage(img.replace(/^ext:/,'extension/'));
this.node.avatar.style.backgroundSize='cover';
}
@@ -29375,7 +29342,7 @@
}
}
else if(lib.card[bg].image){
- if(lib.card[bg].image.indexOf('character:')==0){
+ if(lib.card[bg].image.startsWith('character:')){
this.node.avatar.setBackground(lib.card[bg].image.slice(10),'character');
}
else{
@@ -29398,7 +29365,7 @@
}
else if(typeof lib.card[bg].image=='string'&&!lib.card[bg].fullskin){
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
this.setBackgroundImage(img.replace(/^ext:/,'extension/'));
this.style.backgroundSize='cover';
}
@@ -30212,7 +30179,7 @@
listAdded={};
var notemp=player.skills.slice(0);
for(var j in player.additionalSkills){
- if(j.indexOf('hidden:')!=0) notemp.addArray(player.additionalSkills[j]);
+ if(!j.startsWith('hidden:')) notemp.addArray(player.additionalSkills[j]);
}
for(var j in player.tempSkills){
if(notemp.contains(j)) continue;
@@ -30347,7 +30314,7 @@
dialog:{
add:function(item,noclick,zoom){
if(typeof item=='string'){
- if(item.indexOf('###')==0){
+ if(item.startsWith('###')){
var items=item.slice(3).split('###');
this.add(items[0],noclick,zoom);
this.addText(items[1],items[1].length<=20,zoom);
@@ -30395,7 +30362,7 @@
return item;
},
addText:function(str,center){
- if(str&&str.indexOf(''+str+'
');
}
@@ -31260,10 +31227,10 @@
const del=groupSort(a)-groupSort(b);
if(del!=0) return del;
let aa=a,bb=b;
- if(a.indexOf('_')!=-1){
+ if(a.includes('_')){
a=a.slice(a.indexOf('_')+1);
}
- if(b.indexOf('_')!=-1){
+ if(b.includes('_')){
b=b.slice(b.indexOf('_')+1);
}
if(a!=b){
@@ -31288,10 +31255,10 @@
var del=typeSort(a)-typeSort(b);
if(del!=0) return del;
var aa=a,bb=b;
- if(a.indexOf('_')!=-1){
+ if(a.includes('_')){
a=a.slice(a.indexOf('_')+1);
}
- if(b.indexOf('_')!=-1){
+ if(b.includes('_')){
b=b.slice(b.indexOf('_')+1);
}
if(a!=b){
@@ -31333,10 +31300,10 @@
},
capt:function(a,b){
var aa=a,bb=b;
- if(aa.indexOf('_')!=-1){
+ if(aa.includes('_')){
aa=aa.slice(aa.indexOf('_')+1);
}
- if(bb.indexOf('_')!=-1){
+ if(bb.includes('_')){
bb=bb.slice(bb.indexOf('_')+1);
}
if(aa!=bb){
@@ -32083,7 +32050,7 @@
if(info[3].contains('dualside')&&info[4]){
player.storage.dualside=[list[i],player.hp,player.maxHp];
for(var j=0;j{
var numberOfCardsToDraw=cards.length;
cards.forEach(value=>{
- if(lib.config.mode=='stone'&&_status.mode=='deck'&&!player.isMin()&&get.type(value).indexOf('stone')==0){
+ if(lib.config.mode=='stone'&&_status.mode=='deck'&&!player.isMin()&&get.type(value).startsWith('stone')){
var stonecard=get.stonecard(1,player.career);
if(stonecard.length){
numberOfCardsToDraw-=stonecard.length;
@@ -33922,6 +33889,13 @@
game.callHook("addNature",[nature,translation,config]);
return nature;
},
+ //判断卡牌信息/事件是否有某个属性
+ hasNature:(item,nature,player)=>{
+ var natures=get.natureList(item,player);
+ if(!nature) return natures.length>0;
+ if(nature=='linked') return natures.some(n=>lib.linked.includes(n));
+ return get.is.sameNature(natures,nature);
+ },
//设置卡牌信息/事件的属性
setNature:(item,nature,addNature)=>{
if(!nature) nature=[];
@@ -34142,14 +34116,14 @@
}
document.body.insertBefore(ui.background,document.body.firstChild);
- if(background.indexOf('ext:')==0){
+ if(background.startsWith('ext:')){
ui.background.setBackgroundImage('extension/'+background.slice(4));
}
else if(background=='default'){
ui.background.animate('start');
ui.background.style.backgroundImage="none";
}
- else if(background.indexOf('custom_')==0){
+ else if(background.startsWith('custom_')){
ui.background.style.backgroundImage="none";
game.getDB('image',background,function(fileToLoad){
if(!fileToLoad) return;
@@ -34815,10 +34789,10 @@
}
else{
if(ui.confirm&&ui.confirm.str){
- if(ui.confirm.str.indexOf('c')!=-1){
+ if(ui.confirm.str.includes('c')){
ui.click.cancel();
}
- else if(ui.confirm.str.indexOf('o')!=-1){
+ else if(ui.confirm.str.includes('o')){
ui.click.ok();
}
}
@@ -34885,7 +34859,7 @@
delete game.ws;
}
var str='';
- if(ip.indexOf('wss://')!=0&&ip.indexOf('ws://')!=0) str=(get.config('wss_mode','connect')?'wss://':'ws://');
+ if(!ip.startsWith('wss://')&&!ip.startsWith('ws://')) str=(get.config('wss_mode','connect')?'wss://':'ws://');
game.ws=new WebSocket(str+ip+'');
}
catch(e){
@@ -34967,8 +34941,8 @@
else if(typeof argument=='function') onError=argument;
if(_status.video) break;
}
- if(path.indexOf('ext:')==0) path=path.replace(/^ext:/,'extension/');
- else if(path.indexOf('db:')!=0) path=`audio/${path}`;
+ if(path.startsWith('ext:')) path=path.replace(/^ext:/,'extension/');
+ else if(!path.startsWith('db:')) path=`audio/${path}`;
if(!lib.config.repeat_audio&&_status.skillaudio.contains(path)) return;
_status.skillaudio.add(path);
game.addVideo('playAudio',null,path);
@@ -34989,7 +34963,7 @@
//Some browsers do not support "autoplay", so "oncanplay" listening has been added
audio.oncanplay=()=>Promise.resolve(audio.play()).catch(()=>void 0);
new Promise((resolve,reject)=>{
- if(path.indexOf('db:')==0) game.getDB('image',path.slice(3)).then(octetStream=>resolve(get.objectURL(octetStream)),reject);
+ if(path.startsWith('db:')) game.getDB('image',path.slice(3)).then(octetStream=>resolve(get.objectURL(octetStream)),reject);
else if(lib.path.extname(path)) resolve(`${lib.assetURL}${path}`);
else resolve(`${lib.assetURL}${path}.mp3`);
}).then(resolvedPath=>{
@@ -35048,7 +35022,7 @@
else if(info.audioname.includes(player.name2)&&(!info.audioname2||!info.audioname2[player.name2])) audioName+='_'+player.name2;
}
if(typeof audioInfo=='string'){
- if(audioInfo.indexOf('db:')==0){
+ if(audioInfo.startsWith('db:')){
audioInfo=audioInfo.split(':');
if(audioInfo.length<4) return;
if(audioInfo[3]=='true') game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${audioName}.${audioInfo[4]||'mp3'}`);
@@ -35058,7 +35032,7 @@
game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${audioName}${Math.floor(audioInfo[3]*Math.random())+1}.${audioInfo[4]||'mp3'}`);
}
}
- else if(audioInfo.indexOf('ext:')==0){
+ else if(audioInfo.startsWith('ext:')){
audioInfo=audioInfo.split(':');
if(audioInfo.length<3) return;
if(audioInfo[2]=='true') game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${audioName}.${audioInfo[3]||'mp3'}`);
@@ -35140,7 +35114,7 @@
aozhan=Object.keys(lib.mode.guozhan.config.aozhan_bgm.item).randomGet('disabled','random',_status.currentAozhan);
}
_status.currentAozhan=aozhan;
- ui.backgroundMusic.src=lib.assetURL+(aozhan.indexOf('ext:')==0?'extension/'+aozhan.slice(4):'audio/background/aozhan_'+aozhan+'.mp3');
+ ui.backgroundMusic.src=lib.assetURL+(aozhan.startsWith('ext:')?'extension/'+aozhan.slice(4):'audio/background/aozhan_'+aozhan+'.mp3');
}
else{
var music=_status.tempMusic||lib.config.background_music;
@@ -35157,7 +35131,7 @@
}
}
else{
- ui.backgroundMusic.src=lib.assetURL+(music.indexOf('ext:')==0?'extension/'+music.slice(4):'audio/background/'+music+'.mp3');
+ ui.backgroundMusic.src=lib.assetURL+(music.startsWith('ext:')?'extension/'+music.slice(4):'audio/background/'+music+'.mp3');
}
}
},
@@ -35263,7 +35237,7 @@
if(!object||!libConfig[`${extensionName}_enable`]) return;
if(!noEval) lib.init.eval(object);
const config=Object.keys(libConfig).reduce((constructingConfig,key)=>{
- if(key!=extensionName&&key.indexOf(extensionName)==0) constructingConfig[key.slice(11+name.length)]=libConfig[key];
+ if(key!=extensionName&&key.startsWith(extensionName)) constructingConfig[key.slice(11+name.length)]=libConfig[key];
return constructingConfig;
},{});
try{
@@ -35519,10 +35493,10 @@
else{
current2=current;
}
- if(current.indexOf('theme')==0){
+ if(current.startsWith('theme')){
game.print(current.slice(6));
}
- else if(current.indexOf('image/skin')==0){
+ else if(current.startsWith('image/skin')){
game.print(current.slice(11));
}
else{
@@ -36966,7 +36940,7 @@
},
exit:function(){
var ua=navigator.userAgent.toLowerCase();
- var ios=ua.indexOf('iphone')!=-1||ua.indexOf('ipad')!=-1||ua.indexOf('macintosh')!=-1;
+ var ios=ua.includes('iphone')||ua.includes('ipad')||ua.includes('macintosh');
//electron
if(typeof window.process=='object'&&typeof window.require=='function'){
var versions=window.process.versions;
@@ -37102,7 +37076,7 @@
noinput=true;
}
else if(typeof arguments[i]=='string'){
- if(arguments[i].indexOf('###')==0){
+ if(arguments[i].startsWith('###')){
var list=arguments[i].slice(3).split('###');
str=list[0];
str2=list[1];
@@ -37889,7 +37863,7 @@
removeExtension:(extensionName,keepFile)=>{
const prefix=`extension_${extensionName}`;
Object.keys(lib.config).forEach(key=>{
- if(key.indexOf(prefix)==0) game.saveConfig(key);
+ if(key.startsWith(prefix)) game.saveConfig(key);
});
localStorage.removeItem(`${lib.configprefix}${prefix}`);
game.deleteDB('data',prefix);
@@ -38484,7 +38458,7 @@
if(modecharacters){
if(get.mode()=='guozhan'){
if(modecharacters[newvid.name1]){
- if(newvid.name1.indexOf('gz_shibing')==0){
+ if(newvid.name1.startsWith('gz_shibing')){
newvid.name1=newvid.name1.slice(3,11);
}
else{
@@ -38492,7 +38466,7 @@
}
}
if(modecharacters[newvid.name2]){
- if(newvid.name2.indexOf('gz_shibing')==0){
+ if(newvid.name2.startsWith('gz_shibing')){
newvid.name2=newvid.name2.slice(3,11);
}
else{
@@ -38509,10 +38483,10 @@
}
}
}
- if(newvid.name1&&newvid.name1.indexOf('subplayer_')==0){
+ if(newvid.name1&&newvid.name1.startsWith('subplayer_')){
newvid.name1=newvid.name1.slice(10,newvid.name1.lastIndexOf('_'));
}
- if(newvid.name2&&newvid.name2.indexOf('subplayer_')==0){
+ if(newvid.name2&&newvid.name2.startsWith('subplayer_')){
newvid.name1=newvid.name2.slice(10,newvid.name1.lastIndexOf('_'));
}
lib.videos.unshift(newvid);
@@ -38991,7 +38965,7 @@
}
if(lib.config.popequip&&get.is.phoneLayout()&&
- typeof event.position=='string'&&event.position.indexOf('e')!=-1&&
+ typeof event.position=='string'&&event.position.includes('e')&&
player.node.equips.querySelector('.card.selectable')){
player.node.equips.classList.add('popequip');
auto_confirm=false;
@@ -41006,13 +40980,13 @@
const caption=lib.version==lib.config.version?'扩展更新':`${lib.version}更新内容`;
let players=null,cards=null;
if(lib.version!=lib.config.version) lib.changeLog.forEach(value=>{
- if(value.indexOf('players://')==0) try{
+ if(value.startsWith('players://')) try{
players=JSON.parse(value.slice(10)).filter(value=>lib.character[value]);
}
catch(e){
players=null;
}
- else if(value.indexOf('cards://')==0) try{
+ else if(value.startsWith('cards://')) try{
cards=JSON.parse(value.slice(8)).filter(value=>lib.card[value]);
}
catch(e){
@@ -41602,16 +41576,16 @@
node.classList.add('tempimage');
let img=lib.card[cardName].image;
if(img){
- if(img.indexOf('db:')==0){
+ if(img.startsWith('db:')){
img=img.slice(3);
}
- else if(img.indexOf('ext:')!=0){
+ else if(!img.startsWith('ext:')){
img=null;
}
}
if(lib.card[cardName].fullskin){
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
bg.setBackgroundImage(img.replace(/^ext:/,'extension/'));
}
else{
@@ -41634,7 +41608,7 @@
}
else if(lib.card[cardName].fullimage){
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
bg.setBackgroundImage(img.replace(/^ext:/,'extension/'));
bg.style.backgroundSize='cover';
}
@@ -41643,7 +41617,7 @@
}
}
else if(lib.card[cardName].image){
- if(lib.card[cardName].image.indexOf('character:')==0){
+ if(lib.card[cardName].image.startsWith('character:')){
bg.setBackground(lib.card[cardName].image.slice(10),'character');
}
else{
@@ -41666,7 +41640,7 @@
}
else if(typeof lib.card[cardName].image=='string'&&!lib.card[cardName].fullskin){
if(img){
- if(img.indexOf('ext:')==0){
+ if(img.startsWith('ext:')){
bg.setBackgroundImage(img.replace(/^ext:/,'extension/'));
bg.style.backgroundSize='cover';
}
@@ -43010,10 +42984,10 @@
list.sort(function(a,b){
a=a[0];b=b[0];
var aa=a,bb=b;
- if(aa.indexOf('_')!=-1){
+ if(aa.includes('_')){
aa=aa.slice(aa.indexOf('_')+1);
}
- if(bb.indexOf('_')!=-1){
+ if(bb.includes('_')){
bb=bb.slice(bb.indexOf('_')+1);
}
if(aa!=bb){
@@ -43211,7 +43185,7 @@
if(fileToLoad){
if(!lib.config.customBackgroundMusic) lib.config.customBackgroundMusic={};
var name=fileToLoad.name;
- if(name.indexOf('.')!=-1){
+ if(name.includes('.')){
name=name.slice(0,name.indexOf('.'));
}
var link=(game.writeFile?'cdv_':'custom_')+name;
@@ -43350,9 +43324,9 @@
var images=[],audios=[],fonts=[],directories={},directoryList=[];
Object.keys(zip.files).forEach(file=>{
const parsedPath=lib.path.parse(file),directory=parsedPath.dir,fileExtension=parsedPath.ext.toLowerCase();
- if(directory.indexOf('audio')==0&&(fileExtension=='.mp3'||fileExtension=='.ogg')) audios.push(file);
- else if(directory.indexOf('font')==0&&fileExtension=='.woff2') fonts.push(file);
- else if(directory.indexOf('image')==0&&(fileExtension=='.jpg'||fileExtension=='.png')) images.push(file);
+ if(directory.startsWith('audio')&&(fileExtension=='.mp3'||fileExtension=='.ogg')) audios.push(file);
+ else if(directory.startsWith('font')&&fileExtension=='.woff2') fonts.push(file);
+ else if(directory.startsWith('image')&&(fileExtension=='.jpg'||fileExtension=='.png')) images.push(file);
else return;
if(!directories[directory]){
directories[directory]=[];
@@ -43895,7 +43869,7 @@
for(var i=0;i该武将包不可被隐藏',page);
}
- else if(mode.indexOf('mode_')!=0){
+ else if(!mode.startsWith('mode_')){
ui.create.div('.config.pointerspan','隐藏武将包',page,function(){
if(this.firstChild.innerHTML=='隐藏武将包'){
if(confirm('真的要隐藏“'+get.translation(mode+'_character_config')+'”武将包吗?\n建议使用“关闭”而不是“隐藏”功能,否则将会影响其他相关武将包的正常运行!')){
@@ -44257,13 +44231,9 @@
for(var i=0;i{
+ if(key.startsWith('mode_')) createModeConfig(key,start.firstChild);
+ });
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
@@ -44343,7 +44313,7 @@
for(var i=0;i隐藏卡牌包',page,function(){
if(this.firstChild.innerHTML=='隐藏卡牌包'){
this.firstChild.innerHTML='卡牌包将在重启后隐藏';
@@ -44533,7 +44503,7 @@
game.saveConfig('hiddenCardPack',lib.config.hiddenCardPack);
});
}
- if(mode.indexOf('mode_')!=0&&lib.cardPile[mode]){
+ if(!mode.startsWith('mode_')&lib.cardPile[mode]){
var cardpileNodes=[];
var cardpileexpanded=false;
if(!lib.config.bannedpile[mode]){
@@ -44708,13 +44678,9 @@
if(connectMenu&&!lib.connectCardPack.contains(lib.config.all.cards[i])) continue;
createModeConfig(lib.config.all.cards[i],start.firstChild);
}
- if(!connectMenu){
- for(var i in lib.cardPack){
- if(i.indexOf('mode_')==0){
- createModeConfig(i,start.firstChild);
- }
- }
- }
+ if(!connectMenu) Object.keys(lib.cardPack).forEach(key=>{
+ if(key.startsWith('mode_')) createModeConfig(key,start.firstChild);
+ });
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
@@ -44905,7 +44871,7 @@
var node=start.firstChild.childNodes[i];
if(node.mode=='get') continue;
if(node.mode=='create') continue;
- if(node.mode&&node.mode.indexOf('extension_')==0){
+ if(node.mode&&node.mode.startsWith('extension_')){
if(lib.config[node.mode+'_enable']){
node.classList.remove('off');
if(node.link) node.link.firstChild.classList.add('on');
@@ -44929,7 +44895,7 @@
}
var togglePack=function(bool){
var name=this._link.config._name;
- if(name.indexOf('extension_')==0){
+ if(name.startsWith('extension_')){
if(bool){
game.saveConfig(name,true);
}
@@ -44957,7 +44923,7 @@
var page=ui.create.div('');
page.style.paddingBottom='10px';
var node;
- if(mode.indexOf('extension_')==0){
+ if(mode.startsWith('extension_')){
node=ui.create.div('.menubutton.large',mode.slice(10),position,clickMode);
}
else{
@@ -44973,7 +44939,7 @@
if(i=='game') continue;
var cfg=copyObj(lib.extensionMenu[mode][i]);
var j;
- if(mode.indexOf('extension_')==0){
+ if(mode.startsWith('extension_')){
j=mode+'_'+i;
}
else{
@@ -45492,7 +45458,7 @@
}
}
for(var i=0;i{
+ const updateURLS=lib.updateURLS;
+ for(const key in updateURLS){
+ const updateURL=updateURLS[key];
+ if(url==updateURL) return lib.configMenu.general.config.update_link.item[key];
}
- if(str==lib.updateURLS.coding){
- return 'Coding';
+ let index=url.indexOf('://');
+ if(index!=-1) url=url.slice(index+3);
+ index=url.indexOf('/');
+ if(index!=-1) url=url.slice(0,index);
+ if(url.length>15){
+ const list=url.split('.');
+ if(list.length>1) list.shift();
+ url=list.join('.');
}
- var index;
- index=str.indexOf('://');
- if(index!=-1){
- str=str.slice(index+3);
+ if(url.length>15){
+ const list=url.split('.');
+ if(list.length>1) list.pop();
+ url=list.join('.');
}
- index=str.indexOf('/');
- if(index!=-1){
- str=str.slice(0,index);
- }
- if(str.length>15){
- var list=str.split('.');
- if(list.length>1){
- list.shift();
- }
- str=list[0];
- for(var i=1;i15){
- var list=str.split('.');
- if(list.length>1){
- list.pop();
- }
- str=list[0];
- for(var i=1;i
';
li2.innerHTML='素材版本:'+(lib.config.asset_version||'无')+'';
- li3.innerHTML='更新地址:'+trimurl(lib.config.updateURL||lib.updateURL)+'';
+ li3.innerHTML='更新地址:'+trimURL(lib.config.updateURL||lib.updateURL)+'';
li3.style.whiteSpace='nowrap';
li3.style.display='none';// coding
@@ -47580,7 +47530,7 @@
str=files[i].slice(0,str);
files.splice(i--,1);
for(var j=0;j';
+ if(!str.startsWith('';
var next=dialog.add(str);
if(!noclick) next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=link;
@@ -51906,7 +51856,7 @@
},
skin:function(avatar,name,callback){
var num=1;
- if(name.indexOf('gz_')==0){
+ if(name.startsWith('gz_')){
name=name.slice(3);
}
if(lib.config.skin[name]){
@@ -54440,10 +54390,10 @@
var nameskin=name;
var nameskin2=name;
var gzbool=false;
- if(nameskin.indexOf('gz_shibing')==0){
+ if(nameskin.startsWith('gz_shibing')){
nameskin=nameskin.slice(3,11);
}
- else if(nameskin.indexOf('gz_')==0){
+ else if(nameskin.startsWith('gz_')){
nameskin=nameskin.slice(3);
gzbool=true;
}
@@ -54696,14 +54646,14 @@
rightParenthesisRP.textContent=')';
ruby.appendChild(rightParenthesisRP);
characterIntroTable.appendChild(ruby);
- const characterSexDiv=ui.create.div('.character-sex',characterIntroTable),exInfoSex=exInfo&&exInfo.find(value=>value.indexOf('sex:')==0),characterSex=exInfoSex?exInfoSex.split(':').pop():nameInfo[0];
+ const characterSexDiv=ui.create.div('.character-sex',characterIntroTable),exInfoSex=exInfo&&exInfo.find(value=>value.startsWith('sex:')),characterSex=exInfoSex?exInfoSex.split(':').pop():nameInfo[0];
new Promise((resolve,reject)=>{
const imageName=`sex_${characterSex}`,information=lib.card[imageName];
if(!information) resolve(`${lib.assetURL}image/card/${imageName}.png`);
const image=information.image;
if(!image) resolve(`${lib.assetURL}image/card/${imageName}.png`);
- else if(image.indexOf('db:')==0) game.getDB('image',image.slice(3)).then(resolve,reject);
- else if(image.indexOf('ext:')==0) resolve(`${lib.assetURL}${image.replace(/^ext:/,'extension/')}`);
+ else if(image.startsWith('db:')) game.getDB('image',image.slice(3)).then(resolve,reject);
+ else if(image.startsWith('ext:')) resolve(`${lib.assetURL}${image.replace(/^ext:/,'extension/')}`);
else resolve(`${lib.assetURL}${image}`);
}).then(source=>new Promise((resolve,reject)=>{
const image=new Image();
@@ -54717,8 +54667,8 @@
if(!information) resolve(`${lib.assetURL}image/card/${imageName}.png`);
const image=information.image;
if(!image) resolve(`${lib.assetURL}image/card/${imageName}.png`);
- else if(image.indexOf('db:')==0) game.getDB('image',image.slice(3)).then(resolve,reject);
- else if(image.indexOf('ext:')==0) resolve(`${lib.assetURL}${image.replace(/^ext:/,'extension/')}`);
+ else if(image.startsWith('db:')) game.getDB('image',image.slice(3)).then(resolve,reject);
+ else if(image.startsWith('ext:')) resolve(`${lib.assetURL}${image.replace(/^ext:/,'extension/')}`);
else resolve(`${lib.assetURL}${image}`);
}).then(source=>new Promise((resolve,reject)=>{
const image=new Image();
@@ -54737,8 +54687,8 @@
if(!information) resolve(`${lib.assetURL}image/card/${imageName}.png`);
const image=information.image;
if(!image) resolve(`${lib.assetURL}image/card/${imageName}.png`);
- else if(image.indexOf('db:')==0) game.getDB('image',image.slice(3)).then(resolve,reject);
- else if(image.indexOf('ext:')==0) resolve(`${lib.assetURL}${image.replace(/^ext:/,'extension/')}`);
+ else if(image.startsWith('db:')) game.getDB('image',image.slice(3)).then(resolve,reject);
+ else if(image.startsWith('ext:')) resolve(`${lib.assetURL}${image.replace(/^ext:/,'extension/')}`);
else resolve(`${lib.assetURL}${image}`);
}).then(source=>new Promise((resolve,reject)=>{
const image=new Image();
@@ -54882,7 +54832,7 @@
if(!get.info(list[i])||get.info(list[i]).nopop) continue;
if(!lib.translate[list[i]]||!lib.translate[list[i]+'_info']) continue;
var skilltrans=get.translation(list[i]);
- if(skilltrans.indexOf(' ')==0){
+ if(skilltrans.startsWith(' ')){
skilltrans=skilltrans.slice(6);
}
var current=ui.create.div('.menubutton.large',skills,clickSkill,skilltrans);
@@ -55856,7 +55806,13 @@
const get={
//Generate an object URL from the Base64-encoded octet stream
//从Base64编码的八位字节流生成对象URL
- objectURL:octetStream=>URL.createObjectURL(new Blob([Uint8Array.from(atob(octetStream.replace(/^data:[\s\S]*\/[\s\S]*;base64,/,'')),v=>v.charCodeAt())])),
+ objectURL:octetStream=>{
+ const objectURLMap=lib.objectURL;
+ if(objectURLMap.has(octetStream)) return objectURLMap.get(octetStream);
+ const objectURL=URL.createObjectURL(new Blob([Uint8Array.from(atob(octetStream.replace(/^data:[\s\S]*\/[\s\S]*;base64,/,'')),character=>character.charCodeAt())]));
+ objectURLMap.set(octetStream,objectURL);
+ return objectURL;
+ },
//Get the card name length
//获取此牌的字数
cardNameLength:(card,player)=>{
@@ -55937,7 +55893,7 @@
}
//排除声母
for(let i of lib.pinyins._metadata.shengmu){
- if(str.indexOf(i)==0){
+ if(str.startsWith(i)){
str=str.slice(i.length);
if(str[0]=='u'&&lib.pinyins._metadata.special_shengmu.contains(i)) str='ü'+str.slice(1);
break;
@@ -55949,7 +55905,7 @@
if(str[0]==i){
let goon=false;
for(let j of lib.pinyins._metadata.feijiemu[i]){
- if(str.indexOf(j)==0) goon=true;
+ if(str.startsWith(j)) goon=true;
}
if(!goon) str=str.slice(1);
break;
@@ -55966,7 +55922,7 @@
}
else{
for(let i of lib.pinyins._metadata.shengmu){
- if(str.indexOf(i)==0){
+ if(str.startsWith(i)){
str=str.slice(i.length);
if(str[0]=='u'&&lib.pinyins._metadata.special_shengmu.contains(i)) str='ü'+str.slice(1);
break;
@@ -56036,20 +55992,20 @@
},
infoHp:function(hp){
if(typeof hp=='number') return hp;
- else if(typeof hp=='string'&&hp.indexOf('/')!=-1){
+ else if(typeof hp=='string'&&hp.includes('/')){
return parseInt(hp.split('/')[0]);
}
return 0;
},
infoMaxHp:function(hp){
if(typeof hp=='number') return hp;
- else if(typeof hp=='string'&&hp.indexOf('/')!=-1){
+ else if(typeof hp=='string'&&hp.includes('/')){
return parseInt(hp.split('/')[1]);
}
return 0;
},
infoHujia:function(hp){
- if(typeof hp=='string'&&hp.indexOf('/')!=-1){
+ if(typeof hp=='string'&&hp.includes('/')){
var splited=hp.split('/');
if(splited.length>2) return parseInt(splited[2]);
}
@@ -56119,11 +56075,10 @@
});
},
//判断一张牌是否为明置手牌
- shownCard:function(card){
- if(card&&Array.isArray(card.gaintag)){
- return card.gaintag.some(tag=>tag.indexOf('visible_')==0)
- }
- return false;
+ shownCard:card=>{
+ if(!card) return false;
+ const gaintag=card.gaintag;
+ return Array.isArray(gaintag)&&gaintag.some(tag=>tag.startsWith('visible_'));
},
//是否是虚拟牌
vituralCard:card=>card.isCard||(!("cards" in card)||!Array.isArray(card.cards)||card.cards.length==0),
@@ -56148,13 +56103,11 @@
return false;
},
double:(name,array)=>{
- let info=get.character(name,4);
- if(!info) return false;
- for(let i of info){
- if(i.indexOf('doublegroup:')==0){
- if(!array) return true;
- return i.split(':').slice(1);
- }
+ const extraInformations=get.character(name,4);
+ if(!extraInformations) return false;
+ for(const extraInformation of extraInformations){
+ if(!extraInformation.startsWith('doublegroup:')) continue;
+ return Boolean(array)&&extraInformation.split(':').slice(1);
}
return false;
},
@@ -56231,7 +56184,7 @@
banWords:function(str){
if(get.is.emoji(str)) return true;
for(var i of window.bannedKeyWords){
- if(str.indexOf(i)!=-1) return true;
+ if(str.includes(i)) return true;
}
return false;
},
@@ -56316,7 +56269,7 @@
if(name.isUnseen&&name.isUnseen(0)) return false;
name=name.name1;
}
- if(typeof name=='string'&&name.indexOf('gz_jun_')==0){
+ if(typeof name=='string'&&name.startsWith('gz_jun_')){
return true;
}
}
@@ -56439,7 +56392,7 @@
next.set('prompt2',str);
}
else{
- if(str.indexOf('###')==0){
+ if(str.startsWith('###')){
var prompts=str.slice(3).split('###');
if(prompts[0]) next.set('prompt',prompts[0]);
if(prompts[1]) next.set('prompt2',prompts[1]);
@@ -56614,12 +56567,12 @@
var tags=get.character(name,4);
if(tags){
for(var i=0;i
1&&threaten>1){
num+=Math.sqrt(threaten)-1;
}
}
- if(type&&type.indexOf('out')!=-1){
+ if(type&&type.includes('out')){
if(threaten<1){
num*=1/Math.sqrt(threaten);
}
@@ -57256,12 +57209,12 @@
var list=Array.isArray(info.trigger.global)?info.trigger.global:[info.trigger.global];
num+=Math.min(3,list.length)/10;
for(var i of list){
- if(i.indexOf('lose')==0||i.indexOf('use')==0) num+=0.3;
- if(i.indexOf('cardsDiscard')==0) num+=0.4;
+ if(i.startsWith('lose')||i.startsWith('use')) num+=0.3;
+ if(i.startsWith('cardsDiscard')) num+=0.4;
}
}
if(info.trigger.target||(typeof info.trigger.player=='string'&&
- (info.trigger.player.indexOf('damage')==0||info.trigger.player.indexOf('lose')==0))) num+=0.1;
+ (info.trigger.player.startsWith('damage')||info.trigger.player.startsWith('lose')))) num+=0.1;
}
if(info.ai){
if(info.ai.maixie||info.ai.maixie_hp||info.ai.maixie_defend){
@@ -57501,16 +57454,16 @@
parsedResult:function(item){
if(!item) return item;
if(typeof item=='string'){
- if(item.indexOf('_noname_func:')==0){
+ if(item.startsWith('_noname_func:')){
return get.infoFuncOL(item);
}
- else if(item.indexOf('_noname_card:')==0){
+ else if(item.startsWith('_noname_card:')){
return get.infoCardOL(item);
}
- else if(item.indexOf('_noname_player:')==0){
+ else if(item.startsWith('_noname_player:')){
return get.infoPlayerOL(item);
}
- else if(item.indexOf('_noname_event:')==0){
+ else if(item.startsWith('_noname_event:')){
return get.infoEventOL(item);
}
else if(item=='_noname_infinity'){
@@ -57625,7 +57578,7 @@
}
if(bool) return 'position';
}
- if(obj.indexOf(lib.natureSeparator)!=-1&&obj.split(lib.natureSeparator).every(n=>lib.nature.has(n))) return 'natures';
+ if(obj.includes(lib.natureSeparator)&&obj.split(lib.natureSeparator).every(n=>lib.nature.has(n))) return 'natures';
if(lib.nature.has(obj)) return 'nature';
}
if(Array.isArray(obj)&&obj.length){
@@ -57700,7 +57653,7 @@
},
equiptype:function(card,player){
var subtype=get.subtype(card,player);
- if(subtype.indexOf('equip')==0) return parseInt(subtype[5]);
+ if(subtype.startsWith('equip')) return parseInt(subtype[5]);
return 0;
},
name:function(card,player){
@@ -58014,7 +57967,7 @@
},
skillTranslation:function(str,player){
var str2;
- if(str.indexOf('re')==0){
+ if(str.startsWith('re')){
str2=str.slice(2);
if(str2){
if(lib.translate[str]==lib.translate[str2]){
@@ -58024,7 +57977,7 @@
}
}
}
- else if(str.indexOf('xin')==0){
+ else if(str.startsWith('xin')){
str2=str.slice(3);
if(str2){
if(lib.translate[str]==lib.translate[str2]){
@@ -59085,10 +59038,10 @@
var nameskin=(avatar2?node.name2:node.name1);
var nameskin2=nameskin;
var gzbool=false;
- if(nameskin.indexOf('gz_shibing')==0){
+ if(nameskin.startsWith('gz_shibing')){
nameskin=nameskin.slice(3,11);
}
- else if(nameskin.indexOf('gz_')==0){
+ else if(nameskin.startsWith('gz_')){
nameskin=nameskin.slice(3);
gzbool=true;
}
@@ -59149,10 +59102,10 @@
var nameskin=(avatar2?node.name2:node.name1);
var nameskin2=nameskin;
var gzbool=false;
- if(nameskin.indexOf('gz_shibing')==0){
+ if(nameskin.startsWith('gz_shibing')){
nameskin=nameskin.slice(3,11);
}
- else if(nameskin.indexOf('gz_')==0){
+ else if(nameskin.startsWith('gz_')){
nameskin=nameskin.slice(3);
gzbool=true;
}
@@ -59170,10 +59123,10 @@
setTimeout(function(){
var nameskin1=node.name1;
var nameskin2=node.name2;
- if(nameskin1&&nameskin1.indexOf('gz_')==0){
+ if(nameskin1&&nameskin1.startsWith('gz_')){
nameskin1=nameskin1.slice(3);
}
- if(nameskin2&&nameskin2.indexOf('gz_')==0){
+ if(nameskin2&&nameskin2.startsWith('gz_')){
nameskin2=nameskin2.slice(3);
}
if(!node.isUnseen(0)&&lib.skin[nameskin1]){
@@ -59207,7 +59160,7 @@
else if(info.name!==false){
uiintro.add(get.translation(node.skill));
}
- if(typeof info.id=='string'&&info.id.indexOf('subplayer')==0&&
+ if(typeof info.id=='string'&&info.id.startsWith('subplayer')&&
player.isUnderControl(true)&&player.storage[info.id]&&!_status.video){
var storage=player.storage[info.id];
uiintro.addText('当前体力:'+storage.hp+'/'+storage.maxHp);
@@ -59224,7 +59177,7 @@
var stint=info.mark(uiintro,player.storage[node.skill],player);
if(stint){
var placetext=uiintro.add(''+stint+'
');
- if(stint.indexOf(''+stint+'
');
- if(stint.indexOf(''+str+'
');
- if(str.indexOf(''+lib.translate[name+'_info']+'
');
- if(lib.translate[name+'_info'].indexOf('已横置
');
var list=[];
for(var i=0;i