Skip to content

Slow prosperity growth past 80 and add workshop trade upkeep - #45

Merged
Drefvelin merged 1 commit into
mainfrom
prosperity-soft-cap
Sep 25, 2026
Merged

Drefvelin merged 1 commit into
mainfrom
prosperity-soft-cap

Conversation

@Drefvelin

@Drefvelin Drefvelin commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two changes so the richest trade guilds level off instead of compounding forever. Collection stays 1:1: a guild still collects exactly its trade share of a province's prosperity.

  • Prosperity soft cap. Province.calculateProsperity now runs the final value through ProsperitySoftCap. Up to prosperity-soft-cap (80) nothing changes. Past it the excess grows with a square root (cap + 2S(√(1 + (p − cap)/S) − 1), S = prosperity-soft-cap-scale = 20). The curve is smooth at 80 and has no ceiling. Each extra point is worth half at 140 and a third at 240. Setting either value to 0 turns it off.
  • Workshop trade upkeep. Workshops add trade_upkeep 0 0.01 (1% per level). Guild halls (1%) and storehouses (2%) already did, so workshops were the one upkeep-free way to keep growing.

Why

In a simulation on the live Main data (trade flood, production and prosperity copied from this code), YevaKeepers and The_Chisels reinvesting everything (+600/day from grinding) grew net trade income from about 600 to over 3,000/day within 90 days. Their helper guilds could also pool workshops into the same provinces, pushing a single province past 570 prosperity.

Scenario (net/day, Yeva / Chisels) Day 30 Peak Top province, day 90
No change 1,824 / 1,721 still rising (3,154 at day 90) about 214
Workshop upkeep only 1,020 / 945 1,086 / 1,014 about 214
Upkeep, helpers pooling, no cap 1,433 / 1,217 1,524 / 1,252 about 574
Upkeep + cap, helpers pooling 1,190 / 1,046 1,233 / 1,060 about 230

Today the cap touches one province on Main (province 15: 81.78 → about 81.7). Workshop upkeep costs guilds with workshops about 1% of trade income per level; Yeva and Chisels lose about 12% on day one.

Deploy note

The plugin does not overwrite existing configs. On each server, add - trade_upkeep 0 0.01 under workshops.modifiers in plugins/SimpleFactions/Guilds/branches.yml. The two prosperity-soft-cap keys default to 80 and 20 when missing from config.yml.

Test plan

  • mvn package: all 2,068 tests pass, including the new ProsperitySoftCapTest (unchanged below the cap, smooth at the seam, half value at cap + 3S, no ceiling, 0 turns it off)
  • CI jar on TFMCDev: loads cleanly; with the cap at 80 all 806 provinces are unchanged (Dev tops out at 47); with a temporary cap at 30 the top provinces matched the curve exactly (47.21 → 44.56, 40.37 → 39.29) and everything below 30 was untouched. Temporary config reverted.

🤖 Generated with Claude Code

Province prosperity is unchanged up to prosperity-soft-cap (80). Past it
the excess grows with a square root, so each point is worth less (half at
140, a third at 240) without a hard ceiling. This stops guilds from
stacking production into the same provinces to run them far past 80.

Workshops now add 1% trade upkeep per level, like guild halls and
storehouses already do, so reinvesting in production levels off instead
of compounding forever.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d5f110d8-c012-404b-8991-b228e1c272ef

📥 Commits

Reviewing files that changed from the base of the PR and between 57cfc02 and 3919a75.

📒 Files selected for processing (7)
  • src/main/java/net/tfminecraft/simplefactions/Cache.java
  • src/main/java/net/tfminecraft/simplefactions/loaders/ConfigLoader.java
  • src/main/java/net/tfminecraft/simplefactions/map/provinces/ProsperitySoftCap.java
  • src/main/java/net/tfminecraft/simplefactions/map/provinces/Province.java
  • src/main/resources/Guilds/branches.yml
  • src/main/resources/config.yml
  • src/test/java/net/tfminecraft/simplefactions/map/provinces/ProsperitySoftCapTest.java

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change adds configurable diminishing growth to province prosperity and adds a trade_upkeep modifier to the workshops branch.

Changes

Prosperity Soft Cap

Layer / File(s) Summary
Configure the prosperity cap
src/main/java/net/tfminecraft/simplefactions/Cache.java, src/main/java/net/tfminecraft/simplefactions/loaders/ConfigLoader.java, src/main/resources/config.yml
Adds cap and scale settings with defaults of 80 and 20. The configuration comments describe the diminishing square-root growth and how to disable it.
Apply and test diminishing growth
src/main/java/net/tfminecraft/simplefactions/map/provinces/ProsperitySoftCap.java, src/main/java/net/tfminecraft/simplefactions/map/provinces/Province.java, src/test/java/net/tfminecraft/simplefactions/map/provinces/ProsperitySoftCapTest.java
Province prosperity calculation applies the soft cap before rounding. Tests cover values through and above the cap, continued growth, behavior near the cap, and disabled settings.

Workshop Trade Upkeep

Layer / File(s) Summary
Add workshop trade upkeep modifier
src/main/resources/Guilds/branches.yml
Adds a trade_upkeep modifier with values 0 and 0.01 to the workshops branch.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Suggested reviewers: ryanbarlow97

Merge Risk: ⚪ Minimal · up to 3919a

The change appears mergeable after normal checks. Existing server configurations still need the documented workshop modifier added manually.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 3919a

The change uses existing calculation and income paths, with no identified new security boundary bypass. An existing recalculation order could briefly leave displayed or saved income out of step with newly capped prosperity.

Retained concerns

  • Low · reliability · inferred: On a single-guild recalculation, saved income can reflect the previous prosperity while the province subsequently stores its newly soft-capped value. The reversed ordering is pre-existing, but introducing the cap creates a possible mismatch during the transition from an uncapped value; a later full recalculation would restore the normal ordering.
Security review details

Security Blast Radius

  • inferred — The economic effect can span guilds sharing affected provinces because the capped amount is stored per province and allocated to guilds by trade share. No new cross-service path is established by the supplied change evidence.

Trust Boundaries and Controls

  • observed — The changed public prosperity method transforms a computed numeric total; the inspected change does not add a caller or alter the existing trade-share and upkeep controls. Repository evidence does not establish who, if anyone, invokes that public method externally.

Resilience and Maintainability Implications

  • inferred — The pre-existing single-guild ordering is a control-drift risk for the new economic rule if it is the first recalculation after a cap change. The evidence does not establish an exploitable payout path or a failed recovery.

Hardening Proposals

  • proposed — Recompute prosperity before saving dependent income on the single-guild path, and establish a full recalculation step when changing or rolling back the cap settings.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes both primary changes: applying slower prosperity growth above 80 and adding workshop trade upkeep.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 5 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

I twitch my nose at curves that bend,
The cap lets growth slow, not end.
Configured scales guide the way,
Workshops trade upkeep joins the play.
I hop through tests, then rest in hay.

Comment @coderabbitai help to get the list of available commands.

@Drefvelin
Drefvelin merged commit e35a5da into main Sep 25, 2026
2 checks passed
@Drefvelin
Drefvelin deleted the prosperity-soft-cap branch September 25, 2026 23:54
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.

2 participants