-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add super subclass plugs. #627
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
144959979, | ||
180411040, | ||
902963970, | ||
1080622901, | ||
1684765285, | ||
1774026300, | ||
1861253111, | ||
2285394316, | ||
2613010961, | ||
2850085618, | ||
2997411645, | ||
3151809860, | ||
3468785159, | ||
4141244538, | ||
4145425829 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Collect all the subclass super plug plugCategoryHashes. | ||
*/ | ||
import { getAllDefs, getDef } from '@d2api/manifest-node'; | ||
import { uniqAndSortArray, writeFile } from './helpers.js'; | ||
import { infoLog, infoTable } from './log.js'; | ||
|
||
const TAG = 'SUBCLASS-PLUG'; | ||
const DEBUG = false; | ||
|
||
const getItem = (hash: number) => getDef('InventoryItem', hash); | ||
const getPlugSet = (hash: number) => getDef('PlugSet', hash); | ||
|
||
const allItems = getAllDefs('InventoryItem'); | ||
|
||
const classBucketHash = 3284755031; | ||
|
||
const superSocketCategoryHash = 457473665; | ||
|
||
function findAllSubclassSuperPlugs() { | ||
const plugTracker: Record<string, number> = {}; | ||
|
||
for (const item of allItems) { | ||
if (item.inventory?.bucketTypeHash === classBucketHash && item.sockets) { | ||
const indexes: number[] = []; | ||
|
||
// get all the socket indexes that have the right category hash | ||
for (const socketCategory of item.sockets.socketCategories) { | ||
if (socketCategory.socketCategoryHash === superSocketCategoryHash) { | ||
for (const index of socketCategory.socketIndexes) { | ||
indexes.push(index); | ||
} | ||
} | ||
} | ||
|
||
for (const socketIndex of indexes) { | ||
const socket = item.sockets.socketEntries[socketIndex]; | ||
const plugSet = socket.reusablePlugSetHash | ||
? getPlugSet(socket.reusablePlugSetHash) | ||
: undefined; | ||
const plugItems = | ||
plugSet?.reusablePlugItems.map(({ plugItemHash }) => getItem(plugItemHash)) || []; | ||
for (const plugItem of plugItems) { | ||
const plugCategoryHash = plugItem?.plug?.plugCategoryHash; | ||
if (plugCategoryHash) { | ||
plugTracker[ | ||
`${plugItem.plug.plugCategoryIdentifier} - ${plugItem.displayProperties.name}` | ||
] = plugCategoryHash; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Log this to make debugging easier | ||
if (DEBUG) { | ||
infoLog(TAG, 'Subclass super plugs found'); | ||
infoTable(plugTracker); | ||
} | ||
return Array.from(new Set(Object.values(plugTracker))); | ||
} | ||
|
||
const subclassPlugs = uniqAndSortArray(findAllSubclassSuperPlugs()); | ||
|
||
writeFile('./output/subclass-super-plug-category-hashes.json', subclassPlugs); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README.md documents these output files in a table, wouldn't hurt to add this one too.