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

Method inflictDamage

code/main/QuestEntity.ts:281–294  ·  view source on GitHub ↗
(damage: number, reason: QuestEntityDamageReason)

Source from the content-addressed store, hash-verified

279 }
280
281 public inflictDamage(damage: number, reason: QuestEntityDamageReason): void{
282 // We save the damage reason
283 this.lastDamageReason = reason;
284
285 // If we're destructible, we get the damage
286 if(this.destructible){
287 // If we're not a turtle
288 if(this.turtle == false)
289 this.setHp(this.getHp()-damage);
290 // Else, we're a turtle
291 else
292 this.setHp(this.getHp()-Math.ceil(damage/2));
293 }
294 }
295
296 public isOutOfArea(): boolean{
297 // If the entity if too much out of the area, we return true

Callers 1

hitMethod · 0.45

Calls 2

setHpMethod · 0.95
getHpMethod · 0.95

Tested by

no test coverage detected