Merge pull request #373 from nofficalfs/PR-Enhancement-Storage

[Enhancement] 函数增加 | 还是和`Storage`相关的函数
This commit is contained in:
Spmario233 2023-09-22 17:43:58 +08:00 committed by GitHub
commit f4915bc8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 2 deletions

View File

@ -24815,8 +24815,26 @@
getStorage:function(name){ getStorage:function(name){
return this.storage[name]||[]; return this.storage[name]||[];
}, },
hasStorage:function(name){ hasStorage:function(name,value){
return name in this.storage; if(!(name in this.storage)) return false;
if(typeof value=="undefined") return true;
const storage=this.storage[name];
if(storage===value) return true;
return !Array.isArray(storage) || storage.contains(value);
},
hasStorageAny:function(name,values){
const storage=this.storage[name];
if(!Array.isArray(values)) values=Array.from(arguments).slice(1);
if(!storage) return false;
if (!Array.isArray(storage)) return values.contains(storage);
return values.some(item => storage.contains(item));
},
hasStorageAll:function(name,values){
const storage=this.storage[name];
if(!Array.isArray(values)) values=Array.from(arguments).slice(1);
if(!storage) return false;
if (!Array.isArray(storage)) return false;
return values.every(item => storage.contains(item));
}, },
initStorage:function(name,value){ initStorage:function(name,value){
return this.hasStorage(name)?this.getStorage(name):this.setStorage(name,value); return this.hasStorage(name)?this.getStorage(name):this.setStorage(name,value);
@ -24829,6 +24847,9 @@
.then(value=>operation(value)) .then(value=>operation(value))
.then(value=>this.setStorage(name,value)) .then(value=>this.setStorage(name,value))
}, },
removeStorage:function(name){
return player.hasStorage(name)&&delete player.storage[name];
},
markSkill:function(name,info,card){ markSkill:function(name,info,card){
if(info===true){ if(info===true){
this.syncStorage(name); this.syncStorage(name);