Skip to content

Commit

Permalink
Merge pull request #10713 from FlaminSarge/enhancement-tier
Browse files Browse the repository at this point in the history
Add enhancementTier to craftedInfo and display it in weapon level bar
  • Loading branch information
FlaminSarge authored Sep 3, 2024
2 parents c1eaa4d + 78e37a3 commit 58fc02e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@
"Consolidate": "Consolidate",
"CommunityData": "Community Insight",
"DistributeEvenly": "Distribute Evenly",
"EnhancementTier": "Tier {{tier}}",
"Equip": "Equip on:",
"EquipWithName": "Equip on {{character}}",
"FavoriteUnFavorite": {
Expand Down
2 changes: 2 additions & 0 deletions src/app/inventory/item-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ export interface DimCrafted {
progress: number;
/** when this weapon was crafted, UTC epoch seconds timestamp */
craftedDate: number;
/** the enhancement tier for this weapon, if enhanced. 0 otherwise. */
enhancementTier: number;
}

export interface DimCatalyst {
Expand Down
29 changes: 26 additions & 3 deletions src/app/inventory/store/crafted.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { D2ManifestDefinitions } from 'app/destiny2/d2-definitions';
import { warnLog } from 'app/utils/log';
import { getFirstSocketByCategoryHash } from 'app/utils/socket-utils';
import { HashLookup } from 'app/utils/util-types';
import { DestinyObjectiveProgress, DestinyObjectiveUiStyle } from 'bungie-api-ts/destiny2';
import { DimCrafted, DimItem, DimSocket } from '../item-types';

Expand All @@ -10,6 +11,14 @@ export const craftedSocketCategoryHash = 3583996951;
/** the socket category containing the Mementos */
export const mementoSocketCategoryHash = 3201856887;

/** the socket containing the enhancement tier plugs */
export const enhancementSocketHash = 4251072212;
export const plugHashToEnhancementTier: HashLookup<number> = {
2728416798: 1,
2728416797: 2,
2728416796: 3,
};

export function buildCraftedInfo(
item: DimItem,
defs: D2ManifestDefinitions,
Expand All @@ -23,8 +32,12 @@ export function buildCraftedInfo(
if (!objectives) {
return undefined;
}

return getCraftingInfo(defs, objectives);
const craftingInfo = getCraftingInfo(defs, objectives);
if (!craftingInfo) {
return undefined;
}
craftingInfo.enhancementTier = getEnhancementTier(item);
return craftingInfo;
}

/** find the item socket that could contain the "this weapon was crafted" plug with its objectives */
Expand All @@ -34,6 +47,16 @@ export function getCraftedSocket(item: DimItem): DimSocket | undefined {
}
}

export function getEnhancementTier(item: DimItem): number {
if (item.bucket.inWeapons && item.sockets) {
const plugHash = item.sockets.allSockets.find(
(s) => s.socketDefinition.socketTypeHash === enhancementSocketHash,
)?.plugged?.plugDef.hash;
return (plugHash && plugHashToEnhancementTier[plugHash]) || 0;
}
return 0;
}

function getCraftingInfo(
defs: D2ManifestDefinitions,
objectives: DestinyObjectiveProgress[],
Expand Down Expand Up @@ -64,5 +87,5 @@ function getCraftingInfo(
return undefined;
}

return { level, progress, craftedDate };
return { level, progress, craftedDate, enhancementTier: 0 };
}
2 changes: 2 additions & 0 deletions src/app/item-popup/WeaponCraftedInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export function WeaponCraftedInfo({ item, className }: { item: DimItem; classNam
<div className="objective-progress">
<div className="objective-progress-bar" style={progressBarStyle} />
<div className="objective-description">
{item.craftedInfo?.enhancementTier > 0 &&
`${t('MovePopup.EnhancementTier', { tier: item.craftedInfo?.enhancementTier })} - `}
{t('MovePopup.WeaponLevel', { level: item.craftedInfo.level })}
</div>
<div className="objective-text">{percentWithSingleDecimal(progress)}</div>
Expand Down

0 comments on commit 58fc02e

Please sign in to comment.