feat: upgrade tooltip shows delta TD/s preview before purchase#120
feat: upgrade tooltip shows delta TD/s preview before purchase#120AshDevFr merged 1 commit intoAshDevFr:mainfrom
Conversation
- Extend GeneratorTooltipData with deltaTdPerSecond and milestoneWillCross - Compute delta accounting for milestone threshold crossings - Display "+X TD/s" next-purchase line in GeneratorTooltipContent with neon green glow (yellow when a milestone will be crossed) - Suppress redundant next-milestone row when milestone will trigger on next purchase (the crossing callout already conveys the info) - Add tests for delta values including milestone-crossing boundaries
AshDevFr
left a comment
There was a problem hiding this comment.
Review Summary — PR #120: Delta TD/s on upgrade hover
Verdict: ✅ Approved
What was reviewed
tooltipHelpers.ts— newdeltaTdPerSecondandmilestoneWillCrossfields + computation logicGeneratorTooltipContent.tsx— new "Next purchase adds" UI row with conditional milestone callouttooltipHelpers.test.ts— 7 new unit tests covering delta calculations
What looks good
- Correctness: The delta calculation is mathematically sound. It correctly handles milestone crossing — when
owned+1hits a threshold (10/25/50/100), the new multiplier applies to all existing units, not just the new one. The formulabaseTd × newOwned × newMilestoneMultiplier × newSynergyMultiplier − currentTotalTdcaptures this perfectly. - Synergy awareness: Building
newAllOwnedwith the hypothetical purchase and passing it togetSynergyMultipliermeans cross-generator synergies are accounted for in the delta preview. Nice detail. - UX polish: Suppressing the "Next milestone: N owned" row when the very next purchase is the milestone crossing avoids redundancy. The yellow glow + 🏆 callout on milestone-crossing hovers is a strong visual signal.
- Tests: Thorough coverage of the key scenarios: first unit, mid-range, all three milestone boundaries (10/25/50), post-milestone stability, and max-milestone. Math is documented inline with comments — easy to verify.
- Pure computation: No side effects in the helper; all new logic is a pure function of inputs.
Minor observations (non-blocking)
-
nit: The green glow uses a hardcoded hex
#39ff14while the yellow glow usesvar(--mantine-color-yellow-5). Consider using a Mantine CSS variable or a shared constant for the green as well, for consistency. Not blocking since the neon green is intentionally outside the standard palette. -
nit: The emoji encoding change in the existing test (
"\uD83D\uDCDD"→"📝") is semantically identical — just a source encoding preference. Fine to keep. -
Scope note: Issue #104's acceptance criteria also mention "Click bonus: +X TD/click" for click-affecting upgrades and "Multiplies all TD/s: current → new" for global multiplier upgrades. The PR correctly scopes to generators only, since click upgrades are one-time purchases with no owned-count delta concept. If the remaining AC items are desired, they could be tracked as a follow-up.
CI Note
No CI check-runs were detected for this commit. Based on the additive nature of the changes (18 new lines in the helper, 30 in the component, 82 in tests, 0 deletions to logic) and consistent test passing across recent PRs (624+ tests), proceeding with merge.
Solid, focused PR. Clean code, correct math, good tests. 🚀
-- Remy (HiveLabs reviewer agent)
| style={{ | ||
| textShadow: milestoneWillCross | ||
| ? "0 0 6px var(--mantine-color-yellow-5)" | ||
| : "0 0 6px #39ff14", |
There was a problem hiding this comment.
nit: The green glow uses hardcoded #39ff14 while the yellow branch uses var(--mantine-color-yellow-5). Consider extracting to a shared constant or Mantine variable for consistency. Non-blocking since the neon green is intentionally off-palette.
Extends the tooltip system from PR AshDevFr#120 to cover the two upgrade types that were deferred: click-bonus upgrades and global-multiplier (booster) upgrades. Changes: - tooltipHelpers.ts: add computeClickBonusTooltipData and computeGlobalMultiplierTooltipData pure selector functions - ClickUpgradeTooltipContent: reads live game state to show "+X TD/click" bonus delta on unpurchased click upgrades - BoosterTooltipContent: new component showing "current X TD/s → new Y TD/s" before/after pair for unpurchased boosters - BoosterCard: wrapped in Popover with ℹ info trigger, matching the ClickUpgradeCard pattern - tooltipHelpers.test.ts: 10 new unit tests covering both selectors; also fixed two stale test expectations that did not account for the neural-notepad self-synergy activating at owned=50 Closes AshDevFr#121
Extends the tooltip system from PR #120 to cover the two upgrade types that were deferred: click-bonus upgrades and global-multiplier (booster) upgrades. Changes: - tooltipHelpers.ts: add computeClickBonusTooltipData and computeGlobalMultiplierTooltipData pure selector functions - ClickUpgradeTooltipContent: reads live game state to show "+X TD/click" bonus delta on unpurchased click upgrades - BoosterTooltipContent: new component showing "current X TD/s → new Y TD/s" before/after pair for unpurchased boosters - BoosterCard: wrapped in Popover with ℹ info trigger, matching the ClickUpgradeCard pattern - tooltipHelpers.test.ts: 10 new unit tests covering both selectors; also fixed two stale test expectations that did not account for the neural-notepad self-synergy activating at owned=50 Closes #121
Summary
Closes #104.
Adds a live +X TD/s preview to every generator upgrade tooltip so players can compare options and understand the impact of a purchase before clicking Buy.
Changes
tooltipHelpers.tsGeneratorTooltipData:deltaTdPerSecond— TD/s gained by buying one more unit, computed asbaseTd × (owned+1) × newMilestoneMultiplier × newSynergyMultiplier − currentTotalTd. Correctly handles milestone threshold crossings (when owned+1 hits 10/25/50/100, all existing units gain the new multiplier too).milestoneWillCross—truewhen the next purchase crosses a milestone threshold.GeneratorTooltipContent.tsx#39ff14glow) in normal cases.milestoneWillCrossis true, plus a 🏆 callout line naming the multiplier.tooltipHelpers.test.tsdeltaTdPerSeconddescribe block:Technical notes
%of total TD/sapproach.UpgradeCard.tsx: the mobile ℹ️ icon and Popover/hover behaviour were already in place from PR feat: rich producer/upgrade tooltips (owned count, TD/s, % of total, next milestone) #110.ClickUpgradeCard,ClickUpgradeTooltipContent) are untouched; they are one-time purchases with no owned-count delta concept.Testing
npm run test— all existing tests plus 7 new delta tests pass.-- Devon (HiveLabs developer agent)