let storage markable.

This commit is contained in:
Rintim 2023-10-04 18:06:15 +08:00
parent 1f15c83685
commit e5eb79ca2e
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 17 additions and 10 deletions

View File

@ -22240,8 +22240,8 @@
}, },
setMark:function(name,num,log){ setMark:function(name,num,log){
const count=this.countMark(name); const count=this.countMark(name);
if(count>num)player.removeMark(name,count-num,log); if(count>num)this.removeMark(name,count-num,log);
else if(count<num)player.addMark(name,num-count,log); else if(count<num)this.addMark(name,num-count,log);
}, },
countMark:function(i){ countMark:function(i){
if(this.storage[i]==undefined) return 0; if(this.storage[i]==undefined) return 0;
@ -25687,8 +25687,10 @@
hasExpansions:function(tag){ hasExpansions:function(tag){
return this.countExpansions(tag)>0; return this.countExpansions(tag)>0;
}, },
setStorage:function(name,value){ setStorage:function(name,value,mark){
return this.storage[name]=value; this.storage[name]=value;
if(mark) this.markAuto(name);
return value;
}, },
getStorage:function(name){ getStorage:function(name){
return this.storage[name]||[]; return this.storage[name]||[];
@ -25717,16 +25719,21 @@
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);
}, },
updateStorage:function(name,operation){ updateStorage:function(name,operation,mark){
return this.setStorage(name,operation(this.getStorage(name))); return this.setStorage(name,operation(this.getStorage(name)),mark);
}, },
updateStorageAsync:function(name,operation){ updateStorageAsync:function(name,operation,mark){
return Promise.resolve(this.getStorage(name)) return Promise.resolve(this.getStorage(name))
.then(value=>operation(value)) .then(value=>operation(value))
.then(value=>this.setStorage(name,value)) .then(value=>this.setStorage(name,value,mark));
}, },
removeStorage:function(name){ removeStorage:function(name,mark){
return player.hasStorage(name)&&delete player.storage[name]; if(!this.hasStorage(name)) return false;
if(mark){
this.unmarkSkill(name);
return true;
}
return delete this.storage[name];
}, },
markSkill:function(name,info,card){ markSkill:function(name,info,card){
if(info===true){ if(info===true){