|
1 | 1 | import { t } from 'app/i18next-t';
|
2 | 2 | import { statsMs } from 'app/inventory/store/stats';
|
3 | 3 | import { useD2Definitions } from 'app/manifest/selectors';
|
| 4 | +import { |
| 5 | + D2PlugCategoryByStatHash, |
| 6 | + weaponMasterworkY2SocketTypeHash, |
| 7 | +} from 'app/search/d2-known-values'; |
4 | 8 | import { useSetting } from 'app/settings/hooks';
|
5 | 9 | import { AppIcon, faGrid, faList } from 'app/shell/icons';
|
6 | 10 | import { isKillTrackerSocket } from 'app/utils/item-utils';
|
7 | 11 | import { getSocketsByIndexes, getWeaponSockets } from 'app/utils/socket-utils';
|
8 | 12 | import { LookupTable } from 'app/utils/util-types';
|
9 | 13 | import clsx from 'clsx';
|
10 | 14 | import { ItemCategoryHashes, StatHashes } from 'data/d2/generated-enums';
|
| 15 | +import { maxBy } from 'es-toolkit'; |
11 | 16 | import { useSelector } from 'react-redux';
|
12 | 17 | import { DimItem, DimSocket } from '../inventory/item-types';
|
13 | 18 | import { wishListSelector } from '../wishlists/selectors';
|
@@ -45,6 +50,40 @@ export default function ItemSocketsWeapons({
|
45 | 50 | // Improve this when we use iterator-helpers
|
46 | 51 | const mods = [...modSocketsByCategory.values()].flat();
|
47 | 52 |
|
| 53 | + if (item.crafted) { |
| 54 | + const y2MasterworkSocket = item.sockets?.allSockets.find( |
| 55 | + (socket) => socket.socketDefinition.socketTypeHash === weaponMasterworkY2SocketTypeHash, |
| 56 | + ); |
| 57 | + const plugSet = y2MasterworkSocket?.plugSet; |
| 58 | + if (y2MasterworkSocket && plugSet) { |
| 59 | + // const plug = y2MasterworkSocket?.plugSet?.plugs.find( |
| 60 | + // (p) => p.plugDef.plug.plugCategoryHash === PlugCategoryHashes.V400PlugsWeaponsMasterworks, |
| 61 | + // ); |
| 62 | + const mwHash = item.masterworkInfo?.stats?.find((s) => s.isPrimary)?.hash || 0; |
| 63 | + const newCategory = |
| 64 | + mwHash in D2PlugCategoryByStatHash |
| 65 | + ? D2PlugCategoryByStatHash[mwHash as keyof typeof D2PlugCategoryByStatHash] |
| 66 | + : null; |
| 67 | + let fullMasterworkPlug = newCategory |
| 68 | + ? maxBy( |
| 69 | + plugSet.plugs.filter((p) => p.plugDef.plug.plugCategoryHash === newCategory), |
| 70 | + (plugOption) => plugOption.plugDef.investmentStats[0]?.value, |
| 71 | + ) |
| 72 | + : null; |
| 73 | + if (fullMasterworkPlug) { |
| 74 | + fullMasterworkPlug = { |
| 75 | + ...fullMasterworkPlug, |
| 76 | + plugDef: { ...fullMasterworkPlug.plugDef, iconWatermark: '' }, |
| 77 | + }; |
| 78 | + y2MasterworkSocket.plugged = fullMasterworkPlug; |
| 79 | + y2MasterworkSocket.plugOptions = [fullMasterworkPlug]; |
| 80 | + y2MasterworkSocket.visibleInGame = true; |
| 81 | + y2MasterworkSocket.reusablePlugItems = []; |
| 82 | + y2MasterworkSocket.isPerk = true; |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + |
48 | 87 | const keyStats =
|
49 | 88 | item.stats &&
|
50 | 89 | !item.itemCategoryHashes.includes(ItemCategoryHashes.Sword) &&
|
|
0 commit comments