Skip to content

fix: protect legendary companions from accidental egg discard (#314) - #335

Open
justinjeong5 wants to merge 1 commit into
chattymin:mainfrom
justinjeong5:fix/egg-rarity-discard-confirm
Open

justinjeong5 wants to merge 1 commit into
chattymin:mainfrom
justinjeong5:fix/egg-rarity-discard-confirm

Conversation

@justinjeong5

Copy link
Copy Markdown
Contributor

Summary

Adds an extra confirmation step before discarding a Legendary or Shiny companion when purchasing an egg (regular, uncommon, or rare) in the Token Shop.

Previously, EggCard only triggered a second-stage warning (stage = .shinyConfirm) if store.currentIsShiny was true. Non-shiny Legendary companions (1/512 hatch odds) were discarded immediately on the first prompt without any safeguard, leading to accidental loss of rare companions (#314).

Key Decisions & Safeguards (Red-Team Validated)

  • High-Value Guard (isHighValueCompanion): Evaluated cleanly in CompanionStore as currentIsShiny || rarity == .legendary.
  • Ditto Disguise Invariant Preserved: While disguised as a common Pokémon, a Ditto returns store.currentIsShiny == false and store.rarity == .common, ensuring the disguise is never prematurely revealed through the egg purchase modal.
  • Avoid Alert Fatigue for Rerolls: Non-shiny .rare companions are intentionally excluded from the double-stage confirmation. High-tier players repeatedly buying Rare Eggs to hunt specific species/shinies are spared repetitive prompts, ensuring alerts remain meaningful for truly rare companions.
  • Minimal & Future-Proof: Generalized the UI stage to preciousConfirm with appropriate copy, adding only 2 localized strings across all 7 supported languages without enum proliferation.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • Other:

UI changes

Before After
When buying an egg while raising a non-shiny Legendary companion, clicking "Buy" on the confirmation prompt immediately discarded the companion and started incubating the new egg. Only shiny companions showed a secondary warning. When buying an egg while raising a Legendary or Shiny companion, confirming the initial prompt transitions to an orange secondary warning: "⚠️ This is a Legendary Pokémon! Really send it off?" with an orange prominent "Send off" button. Canceling safely returns to the idle state.

Checklist

  • swift build and swift test pass locally (1,171 tests passed, 0 failures, 13 skipped; logic-core line coverage 93.39% >= 75%)
  • PR title and description are written in English
  • UI changes are described above (before/after — images optional)
  • No copyrighted assets, secrets, or private tooling references are committed (see CONTRIBUTING)
  • Tests were added or updated for this change (PreciousCompanionGuardTests.swift covering legendary, shiny, rare exclusion, disguised Ditto secrecy, and 7-language localization)

🤖 Generated with Antigravity 2.0 (AGY 2.0)

…min#314)

Require an extra confirmation step before discarding a legendary or shiny companion when buying an egg in the token shop.

- CompanionStore: Add isHighValueCompanion (currentIsShiny || rarity == .legendary) keeping evaluation in the store and preserving Ditto disguise secrecy.
- ShopView: Generalize EggCard confirmation stage to preciousConfirm with appropriate legendary/shiny warning copy and discard buttons.
- Localization: Add freshEggLegendaryWarning and freshEggDiscardValuable across all 7 supported languages.
- Tests: Add PreciousCompanionGuardTests covering legendary, shiny, rare exclusion (avoiding reroll fatigue), disguised Ditto invariants, and 7-language copy.
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