Skip to content

Commit

Permalink
Merge pull request #10617 from DestinyItemManager/activity-rewards
Browse files Browse the repository at this point in the history
Better detection of which activity is active in milestones
  • Loading branch information
bhollis authored Jun 28, 2024
2 parents dfaee66 + a9a6d8f commit d9089a1
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions src/app/progress/milestone-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ function availableQuestToItem(
objectives,
store,
);
if (dimItem.pursuit === null) {
throw new Error(''); // can't happen
}

dimItem.secondaryIcon = challengeItem?.secondaryIcon;

dimItem.pursuit = {
expiration: milestoneExpiration(milestone),
modifierHashes: availableQuest?.activity?.modifierHashes || [],
rewards: [],
};
dimItem.pursuit.modifierHashes = availableQuest?.activity?.modifierHashes || [];

if (questRewards?.length) {
dimItem.pursuit.rewards = questRewards.map((r) => ({
Expand All @@ -149,8 +147,6 @@ function availableQuestToItem(
hasConditionalVisibility: false,
}));
}
} else if (milestone.rewards) {
dimItem.pursuit.rewards = processRewards(milestone.rewards, milestoneDef);
}

return dimItem;
Expand All @@ -163,13 +159,16 @@ function activityMilestoneToItem(
defs: D2ManifestDefinitions,
store: DimStore,
): DimItem | null {
const activity = milestone.activities[0];
const activityDef = defs.Activity.get(activity.activityHash);
const objectives = activity.challenges.map((a) => a.objective);
if (objectives.every((objective) => objective.complete)) {
// Find the first activity that hasn't been completed. TODO: Can we show all of them?
const activity = milestone.activities.find((a) =>
a.challenges.some((c) => !c.objective.complete),
);
// Ignore the milestone if all activities are complete or there are no challenges.
if (!activity) {
return null;
}

const activityDef = activity && defs.Activity.get(activity.activityHash);
const objectives = activity.challenges.map((a) => a.objective);
const dimItem = makeMilestonePursuitItem(
buckets,
milestone,
Expand All @@ -178,18 +177,17 @@ function activityMilestoneToItem(
objectives,
store,
);

dimItem.pursuit = {
expiration: milestoneExpiration(milestone),
modifierHashes: activity.modifierHashes || [],
rewards: [],
};
if (milestone.rewards) {
dimItem.pursuit.rewards = processRewards(milestone.rewards, milestoneDef);
if (dimItem.pursuit === null) {
throw new Error(''); // can't happen
}

dimItem.pursuit.modifierHashes = activity.modifierHashes || [];

if (activityDef) {
if (!milestone.rewards) {
dimItem.pursuit.rewards = activityDef.challenges.flatMap((c) => c.dummyRewards);
dimItem.pursuit.rewards = activityDef.challenges
.filter((c) => objectives.some((o) => o.objectiveHash === c.objectiveHash))
.flatMap((c) => c.dummyRewards);
}
if (milestoneDef.hash === 2029743966 /* Nightfall Weekly Score Challenge */) {
dimItem.name = `${dimItem.name}: ${activityDef.displayProperties.description}`;
Expand Down

0 comments on commit d9089a1

Please sign in to comment.