From 4aae8e4e4ec0f46d8b2d9c579506106f79c0a085 Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Tue, 7 Nov 2023 23:21:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=97=A0=E7=BB=A7=E6=89=BF=E5=85=B3?= =?UTF-8?q?=E7=B3=BB=E7=9A=84hasOwnProperty=E6=94=B9=E4=B8=BAin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 1 - game/game.js | 40 ++++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 19f5d666d..4bc0cf66e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,6 @@ "no-unused-vars": 0, "no-undef": 0, "no-redeclare": 0, - "no-prototype-builtins": 0, "require-yield": 0, "no-irregular-whitespace": ["error", { "skipStrings": true, "skipTemplates": true }], "no-constant-condition": ["error", { "checkLoops": false }]/* , diff --git a/game/game.js b/game/game.js index aa99e4b64..bd937a219 100644 --- a/game/game.js +++ b/game/game.js @@ -8136,7 +8136,7 @@ run:function(time){ lib.status.time=time; for(var i=0;i{ const configObject=config[value]; - if(configObject&&Object.prototype.hasOwnProperty.call(configObject, 'init')) game.saveConfig(`extension_${extensionName}_${value}`,configObject.init); + if(configObject&&('init' in configObject)) game.saveConfig(`extension_${extensionName}_${value}`,configObject.init); }); if(game.download){ const files=zip.files,hiddenFileFlags=['.','_'],fileList=Object.keys(files).filter(key=>!files[key].dir&&!hiddenFileFlags.includes(key[0])).reverse(); @@ -42029,7 +42029,7 @@ config.num=config.num||num||3; config.ratio=config.ratio||ratio||1.2; config.update=config.update||update; - if(!Object.prototype.hasOwnProperty.call(config, 'first')){ + if(!('first' in config)){ if(typeof first=='boolean'){ config.first=first; } @@ -42643,10 +42643,10 @@ } if(info.marktext) lib.translate[`${i}_bg`]=info.marktext; if(info.silent){ - if(!Object.prototype.hasOwnProperty.call(info, 'forced')) info.forced=true; - if(!Object.prototype.hasOwnProperty.call(info, 'popup')) info.popup=false; + if(!('forced' in info)) info.forced=true; + if(!('popup' in info)) info.popup=false; } - if(!Object.prototype.hasOwnProperty.call(info, '_priority')){ + if(!('_priority' in info)){ let priority=0; if(info.priority){ priority=info.priority*100; @@ -44943,7 +44943,7 @@ var cfg=copyObj(infoconfig[j]); cfg._name=j; cfg.mode=mode; - if(!Object.prototype.hasOwnProperty.call(config, j)){ + if(!(j in config)){ game.saveConfig(j,cfg.init,mode); } else{ @@ -45411,7 +45411,7 @@ } var cfg=copyObj(info.config[j]); cfg._name=j; - if(!Object.prototype.hasOwnProperty.call(config, j)){ + if(!(j in config)){ if(cfg.type!='autoskill'&&cfg.type!='banskill'){ game.saveConfig(j,cfg.init); } @@ -47285,7 +47285,7 @@ j=mode+'_'+i+'_playpackconfig'; } cfg._name=j; - if(!Object.prototype.hasOwnProperty.call(lib.config, j)){ + if(!(j in lib.config)){ game.saveConfig(j,cfg.init); } else{ @@ -49678,7 +49678,7 @@ game.saveConfig('extension_'+extname+'_enable',true); game.saveConfig('extension_'+extname+'_version',that.info.version); for(var i in game.importedPack.config){ - if(game.importedPack.config[i]&&Object.prototype.hasOwnProperty.call(game.importedPack.config[i], 'init')){ + if(game.importedPack.config[i]&&('init' in game.importedPack.config[i])){ game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init); } } @@ -58298,7 +58298,7 @@ priority:skill=>{ const info=get.info(skill); if(!info) return 0; - if(Object.prototype.hasOwnProperty.call(info, '_priority')) return info._priority; + if('_priority' in info) return info._priority; let priority=0; if(info.priority){ priority=info.priority*100; @@ -58946,7 +58946,7 @@ character:(name,num)=>{ let info=lib.character[name]; if(!info){ - const pack=Object.keys(lib.characterPack).find(pack=>Object.prototype.hasOwnProperty.call(lib.characterPack[pack], name)); + const pack=Object.keys(lib.characterPack).find(pack=>name in lib.characterPack[pack]); if(pack) info=lib.characterPack[pack][name]; } if(info){ @@ -60004,7 +60004,7 @@ if(card.length==1) return get.suit(card[0],player); return 'none'; } - else if(!Object.prototype.hasOwnProperty.call(card, 'suit')&&Array.isArray(card.cards)){ + else if(!('suit' in card)&&Array.isArray(card.cards)){ return get.suit(card.cards,player); } else{ @@ -60056,7 +60056,7 @@ if(!card) return; //狗卡你是真敢出啊 var number=null; - if(Object.prototype.hasOwnProperty.call(card, 'number')){ + if('number' in card){ number=card.number; if(typeof number!='number') number=null; }