Skip to content

Commit

Permalink
Safari: Stop the automation on player exit (issue #49)
Browse files Browse the repository at this point in the history
If the player exists the Safari while the automation is enabled
it will now be disabled.
  • Loading branch information
Farigh committed Nov 10, 2023
2 parents 104dcda + 15ae1b0 commit a402a1b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lib/Instances/Safari.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,32 @@ class AutomationSafari
return;
}

// The user left the Safari, disable the feature
if (App.game.gameState !== GameConstants.GameState.safari)
{
Automation.Menu.forceAutomationState(this.Settings.FeatureEnabled, false);

// Exit any battle that might have started
let loopCount = 0;
const process = setInterval(function()
{
if (Safari.inBattle())
{
// Let the time for the animation to finish...
setTimeout(SafariBattle.endBattle, 500);
clearInterval(process);
}

++loopCount;
if (loopCount > 20)
{
clearInterval(process);
}
}, 50);

return;
}

// No more balls, the safari will exit soon
if (Safari.balls() == 0) return;

Expand Down

0 comments on commit a402a1b

Please sign in to comment.