Skip to content

Add optional purchase confirmation before buying a generator (#109) - #157

Merged
tastybento merged 1 commit into
developfrom
109-purchase-confirmation
Jul 4, 2026
Merged

Add optional purchase confirmation before buying a generator (#109)#157
tastybento merged 1 commit into
developfrom
109-purchase-confirmation

Conversation

@tastybento

Copy link
Copy Markdown
Member

Closes #109

Problem

Players reported buying generators unwittingly — a single click on the BUY action purchases immediately.

Change

Adds a buy-confirmation config option (default true). When enabled, buying a generator asks the player to confirm in chat before any money is taken.

The three BUY click handlers (GeneratorUserPanel ×1, GeneratorViewPanel ×2) previously duplicated the same purchase logic. They now delegate to a shared CommonPanel.purchaseGenerator(island, data, tier) helper, which:

  • refreshes the panel and returns if the generator can't be purchased (the reason is already messaged by canPurchaseGenerator),
  • purchases directly when confirmation is disabled,
  • otherwise requests a chat confirmation via the existing ConversationUtils.createConfirmation and only purchases on confirm.

The chat-confirmation approach matches how this addon already confirms other actions (e.g. library data replacement).

Added

  • Settings.buyConfirmation (buy-confirmation, default true) + getter/setter.
  • stone-generator.conversations.confirm-generator-purchase locale string (en-US).
  • CommonPanel.purchaseGenerator shared helper.

Tests

CommonPanelPurchaseTest:

  • setting defaults to true,
  • can't-purchase → no buy, panel rebuilt,
  • confirmation disabled → buys directly, no conversation,
  • confirmation enabled → buys only after confirm; decline → no buy.

Full suite: 66 tests pass.

Note: uses a chat confirmation (consistent with existing confirmations). If a yes/no button GUI is preferred instead, that's a straightforward follow-up.

🤖 Generated with Claude Code

Players could accidentally buy a generator with a single click. Add a
buy-confirmation config option (default true) that asks the player to
confirm in chat before the purchase is made.

The three BUY click handlers in the player panels now delegate to a new
shared CommonPanel.purchaseGenerator helper, which:
- refreshes the panel and bails out if the generator cannot be purchased
  (the reason is already messaged by canPurchaseGenerator),
- purchases directly when confirmation is disabled,
- otherwise requests a chat confirmation and only purchases on confirm.

Adds the buy-confirmation setting, a confirm-generator-purchase locale
string, and tests for the helper and the setting default.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01D7NWPeGXmsUJnnX42X24Rd
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

@tastybento
tastybento merged commit 6dfc8ae into develop Jul 4, 2026
4 checks passed
@tastybento
tastybento deleted the 109-purchase-confirmation branch July 4, 2026 18:21
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.

validation of purchase

1 participant