Skip to content

Commit d4a6190

Browse files
committed
Enum + Structural Change to AntUpgrades as well
1 parent 9950f2f commit d4a6190

14 files changed

Lines changed: 228 additions & 175 deletions

src/Ants.ts

Lines changed: 130 additions & 127 deletions
Large diffs are not rendered by default.

src/Buy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { DecimalSource } from 'break_infinity.js'
22
import Decimal from 'break_infinity.js'
33
import { awardAchievementGroup } from './Achievements'
4-
import { getAntUpgradeEffect } from './Ants'
4+
import { AntUpgrades, getAntUpgradeEffect } from './Ants'
55
import { CalcECC } from './Challenges'
66
import { reset } from './Reset'
77
import { getRuneBlessingEffect } from './RuneBlessings'
@@ -18,7 +18,7 @@ export const getReductionValue = () => {
1818
reduction += (player.researches[56] + player.researches[57] + player.researches[58] + player.researches[59]
1919
+ player.researches[60]) / 200
2020
reduction += CalcECC('transcend', player.challengecompletions[4]) / 200
21-
reduction += getAntUpgradeEffect('buildingCostScale').buildingCostScale
21+
reduction += getAntUpgradeEffect(AntUpgrades.BuildingCostScale).buildingCostScale
2222
return reduction
2323
}
2424

@@ -573,7 +573,7 @@ export const buyProducer = (
573573
r += (player.researches[56] + player.researches[57] + player.researches[58] + player.researches[59]
574574
+ player.researches[60]) / 200
575575
r += CalcECC('transcend', player.challengecompletions[4]) / 200
576-
r += getAntUpgradeEffect('buildingCostScale').buildingCostScale
576+
r += getAntUpgradeEffect(AntUpgrades.BuildingCostScale).buildingCostScale
577577

578578
const posCostType = `${pos}Cost${type}` as const
579579
const posOwnedType = `${pos}Owned${type}` as const

src/Calculate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import i18next from 'i18next'
33
import { awardUngroupedAchievement, getAchievementReward } from './Achievements'
44
import {
55
AntProducers,
6+
AntUpgrades,
67
clearDailyLeaderboard,
78
generateAntsAndCrumbs,
89
getAntUpgradeEffect,
@@ -467,7 +468,7 @@ export const calculateTotalAcceleratorBoost = () => {
467468
* (1 + (1 / 2) * CalcECC('ascension', player.challengecompletions[14]))
468469
b *= 1 + (1 / 20) * player.researches[16] + (1 / 20) * player.researches[17]
469470
b *= 1 + (1 / 20) * player.researches[88]
470-
b *= getAntUpgradeEffect('acceleratorBoosts').acceleratorBoostMult
471+
b *= getAntUpgradeEffect(AntUpgrades.AcceleratorBoosts).acceleratorBoostMult
471472
b *= 1 + (1 / 100) * player.researches[127]
472473
b *= 1 + (0.8 / 100) * player.researches[142]
473474
b *= 1 + (0.6 / 100) * player.researches[157]

src/EventListeners.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import {
55
antProducerHTML,
66
AntProducers,
77
antUpgradeHTML,
8-
antUpgradeKeys,
8+
AntUpgrades,
99
antUpgrades,
1010
baseAntInfo,
1111
buyAntMastery,
1212
buyAntProducers,
1313
buyAntUpgrade,
1414
LAST_ANT,
15+
LAST_ANT_UPGRADE,
1516
sacrificeAnts,
1617
toggleLeaderboardMode,
1718
toggleRebornELOInfo
@@ -803,28 +804,27 @@ export const generateEventHandlers = () => {
803804
})
804805
}
805806
// Part 2: Ant Upgrades
806-
for (const key of antUpgradeKeys) {
807-
const index = antUpgrades[key].index
808-
const antUpgrade = DOMCacheGetOrSet(`antUpgrade${index + 1}`)
807+
for (let upgrade = AntUpgrades.AntSpeed; upgrade <= LAST_ANT_UPGRADE; upgrade++) {
808+
const antUpgrade = DOMCacheGetOrSet(`antUpgrade${upgrade + 1}`)
809809

810810
antUpgrade.style.setProperty(
811811
'--glow-color',
812-
`color-mix(in srgb, ${antUpgrades[key].antUpgradeHTML.color} 75%, crimson 25%)`
812+
`color-mix(in srgb, ${antUpgrades[upgrade].antUpgradeHTML.color} 75%, crimson 25%)`
813813
)
814814

815815
antUpgrade.addEventListener(
816816
'mousemove',
817-
(e: MouseEvent) => Modal(antUpgradeHTML(key), e.clientX, e.clientY, { borderColor: 'burlywood' })
817+
(e: MouseEvent) => Modal(antUpgradeHTML(upgrade), e.clientX, e.clientY, { borderColor: 'burlywood' })
818818
)
819819
antUpgrade.addEventListener('focus', () => {
820820
const elmRect = antUpgrade.getBoundingClientRect()
821-
Modal(antUpgradeHTML(key), elmRect.x, elmRect.y + elmRect.height / 2, { borderColor: 'burlywood' })
821+
Modal(antUpgradeHTML(upgrade), elmRect.x, elmRect.y + elmRect.height / 2, { borderColor: 'burlywood' })
822822
})
823823
antUpgrade.addEventListener('mouseout', () => CloseModal())
824824
antUpgrade.addEventListener('blur', () => CloseModal())
825825
antUpgrade.addEventListener('click', (event) => {
826-
buyAntUpgrade(key, player.antMax)
827-
Modal(antUpgradeHTML(key), event.clientX, event.clientY, { borderColor: 'burlywood' }, true)
826+
buyAntUpgrade(upgrade, player.antMax)
827+
Modal(antUpgradeHTML(upgrade), event.clientX, event.clientY, { borderColor: 'burlywood' }, true)
828828
})
829829
}
830830
// Part 3: Sacrifice

src/Reset.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Decimal from 'break_infinity.js'
22
import i18next from 'i18next'
33
import { awardAchievementGroup, challengeAchievementCheck, getAchievementReward } from './Achievements'
4-
import { AntProducers, LAST_ANT } from './Ants'
4+
import { AntProducers, AntUpgrades, antUpgrades, LAST_ANT, LAST_ANT_UPGRADE } from './Ants'
55
import type { BlueberryLoadoutMode } from './BlueberryUpgrades'
66
import { buyTesseractBuilding, calculateTessBuildingsInBudget } from './Buy'
77
import type { TesseractBuildings } from './Buy'
@@ -1451,16 +1451,19 @@ const resetUpgrades = (i: number) => {
14511451
}
14521452

14531453
export const resetAnts = (resetTier: resetTiers) => {
1454+
// Reset Upgrades Appropriately
1455+
for (let upgrade = AntUpgrades.AntSpeed; upgrade <= LAST_ANT_UPGRADE; upgrade++) {
1456+
if (resetTier >= antUpgrades[upgrade].minimumResetTier) {
1457+
player.ants.upgrades[upgrade] = 0
1458+
}
1459+
}
1460+
14541461
if (resetTier >= resetTiers.reincarnation) {
14551462
for (let ants = AntProducers.Workers; ants <= LAST_ANT; ants++) {
14561463
player.ants.producers[ants].purchased = 0
14571464
player.ants.producers[ants].generated = new Decimal(0)
14581465
}
14591466

1460-
const numAntUpgrades = player.ants.upgrades.length
1461-
const mortuus = player.ants.upgrades[11]
1462-
player.ants.upgrades = Array(numAntUpgrades).fill(0)
1463-
player.ants.upgrades[11] = mortuus
14641467
player.ants.crumbs = new Decimal('1')
14651468
player.ants.highestCrumbsThisSacrifice = new Decimal('1')
14661469

src/Runes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Globals as G } from './Variables'
55
import Decimal from 'break_infinity.js'
66
import i18next from 'i18next'
77
import { awardAchievementGroup, getAchievementReward } from './Achievements'
8-
import { getAntUpgradeEffect } from './Ants'
8+
import { AntUpgrades, getAntUpgradeEffect } from './Ants'
99
import { getAmbrosiaUpgradeEffects } from './BlueberryUpgrades'
1010
import { DOMCacheGetOrSet } from './Cache/DOM'
1111
import { CalcECC } from './Challenges'
@@ -115,7 +115,7 @@ export interface RuneData<K extends RuneKeys> {
115115

116116
export const firstFiveFreeLevels = () => {
117117
return (
118-
getAntUpgradeEffect('freeRunes').freeRuneLevel
118+
getAntUpgradeEffect(AntUpgrades.FreeRunes).freeRuneLevel
119119
+ 7 * Math.min(player.constantUpgrades[7], 1000)
120120
)
121121
}

src/Statistics.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import Decimal, { type DecimalSource } from 'break_infinity.js'
22
import i18next from 'i18next'
33
import { getAchievementReward } from './Achievements'
4-
import { AntProducers, calculateAntSpeedMultFromELO, calculateTrueAntLevelFromKey, getAntUpgradeEffect } from './Ants'
4+
import {
5+
AntProducers,
6+
AntUpgrades,
7+
calculateAntSpeedMultFromELO,
8+
calculateTrueAntLevel,
9+
getAntUpgradeEffect
10+
} from './Ants'
511
import { getAmbrosiaUpgradeEffects } from './BlueberryUpgrades'
612
import { DOMCacheGetOrSet } from './Cache/DOM'
713
import {
@@ -406,7 +412,7 @@ export const allWowCubeStats: NumberStatLine[] = [
406412
* (1 + (0.8 * player.researches[167]) / 100) // 7x17
407413
* (1 + (0.7 * player.researches[182]) / 100) // 8x7
408414
* (1
409-
+ (0.03 / 100) * player.researches[192] * calculateTrueAntLevelFromKey('mortuus')) // 8x17
415+
+ (0.03 / 100) * player.researches[192] * calculateTrueAntLevel(AntUpgrades.Mortuus)) // 8x17
410416
* (1 + (0.6 * player.researches[197]) / 100) // 8x22
411417
},
412418
{
@@ -917,7 +923,7 @@ export const allOfferingStats: DecimalSourceLine[] = [
917923
},
918924
{
919925
i18n: 'AntUpgrade',
920-
stat: () => getAntUpgradeEffect('offerings').offeringMult // Ant Upgrade
926+
stat: () => getAntUpgradeEffect(AntUpgrades.Offerings).offeringMult // Ant Upgrade
921927
},
922928
{
923929
i18n: 'Brutus',
@@ -1557,7 +1563,7 @@ export const allObtainiumStats: DecimalSourceLine[] = [
15571563
},
15581564
{
15591565
i18n: 'Ant10',
1560-
stat: () => getAntUpgradeEffect('obtainium').obtainiumMult // Ant 10
1566+
stat: () => getAntUpgradeEffect(AntUpgrades.Obtainium).obtainiumMult // Ant 10
15611567
},
15621568
{
15631569
i18n: 'CubeBonus',
@@ -1705,7 +1711,7 @@ export const antSacrificeRewardStats: DecimalSourceLine[] = [
17051711
},
17061712
{
17071713
i18n: 'AntUpgrade11',
1708-
stat: () => getAntUpgradeEffect('antSacrifice').antSacrificeMultiplier
1714+
stat: () => getAntUpgradeEffect(AntUpgrades.AntSacrifice).antSacrificeMultiplier
17091715
},
17101716
{
17111717
i18n: 'Research103',
@@ -1858,7 +1864,7 @@ export const allGlobalSpeedStats: NumberStatLine[] = [
18581864
},
18591865
{
18601866
i18n: 'Ant12',
1861-
stat: () => getAntUpgradeEffect('mortuus').globalSpeed // ant 12
1867+
stat: () => getAntUpgradeEffect(AntUpgrades.Mortuus).globalSpeed // ant 12
18621868
},
18631869
{
18641870
i18n: 'ChronosTalisman',
@@ -2876,7 +2882,7 @@ export const positiveSalvageStats: NumberStatLine[] = [
28762882
},
28772883
{
28782884
i18n: 'AntUpgrade',
2879-
stat: () => getAntUpgradeEffect('salvage').salvage // Ant Upgrade
2885+
stat: () => getAntUpgradeEffect(AntUpgrades.Salvage).salvage // Ant Upgrade
28802886
},
28812887
{
28822888
i18n: 'CubeBlessing',
@@ -2940,7 +2946,7 @@ export const antSpeedStats: DecimalSourceLine[] = [
29402946
},
29412947
{
29422948
i18n: 'AntUpgrade1',
2943-
stat: () => getAntUpgradeEffect('antSpeed').antSpeed // Ant Upgrade 1
2949+
stat: () => getAntUpgradeEffect(AntUpgrades.AntSpeed).antSpeed // Ant Upgrade 1
29442950
},
29452951
{
29462952
i18n: 'DiamondUpgrade19',

src/Synergism.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ import {
3636
updateProgressiveCache
3737
} from './Achievements'
3838
import {
39+
AntUpgrades,
3940
autobuyAntMasteries,
4041
autobuyAntProducers,
4142
autoBuyAntUpgrades,
4243
emptyAntProducer,
4344
generateAntsAndCrumbs,
44-
getAntUpgradeEffect,
45-
NUM_ANT_UPGRADES
45+
getAntUpgradeEffect
4646
} from './Ants'
4747
import { autoUpgrades } from './Automation'
4848
import type { TesseractBuildings } from './Buy'
@@ -368,7 +368,20 @@ export const player: Player = {
368368
[7]: { ...emptyAntProducer },
369369
[8]: { ...emptyAntProducer }
370370
},
371-
upgrades: Array(NUM_ANT_UPGRADES).fill(0) as number[],
371+
upgrades: {
372+
[0]: 0,
373+
[1]: 0,
374+
[2]: 0,
375+
[3]: 0,
376+
[4]: 0,
377+
[5]: 0,
378+
[6]: 0,
379+
[7]: 0,
380+
[8]: 0,
381+
[9]: 0,
382+
[10]: 0,
383+
[11]: 0
384+
},
372385
crumbs: new Decimal('1'),
373386
highestCrumbsThisSacrifice: new Decimal('1'),
374387
highestCrumbsEver: new Decimal('1'),
@@ -2722,7 +2735,7 @@ export const updateAllMultiplier = (): void => {
27222735
a *= 1 + (0.2 / 100) * player.researches[188]
27232736
a *= 1 + (0.01 / 100) * player.researches[200]
27242737
a *= 1 + (0.01 / 100) * player.cubeUpgrades[50]
2725-
a *= getAntUpgradeEffect('multipliers').multiplierMult
2738+
a *= getAntUpgradeEffect(AntUpgrades.Multipliers).multiplierMult
27262739
a *= calculateMultiplierCubeBlessing()
27272740
if (
27282741
(player.currentChallenge.transcension !== 0
@@ -2852,7 +2865,7 @@ export const multipliers = (): void => {
28522865
)
28532866
G.reincarnationMultiplier = Decimal.pow(G.buildingPower, G.totalCoinOwned)
28542867

2855-
G.antMultiplier = getAntUpgradeEffect('coins').coinMultiplier
2868+
G.antMultiplier = getAntUpgradeEffect(AntUpgrades.Coins).coinMultiplier
28562869

28572870
s = s.times(G.multiplierEffect)
28582871
s = s.times(G.acceleratorEffect)

src/Talismans.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Decimal from 'break_infinity.js'
22
import i18next from 'i18next'
33
import { achievementPoints, awardUngroupedAchievement, getAchievementReward } from './Achievements'
4-
import { getAntUpgradeEffect } from './Ants'
4+
import { AntUpgrades, getAntUpgradeEffect } from './Ants'
55
import { DOMCacheGetOrSet } from './Cache/DOM'
66
import { isShopTalismanUnlocked } from './Calculate'
77
import { CalcECC } from './Challenges'
@@ -489,7 +489,7 @@ export const talismans: { [K in TalismanKeys]: TalismanData<K> } = {
489489
},
490490
minimalResetTier: 'ascension',
491491
isUnlocked: () => {
492-
return getAntUpgradeEffect('mortuus').talismanUnlock || player.ascensionCount > 0
492+
return getAntUpgradeEffect(AntUpgrades.Mortuus).talismanUnlock
493493
},
494494
name: () => i18next.t('runes.talismans.mortuus.name'),
495495
description: () => i18next.t('runes.talismans.mortuus.description')

src/Tax.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Globals as G } from './Variables'
44

55
import Decimal from 'break_infinity.js'
66
import { awardUngroupedAchievement, getAchievementReward } from './Achievements'
7-
import { getAntUpgradeEffect } from './Ants'
7+
import { AntUpgrades, getAntUpgradeEffect } from './Ants'
88
import { CalcECC } from './Challenges'
99
import { calculateTaxPlatonicBlessing } from './PlatonicCubes'
1010
import { getRuneEffects } from './Runes'
@@ -87,7 +87,7 @@ export const calculatetax = () => {
8787
exponent *= Math.pow(0.965, CalcECC('reincarnation', player.challengecompletions[6]))
8888
exponent *= getRuneEffects('duplication').taxReduction
8989
exponent *= getRuneEffects('thrift').taxReduction
90-
exponent *= getAntUpgradeEffect('taxes').taxReduction
90+
exponent *= getAntUpgradeEffect(AntUpgrades.Taxes).taxReduction
9191
exponent *= 1
9292
/ Math.pow(
9393
1 + Decimal.log(player.ascendShards.add(1), 10),

0 commit comments

Comments
 (0)