add ability of `Player#hasStorage`

This commit is contained in:
Rintim 2023-09-21 19:56:13 +08:00
parent e5054cc520
commit 47f086fb45
1 changed files with 9 additions and 2 deletions

View File

@ -24816,8 +24816,12 @@
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);
}, },
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);
@ -24830,6 +24834,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);