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

Method reCalcMaxHp

code/main/Player.ts:314–341  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

312 }
313
314 public reCalcMaxHp(): void{
315 // Base maximum hp : 100
316 var maxHp: number = 100;
317
318 // We add to the base, depending on how much candies eaten, if we're not playing in hard mode
319 if(Saving.loadString("gameGameMode") != "hard"){
320 maxHp += Math.ceil((1-Math.exp(-this.game.getCandiesEaten().getCurrent()/3000))*100) + Math.ceil((1-Math.exp(-this.game.getCandiesEaten().getCurrent()/400000))*800);
321 }
322
323 // We add 300 if we have the heart pendant
324 if(Saving.loadBool("gridItemPossessedHeartPendant"))
325 maxHp += 300;
326
327 // We add 20% if we have the heart plug
328 if(Saving.loadBool("gridItemPossessedHeartPlug"))
329 maxHp = Math.ceil(maxHp * 1.2);
330
331 // Health gift
332 if(Saving.loadNumber("gameGiftHealth") > 0){
333 maxHp = maxHp + maxHp * (Saving.loadNumber("gameGiftHealth")/5);
334 }
335
336 // We finally set the value we calculated
337 this.setMaxHp(maxHp);
338
339 // We update the status bar
340 this.game.updateStatusBar();
341 }
342
343 public save(): void{
344 Saving.saveNumber("playerHp", this.getHp());

Callers 5

setCurrentMethod · 0.80
selectedEqItemMethod · 0.80
chooseGiftMethod · 0.80
gainItemMethod · 0.80
postLoadMethod · 0.80

Calls 4

setMaxHpMethod · 0.95
getCurrentMethod · 0.80
getCandiesEatenMethod · 0.80
updateStatusBarMethod · 0.80

Tested by

no test coverage detected