message: Well-Rested: handle edge cases around gaining first 4 prestige levels
diff: @@ -27,6 +27,7 @@ export function isWellRested(
  };
  }
  + const WELL_RESTED_LEVELS = 5;
  const seasonPassProgressionHash = seasonPass?.rewardProgressionHash;
  const prestigeProgressionHash = seasonPass?.prestigeProgressionHash;
  @@ -36,27 +37,30 @@ export function isWellRested(
  };
  }
  - const prestigeMode =
  - characterProgression.progressions[seasonPassProgressionHash].level ===
  - characterProgression.progressions[seasonPassProgressionHash].levelCap;
  + const seasonProgress = characterProgression.progressions[seasonPassProgressionHash];
  + const prestigeProgress = characterProgression.progressions[prestigeProgressionHash];
  - const seasonProgress =
  - characterProgression.progressions[
  - prestigeMode ? prestigeProgressionHash : seasonPassProgressionHash
  - ];
  + const prestigeMode = seasonProgress.level === seasonProgress.levelCap;
  - const seasonProgressDef = defs.Progression.get(
  - prestigeMode ? prestigeProgressionHash : seasonPassProgressionHash
  - );
  + const seasonProgressDef = defs.Progression.get(seasonPassProgressionHash);
  + const prestigeProgressDef = defs.Progression.get(prestigeProgressionHash);
  - const progress = seasonProgress.weeklyProgress;
  - const requiredXP = prestigeMode
  - ? xpRequiredForLevel(0, seasonProgressDef) * 5
  - : xpRequiredForLevel(seasonProgress.level, seasonProgressDef) +
  - xpRequiredForLevel(seasonProgress.level - 1, seasonProgressDef) +
  - xpRequiredForLevel(seasonProgress.level - 2, seasonProgressDef) +
  - xpRequiredForLevel(seasonProgress.level - 3, seasonProgressDef) +
  - xpRequiredForLevel(seasonProgress.level - 4, seasonProgressDef);
  + if (seasonProgressDef.steps.length === seasonProgress.levelCap) {
  + for (let i = 0; i < WELL_RESTED_LEVELS; i++) {
  + seasonProgressDef.steps.push(prestigeProgressDef.steps[0]);
  + }
  + }
  +
  + const totalLevel = prestigeMode
  + ? seasonProgress.level + prestigeProgress.level
  + : seasonProgress.level;
  +
  + const progress = prestigeMode ? prestigeProgress.weeklyProgress : seasonProgress.weeklyProgress;
  +
  + const requiredXP =
  + prestigeMode && prestigeProgress.level >= WELL_RESTED_LEVELS
  + ? xpRequiredForLevel(0, prestigeProgressDef) * WELL_RESTED_LEVELS
  + : xpTotalRequiredForLevel(totalLevel, seasonProgressDef, WELL_RESTED_LEVELS);
  // Have you gained XP equal to three full levels worth of XP?
  return {
  @@ -73,3 +77,11 @@ function xpRequiredForLevel(level: number, progressDef: DestinyProgressionDefini
  const stepIndex = Math.min(Math.max(1, level), progressDef.steps.length - 1);
  return progressDef.steps[stepIndex].progressTotal;
  }
  +
  +function xpTotalRequiredForLevel(totalLevel, seasonProgressDef, WELL_RESTED_LEVELS) {
  + let totalXP = 0;
  + for (let i = 0; i < WELL_RESTED_LEVELS; i++) {
  + totalXP += xpRequiredForLevel(totalLevel - i, seasonProgressDef);
  + }
  + return totalXP;
  +}
  