Skip to content

Add option to count stackable plants as a single plant#285

Merged
tastybento merged 1 commit into
masterfrom
feat/53-stackable-plants
Jul 10, 2026
Merged

Add option to count stackable plants as a single plant#285
tastybento merged 1 commit into
masterfrom
feat/53-stackable-plants

Conversation

@tastybento

Copy link
Copy Markdown
Member

Fixes #53.

Adds the config option Poslovitch suggested on the ticket:

# Count stackable plants (SUGAR_CANE, BAMBOO) as a single plant no matter how tall
# they grow. When false (default), every segment of the plant counts toward the limit.
stacked-plants-count-as-one: false

How it works

One rule, applied in three places: a stackable segment sitting on the same plant is invisible to counting — only the base segment represents the plant.

  • process() (all place/grow/spread paths funnel through it): segments above the same plant are skipped for counting, limit checks, and decrements.
  • handleBreak(): the existing stem-cascade decrement is disabled when the option is on, since stems were never counted. Breaking a middle stem leaves the plant counted (the base still stands); breaking the base decrements the one counted plant.
  • RecountCalculator: the column scan skips a stackable whose block below normalised to the same plant, so recounts agree with live counts.

BAMBOO_SAPLING normalises to BAMBOO (existing variant map), so a stem above a sapling reads as the same plant. Default off preserves today's per-segment behaviour exactly — the config comment tells admins to run a recount after flipping the option.

Tests

Segment-not-counted, base-counted, and break-decrements-exactly-one cases, plus config parsing; the pre-existing cascade test pins the default-off behaviour. Full suite green.

In-game test plan

  1. Enable the option, set SUGAR_CANE: 5, restart.
  2. Plant 5 canes → 6th blocked. Let them grow to full height → /is limits still 5/5.
  3. Break a middle segment of one cane → still 5/5 (plant remains). Break a base → 4/5.
  4. /is limits recount at any point → number unchanged.
  5. Repeat 2–4 with bamboo (including placing bamboo items on existing stalks — should not change the count).

🤖 Generated with Claude Code

https://claude.ai/code/session_015dbJyrv2uxHfTmiWkqGUJB

New config option stacked-plants-count-as-one (default false, current
behaviour). When enabled, a column of SUGAR_CANE or BAMBOO counts as one
plant toward the limit no matter how tall it grows: segments sitting on
the same plant are not counted at placement or growth, the break cascade
does not decrement stems, and the recount applies the same rule so live
counts and recounts agree. BAMBOO_SAPLING normalises to BAMBOO so a stem
above a sapling still reads as the same plant.

Fixes #53

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015dbJyrv2uxHfTmiWkqGUJB
@tastybento tastybento force-pushed the feat/53-stackable-plants branch from 89607bb to 06ee8eb Compare July 10, 2026 20:30
@sonarqubecloud

Copy link
Copy Markdown

@tastybento tastybento merged commit 7255a2f into master Jul 10, 2026
3 checks passed
@tastybento tastybento deleted the feat/53-stackable-plants branch July 10, 2026 20:32
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