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

Method castFireball

code/main/Devil.ts:82–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80
81 // Private methods
82 private castFireball(): void{
83 // Create the fireball
84 var fireBall: Fireball = new Fireball(this.getQuest(),
85 this.getGlobalPosition().plus(new Pos(3, 4)),
86 new Naming("The devil's fireball", "the devil's fireball"),
87 new Color(ColorType.DEVIL_FIREBALL),
88 new Pos(2, 1),
89 800,
90 this.getAndPossiblyCreateSpellCastingDamageReason(new Naming("The devil's fireball", "the devil's fireball"))
91 );
92
93 // If the player is on our left
94 if(this.getQuest().getGame().getPlayer().getGlobalPosition().x < this.getGlobalPosition().x){
95 // No target
96 fireBall.setTargetTypeNoTarget(new Pos(-Random.between(3, 7), 0));
97 }
98 // Else
99 else{
100 // We target the player
101 fireBall.setTargetTypeTargetEntity(this.getQuest().getGame().getPlayer(), null, new Pos(1, 1));
102 }
103
104 // Add the entity
105 this.getQuest().addEntity(fireBall);
106 }
107
108 private handleFireballs(): void{
109 if(Random.oneChanceOutOf(2)) this.castFireball();

Callers 1

handleFireballsMethod · 0.95

Calls 9

setTargetTypeNoTargetMethod · 0.95
getQuestMethod · 0.80
plusMethod · 0.80
getGlobalPositionMethod · 0.80
getPlayerMethod · 0.80
addEntityMethod · 0.80
getGameMethod · 0.45

Tested by

no test coverage detected