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

Method drawStats

code/main/Inventory.ts:157–222  ·  view source on GitHub ↗
(x: number, y: number)

Source from the content-addressed store, hash-verified

155 }
156
157 private drawStats(x: number, y: number): number{
158 // Set the additional damage text
159 var additionalDamageText: string;
160 if(Saving.loadBool("gridItemPossessedXinopherydonClaw") && (this.getGame().getSelectedEqItems()["bodyArmour"] != null && this.getGame().getSelectedEqItems()["bodyArmour"].getSavingName() == "eqItemBodyArmoursEnchantedKnightBodyArmour")) // If we have the armour en the claw
161 additionalDamageText = "";
162 else if(Saving.loadBool("gridItemPossessedXinopherydonClaw")) // Else, if we just have the claw
163 additionalDamageText = " x 2";
164 else if((this.getGame().getSelectedEqItems()["bodyArmour"] != null && this.getGame().getSelectedEqItems()["bodyArmour"].getSavingName() == "eqItemBodyArmoursEnchantedKnightBodyArmour")) // Else, if we just have the armour
165 additionalDamageText = " / 2";
166 else // Else, we have nothing special
167 additionalDamageText = "";
168
169 // This array will contain the special abilities
170 var specialAbilities: string[] = [];
171
172 // First line
173 this.renderArea.drawString(this.getGame().getPlayer().getMaxHp().toString(), x+16, y); // player's maximum HP
174 this.renderArea.drawString(this.getGame().getPlayer().getQuestEntityWeapon().getRealDamageText() + additionalDamageText, x+43, y); // weapon damage
175 this.renderArea.drawString(this.getGame().getPlayer().getQuestEntityWeapon().getSpeedText(), x+71, y); // weapon speed
176
177 // Fill the special abilities array with grid items abilities
178 for(var savingName in this.getGame().getGridItems()){
179 // If we possess this item
180 if(this.getGame().getGridItems()[savingName].isPossessed()){
181 // If it has a special ability, we add it
182 if(this.getGame().getGridItems()[savingName].getSpecialAbility() != null)
183 specialAbilities.push(this.getGame().getGridItems()[savingName].getSpecialAbility());
184 }
185 }
186
187 // Fill the special abilities array with eq items abilities
188 if(this.getGame().getSelectedEqItems()["weapon"] != null && this.getGame().getSelectedEqItems()["weapon"].getSpecialAbility() != null) specialAbilities.push(this.getGame().getSelectedEqItems()["weapon"].getSpecialAbility());
189 if(this.getGame().getSelectedEqItems()["hat"] != null && this.getGame().getSelectedEqItems()["hat"].getSpecialAbility() != null) specialAbilities.push(this.getGame().getSelectedEqItems()["hat"].getSpecialAbility());
190 if(this.getGame().getSelectedEqItems()["bodyArmour"] != null && this.getGame().getSelectedEqItems()["bodyArmour"].getSpecialAbility() != null) specialAbilities.push(this.getGame().getSelectedEqItems()["bodyArmour"].getSpecialAbility());
191 if(this.getGame().getSelectedEqItems()["gloves"] != null && this.getGame().getSelectedEqItems()["gloves"].getSpecialAbility() != null) specialAbilities.push(this.getGame().getSelectedEqItems()["gloves"].getSpecialAbility());
192 if(this.getGame().getSelectedEqItems()["boots"] != null && this.getGame().getSelectedEqItems()["boots"].getSpecialAbility() != null) specialAbilities.push(this.getGame().getSelectedEqItems()["boots"].getSpecialAbility());
193
194 // Fill the special abilities with gifts
195 if(Saving.loadNumber("gameGiftPower") > 0){
196 specialAbilities.push("GIFT : your attacks are " + (Saving.loadNumber("gameGiftPower")*20).toString() + "% more powerful.");
197 }
198 if(Saving.loadNumber("gameGiftHealth") > 0){
199 specialAbilities.push("GIFT : you have " + (Saving.loadNumber("gameGiftHealth")*20).toString() + "% more health points.");
200 }
201 if(Saving.loadNumber("gameGiftMagic") > 0){
202 specialAbilities.push("GIFT : the spell and potion countdowns are reduced by " + (Saving.loadNumber("gameGiftMagic")*15) + "%.");
203 }
204
205 // If the special abilities array is empty, add the "no special ability" text
206 if(specialAbilities.length == 0)
207 specialAbilities.push("You have no special ability.");
208
209 // Draw the special abilities
210 for(var i = 0; i < specialAbilities.length; i++){
211 // If it's not the first one, we draw the background
212 if(i != 0){
213 this.renderArea.drawArray(Database.getAscii("general/specialAbilityBackground"), x, y+2+i);
214 }

Callers 1

updateMethod · 0.95

Calls 14

getSelectedEqItemsMethod · 0.80
drawStringMethod · 0.80
getPlayerMethod · 0.80
getSpeedTextMethod · 0.80
getGridItemsMethod · 0.80
drawArrayMethod · 0.80
getAsciiMethod · 0.80
getGameMethod · 0.45
getSavingNameMethod · 0.45
getMaxHpMethod · 0.45
getRealDamageTextMethod · 0.45
getQuestEntityWeaponMethod · 0.45

Tested by

no test coverage detected