Skip to content

feat(quests): overland trade caravan escort and dynamic ambush engine - #194

Open
angelTomo9 wants to merge 2 commits into
Bitcoindefi:mainfrom
angelTomo9:feat-caravan-escort-1787842851242
Open

feat(quests): overland trade caravan escort and dynamic ambush engine#194
angelTomo9 wants to merge 2 commits into
Bitcoindefi:mainfrom
angelTomo9:feat-caravan-escort-1787842851242

Conversation

@angelTomo9

Copy link
Copy Markdown

Summary

Implements an overland trade caravan escort and dynamic bandit ambush mission engine for OpenAO MMORPG.

Features

  • Route waypoint traversal and player protection radius enforcement
  • Dynamic bandit ambush probability scaling with cargo value
  • Cart integrity monitoring and delivery reward scaling
  • Full unit test coverage under Vitest

Comment thread api/src/lib/caravanEscortTrade.ts Outdated
Comment on lines +17 to +31
it("applies ambush damage to cart and scales down final reward payout", () => {
const mission = CaravanEscortTradeEngine.startMission("player_1", mockManifest, mockWaypoints, 500);

// WP 1 with ambush triggered (rng = 0.01) -> takes 150 damage (500 -> 350 HP)
const tick1 = CaravanEscortTradeEngine.advanceWaypoint(mission, { x: 10, y: 10 }, () => 0.01);
expect(tick1.isAmbushTriggered).toBe(true);
expect(tick1.cartRemainingHp).toBe(350);
expect(mission.cartCurrentHp).toBe(350);

// WP 2 destination without ambush (350 / 500 = 70% health ratio -> 1400 gold payout)
const tick2 = CaravanEscortTradeEngine.advanceWaypoint(mission, { x: 20, y: 20 }, () => 0.99);
expect(tick2.isCompleted).toBe(true);
expect(tick2.rewardGoldAwarded).toBe(1400); // 2000 * 70%
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Quality: Deleted tests drop coverage for radius and ambush probability

This commit removed the two existing tests "calculates ambush probability scaled by cargo value" and "pauses progression when player is beyond escort protection radius", replacing them with damage/failure tests. As a result calculateAmbushProbability and the escort-radius enforcement branch (advanceWaypoint's dist > ESCORT_PROTECTION_RADIUS path) are no longer exercised, even though the PR summary lists both as key features. Re-add coverage for the probability scaling/clamping and the radius-exceeded case alongside the new ambush tests.

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 1 resolved / 2 findings

Implements an overland trade caravan escort and dynamic ambush engine with updated damage and mission failure logic. Re-add coverage for the probability scaling/clamping and the radius-exceeded case as deleted tests dropped coverage for radius and ambush probability.

💡 Quality: Deleted tests drop coverage for radius and ambush probability

📄 api/src/tests/caravanEscortTrade.test.ts:17-31

This commit removed the two existing tests "calculates ambush probability scaled by cargo value" and "pauses progression when player is beyond escort protection radius", replacing them with damage/failure tests. As a result calculateAmbushProbability and the escort-radius enforcement branch (advanceWaypoint's dist > ESCORT_PROTECTION_RADIUS path) are no longer exercised, even though the PR summary lists both as key features. Re-add coverage for the probability scaling/clamping and the radius-exceeded case alongside the new ambush tests.

✅ 1 resolved
Bug: Ambush trigger has no effect; cart HP and failure unused

📄 api/src/lib/caravanEscortTrade.ts:126-140
isAmbushTriggered is computed and returned but never applies any consequence: cartCurrentHp is never decremented, and isFailed is never set to true anywhere in the engine. As a result the health-scaled payout at line 136-137 always uses a 1.0 health ratio (full reward), and the advertised "cart integrity monitoring" / "delivery reward scaling" and mission-failure paths are dead. Apply ambush damage to state.cartCurrentHp when isAmbushTriggered is true, and set state.isFailed = true (returning early) when HP reaches 0.

🤖 Prompt for agents
Code Review: Implements an overland trade caravan escort and dynamic ambush engine with updated damage and mission failure logic. Re-add coverage for the probability scaling/clamping and the radius-exceeded case as deleted tests dropped coverage for radius and ambush probability.

1. 💡 Quality: Deleted tests drop coverage for radius and ambush probability
   Files: api/src/tests/caravanEscortTrade.test.ts:17-31

   This commit removed the two existing tests "calculates ambush probability scaled by cargo value" and "pauses progression when player is beyond escort protection radius", replacing them with damage/failure tests. As a result `calculateAmbushProbability` and the escort-radius enforcement branch (advanceWaypoint's `dist > ESCORT_PROTECTION_RADIUS` path) are no longer exercised, even though the PR summary lists both as key features. Re-add coverage for the probability scaling/clamping and the radius-exceeded case alongside the new ambush tests.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Important

Your trial ends in 5 days — upgrade now to keep code review, CI analysis, auto-apply, custom automations, and more.

Was this helpful? React with 👍 / 👎 | Gitar

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