Skip to content

Commit 19cd742

Browse files
committed
Now using Math min
- Using Math min function to get max power limits - Allows for cleaner code and also removed cognitive complexity Sonarlint issue
1 parent c6dea00 commit 19cd742

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

project/webpage/scripts/paragoncalc.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,13 @@ class ParagonCalc extends LitElement {
329329

330330
// Tier5s. Max is 50,000 power
331331
if(form.tier5.value) {
332-
this.power += form.tier5.value*6000;
333-
if(this.power > 50000) this.power = 50000;
332+
this.power += Math.min(form.tier5.value*6000, 50000);
334333
}
335334

336335
// Upgrades. Max is 10,000 power
337-
if(form.towerupgrades.value) this.power += form.towerupgrades.value*100;
336+
if(form.towerupgrades.value) {
337+
this.power += Math.min(form.towerupgrades.value*100, 10000);
338+
}
338339

339340
// Money Spent. Max is 60,000 power
340341
if(this.paragoncost !== 0) {
@@ -352,25 +353,20 @@ class ParagonCalc extends LitElement {
352353
costpower += Math.floor(form.cashslider.value/sliderratio);
353354
}
354355

355-
if(costpower > 60000) costpower = 60000;
356-
this.power += costpower;
356+
this.power += Math.min(costpower, 60000);
357357
}
358358

359359
// Pops or Income. Max is 90,000 power
360360
let temp = 0;
361361
if(form.popcount.value) temp += Math.floor(form.popcount.value/180);
362362
if(form.incomegenerated.value) temp += Math.floor(form.incomegenerated.value/45);
363-
if(temp > 90000) temp = 90000;
364-
this.power += temp;
365-
363+
this.power += Math.min(temp, 90000);
366364

367365
// Totems. No Max
368366
if(form.paragontotems.value) this.power += form.paragontotems.value*2000;
369367

370368
// Capping Total Max Power
371-
if(this.power > 200000) {
372-
this.power = 200000;
373-
}
369+
this.power = Math.min(this.power, 200000);
374370
}
375371

376372
hideWidget(e) {

0 commit comments

Comments
 (0)