Skip to content

Commit

Permalink
Merge pull request #398 from umbralOptimatum/update-fixes
Browse files Browse the repository at this point in the history
Auto Dungeon update fixes
  • Loading branch information
Ephenia authored Jun 18, 2024
2 parents c17d7a2 + d0a9588 commit 53fd461
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion additionalvisualsettings.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function addOptimizeVitamins() {
btn.setAttribute('style', 'line-height: 0.6; font-size: 1rem; float: right;');
btn.setAttribute('data-bind', `click: () => { if ($data) { $data.optimizeVitamins() } }, class: (!$data.breeding ? 'text-success' : 'text-muted')`);
btn.innerHTML = '⚖';
document.querySelector('#pokemonVitaminExpandedModal tbody[data-bind*="PartyController.getvitaminSortedList"] td').appendChild(btn);
document.querySelector('#pokemonVitaminExpandedModal tbody[data-bind*="PartyController.getVitaminSortedList"] td').appendChild(btn);

// Add optimize-vitamin functions for party pokemon (adapted from wiki)
PartyPokemon.prototype.calcBreedingEfficiency = function(vitaminsUsed) {
Expand Down
26 changes: 21 additions & 5 deletions enhancedautoclicker.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// @description Clicks through battles, with adjustable speed, and provides various insightful statistics. Also includes an automatic gym battler and automatic dungeon explorer with multiple pathfinding modes.
// @copyright https://github.com/Ephenia
// @license GPL-3.0 License
// @version 3.5.2
// @version 3.5.3

// @homepageURL https://github.com/Ephenia/Pokeclicker-Scripts/
// @supportURL https://github.com/Ephenia/Pokeclicker-Scripts/issues
Expand Down Expand Up @@ -329,9 +329,19 @@ class EnhancedAutoClicker {

static toggleAutoDungeon(allowSlowStop = false) {
const element = document.getElementById('auto-dungeon-start');
const newState = !this.autoDungeonState();

if (newState && !this.canStartAutoDungeon()) {
let newState = !this.autoDungeonState();

if (DungeonGuides.hired()) {
// Auto Dungeon can't run alongside dungeon guides, force stop
newState = false;
allowSlowStop = false;
Notifier.notify({
type: NotificationConstants.NotificationOption.warning,
title: 'Enhanced Auto Clicker',
message: `Auto Dungeon mode is not compatible with Dungeon Guides.`,
timeout: GameConstants.SECOND * 15,
});
} else if (newState && !this.canStartAutoDungeon()) {
// Don't turn on if there's no dungeon here
return;
} else if (newState && this.autoGymState()) {
Expand Down Expand Up @@ -632,6 +642,9 @@ class EnhancedAutoClicker {
if (!(App.game.gameState === GameConstants.GameState.dungeon || (App.game.gameState === GameConstants.GameState.town && player.town instanceof DungeonTown))) {
return false;
}
if (DungeonGuides.hired()) {
return false;
}
const dungeon = player.town.dungeon;
return dungeon?.isUnlocked() && App.game.wallet.hasAmount(new Amount(dungeon.tokenCost, GameConstants.Currency.dungeonToken));
}
Expand Down Expand Up @@ -866,6 +879,9 @@ class EnhancedAutoClicker {
static restartDungeon() {
if (App.game.gameState !== GameConstants.GameState.dungeon) {
return;
} else if (!EnhancedAutoClicker.canStartAutoDungeon()) {
MapHelper.moveToTown(DungeonRunner.dungeon.name);
return;
}
this.autoDungeonTracker.dungeonFinished = false;

Expand Down Expand Up @@ -903,7 +919,7 @@ class EnhancedAutoClicker {
EnhancedAutoClicker.toggleAutoDungeon();
}

if (EnhancedAutoClicker.autoDungeonState() && DungeonRunner.hasEnoughTokens()) {
if (EnhancedAutoClicker.autoDungeonState() && EnhancedAutoClicker.canStartAutoDungeon()) {
// Restart the dungeon with a delay, giving Defeat Dungeon Boss quests time to update
EnhancedAutoClicker.autoDungeonTracker.dungeonFinished = true;
setTimeout(() => EnhancedAutoClicker.restartDungeon(), 50);
Expand Down

0 comments on commit 53fd461

Please sign in to comment.