From 47f086fb45cce7764f2c5aeb7d102083584f671d Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 21 Sep 2023 19:56:13 +0800 Subject: [PATCH] add ability of `Player#hasStorage` --- game/game.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/game/game.js b/game/game.js index 2c91c5b2c..d9ede4c08 100644 --- a/game/game.js +++ b/game/game.js @@ -24816,8 +24816,12 @@ getStorage:function(name){ return this.storage[name]||[]; }, - hasStorage:function(name){ - return name in this.storage; + hasStorage:function(name,value){ + 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){ return this.hasStorage(name)?this.getStorage(name):this.setStorage(name,value); @@ -24830,6 +24834,9 @@ .then(value=>operation(value)) .then(value=>this.setStorage(name,value)) }, + removeStorage:function(name){ + return player.hasStorage(name)&&delete player.storage[name]; + }, markSkill:function(name,info,card){ if(info===true){ this.syncStorage(name);