Skip to content

feat: add daily streak growth multiplier (#260) - #342

Open
justinjeong5 wants to merge 2 commits into
chattymin:mainfrom
justinjeong5:feat/daily-streak-multiplier
Open

justinjeong5 wants to merge 2 commits into
chattymin:mainfrom
justinjeong5:feat/daily-streak-multiplier

Conversation

@justinjeong5

@justinjeong5 justinjeong5 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements Point 1 of #260 by introducing a Daily Streak Multiplier that rewards consistent daily coding with accelerated Pokémon incubation and evolution growth.

Key features:

  1. Streak tracking & morning tolerance:
    • Tracks consecutive days with usage reaching the daily threshold (10M tokens by default, configurable) in CompanionState.streak (StreakState).
    • Morning tolerance: If the user hit their threshold yesterday, yesterday's streak remains active today until midnight, giving users their active streak multiplier during morning sessions before the first token is burned.
    • Timezone travel safety: Moving west to a timezone where local calendar date is earlier does not regress or wipe out streak records.
    • Streak automatically resets to 0 if a full calendar day is missed without active usage.
    • On initial launch with an existing installation, bootstraps streak from the current month's monthDailyTotals history.
  2. Tiered growth multiplier:
    • 3 consecutive days: 1.10× (+10% speed)
    • 7 consecutive days: 1.25× (+25% speed)
    • 14 consecutive days: 1.35× (+35% speed)
    • 30+ consecutive days: 1.50× (+50% speed)
    • Egg hatch thresholds and evolution stage thresholds scale with growthDifficulty / streakMultiplier (decoupled from difficulty clamping so even lowest 0.1 difficulty receives the full bonus), compounding multiplicatively with existing repeat growth boost (2.0×).
  3. UI & Localization:
    • Displays a compact flame badge (🔥 1d, 🔥 7d (1.25×)) in CompanionHeader next to the stage & nature row for active companions and next to incubation status for eggs.
    • Rich hover tooltip explaining consecutive active days and active boost percentage.
    • Consistent 2-decimal formatting (1.10×, 1.25×, 1.35×, 1.50×).
    • Fully localized across all 7 supported languages (en, ko, ja, es, fr, pt, de).
  4. Performance & state safety:
    • Only computes monthDailyTotals on initial bootstrap, skipping heavy snapshot transformations during normal 10-second refresh ticks.
    • CompanionState.streak is classified under progress transfer and preserved across Mac backups.
    • Clamped within valid bounds [0, 3650] during import sanitization.

Type of change

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

UI changes

Before After
Companion header showed stage/nature text and repeat growth boost capsule without streak info. Companion header displays a streak badge (e.g. 🔥 1d or 🔥 7d (1.25×)) next to the stage & nature row when active (≥ 1 day, with growth boost kicking in at 3 days). Hovering displays a detailed tooltip with current boost percentage. Incubating eggs also display the active streak badge.

Checklist

  • swift build and swift test pass locally
  • 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

🤖 Generated with Antigravity 2.0 (AGY 2.0)

- Track consecutive active days in CompanionState.streak (StreakState)
- Multiplier tiers: 3d (1.10x), 7d (1.25x), 14d (1.35x), 30d (1.50x)
- Apply morning tolerance so yesterday's streak is active today before first token
- Scale egg hatch and stage thresholds by growthDifficulty / streakMultiplier
- Multiplicatively compose with repeat boost (2x) and difficulty settings
- Bootstrap streak on first launch from monthDailyTotals
- Preserve and sanitize streak state during SaveTransfer
- Display header flame badge with localized tooltips across 7 languages
- Add comprehensive unit tests in StreakMultiplierTests (1169 total tests pass)
…nd optimize tick updates (chattymin#260)

- Decouple difficulty clamping from streak multiplier so lowest difficulty (0.1) receives full streak acceleration
- Guard against west-bound timezone travel (todayDate <= lastDay) in effectiveDays and recordActiveDay
- Only compute monthDailyTotals in updateCompanion when needsStreakBootstrap is true
- Immediately persist CompanionState when active day advances streak
- Early return 0 for identical dates in dayDifference without DateFormatter allocations
- Unify streak multiplier formatting to consistent 2 decimals (1.10x, 1.25x, 1.35x, 1.50x)
- Polish Korean, Japanese, and German localized streak tooltips
- Add lineLimit(1) and tail truncation to stage text in CompanionHeader
- Add 5 new test cases in StreakMultiplierTests covering extreme difficulties, timezone travel, multi-provider updates, threshold clamping, and formatting (1174 tests pass)

This branch has not been deployed

No deployments
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