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

Method setHp

code/main/YourselfEntity.ts:32–48  ·  view source on GitHub ↗
(hp: number)

Source from the content-addressed store, hash-verified

30
31 // setHp()
32 public setHp(hp: number): void{
33 // If we don't have the crown
34 if(this.getQuest().getGame().isEquipped("hat", "eqItemHatOctopusKingCrown") == false){
35 // When anyone want to change our hp, we change the player's hp first :)
36 this.getQuest().getGame().getPlayer().setHp(hp);
37 }
38 // Else, we have the crown
39 else{
40 // When anyone want to change our hp, we change the player's hp first :) (but here we keep it over 0!)
41 if(hp > 0)
42 this.getQuest().getGame().getPlayer().setHp(hp);
43 else
44 this.getQuest().getGame().getPlayer().setHp(1);
45 }
46
47 super.setHp(hp);
48 }
49
50 // willDie()
51 public willDie(): void{

Callers 1

constructorMethod · 0.95

Calls 4

isEquippedMethod · 0.80
getQuestMethod · 0.80
getPlayerMethod · 0.80
getGameMethod · 0.45

Tested by

no test coverage detected