Skip to content

Commit c1e1761

Browse files
committed
Toggles, Sacrifice properly moved to Features
1 parent d04e2dc commit c1e1761

39 files changed

Lines changed: 450 additions & 128 deletions

Synergism.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,28 @@ p#reincarnatehotkeys {
24262426
font-size: 1.2em;
24272427
}
24282428

2429+
.enabledAntToggle {
2430+
border-color: green;
2431+
}
2432+
2433+
.disabledAntToggle {
2434+
border-color: crimson;
2435+
}
2436+
2437+
.singlePurchaseAnt {
2438+
border-color: white;
2439+
}
2440+
2441+
.maxPurchaseAnt {
2442+
border-color: gold;
2443+
}
2444+
2445+
.antToggleBtn {
2446+
min-width: 150px;
2447+
cursor: pointer;
2448+
border-width: 1px;
2449+
}
2450+
24292451
#antToggleFeatures {
24302452
display: flex;
24312453
justify-content: center;

index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,8 +1736,12 @@ <h3 class="reincarnationunlock" id="reincarnationtext" style="color: limegreen"
17361736
</div>
17371737

17381738
<div id="antToggleFeatures">
1739-
<button id="toggleAntMax"></button>
1740-
<button id="toggleAutoSacrificeAnt"></button>
1739+
<button id="toggleBuyAntProducerMax" class="antToggleBtn"></button>
1740+
<button id="toggleBuyAntUpgradesMax" class="antToggleBtn"></button>
1741+
<button id="toggleAutobuyAntProducer" class="antToggleBtn"></button>
1742+
<button id="toggleAutobuyAntMastery" class="antToggleBtn"></button>
1743+
<button id="toggleAutobuyAntUpgrades" class="antToggleBtn"></button>
1744+
<button id="toggleAutoSacrificeAnt" class="antToggleBtn"></button>
17411745
<div class="antSacrificeSettingsContainer" id="antSacrificeButtons">
17421746
<button id="autoSacrificeAntMode"></button>
17431747
<input id="autoAntSacrificeAmount" type="number">

src/EventListeners.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ import { antUpgradeHTML } from './Features/Ants/HTML/modals/upgrade-modal'
4545
import { toggleRebornELOInfo } from './Features/Ants/HTML/updates/elo-info'
4646
import { toggleLeaderboardMode } from './Features/Ants/HTML/updates/leaderboard'
4747
import { AntProducers, LAST_ANT_PRODUCER } from './Features/Ants/structs/structs'
48+
import { toggleAutoAntSacrificeEnabled, toggleAutoAntSacrificeMode } from './Features/Ants/toggles/auto-sacrifice'
49+
import { toggleAutobuyAntMastery } from './Features/Ants/toggles/autobuy-mastery'
50+
import { toggleAutobuyAntProducer } from './Features/Ants/toggles/autobuy-producer'
51+
import { toggleAutobuyAntUpgrade } from './Features/Ants/toggles/autobuy-upgrade'
52+
import { toggleMaxBuyAntProducer } from './Features/Ants/toggles/max-producer-buy'
53+
import { toggleMaxBuyAntUpgrade } from './Features/Ants/toggles/max-upgrade-buy'
4854
import {
4955
craftHepteracts,
5056
expandHepteracts,
@@ -136,8 +142,6 @@ import { IconSets, imgErrorHandler, toggleAnnotation, toggleIconSet, toggleTheme
136142
import {
137143
autoCubeUpgradesToggle,
138144
autoPlatonicUpgradesToggle,
139-
toggleAntAutoSacrifice,
140-
toggleAntMaxBuy,
141145
toggleAscStatPerSecond,
142146
toggleAutoAscend,
143147
toggleAutoBuyFragment,
@@ -774,7 +778,7 @@ export const generateEventHandlers = () => {
774778
antTier.addEventListener('mouseout', () => CloseModal())
775779
antTier.addEventListener('blur', () => CloseModal())
776780
antTier.addEventListener('click', (event) => {
777-
buyAntProducers(ant, player.antMax)
781+
buyAntProducers(ant, player.ants.toggles.maxBuyProducers)
778782
Modal(antProducerHTML(ant), event.clientX, event.clientY, { borderColor: antProducerData[ant].color }, true)
779783
})
780784

@@ -819,7 +823,7 @@ export const generateEventHandlers = () => {
819823
antUpgrade.addEventListener('mouseout', () => CloseModal())
820824
antUpgrade.addEventListener('blur', () => CloseModal())
821825
antUpgrade.addEventListener('click', (event) => {
822-
buyAntUpgrade(upgrade, player.antMax)
826+
buyAntUpgrade(upgrade, player.ants.toggles.maxBuyUpgrades)
823827
Modal(antUpgradeHTML(upgrade), event.clientX, event.clientY, { borderColor: 'burlywood' }, true)
824828
})
825829
}
@@ -831,9 +835,13 @@ export const generateEventHandlers = () => {
831835
DOMCacheGetOrSet('antLeaderboardToggle').addEventListener('click', () => toggleLeaderboardMode())
832836

833837
// Part 4: QoL Buttons
834-
DOMCacheGetOrSet('toggleAntMax').addEventListener('click', () => toggleAntMaxBuy())
835-
DOMCacheGetOrSet('toggleAutoSacrificeAnt').addEventListener('click', () => toggleAntAutoSacrifice(0))
836-
DOMCacheGetOrSet('autoSacrificeAntMode').addEventListener('click', () => toggleAntAutoSacrifice(1))
838+
DOMCacheGetOrSet('toggleBuyAntProducerMax').addEventListener('click', () => toggleMaxBuyAntProducer())
839+
DOMCacheGetOrSet('toggleBuyAntUpgradesMax').addEventListener('click', () => toggleMaxBuyAntUpgrade())
840+
DOMCacheGetOrSet('toggleAutobuyAntProducer').addEventListener('click', () => toggleAutobuyAntProducer())
841+
DOMCacheGetOrSet('toggleAutobuyAntMastery').addEventListener('click', () => toggleAutobuyAntMastery())
842+
DOMCacheGetOrSet('toggleAutobuyAntUpgrades').addEventListener('click', () => toggleAutobuyAntUpgrade())
843+
DOMCacheGetOrSet('toggleAutoSacrificeAnt').addEventListener('click', () => toggleAutoAntSacrificeEnabled())
844+
DOMCacheGetOrSet('autoSacrificeAntMode').addEventListener('click', () => toggleAutoAntSacrificeMode())
837845

838846
// WOW! Cubes Tab
839847
// Part 0: Subtab UI
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
import type Decimal from 'break_infinity.js'
2+
13
export const MINIMUM_CRUMBS_FOR_SACRIFICE = 1e70
4+
5+
export const hasEnoughCrumbsForSacrifice = (crumbs: Decimal): boolean => {
6+
return crumbs.gte(MINIMUM_CRUMBS_FOR_SACRIFICE)
7+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const autobuyAntProducers = () => {
77
const tiersUnlocked = +getAchievementReward('antAutobuyers') - 1
88
for (let ant = LAST_ANT_PRODUCER; ant >= AntProducers.Workers; ant--) {
99
if (ant <= tiersUnlocked) {
10-
buyAntProducers(ant, player.antMax)
10+
buyAntProducers(ant, player.ants.toggles.maxBuyProducers)
1111
}
1212
}
1313
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import type Decimal from 'break_infinity.js'
2+
import i18next from 'i18next'
3+
import { format, player } from '../../../Synergism'
4+
import { hasEnoughCrumbsForSacrifice } from '../AntSacrifice/constants'
5+
import { antSacrificeRewards } from '../AntSacrifice/Rewards/calculate-rewards'
6+
import { AutoSacrificeModes } from '../toggles/structs/sacrifice'
7+
import type { AutoSacrificeModeData } from './structs/structs'
8+
9+
export const autoSacrificeData: Record<AutoSacrificeModes, AutoSacrificeModeData> = {
10+
[AutoSacrificeModes.InGameTime]: {
11+
sacrificeCheck: () => {
12+
return player.antSacrificeTimer >= player.ants.toggles.autoSacrificeThreshold
13+
},
14+
modeName: () => i18next.t('ants.autoSacrifice.inGameTimer.name'),
15+
infoText: () =>
16+
i18next.t('ants.autoSacrifice.inGameTimer.info', {
17+
curr: format(player.antSacrificeTimer, 2, true),
18+
req: format(player.ants.toggles.autoSacrificeThreshold, 0, true)
19+
})
20+
},
21+
[AutoSacrificeModes.RealTime]: {
22+
sacrificeCheck: () => {
23+
return player.antSacrificeTimerReal >= player.ants.toggles.autoSacrificeThreshold
24+
},
25+
modeName: () => i18next.t('ants.autoSacrifice.realLifeTimer.name'),
26+
infoText: () =>
27+
i18next.t('ants.autoSacrifice.realLifeTimer.info', {
28+
curr: format(player.antSacrificeTimerReal, 2, true),
29+
req: format(player.ants.toggles.autoSacrificeThreshold, 0, true)
30+
})
31+
},
32+
[AutoSacrificeModes.ImmortalELOGain]: {
33+
sacrificeCheck: () => {
34+
const immortalELOToGain = antSacrificeRewards().immortalELO
35+
return immortalELOToGain >= player.ants.toggles.autoSacrificeThreshold // Todo: Replace with an actual criterion in Ants
36+
},
37+
modeName: () => i18next.t('ants.autoSacrifice.immortalELOGain.name'),
38+
infoText: () =>
39+
i18next.t('ants.autoSacrifice.immortalELOGain.info', {
40+
curr: format(antSacrificeRewards().immortalELO, 0, true),
41+
req: format(player.ants.toggles.autoSacrificeThreshold, 0, true)
42+
})
43+
},
44+
[AutoSacrificeModes.MaxRebornELO]: {
45+
sacrificeCheck: () => {
46+
const rebornELOToGain = player.ants.immortalELO - player.ants.rebornELO
47+
return rebornELOToGain <= 0.001 // Effectively maxed out
48+
},
49+
modeName: () => i18next.t('ants.autoSacrifice.maxRebornELO.name'),
50+
infoText: () => {
51+
const rebornELOToGain = player.ants.immortalELO - player.ants.rebornELO
52+
return i18next.t('ants.autoSacrifice.maxRebornELO.info', {
53+
curr: format(rebornELOToGain, 0, true)
54+
})
55+
}
56+
}
57+
}
58+
59+
export const canAutoSacrifice = (crumbs: Decimal, sacMode: AutoSacrificeModes): boolean => {
60+
return hasEnoughCrumbsForSacrifice(crumbs) && autoSacrificeData[sacMode].sacrificeCheck()
61+
&& player.ants.toggles.autoSacrificeEnabled
62+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export interface AutoSacrificeModeData {
2+
sacrificeCheck: () => boolean
3+
modeName: () => string
4+
infoText: () => string
5+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export const autobuyAntUpgrades = () => {
77
const upgradesUnlocked = +getAchievementReward('antUpgradeAutobuyers')
88
for (let upgrade = AntUpgrades.AntSpeed; upgrade < LAST_ANT_UPGRADE; upgrade++) {
99
if (upgrade < upgradesUnlocked) {
10-
buyAntUpgrade(upgrade, player.antMax)
10+
buyAntUpgrade(upgrade, player.ants.toggles.maxBuyUpgrades)
1111
}
1212
}
1313

1414
// The way mortuus autobuy is unlocked is
1515
// research 6x20. The above loop won't catch it!
1616
if (player.researches[145] > 0) {
17-
buyAntUpgrade(AntUpgrades.Mortuus, player.antMax)
17+
buyAntUpgrade(AntUpgrades.Mortuus, player.ants.toggles.maxBuyUpgrades)
1818
}
1919
}

src/Features/Ants/HTML/modals/producer-modal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const antProducerHTML = (ant: AntProducers) => {
3535

3636
let costHTML: string
3737
const maxBuy = getMaxPurchasableAnts(ant, player.ants.crumbs)
38-
if (player.antMax && maxBuy > player.ants.producers[ant].purchased) {
38+
if (player.ants.toggles.maxBuyProducers && maxBuy > player.ants.producers[ant].purchased) {
3939
const cost = getCostMaxAnts(ant)
4040
costHTML = i18next.t('ants.costMaxLevels', {
4141
x: format(maxBuy - player.ants.producers[ant].purchased, 0, true),

0 commit comments

Comments
 (0)