feat(travel): add SmartBlTravel low-level travel behavior - #302
Merged
Conversation
Contributor
Reviewer's GuideIntroduces a new SmartBlTravel behavior that intercepts low‑level BL travel to enemy X-6/7/8 maps, rerouting via 4-4 when needed, with periodic checks and conflict detection, and wires it into the plugin configuration and versioning. Sequence diagram for SmartBlTravel rerouting via 4-4 for low-level BL travelsequenceDiagram
actor Bot
participant SmartBlTravel
participant StarSystemAPI as StarSystem
participant StatsAPI as Stats
participant BotAPI as BotAPI
participant MapModule
Bot->>SmartBlTravel: onTickBehavior()
SmartBlTravel->>SmartBlTravel: [nextCheck elapsed?]
SmartBlTravel-->>Bot: [no] return
SmartBlTravel->>SmartBlTravel: [hasConflictiveModuleInUse?]
SmartBlTravel-->>Bot: [yes] return
SmartBlTravel->>StarSystem: getCurrentMap()
StarSystem-->>SmartBlTravel: current
SmartBlTravel->>StarSystem: findMap(workingMap)
StarSystem-->>SmartBlTravel: target
SmartBlTravel->>Stats: getLevel()
Stats-->>SmartBlTravel: level
SmartBlTravel->>SmartBlTravel: isEnemyHighMap(target)
SmartBlTravel->>SmartBlTravel: isOwnHighOrBl(current)
alt level < BL_PORTAL_MIN_LEVEL and enemy high map and own high/BL
SmartBlTravel->>StarSystem: findFourFour()
StarSystem-->>SmartBlTravel: fourFour
SmartBlTravel->>BotAPI: setModule(api.requireInstance(MapModule))
BotAPI-->>SmartBlTravel: MapModule
SmartBlTravel->>MapModule: setTarget(fourFour)
SmartBlTravel->>SmartBlTravel: overrideActive = true
end
alt overrideActive and not isFourFour(current)
SmartBlTravel->>StarSystem: findFourFour()
StarSystem-->>SmartBlTravel: fourFour
SmartBlTravel->>BotAPI: setModule(api.requireInstance(MapModule))
BotAPI-->>SmartBlTravel: MapModule
SmartBlTravel->>MapModule: setTarget(fourFour)
else overrideActive and isFourFour(current)
SmartBlTravel->>SmartBlTravel: overrideActive = false
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Add SmartBlTravel behavior that routes via 4-4 map when traveling to enemy X-6/7/8 maps and the ship's level is below 25, bypassing direct BL-to-BL portals. Update plugin version to 2.13.1 beta 4 and register the new behavior in plugin.json.
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
hasConflictiveModuleInUseyou callbot.getModule().getClass()without a null check; consider guarding against a null module to avoid a potential NPE during startup or transitions. - Using
String.matcheswith regex inisEnemyHighMapandisOwnHighOrBlon every tick is relatively expensive; you can replace these with simple character/substring checks (similar to yourisFourFourlogic) or precomputed patterns to reduce per-tick overhead. - Relying on
getClass().getName().contains("CaptchaPicker")inhasConflictiveModuleInUseis brittle; if possible, prefer checking for a concrete type, interface, or a more stable marker to detect conflicting modules.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `hasConflictiveModuleInUse` you call `bot.getModule().getClass()` without a null check; consider guarding against a null module to avoid a potential NPE during startup or transitions.
- Using `String.matches` with regex in `isEnemyHighMap` and `isOwnHighOrBl` on every tick is relatively expensive; you can replace these with simple character/substring checks (similar to your `isFourFour` logic) or precomputed patterns to reduce per-tick overhead.
- Relying on `getClass().getName().contains("CaptchaPicker")` in `hasConflictiveModuleInUse` is brittle; if possible, prefer checking for a concrete type, interface, or a more stable marker to detect conflicting modules.
## Individual Comments
### Comment 1
<location path="src/main/java/com/deeme/behaviours/travel/SmartBlTravel.java" line_range="119-124" />
<code_context>
+ return "4-4".equals(map.getShortName());
+ }
+
+ private boolean isEnemyHighMap(GameMap map) {
+ String s = map.getShortName();
+ if (s == null || !s.matches("^[123]-[678]$")) {
+ return false;
+ }
+ return s.charAt(0) - '0' != hero.getEntityInfo().getFaction().ordinal();
+ }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Potential off-by-one / mismatch between map number and faction ordinal.
Here you compare `s.charAt(0) - '0'` (1/2/3 for X-6/7/8) to `hero.getEntityInfo().getFaction().ordinal()`, which is usually 0-based. If factions are 0,1,2, this will misclassify own vs enemy maps. The same issue appears in `isOwnHighOrBl` when building `prefix`. Please either adjust with `+ 1` or introduce an explicit mapping from faction enum to company number, depending on how the API defines factions.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Move duplicated travel routing, tick handling, and 4-4 map management code from SmartX1Travel and SmartBlTravel into the new abstract FourFourRouter base behavior. This reduces code duplication and simplifies future maintenance of both travel behaviors.
Add null checks in hasConflictiveModuleInUse to prevent NPE when bot has no active module. Enable SmartBlTravel behavior by default for new users. Fix javadoc line wrapping in FourFourRouter for better readability.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add SmartBlTravel behavior that routes via 4-4 map when traveling to enemy X-6/7/8 maps and the ship's level is below 25, bypassing direct BL-to-BL portals. Update plugin version to 2.13.1 beta 4 and register the new behavior in plugin.json.
Summary by Sourcery
Improve travel routing by adding level-aware enemy BL navigation and consolidating 4-4 rerouting behavior.
New Features:
Bug Fixes:
Enhancements: