Skip to content

feat(travel): add SmartBlTravel low-level travel behavior - #302

Merged
dm94 merged 5 commits into
masterfrom
feat/add-SmartBlTravel
Aug 18, 2026
Merged

feat(travel): add SmartBlTravel low-level travel behavior#302
dm94 merged 5 commits into
masterfrom
feat/add-SmartBlTravel

Conversation

@dm94

@dm94 dm94 commented Aug 6, 2026

Copy link
Copy Markdown
Owner

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:

  • Add smart low-level travel routing that uses 4-4 when traveling from allied high-level or BL maps to enemy X-6/7/8 maps.

Bug Fixes:

  • Prevent ships below the BL portal level requirement from attempting direct BL-to-BL travel.

Enhancements:

  • Extract shared 4-4 rerouting and travel interception logic into a reusable base behavior.
  • Refactor X-1 travel behavior to use the shared 4-4 routing implementation.

@sourcery-ai

sourcery-ai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Introduces 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 travel

sequenceDiagram
    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
Loading

File-Level Changes

Change Details Files
Add SmartBlTravel behavior to reroute low-level BL travel via 4-4 instead of direct BL-to-BL portals when going to enemy high maps.
  • Implement SmartBlTravel as a Behavior feature with security/auth checks and donation/Discord prompts in the constructor.
  • Inject core DarkBot APIs (BotAPI, HeroAPI, StarSystemAPI, StatsAPI, ConfigAPI, EntitiesAPI) and cache portals and working_map configuration.
  • On each tick, throttle checks to every 500ms and bail out when a conflicting CaptchaPicker-like module is active or when current/target maps are unavailable.
  • When override is active, keep pushing MapModule towards 4-4 until the hero reaches it, then clear the override.
  • When the ship level is below BL_PORTAL_MIN_LEVEL and the configured working map is an enemy X-6/7/8 and the current map is own high or BL, activate override and route via 4-4 if reachable via portals.
  • Provide helpers to detect 4-4, enemy high maps based on faction and short name, own high or BL maps, and to locate the 4-4 map in the star system.
src/main/java/com/deeme/behaviours/travel/SmartBlTravel.java
Register the new SmartBlTravel behavior and bump plugin version.
  • Update plugin.json to register the SmartBlTravel feature so it becomes available to the bot.
  • Increment the plugin version to 2.13.1 beta 4 to reflect the new behavior addition.
src/main/resources/plugin.json

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

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.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • 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.
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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/main/java/com/deeme/behaviours/travel/SmartBlTravel.java
dm94 added 4 commits August 6, 2026 23:55
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.
@dm94
dm94 merged commit dc5059b into master Aug 18, 2026
8 checks passed
@dm94
dm94 deleted the feat/add-SmartBlTravel branch August 18, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant