MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / add

Method add

code/main/Resource.ts:20–34  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

18
19 // Public methods
20 public add(n: number): boolean{
21 // If the operation would leave an < 0 value, we stop
22 if(this.current + n < 0)
23 return false;
24
25 // If we add a positive value, we also add it to the accumulated
26 if(n > 0)
27 this.setAccumulated(this.accumulated + n);
28
29 // We add to the current value
30 this.setCurrent(this.current + n);
31
32 // We return true
33 return true;
34 }
35
36 public load(): void{
37 this.setAccumulated(Saving.loadNumber(this.savingPrefix + "Accumulated"));

Callers 1

transferToMethod · 0.95

Calls 2

setAccumulatedMethod · 0.95
setCurrentMethod · 0.95

Tested by

no test coverage detected