(resource: Resource, howMany: number = -1, ratio: number = 1)
| 46 | } |
| 47 | |
| 48 | public transferTo(resource: Resource, howMany: number = -1, ratio: number = 1): boolean{ |
| 49 | // If howMany is below 0, then we transfer everything |
| 50 | if(howMany < 0) |
| 51 | howMany = this.current; |
| 52 | else{ |
| 53 | // If we don't have enough to transfer, we return false |
| 54 | if(howMany > this.current) |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | // We lower our current quantity |
| 59 | this.add(-howMany); |
| 60 | |
| 61 | // We add to the other resource |
| 62 | resource.add(howMany * ratio); |
| 63 | |
| 64 | // We return true |
| 65 | return true; |
| 66 | } |
| 67 | |
| 68 | // Public getters |
| 69 | public getAccumulated(): number{ |
no test coverage detected