-
Notifications
You must be signed in to change notification settings - Fork 51
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
Implement programmatic ActionID level filtering for pickers #8
Conversation
ui/core/player.ts
Outdated
getMatchingSpellActionId(src: number[][]): ActionId | null { | ||
const match = src.find(([_, minLevel, maxLevel]) => | ||
(!minLevel || minLevel <= this.getLevel()) && | ||
(!maxLevel || maxLevel >= this.getLevel()) | ||
) | ||
|
||
console.log(this.getLevel(), match) | ||
|
||
if (match) return ActionId.fromSpellId(match[0]) | ||
return null | ||
} | ||
|
||
// Filter a matrix of item IDs, min and max levels for a matching item ID | ||
getMatchingItemActionId(src: number[][]): ActionId | null { | ||
const match = src.find(([_, minLevel, maxLevel]) => | ||
(!minLevel || minLevel <= this.getLevel()) && | ||
(!maxLevel || maxLevel >= this.getLevel()) | ||
) | ||
|
||
console.log(this.getLevel(), match) | ||
|
||
if (match) return ActionId.fromItemId(match[0]) | ||
return null | ||
} |
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.
These functions take in a matrix of up to 3-length arrays representing the item ID, a minimum level to display the buff, and a maximum level to display the buff (if applicable) and finds the correct entry corresponding to the player's current level and returns the ActionID from that entry.
actionId: (player) => player.getMatchingSpellActionId([ | ||
[1126, 1, 9], | ||
[5232, 10, 19], | ||
[6756, 20, 29], | ||
[5234, 30, 39], | ||
[8907, 40, 49], | ||
[9884, 50, 59], | ||
[9885, 60] | ||
]), impId: ActionId.fromSpellId(17055), fieldName: 'giftOfTheWild'}), |
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.
Here are some examples of how this is used to conditionally display the correct buff ranks
ui/core/components/icon_picker.tsx
Outdated
const fillActionid = () => this.config.actionId(this.modObject)?.fillAndSet(this.rootAnchor, true, true); | ||
this.config.changedEvent(this.modObject).on(() => { | ||
console.log('good') | ||
fillActionid() | ||
}) | ||
fillActionid() |
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.
We change this to a function so that we can key off of the changedEvent
to update Action IDs each time
No description provided.