fix some bugs with eslint

This commit is contained in:
kuangshen04 2023-11-06 23:22:32 +08:00
parent 8969a43b18
commit a4178cb2b9
2 changed files with 81 additions and 78 deletions

View File

@ -1,5 +1,5 @@
{ {
"extends": "chrome 46", "extends": "eslint:recommended",
"env": { "env": {
"browser": true, "browser": true,
"node": true, "node": true,
@ -10,6 +10,11 @@
"no-console": 0, "no-console": 0,
"no-unused-vars": 0, "no-unused-vars": 0,
"no-undef": 0, "no-undef": 0,
"no-redeclare": 0 "no-redeclare": 0,
"no-prototype-builtins": 0,
"no-irregular-whitespace": ["error", { "skipStrings": true, "skipTemplates": true }],
"no-constant-condition": ["error", { "checkLoops": false }]/* ,
"comma-dangle": ["error", "only-multiline"],
"complexity": ["error",100] */
} }
} }

View File

@ -6511,7 +6511,7 @@
else{ else{
lib.codeMirrorReady(node,editor); lib.codeMirrorReady(node,editor);
} }
}; }
}, },
}, },
reset_character_three:{ reset_character_three:{
@ -6603,7 +6603,7 @@
else{ else{
lib.codeMirrorReady(node,editor); lib.codeMirrorReady(node,editor);
} }
}; }
}, },
}, },
reset_character_four:{ reset_character_four:{
@ -7057,7 +7057,7 @@
else{ else{
lib.codeMirrorReady(node,editor); lib.codeMirrorReady(node,editor);
} }
}; }
}, },
}, },
reset_character:{ reset_character:{
@ -7694,9 +7694,9 @@
}else if(newMessage.includes("Invalid regular expression flags")){ }else if(newMessage.includes("Invalid regular expression flags")){
newMessage="无效的正则表达式的标记"; newMessage="无效的正则表达式的标记";
}else if(newMessage.includes("missing ) after argument list")){ }else if(newMessage.includes("missing ) after argument list")){
newMessage="参数列表后面缺少 \')\' (丢失运算符或者转义字符等)"; newMessage="参数列表后面缺少 ')' (丢失运算符或者转义字符等)";
}else if(newMessage.includes("Invalid shorthand property initializer")){ }else if(newMessage.includes("Invalid shorthand property initializer")){
newMessage="在定义一个{}对象时,应该使用\':\'而不是\'=\'"; newMessage="在定义一个{}对象时,应该使用':'而不是'='";
}else if(newMessage.includes("Missing initializer in const declaration")){ }else if(newMessage.includes("Missing initializer in const declaration")){
newMessage="在使用const定义一个对象时必须指定初始值"; newMessage="在使用const定义一个对象时必须指定初始值";
}else if(newMessage.includes("Unexpected number")||newMessage.includes("Unexpected string")){ }else if(newMessage.includes("Unexpected number")||newMessage.includes("Unexpected string")){
@ -7723,11 +7723,11 @@
}else if(newMessage.includes("Cannot read property")){ }else if(newMessage.includes("Cannot read property")){
messageName=newMessage.replace('TypeError: Cannot read property ', '').replace(' of null', '').replace(' of undefined', ''); messageName=newMessage.replace('TypeError: Cannot read property ', '').replace(' of null', '').replace(' of undefined', '');
let ofName=newMessage.slice(newMessage.indexOf(" of ")+4); let ofName=newMessage.slice(newMessage.indexOf(" of ")+4);
newMessage="无法读取\'"+ofName+"\'的属性值"+messageName; newMessage="无法读取'"+ofName+"'的属性值"+messageName;
}else if(newMessage.includes("Cannot read properties")){ }else if(newMessage.includes("Cannot read properties")){
messageName=newMessage.slice(newMessage.indexOf("reading '")+9,-2); messageName=newMessage.slice(newMessage.indexOf("reading '")+9,-2);
let ofName=newMessage.slice(newMessage.indexOf(" of ")+4,newMessage.indexOf("(")-1); let ofName=newMessage.slice(newMessage.indexOf(" of ")+4,newMessage.indexOf("(")-1);
newMessage="无法读取\'"+ofName+"\'的属性值"+messageName; newMessage="无法读取'"+ofName+"'的属性值"+messageName;
}else if(newMessage.includes("Property description must be an object")){ }else if(newMessage.includes("Property description must be an object")){
messageName=newMessage.replace('TypeError: Property description must be an object: ', ''); messageName=newMessage.replace('TypeError: Property description must be an object: ', '');
newMessage=messageName+"是非对象类型的值"; newMessage=messageName+"是非对象类型的值";
@ -7740,7 +7740,7 @@
messageName=newMessage.slice(newMessage.indexOf('\'')+1); messageName=newMessage.slice(newMessage.indexOf('\'')+1);
messageName=messageName.slice(0,messageName.indexOf('\'')); messageName=messageName.slice(0,messageName.indexOf('\''));
let obj=newMessage.slice(newMessage.indexOf(messageName)+16); let obj=newMessage.slice(newMessage.indexOf(messageName)+16);
newMessage=obj+"不能添加或修改\'"+messageName+"\'属性,任何 Primitive 值都不允许有property"; newMessage=obj+"不能添加或修改'"+messageName+"'属性,任何 Primitive 值都不允许有property";
}else if(newMessage.includes("Can't add property")&&newMessage.includes("is not extensible")){ }else if(newMessage.includes("Can't add property")&&newMessage.includes("is not extensible")){
newMessage="对象不可添加属性(不可扩展)"; newMessage="对象不可添加属性(不可扩展)";
}else if(newMessage.includes("Cannot redefine property")){ }else if(newMessage.includes("Cannot redefine property")){
@ -7810,10 +7810,10 @@
code=node.editor.getValue(); code=node.editor.getValue();
}else if(node.textarea){ }else if(node.textarea){
code=node.textarea.value; code=node.textarea.value;
}; }
//动态绑定文本 //动态绑定文本
if(code.length&&change.origin=="+input" && if(code.length&&change.origin=="+input" &&
/{|}|\s|=|;|:|,||。|||\!|\?|&|#|%|@|||/.test(change.text[0])==false&& /{|}|\s|=|;|:|,||。|||!|\?|&|#|%|@|||/.test(change.text[0])==false&&
change.text.length==1) { change.text.length==1) {
//输入了代码,并且不包括空格,{}= ; : 逗号等,才可以自动提示 //输入了代码,并且不包括空格,{}= ; : 逗号等,才可以自动提示
node.editor.showHint(); node.editor.showHint();
@ -7942,7 +7942,7 @@
} }
function javascriptHint(editor,options){ function javascriptHint(editor,options){
return scriptHint(editor,javascriptKeywords,function(e,cur){return e.getTokenAt(cur);},options); return scriptHint(editor,javascriptKeywords,function(e,cur){return e.getTokenAt(cur);},options);
}; }
//覆盖原本的javascript提示 //覆盖原本的javascript提示
CodeMirror.registerHelper("hint","javascript",javascriptHint); CodeMirror.registerHelper("hint","javascript",javascriptHint);
const stringProps=Object.getOwnPropertyNames(String.prototype); const stringProps=Object.getOwnPropertyNames(String.prototype);
@ -8136,7 +8136,7 @@
run:function(time){ run:function(time){
lib.status.time=time; lib.status.time=time;
for(var i=0;i<lib.updates.length;i++){ for(var i=0;i<lib.updates.length;i++){
if(!lib.updates[i].hasOwnProperty('_time')){ if(!Object.prototype.hasOwnProperty.call(lib.updates[i], '_time')){
lib.updates[i]._time=time; lib.updates[i]._time=time;
} }
if(lib.updates[i](time-lib.updates[i]._time-lib.status.delayed)===false){ if(lib.updates[i](time-lib.updates[i]._time-lib.status.delayed)===false){
@ -9006,7 +9006,7 @@
str+=`\n行号: ${line}`; str+=`\n行号: ${line}`;
str+=`\n列号: ${column}`; str+=`\n列号: ${column}`;
const version=lib.version||''; const version=lib.version||'';
const reg=/[^\d\.]/; const reg=/[^\d.]/;
const match=version.match(reg)!=null; const match=version.match(reg)!=null;
str+='\n'+`${match?'游戏':'无名杀'}版本: ${version||'未知版本'}`; str+='\n'+`${match?'游戏':'无名杀'}版本: ${version||'未知版本'}`;
if(match) str+='\n⚠您使用的游戏代码不是源于libccy/noname无名杀官方仓库请自行寻找您所使用的游戏版本开发者反馈'; if(match) str+='\n⚠您使用的游戏代码不是源于libccy/noname无名杀官方仓库请自行寻找您所使用的游戏版本开发者反馈';
@ -9045,7 +9045,7 @@
} }
str+='\n-------------'; str+='\n-------------';
if(typeof line=='number'&&(typeof game.readFile=='function'||location.origin!='file://')){ if(typeof line=='number'&&(typeof game.readFile=='function'||location.origin!='file://')){
function createShowCode(lines){ const createShowCode=function(lines){
let showCode=''; let showCode='';
if(lines.length>=10){ if(lines.length>=10){
if(line>4){ if(line>4){
@ -11368,7 +11368,7 @@
function Legacy(func){ function Legacy(func){
//Remove all comments //Remove all comments
//移除所有注释 //移除所有注释
let str=func.toString().replace(/((?:(?:^[ \t]*)?(?:\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\/(?:[ \t]*\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/)))?|\/\/(?:[^\\]|\\(?:\r?\n)?)*?(?:\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/))|(?=\r?\n))))+)|("(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|(?:\r?\n|[\s\S])[^\/"'\\\s]*)/mg,'$2').trim(); let str=func.toString().replace(/((?:(?:^[ \t]*)?(?:\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\/(?:[ \t]*\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/)))?|\/\/(?:[^\\]|\\(?:\r?\n)?)*?(?:\r?\n(?=[ \t]*(?:\r?\n|\/\*|\/\/))|(?=\r?\n))))+)|("(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|(?:\r?\n|[\s\S])[^/"'\\\s]*)/mg,'$2').trim();
//获取第一个 { 后的所有字符 //获取第一个 { 后的所有字符
str=str.slice(str.indexOf('{')+1); str=str.slice(str.indexOf('{')+1);
//判断代码中是否有debugger //判断代码中是否有debugger
@ -11502,7 +11502,7 @@
} }
else if(typeof func=='object'){ else if(typeof func=='object'){
for(var i in func){ for(var i in func){
if(func.hasOwnProperty(i)){ if(Object.prototype.hasOwnProperty.call(func, i)){
func[i]=lib.init.eval(func[i]); func[i]=lib.init.eval(func[i]);
} }
} }
@ -14469,7 +14469,7 @@
event.finish(); event.finish();
return; return;
} }
}; }
event.doing=event.map.shift(); event.doing=event.map.shift();
'step 3' 'step 3'
event.num=0; event.num=0;
@ -15021,7 +15021,7 @@
current.getHistory().isRound=true; current.getHistory().isRound=true;
current.getStat().isRound=true; current.getStat().isRound=true;
} }
}; }
if(isRound){ if(isRound){
game.getGlobalHistory().isRound=true; game.getGlobalHistory().isRound=true;
} }
@ -16185,7 +16185,7 @@
result[0].cards=lib.skill[result[0].skill].onCompare(player) result[0].cards=lib.skill[result[0].skill].onCompare(player)
} }
else lose_list.push([player,result[0].cards]); else lose_list.push([player,result[0].cards]);
}; }
for(var j=0; j<targets.length; j++){ for(var j=0; j<targets.length; j++){
if(event.list.contains(targets[j])){ if(event.list.contains(targets[j])){
var i=event.list.indexOf(targets[j]); var i=event.list.indexOf(targets[j]);
@ -16350,7 +16350,7 @@
result[0].cards=lib.skill[result[0].skill].onCompare(player) result[0].cards=lib.skill[result[0].skill].onCompare(player)
} }
else lose_list.push([player,result[0].cards]); else lose_list.push([player,result[0].cards]);
}; }
for(var j=0;j<targets.length;j++){ for(var j=0;j<targets.length;j++){
if(event.list.contains(targets[j])){ if(event.list.contains(targets[j])){
var i=event.list.indexOf(targets[j]); var i=event.list.indexOf(targets[j]);
@ -16541,7 +16541,7 @@
} }
else event.lose_list.push([player,event.resultOL[player.playerid].cards[0]]); else event.lose_list.push([player,event.resultOL[player.playerid].cards[0]]);
event.card1=event.resultOL[player.playerid].cards[0]; event.card1=event.resultOL[player.playerid].cards[0];
}; }
if(!event.card2){ if(!event.card2){
if(event.resultOL[target.playerid].skill&&lib.skill[event.resultOL[target.playerid].skill]&&lib.skill[event.resultOL[target.playerid].skill].onCompare){ if(event.resultOL[target.playerid].skill&&lib.skill[event.resultOL[target.playerid].skill]&&lib.skill[event.resultOL[target.playerid].skill].onCompare){
target.logSkill(event.resultOL[target.playerid].skill); target.logSkill(event.resultOL[target.playerid].skill);
@ -18681,7 +18681,7 @@
next.cards=cards; next.cards=cards;
next.player=player; next.player=player;
return; return;
}; }
var next=game.createEvent(card.name); var next=game.createEvent(card.name);
next.setContent(info.content); next.setContent(info.content);
next.targets=targets; next.targets=targets;
@ -19730,14 +19730,14 @@
cards[i].recheck(); cards[i].recheck();
var info=lib.card[cards[i].name]; var info=lib.card[cards[i].name];
if(cards[i].hasOwnProperty('_destroy')){ if(Object.prototype.hasOwnProperty.call(cards[i], '_destroy')){
if(cards[i]._destroy){ if(cards[i]._destroy){
cards[i].delete(); cards[i].delete();
cards[i].destroyed=cards[i]._destroy; cards[i].destroyed=cards[i]._destroy;
continue; continue;
} }
} }
else if(cards[i].hasOwnProperty('destroyed')){ else if(Object.prototype.hasOwnProperty.call(cards[i], 'destroyed')){
if(event.getlx!==false&&event.position&&cards[i].willBeDestroyed(event.position.id,null,event)){ if(event.getlx!==false&&event.position&&cards[i].willBeDestroyed(event.position.id,null,event)){
cards[i].selfDestroy(event); cards[i].selfDestroy(event);
continue; continue;
@ -20552,7 +20552,7 @@
if(event.judge2){ if(event.judge2){
var judge2=event.judge2(event.result); var judge2=event.judge2(event.result);
if(typeof judge2=='boolean') player.tryJudgeAnimate(judge2); if(typeof judge2=='boolean') player.tryJudgeAnimate(judge2);
}; }
if(event.clearArena!=false){ if(event.clearArena!=false){
game.broadcastAll(ui.clear); game.broadcastAll(ui.clear);
} }
@ -22248,7 +22248,7 @@
default:{ default:{
this.maxHp=maxHp1+maxHp2-3; this.maxHp=maxHp1+maxHp2-3;
this.hp=hp1+hp2-3; this.hp=hp1+hp2-3;
}; }
} }
if(info2[4].contains('hiddenSkill')&&!this.noclick){ if(info2[4].contains('hiddenSkill')&&!this.noclick){
if(!this.hiddenSkills) this.hiddenSkills=[]; if(!this.hiddenSkills) this.hiddenSkills=[];
@ -24082,19 +24082,19 @@
var player=_status.event.player; var player=_status.event.player;
var event=_status.event.getParent(); var event=_status.event.getParent();
var getn=function(card){ var getn=function(card){
if(player.hasSkill('tianbian')&&get.suit(card)=='heart') return 13*(Boolean(event.small)?-1:1); if(player.hasSkill('tianbian')&&get.suit(card)=='heart') return 13*(event.small?-1:1);
return get.number(card)*(Boolean(event.small)?-1:1); return get.number(card)*(event.small?-1:1);
} }
if(source&&source!=player){ if(source&&source!=player){
if(get.attitude(player,source)>1){ if(get.attitude(player,source)>1){
if(Boolean(event.small)) return getn(card)-get.value(card)/2+addi; if(event.small) return getn(card)-get.value(card)/2+addi;
return -getn(card)-get.value(card)/2+addi; return -getn(card)-get.value(card)/2+addi;
} }
if(Boolean(event.small)) return -getn(card)-get.value(card)/2+addi; if(event.small) return -getn(card)-get.value(card)/2+addi;
return getn(card)-get.value(card)/2+addi; return getn(card)-get.value(card)/2+addi;
} }
else{ else{
if(Boolean(event.small)) return -getn(card)-get.value(card)/2+addi; if(event.small) return -getn(card)-get.value(card)/2+addi;
return getn(card)-get.value(card)/2+addi; return getn(card)-get.value(card)/2+addi;
} }
} }
@ -24118,7 +24118,7 @@
var addi=(get.value(card)>=8&&get.type(card)!='equip')?-6:0; var addi=(get.value(card)>=8&&get.type(card)!='equip')?-6:0;
if(card.name=='du') addi-=5; if(card.name=='du') addi-=5;
if(player==event.player){ if(player==event.player){
if(Boolean(event.small)){ if(event.small){
return -getn(card)-get.value(card)/2+addi; return -getn(card)-get.value(card)/2+addi;
} }
return getn(card)-get.value(card)/2+addi; return getn(card)-get.value(card)/2+addi;
@ -25346,7 +25346,7 @@
} }
} }
if(next.animate=='gain2'||next.animate=='draw2'){ if(next.animate=='gain2'||next.animate=='draw2'){
if(!next.hasOwnProperty('log')){ if(!Object.prototype.hasOwnProperty.call(next, 'log')){
next.log=true; next.log=true;
} }
} }
@ -25433,7 +25433,7 @@
} }
} }
if(next.animate=='gain2'||next.animate=='draw2'||next.animate=='give'){ if(next.animate=='gain2'||next.animate=='draw2'||next.animate=='give'){
if(!next.hasOwnProperty('log')){ if(!Object.prototype.hasOwnProperty.call(next, 'log')){
next.log=true; next.log=true;
} }
} }
@ -26237,7 +26237,7 @@
} }
clearTimeout(lib.node.torespondtimeout[this.playerid]); clearTimeout(lib.node.torespondtimeout[this.playerid]);
delete lib.node.torespondtimeout[this.playerid]; delete lib.node.torespondtimeout[this.playerid];
if(!lib.node.torespond.hasOwnProperty(this.playerid)){ if(!Object.prototype.hasOwnProperty.call(lib.node.torespond, this.playerid)){
return; return;
} }
var noresume=false; var noresume=false;
@ -26264,7 +26264,7 @@
else if(_status.paused&&!noresume) game.resume(); else if(_status.paused&&!noresume) game.resume();
} }
tempUnwait(result){ tempUnwait(result){
if(!lib.node.torespond.hasOwnProperty(this.playerid)){ if(!Object.prototype.hasOwnProperty.call(lib.node.torespond, this.playerid)){
return; return;
} }
var proceed; var proceed;
@ -31289,7 +31289,6 @@
parent=parent.parent; parent=parent.parent;
if(historys.contains(parent)) return toreturn; if(historys.contains(parent)) return toreturn;
} }
if(!parent) return toreturn;
} }
if(toreturn===null){ if(toreturn===null){
return null; return null;
@ -31521,7 +31520,7 @@
for(var i=0;i<map.list2.length;i++){ for(var i=0;i<map.list2.length;i++){
if(map.list2[i][0]==toadd[0]&&map.list2[i][1]==toadd[1]) return; if(map.list2[i][0]==toadd[0]&&map.list2[i][1]==toadd[1]) return;
} }
}; }
for(var i=0;i<map.list.length;i++){ for(var i=0;i<map.list.length;i++){
if(map.list[i][0]==toadd[0]&&map.list[i][1]==toadd[1]) return; if(map.list[i][0]==toadd[0]&&map.list[i][1]==toadd[1]) return;
} }
@ -31777,7 +31776,7 @@
} }
evt.list=[]; evt.list=[];
if(evt.doing) evt.doing.list=[]; if(evt.doing) evt.doing.list=[];
}; }
this._triggered=5; this._triggered=5;
} }
else if(player){ else if(player){
@ -37543,7 +37542,7 @@
} }
const blob=zip.generate({ const blob=zip.generate({
type:'blob' type:'blob'
}),fileNameToSaveAs=`${exportExtension.replace(/\\|\/|\:|\?|\"|\*|<|>|\|/g,'-')}.zip`; }),fileNameToSaveAs=`${exportExtension.replace(/\\|\/|:|\?|"|\*|<|>|\|/g,'-')}.zip`;
if(lib.device){ if(lib.device){
const directory=lib.device=='android'?cordova.file.externalDataDirectory:cordova.file.documentsDirectory; const directory=lib.device=='android'?cordova.file.externalDataDirectory:cordova.file.documentsDirectory;
@ -37589,7 +37588,7 @@
const config=game.importedPack.config; const config=game.importedPack.config;
Object.keys(config).forEach(value=>{ Object.keys(config).forEach(value=>{
const configObject=config[value]; const configObject=config[value];
if(configObject&&configObject.hasOwnProperty('init')) game.saveConfig(`extension_${extensionName}_${value}`,configObject.init); if(configObject&&Object.prototype.hasOwnProperty.call(configObject, 'init')) game.saveConfig(`extension_${extensionName}_${value}`,configObject.init);
}); });
if(game.download){ if(game.download){
const files=zip.files,hiddenFileFlags=['.','_'],fileList=Object.keys(files).filter(key=>!files[key].dir&&!hiddenFileFlags.includes(key[0])).reverse(); const files=zip.files,hiddenFileFlags=['.','_'],fileList=Object.keys(files).filter(key=>!files[key].dir&&!hiddenFileFlags.includes(key[0])).reverse();
@ -37667,7 +37666,7 @@
export:function(textToWrite,name){ export:function(textToWrite,name){
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'}); var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = name||'noname'; var fileNameToSaveAs = name||'noname';
fileNameToSaveAs=fileNameToSaveAs.replace(/\\|\/|\:|\?|\"|\*|<|>|\|/g,'.'); fileNameToSaveAs=fileNameToSaveAs.replace(/\\|\/|:|\?|"|\*|<|>|\|/g,'.');
if(lib.device){ if(lib.device){
var directory; var directory;
@ -42029,7 +42028,7 @@
config.num=config.num||num||3; config.num=config.num||num||3;
config.ratio=config.ratio||ratio||1.2; config.ratio=config.ratio||ratio||1.2;
config.update=config.update||update; config.update=config.update||update;
if(!config.hasOwnProperty('first')){ if(!Object.prototype.hasOwnProperty.call(config, 'first')){
if(typeof first=='boolean'){ if(typeof first=='boolean'){
config.first=first; config.first=first;
} }
@ -42643,10 +42642,10 @@
} }
if(info.marktext) lib.translate[`${i}_bg`]=info.marktext; if(info.marktext) lib.translate[`${i}_bg`]=info.marktext;
if(info.silent){ if(info.silent){
if(!info.hasOwnProperty('forced')) info.forced=true; if(!Object.prototype.hasOwnProperty.call(info, 'forced')) info.forced=true;
if(!info.hasOwnProperty('popup')) info.popup=false; if(!Object.prototype.hasOwnProperty.call(info, 'popup')) info.popup=false;
} }
if(!info.hasOwnProperty('_priority')){ if(!Object.prototype.hasOwnProperty.call(info, '_priority')){
let priority=0; let priority=0;
if(info.priority){ if(info.priority){
priority=info.priority*100; priority=info.priority*100;
@ -43065,7 +43064,7 @@
game.reload2(); game.reload2();
reject(event); reject(event);
} }
};; };
record.onsuccess=event=>{ record.onsuccess=event=>{
if(typeof onSuccess=='function'){ if(typeof onSuccess=='function'){
_status.dburgent=true; _status.dburgent=true;
@ -43105,7 +43104,7 @@
game.reload2(); game.reload2();
reject(event); reject(event);
} }
};; };
idbRequest.onsuccess=event=>{ idbRequest.onsuccess=event=>{
const result=event.target.result; const result=event.target.result;
if(typeof onSuccess=='function'){ if(typeof onSuccess=='function'){
@ -43129,7 +43128,7 @@
game.reload2(); game.reload2();
reject(event); reject(event);
} }
};; };
idbRequest.onsuccess=event=>{ idbRequest.onsuccess=event=>{
const result=event.target.result; const result=event.target.result;
if(result){ if(result){
@ -43190,7 +43189,7 @@
request.onerror=event=>{ request.onerror=event=>{
game.reload2(); game.reload2();
reject(event); reject(event);
};; };
request.onsuccess=event=>{ request.onsuccess=event=>{
game.reload2(); game.reload2();
resolve(event); resolve(event);
@ -44943,7 +44942,7 @@
var cfg=copyObj(infoconfig[j]); var cfg=copyObj(infoconfig[j]);
cfg._name=j; cfg._name=j;
cfg.mode=mode; cfg.mode=mode;
if(!config.hasOwnProperty(j)){ if(!Object.prototype.hasOwnProperty.call(config, j)){
game.saveConfig(j,cfg.init,mode); game.saveConfig(j,cfg.init,mode);
} }
else{ else{
@ -45411,7 +45410,7 @@
} }
var cfg=copyObj(info.config[j]); var cfg=copyObj(info.config[j]);
cfg._name=j; cfg._name=j;
if(!config.hasOwnProperty(j)){ if(!Object.prototype.hasOwnProperty.call(config, j)){
if(cfg.type!='autoskill'&&cfg.type!='banskill'){ if(cfg.type!='autoskill'&&cfg.type!='banskill'){
game.saveConfig(j,cfg.init); game.saveConfig(j,cfg.init);
} }
@ -45529,7 +45528,7 @@
} }
var link=(game.writeFile?'cdv_':'custom_')+name; var link=(game.writeFile?'cdv_':'custom_')+name;
if(lib.config.customBackgroundMusic[link]){ if(lib.config.customBackgroundMusic[link]){
if(!confirm('已经存在文件名称相同的背景音乐,是否仍然要继续导入?')){_status.music_importing=false;return}; if(!confirm('已经存在文件名称相同的背景音乐,是否仍然要继续导入?')){_status.music_importing=false;return}
for(var i=1;i<1000;i++){ for(var i=1;i<1000;i++){
if(!lib.config.customBackgroundMusic[link+'_'+i]){ if(!lib.config.customBackgroundMusic[link+'_'+i]){
link=link+'_'+i;break; link=link+'_'+i;break;
@ -47285,7 +47284,7 @@
j=mode+'_'+i+'_playpackconfig'; j=mode+'_'+i+'_playpackconfig';
} }
cfg._name=j; cfg._name=j;
if(!lib.config.hasOwnProperty(j)){ if(!Object.prototype.hasOwnProperty.call(lib.config, j)){
game.saveConfig(j,cfg.init); game.saveConfig(j,cfg.init);
} }
else{ else{
@ -48538,7 +48537,7 @@
editnode.classList.add('disabled'); editnode.classList.add('disabled');
delnode.innerHTML='取消'; delnode.innerHTML='取消';
delete delnode.button; delete delnode.button;
container.code='card={\n \n}\n\n\/*\n示例\ncard={\n type:"basic",\n enable:true,\n filterTarget:true,\n content:function(){\n target.draw()\n },\n ai:{\n order:1,\n result:{\n target:1\n }\n }\n}\n此例的效果为目标摸一张牌\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; container.code='card={\n \n}\n\n/*\n示例\ncard={\n type:"basic",\n enable:true,\n filterTarget:true,\n content:function(){\n target.draw()\n },\n ai:{\n order:1,\n result:{\n target:1\n }\n }\n}\n此例的效果为目标摸一张牌\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
} }
newCard=ui.create.div('.new_character',page); newCard=ui.create.div('.new_character',page);
@ -48737,7 +48736,7 @@
delete window.saveNonameInput; delete window.saveNonameInput;
}; };
var editor=ui.create.editor(container,saveInput); var editor=ui.create.editor(container,saveInput);
container.code='card={\n \n}\n\n\/*\n示例\ncard={\n type:"basic",\n enable:true,\n filterTarget:true,\n content:function(){\n target.draw()\n },\n ai:{\n order:1,\n result:{\n target:1\n }\n }\n}\n此例的效果为目标摸一张牌\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; container.code='card={\n \n}\n\n/*\n示例\ncard={\n type:"basic",\n enable:true,\n filterTarget:true,\n content:function(){\n target.draw()\n },\n ai:{\n order:1,\n result:{\n target:1\n }\n }\n}\n此例的效果为目标摸一张牌\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
var editnode=ui.create.div('.menubutton.large.new_card.disabled','创建卡牌',newCard,function(){ var editnode=ui.create.div('.menubutton.large.new_card.disabled','创建卡牌',newCard,function(){
var name=page.querySelector('input.new_name').value; var name=page.querySelector('input.new_name').value;
@ -49088,7 +49087,7 @@
editnode.classList.add('disabled'); editnode.classList.add('disabled');
delnode.innerHTML='取消'; delnode.innerHTML='取消';
delete delnode.button; delete delnode.button;
container.code='skill={\n \n}\n\n\/*\n示例\nskill={\n trigger:{player:"phaseJieshuBegin"},\n frequent:true,\n content:function(){\n player.draw()\n }\n}\n此例为闭月代码\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; container.code='skill={\n \n}\n\n/*\n示例\nskill={\n trigger:{player:"phaseJieshuBegin"},\n frequent:true,\n content:function(){\n player.draw()\n }\n}\n此例为闭月代码\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
if(page.fromchar=='add'){ if(page.fromchar=='add'){
page.fromchar=true; page.fromchar=true;
} }
@ -49174,7 +49173,7 @@
delete window.saveNonameInput; delete window.saveNonameInput;
}; };
var editor=ui.create.editor(container,saveInput); var editor=ui.create.editor(container,saveInput);
container.code='skill={\n \n}\n\n\/*\n示例\nskill={\n trigger:{player:"phaseJieshuBegin"},\n frequent:true,\n content:function(){\n player.draw()\n }\n}\n此例为闭月代码\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; container.code='skill={\n \n}\n\n/*\n示例\nskill={\n trigger:{player:"phaseJieshuBegin"},\n frequent:true,\n content:function(){\n player.draw()\n }\n}\n此例为闭月代码\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
var citebutton=document.createElement('button'); var citebutton=document.createElement('button');
citebutton.innerHTML='引用代码'; citebutton.innerHTML='引用代码';
@ -49402,10 +49401,10 @@
} }
} }
else{ else{
dashes.content.node.code='function(config,pack){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项见选项代码参数2为扩展定义的武将、卡牌和技能等可在此函数中修改\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; dashes.content.node.code='function(config,pack){\n \n}\n\n/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项见选项代码参数2为扩展定义的武将、卡牌和技能等可在此函数中修改\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
dashes.precontent.node.code='function(){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之前且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; dashes.precontent.node.code='function(){\n \n}\n\n/*\n函数执行时机为游戏数据加载之前且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
dashes.config.node.code='config={\n \n}\n\n\/*\n示例\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; dashes.config.node.code='config={\n \n}\n\n/*\n示例\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
dashes.help.node.code='help={\n \n}\n\n\/*\n示例\nhelp={\n "帮助条目":"<ul><li>列表1-条目1<li>列表1-条目2</ul><ol><li>列表2-条目1<li>列表2-条目2</ul>"\n}\n帮助内容将显示在菜单选项帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'; dashes.help.node.code='help={\n \n}\n\ns/*\n示例\nhelp={\n "帮助条目":"<ul><li>列表1-条目1<li>列表1-条目2</ul><ol><li>列表2-条目1<li>列表2-条目2</ul>"\n}\n帮助内容将显示在菜单选项帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*/';
} }
}; };
var dashes={}; var dashes={};
@ -49511,10 +49510,10 @@
} }
}; };
page.content={} page.content={}
createCode('主','主代码',page,clickCode,'content','function(config,pack){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项见选项代码参数2为扩展定义的武将、卡牌和技能等可在此函数中修改\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); createCode('主','主代码',page,clickCode,'content','function(config,pack){\n \n}\n\n/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项见选项代码参数2为扩展定义的武将、卡牌和技能等可在此函数中修改\n导出时本段代码中的换行、缩进以及注释将被清除\n*/');
createCode('启','启动代码',page,clickCode,'precontent','function(){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之前且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); createCode('启','启动代码',page,clickCode,'precontent','function(){\n \n}\n\n/*\n函数执行时机为游戏数据加载之前且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*/');
createCode('选','选项代码',page,clickCode,'config','config={\n \n}\n\n\/*\n示例\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); createCode('选','选项代码',page,clickCode,'config','config={\n \n}\n\n/*\n示例\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*/');
createCode('帮','帮助代码',page,clickCode,'help','help={\n \n}\n\n\/*\n示例\nhelp={\n "帮助条目":"<ul><li>列表1-条目1<li>列表1-条目2</ul><ol><li>列表2-条目1<li>列表2-条目2</ul>"\n}\n帮助内容将显示在菜单选项帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/'); createCode('帮','帮助代码',page,clickCode,'help','help={\n \n}\n\n/*\n示例\nhelp={\n "帮助条目":"<ul><li>列表1-条目1<li>列表1-条目2</ul><ol><li>列表2-条目1<li>列表2-条目2</ul>"\n}\n帮助内容将显示在菜单选项帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*/');
return page; return page;
}()); }());
@ -49678,7 +49677,7 @@
game.saveConfig('extension_'+extname+'_enable',true); game.saveConfig('extension_'+extname+'_enable',true);
game.saveConfig('extension_'+extname+'_version',that.info.version); game.saveConfig('extension_'+extname+'_version',that.info.version);
for(var i in game.importedPack.config){ for(var i in game.importedPack.config){
if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){ if(game.importedPack.config[i]&&Object.prototype.hasOwnProperty.call(game.importedPack.config[i], 'init')){
game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init); game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init);
} }
} }
@ -56919,7 +56918,7 @@
if(!information) { if(!information) {
resolve(`${lib.assetURL}image/card/${imageName}.png`) resolve(`${lib.assetURL}image/card/${imageName}.png`)
return; return;
}; }
const image=information.image; const image=information.image;
if(!image) resolve(`${lib.assetURL}image/card/${imageName}.png`); if(!image) resolve(`${lib.assetURL}image/card/${imageName}.png`);
else if(image.startsWith('db:')) game.getDB('image',image.slice(3)).then(resolve,reject); else if(image.startsWith('db:')) game.getDB('image',image.slice(3)).then(resolve,reject);
@ -58298,7 +58297,7 @@
priority:skill=>{ priority:skill=>{
const info=get.info(skill); const info=get.info(skill);
if(!info) return 0; if(!info) return 0;
if(info.hasOwnProperty('_priority')) return info._priority; if(Object.prototype.hasOwnProperty.call(info, '_priority')) return info._priority;
let priority=0; let priority=0;
if(info.priority){ if(info.priority){
priority=info.priority*100; priority=info.priority*100;
@ -58946,7 +58945,7 @@
character:(name,num)=>{ character:(name,num)=>{
let info=lib.character[name]; let info=lib.character[name];
if(!info){ if(!info){
const pack=Object.keys(lib.characterPack).find(pack=>lib.characterPack[pack].hasOwnProperty(name)); const pack=Object.keys(lib.characterPack).find(pack=>Object.prototype.hasOwnProperty.call(lib.characterPack[pack], name));
if(pack) info=lib.characterPack[pack][name]; if(pack) info=lib.characterPack[pack][name];
} }
if(info){ if(info){
@ -59145,7 +59144,7 @@
} }
num=Math.floor(num/4); num=Math.floor(num/4);
for(i=0;i<num-level;i++){ for(i=0;i<num-level;i++){
str=str.replace(/\n /g,'\n'); str=str.replace(/\n {4}/g,'\n');
} }
} }
else{ else{
@ -59318,7 +59317,6 @@
case 'purple':return '三对三对二'; case 'purple':return '三对三对二';
case 'zhong':return (config.double_character?'双将':'')+'忠胆英杰'; case 'zhong':return (config.double_character?'双将':'')+'忠胆英杰';
case 'stratagem':return get.cnNumber(parseInt(config.number))+'人'+(config.double_character?'双将':'')+'谋攻'; case 'stratagem':return get.cnNumber(parseInt(config.number))+'人'+(config.double_character?'双将':'')+'谋攻';
debugger
default:return `${get.cnNumber(parseInt(config.number))}${config.double_nei?'双内':''}${config.enable_commoner?'带民':''}${config.double_character?'双将':''}身份`; default:return `${get.cnNumber(parseInt(config.number))}${config.double_nei?'双内':''}${config.enable_commoner?'带民':''}${config.double_character?'双将':''}身份`;
} }
} }
@ -60005,7 +60003,7 @@
if(card.length==1) return get.suit(card[0],player); if(card.length==1) return get.suit(card[0],player);
return 'none'; return 'none';
} }
else if(!card.hasOwnProperty('suit')&&Array.isArray(card.cards)){ else if(!Object.prototype.hasOwnProperty.call(card, 'suit')&&Array.isArray(card.cards)){
return get.suit(card.cards,player); return get.suit(card.cards,player);
} }
else{ else{
@ -60057,7 +60055,7 @@
if(!card) return; if(!card) return;
//狗卡你是真敢出啊 //狗卡你是真敢出啊
var number=null; var number=null;
if(card.hasOwnProperty('number')){ if(Object.prototype.hasOwnProperty.call(card, 'number')){
number=card.number; number=card.number;
if(typeof number!='number') number=null; if(typeof number!='number') number=null;
} }
@ -60590,7 +60588,7 @@
var result=function(){ var result=function(){
if(filter==arguments[i]) return true; if(filter==arguments[i]) return true;
for(var j in filter){ for(var j in filter){
if(filter.hasOwnProperty(j)){ if(Object.prototype.hasOwnProperty.call(filter, j)){
if(get.itemtype(arguments[i])=='card'){ if(get.itemtype(arguments[i])=='card'){
if(j=='name'){ if(j=='name'){
if(Array.isArray(filter[j])){ if(Array.isArray(filter[j])){