You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(diplomacy): unequal treaty leader gets its trade bonus - #254
Reviewed: Fable 5.2 (medium) at c5fe44c. Round 1 found 1 major issue (a stale agreement half softened an embargo) and 1 minor, both fixed; round 2 APPROVE. 6a7d7ce only adds a null guard for a visiting faction without a diplomacy handler (minor, no saved data), so no re-review.
Second opinion: CodeRabbit, no actionable comments.
Dev-tested: PASS at 6a7d7ce. TheHolyOrder was set as unequal-treaty leader over House_Malestroit, and its guild Keepers of Yeva's trade power went from 2824.56 (old jar) to 2835.75. The +11.19 matches +20% of its 55.9 raw trade in Malestroit's provinces. No SimpleFactions errors in the log; the Dev faction data was restored afterwards.
Local tests: TradeRelationHalvesTest 6/6, ProvinceManagerHubTransportTest 19/19, RealmRelationsBoundaryCoverageTest 24/24. Full suite on CI (9339 tests, coverage) green at 6a7d7ce.
Why
The Diplomacy menu promises the stronger side of an Unequal Treaty +20% trade power and +7.5% production for its guilds in the weaker side's land. That bonus never applied.
A guild trading in another faction's province only got the province owner's record of their trade relation. The other side's "our guilds in their territory" bonus was added only when the owner's type was mutual. The leader's bonus sits on the mutual leader type, and the weaker side holds the non-mutual unequal_treaty_subject. So in the weaker side's land, the leader's guilds got nothing, while the weaker side's +5% / +2.5% in the leader's land worked. The repo default diplomacy.yml has the same setup as Main.
What changed
DiplomacyHandler.getTradeModifiersFor reads both halves when the two records are the two halves of one relation: the owner's trade-effects-them plus the visitor's own trade-effects-us towards the owner. That is what the menu shows.
Unpaired records keep exactly the old owner-only reading. An embargo set over the other side's old agreement leaves that side's half behind, and counting it would soften the embargo.
Province.getModifiersForGuild checks both factions' records and passes the faction in hand, so there is no extra lookup by id in the province loop.
Income previews follow automatically, because both lookups go through getTradeRelation, which the preview overlays.
Owner record / visitor record
Before
After
Trade agreement / trade agreement
+15 / +5
+15 / +5
Unequal leader / unequal subject (weaker side visiting)
A guild trading in another faction's province only got the owner's record
of their trade relation ("their guilds in our territory"), plus the other
side's "our guilds" bonus only when the owner's type was mutual. The
leader's half of an unequal treaty is held on the mutual side, so the
leader's +20% trade power / +7.5% production never applied in the weaker
side's land, while the menu promised it.
Visiting guilds now get the owner's trade-effects-them plus their own
faction's trade-effects-us towards the owner. Trade agreements and
embargoes give the same results as before; income previews follow
because both lookups go through getTradeRelation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion
An embargo set over the other side's agreement leaves that side's old
half in place; adding it softened the embargo. Unpaired records keep the
owner-only reading, so only a matching pair (mutual type and its link)
reads both halves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This repository does not receive automatic reviews because it has fewer than 10 stars.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: c94a7512-802c-475c-8219-21c3058020bf
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Trade modifiers now reflect both sides of a faction’s trade relation, including mutual agreements and unequal treaties.
Province modifiers now account for trade relations recorded by either the province owner or the visiting faction.
DiplomacyHandler now calculates trade modifiers using relation records from both factions. Province modifier lookup checks for a trade relation on either side and passes the visiting Guild to the modifier calculation. Tests cover treaty, agreement, embargo, and empty-result cases.
Changes: Trade modifier resolution
Layer / File(s)
Summary
Resolve and apply trade modifiers src/main/java/net/tfminecraft/simplefactions/diplomacy/DiplomacyHandler.java, src/main/java/net/tfminecraft/simplefactions/map/provinces/Province.java, src/test/java/net/tfminecraft/simplefactions/diplomacy/TradeRelationHalvesTest.java
DiplomacyHandler resolves effects from linked relation records and adds an overload that accepts a Faction. Province.getModifiersForGuild checks for a relation in either direction and passes the visiting Guild. Tests cover unequal treaties, mutual agreements, embargoes, and empty results.
This change gives the unequal-treaty leader its trade bonus in the weaker side's land and leaves agreements and embargoes unchanged. No concrete merge-blocking problem was found. Normal CI and dev checks should complete before merging.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
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
size:M30-99 effective changed lines (tests excluded in mixed PRs).
1 participant
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.
Status record
Why
The Diplomacy menu promises the stronger side of an Unequal Treaty +20% trade power and +7.5% production for its guilds in the weaker side's land. That bonus never applied.
A guild trading in another faction's province only got the province owner's record of their trade relation. The other side's "our guilds in their territory" bonus was added only when the owner's type was
mutual. The leader's bonus sits on the mutual leader type, and the weaker side holds the non-mutualunequal_treaty_subject. So in the weaker side's land, the leader's guilds got nothing, while the weaker side's +5% / +2.5% in the leader's land worked. The repo defaultdiplomacy.ymlhas the same setup as Main.What changed
DiplomacyHandler.getTradeModifiersForreads both halves when the two records are the two halves of one relation: the owner'strade-effects-themplus the visitor's owntrade-effects-ustowards the owner. That is what the menu shows.Province.getModifiersForGuildchecks both factions' records and passes the faction in hand, so there is no extra lookup by id in the province loop.getTradeRelation, which the preview overlays.No unequal treaties exist on Main today, so no live faction's income changes at release.
🤖 Generated with Claude Code