Skip to content

Commit

Permalink
Add new setting to enable force reloading for Generic Farming Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
steve1316 committed Jan 17, 2022
1 parent 12a3eeb commit ab6ba64
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src-tauri/backend/bot/combat_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def _reload_for_attack(override: bool = False):
None
"""
# If the "Cancel" button vanishes, that means the attack is in-progress. Now reload the page and wait for either the attack to finish or Battle ended.
if CombatMode._check_raid() or override:
if CombatMode._check_raid() or override or (Settings.farming_mode == "Generic" and Settings.enable_force_reload):
from bot.game import Game

MessageLog.print_message("[COMBAT] Reloading now.")
Expand Down Expand Up @@ -971,6 +971,8 @@ def start_combat_mode(script_commands: List[str] = None, is_nightmare: bool = Fa
return True
else:
CombatMode._enable_auto()
elif ImageUtils.find_button("attack", tries = 1, suppress_error = True) is None and ImageUtils.find_button("next", tries = 1, suppress_error = True) is None:
CombatMode._reload_for_attack()
else:
# Main workflow loop for manually pressing the Attack button and reloading until combat ends.
while not CombatMode._retreat_check:
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/backend/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ class Settings:
# #### arcarum ####
enable_stop_on_arcarum_boss: bool = _data["arcarum"]["enableStopOnArcarumBoss"]
# #### end of arcarum ####

# #### generic ####
enable_force_reload: bool = _data["generic"]["enableForceReload"]
# #### end of generic ####
# ################## end of settings.json ###################
#############################################################

Expand Down
7 changes: 7 additions & 0 deletions src/context/BotStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export interface Settings {
arcarum: {
enableStopOnArcarumBoss: boolean
}

generic: {
enableForceReload: boolean
}
}

// Set the default settings.
Expand Down Expand Up @@ -146,6 +150,9 @@ export const defaultSettings: Settings = {
arcarum: {
enableStopOnArcarumBoss: true,
},
generic: {
enableForceReload: false,
},
}

interface IProviderProps {
Expand Down
20 changes: 20 additions & 0 deletions src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,26 @@ const Settings = () => {
</FormGroup>
) : null}

{botStateContext.settings.game.farmingMode === "Generic" ? (
<FormGroup sx={{ paddingBottom: "16px" }}>
<FormControlLabel
control={
<Checkbox
checked={botStateContext.settings.generic.enableForceReload}
onChange={(e) =>
botStateContext.setSettings({ ...botStateContext.settings, generic: { ...botStateContext.settings.generic, enableForceReload: e.target.checked } })
}
/>
}
label="Enable Forcing Reload after Attack"
/>
<FormHelperText>
Enable this option to force Generic Farming Mode to reload after an attack. This does not take into account whether or not the current battle supports reloading after
an attack.
</FormHelperText>
</FormGroup>
) : null}

{/* Select Item */}
<Autocomplete
options={itemList.map((element) => element)}
Expand Down

0 comments on commit ab6ba64

Please sign in to comment.