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

函数增加 | 一些跟`storage`有关的函数
This commit is contained in:
Spmario233 2023-09-20 11:13:31 +08:00 committed by GitHub
commit 8c5df88ff4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -24746,9 +24746,32 @@
getExpansions:function(tag){
return this.getCards('x',(card)=>card.hasGaintag(tag));
},
countExpansions:function(tag){
return this.getExpansions(tag).length;
},
hasExpansions:function(tag){
return this.countExpansions(tag)>0;
},
setStorage:function(name,value){
return this.storage[name]=value;
},
getStorage:function(name){
return this.storage[name]||[];
},
hasStorage:function(name){
return name in this.storage;
},
initStorage:function(name,value){
return this.hasStorage(name)?this.getStorage(name):this.setStorage(name,value);
},
updateStorage:function(name,operation){
return this.setStorage(name,operation(this.getStorage(name)));
},
updateStorageAsync:function(name,operation){
return Promise.resolve(this.getStorage(name))
.then(value=>operation(value))
.then(value=>this.setStorage(name,value))
},
markSkill:function(name,info,card){
if(info===true){
this.syncStorage(name);