-
Notifications
You must be signed in to change notification settings - Fork 66
Feat/portals weight #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dm94
wants to merge
20
commits into
darkbot-reloaded:master
Choose a base branch
from
dm94:feat/portals-weight
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/portals weight #429
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
84436b5
Added an option for the "DisconnectModule" module to be able to close…
dm94 e087897
Added the console log of why the bot closes.
dm94 2b86884
The bot will now show a pop-up warning the user that the bot will be …
dm94 45eb232
Now it will show the pop-up only when the bot is to be closed.
dm94 d583a85
Merge branch 'master' into master
dm94 044764e
Merge branch 'darkbot-reloaded:master' into master
dm94 1a59564
Merge branch 'darkbot-reloaded:master' into master
dm94 fd9d85e
Merge branch 'darkbot-reloaded:master' into master
dm94 6eb94eb
fix: Now it will not open the popup when creating DisconnectModule
dm94 45fe474
Merge branch 'darkbot-reloaded:master' into master
dm94 d0300bc
Merge branch 'master' into master
dm94 3548d02
Merge branch 'darkbot-reloaded:master' into master
dm94 f0fbd0d
Merge branch 'master' of https://github.com/dm94/DarkBot
dm94 73f05bc
Merge branch 'master' of https://github.com/dm94/DarkBot
dm94 11dcb6d
Merge branch 'master' of https://github.com/dm94/DarkBot
dm94 1328a1f
Merge branch 'darkbot-reloaded:master' into master
dm94 aa46f74
Merge branch 'darkbot-reloaded:master' into master
dm94 9035e8a
feat(StarBuilder): add weight support for portals in star graph
dm94 22fb755
Merge branch 'master' into feat/portals-weight
dm94 93f18e5
Merge branch 'master' into feat/portals-weight
dm94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,12 @@ | |
| import com.github.manolo8.darkbot.utils.I18n; | ||
| import com.github.manolo8.darkbot.utils.Time; | ||
|
|
||
| import javax.swing.JButton; | ||
| import javax.swing.JOptionPane; | ||
| import javax.swing.SwingUtilities; | ||
|
|
||
| import eu.darkbot.util.Popups; | ||
|
|
||
| @SuppressWarnings("removal") | ||
| public class DisconnectModule extends TemporalModule { | ||
|
|
||
|
|
@@ -23,15 +29,27 @@ public class DisconnectModule extends TemporalModule { | |
|
|
||
| private Long pauseUntil = null; | ||
| private boolean refreshing = false; | ||
| private boolean closeBot = false; | ||
| private boolean popupOpened = false; | ||
|
|
||
| /** | ||
| * @param pauseTime null for infinite pause, otherwise pause for that amount of MS. | ||
| * @param pauseTime null for infinite pause, otherwise pause for that amount of | ||
| * MS. | ||
| */ | ||
| public DisconnectModule(Long pauseTime, String reason) { | ||
| this.reason = reason; | ||
| this.pauseTime = pauseTime; | ||
| } | ||
|
|
||
| /** | ||
| * @param pauseTime null for infinite pause, otherwise pause for that amount of | ||
| * MS. | ||
| */ | ||
| public DisconnectModule(Long pauseTime, String reason, boolean closeBot) { | ||
| this(pauseTime, reason); | ||
| this.closeBot = closeBot; | ||
| } | ||
|
|
||
| @Override | ||
| public void install(Main main) { | ||
| super.install(main); | ||
|
|
@@ -55,6 +73,7 @@ public boolean canRefresh() { | |
|
|
||
| @Override | ||
| public void tick() { | ||
| showClosePopup(); | ||
| // Just in case refresh was super quick, don't go back to normal tick. | ||
| if (refreshing) { | ||
| tickStopped(); | ||
|
|
@@ -63,8 +82,10 @@ public void tick() { | |
| main.guiManager.pet.setEnabled(false); | ||
| safety.setRefreshing(true); | ||
| safety.tick(); | ||
| if (hero.locationInfo.isMoving() || safety.state() != SafetyFinder.Escaping.WAITING) return; | ||
| if (!logout.visible) logoutStart = System.currentTimeMillis(); | ||
| if (hero.locationInfo.isMoving() || safety.state() != SafetyFinder.Escaping.WAITING) | ||
| return; | ||
| if (!logout.visible) | ||
| logoutStart = System.currentTimeMillis(); | ||
| logout.show(true); | ||
| // Prevent bug where logout gets to 0 and doesn't log out, just force a reload | ||
| if (System.currentTimeMillis() - logoutStart > 25_000) { | ||
|
|
@@ -76,14 +97,23 @@ public void tick() { | |
|
|
||
| @Override | ||
| public void tickStopped() { | ||
| showClosePopup(); | ||
| if (main.isRunning()) { | ||
| if (!lostConnection.visible) return; | ||
| if (!lostConnection.visible) | ||
| return; | ||
| // Bot done. Pause "forever" (unless a behaviour restarts it). | ||
| if (pauseTime == null) main.setRunning(false); | ||
| else if (pauseTime == 0) goBack(); | ||
| if (pauseTime == null) | ||
| main.setRunning(false); | ||
| else if (pauseTime == 0) | ||
| goBack(); | ||
| else { | ||
| pauseUntil = System.currentTimeMillis() + pauseTime; | ||
| main.setRunning(false); | ||
|
|
||
| if (closeBot) { | ||
| System.out.println("Exit by the Disconnect module, exiting"); | ||
| System.exit(0); | ||
| } | ||
| } | ||
| } else if (pauseUntil != null && System.currentTimeMillis() > pauseUntil - 10_000) { | ||
| if (!refreshing) { | ||
|
|
@@ -104,7 +134,32 @@ public String status() { | |
|
|
||
| @Override | ||
| public String stoppedStatus() { | ||
| if (pauseUntil == null) return I18n.get("module.disconnect.status_stopped", reason); | ||
| else return I18n.get("module.disconnect.status_paused", reason, Time.toString(Math.max(0, pauseUntil - System.currentTimeMillis()))); | ||
| if (pauseUntil == null) | ||
| return I18n.get("module.disconnect.status_stopped", reason); | ||
| else | ||
| return I18n.get("module.disconnect.status_paused", reason, | ||
| Time.toString(Math.max(0, pauseUntil - System.currentTimeMillis()))); | ||
| } | ||
|
|
||
| private void showClosePopup() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. disconnect module changes look good, but them being in the same PR as the other changes is not |
||
| if (!closeBot || popupOpened) { | ||
| return; | ||
| } | ||
|
|
||
| this.popupOpened = true; | ||
| JButton okBtn = new JButton(I18n.get("module.disconnect.popup.ok_btn")); | ||
| JButton cancelBtn = new JButton(I18n.get("module.disconnect.popup.cancel_btn")); | ||
| okBtn.addActionListener(e -> { | ||
| SwingUtilities.getWindowAncestor(okBtn).setVisible(false); | ||
| }); | ||
| cancelBtn.addActionListener(e -> { | ||
| closeBot = false; | ||
| SwingUtilities.getWindowAncestor(cancelBtn).setVisible(false); | ||
| }); | ||
|
|
||
| Popups.of(I18n.get("module.disconnect.popup.title"), | ||
| new JOptionPane(I18n.get("module.disconnect.popup.message"), JOptionPane.INFORMATION_MESSAGE, | ||
| JOptionPane.DEFAULT_OPTION, null, new Object[] { okBtn, cancelBtn })) | ||
| .showAsync(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just makes it so the void will avoid using BL portals even if they may be significantly shorter paths.
I don't understand the rationale behind this, unless its intended to be for accounts of a level lower than minimum requirement, but if that's the aim then it shouldn't be just 10 more weight, it should be straight up disabled until you have the minimum level, and should change based on your level.