Skip to content
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

raidboss: Support for objects in trigger outputStrings #5551

Closed
wants to merge 10 commits into from
Closed

raidboss: Support for objects in trigger outputStrings #5551

wants to merge 10 commits into from

Conversation

valarnin
Copy link
Collaborator

This is a preliminary PR to eventually allow more customization of outputStrings outputs by users. Eventually I'd like to see player names replaced with something like a player object with a default toString that returns player name, which could maybe be a helper on the PartyTracker object.

I have simulated that extremely basically with the data object test trigger added in test.ts. Users should be able to customize the outputStrings entry for text to print e.g. ${data.role}. I'm looking for feedback/thoughts on if this approach makes sense, or if this idea should be approached in a different way, before I fully flesh this out.

I'm not super happy with the logic in popup-text.ts, feels like it could have benefited with a helper func or something rather than switch/casing over type in two separate spots like that, or maybe a recursive function?

@cactbotbot
Copy link
Collaborator

cactbotbot commented Jun 12, 2023

@valarnin Thanks for your contribution! 🌵🚀

@valarnin valarnin changed the title raidboss: Preliminary support for objects in trigger outputStrings raidboss: Support for objects in trigger outputStrings Jun 12, 2023
ui/raidboss/data/00-misc/test.ts Show resolved Hide resolved
types/trigger.d.ts Outdated Show resolved Hide resolved
test/helper/test_trigger.ts Outdated Show resolved Hide resolved
ui/raidboss/popup-text.ts Show resolved Hide resolved
ui/raidboss/popup-text.ts Outdated Show resolved Hide resolved
ui/raidboss/popup-text.ts Show resolved Hide resolved
@valarnin valarnin marked this pull request as ready for review June 12, 2023 23:06
@valarnin
Copy link
Collaborator Author

I think this is ready for general review now. I haven't tested the latest changes (ran out of time, I have another obligation in about 5 minutes), but the underlying code should be relatively complete.

I ended up moving the ShortName logic to Util for this rather than duplicate it in a third place, and cleaned up the duplicate code, hence the oopsy-related files being updated.

ui/raidboss/popup-text.ts Outdated Show resolved Hide resolved
Comment on lines 177 to 178
if (!partyMember)
return;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me a little worried in the face of the OverlayPlugin bug. I think this function should never return undefined. It should at least return what it can (name, shortName) and then elide other fields. And, ideally, if somebody asks for a property that doesn't exist, it should print a warning and pick ~some property rather than nothing. (Maybe shortName if that exists, and any key after that? Maybe these objects need a default: string field in case somebody or some code asks for a non-existent property and we need to fall back on something?)

Doing this would also solve the TODO in the raidboss test.ts where you don't get anything if you're not in a party.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of PRing the adjustments to OverlayPlugin as my next project, a general cleanup of the way the PartyChanged event works under the hood.

As for the other points in this comment, agreed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wanted to add that there are some times where triggers might call out to "stack on (non-party member)" for things like hunts, and so in this case even if OP was 100% working for party members, we'd still want to have reasonable fallback behavior.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final question (and maybe there's no good answer here) is what to do if somebody enters ${data.name} (${data.role}) (e.g. #5554) but role is unknown. I guess it would just say name twice? Do we need a separate nameAndRole entry that could handle this? (Or maybe I am overthinking and this is overkill.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm holding off on this piece until I can look at the OP issue in general, but I think the fallback logic is fuzzy and I'm not 100% sure what would be the best behavior here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, what fallback should be used? Should job/role fall back to name or shortName, or just display ???? If we're displaying something like ???, should that be locale-'d e.g. Outputs.unknown, and if so, passing current locale to this location is complicated.

Copy link
Owner

@quisquous quisquous Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just fall back to shortName always for all objects (and then pick any field after that if it doesn't exist?), but in a general sense where objects are not always players, that seems a little weird.

One thought is that the object should put a (required?) default or fallback field that specifies what value to be used if a user or code specifies a sub param that doesn't exist. Personally, I think shortName is a reasonable choice to use for that value here. I think if there's always a valid fallback, then there's no need for ??? or locale plumbing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming back to this PR, I still think that this is the missing piece here that prevents me from landing this PR. I feel like there needs to be some story around "what happens if a sub param is specified that doesn't exist". I think in general, it would be better to show something reasonable rather than ??? regardless of the OP party bug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is updated with the latest commit (also rebased to main). Hopefully this makes sense and lines up with what you're looking for?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, although I also needed to do e9fcc96 in order for the "no prop specified" case to work.

resources/party.ts Outdated Show resolved Hide resolved
resources/party.ts Show resolved Hide resolved
types/trigger.d.ts Outdated Show resolved Hide resolved
types/trigger.d.ts Show resolved Hide resolved
ui/raidboss/raidboss_options.ts Outdated Show resolved Hide resolved
valarnin and others added 9 commits August 7, 2023 19:47
Extract the ShortName logic/functions to Util, clean up duplicate code
Narrow the typedef for params objects
Add helpers to get party member param object
Add config option for default display label for players
Clean up handling of param objects
Co-authored-by: Adrienne Walker <enne@quisquo.us>
Copy link
Owner

@quisquous quisquous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@@ -42,6 +42,7 @@ export interface RaidbossData {
CanCleanse: () => boolean;
CanFeint: () => boolean;
CanAddle: () => boolean;
partyMemberParam: (name: string) => PartyMemberParamObject | undefined;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to avoid polluting data even more, what do you think about making this be a function on PartyTracker since data.party is already a thing? I'd be fine with data.party.member(name) if you want to keep it brief.

I know this would require passing in nicknames and the default field as well, so maybe it's not ideal. Mostly curious if you think that's polluting party tracker with things it shouldn't know about or if that's cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only way I'd be okay with this would be to pass the whole RaidbossOptions object in, rather than passing in individual values, and AFAIK that would cause issues with oopsy and jobs since their config options don't have that parameter?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oopsy has a nicknames field. It could arguably grow the default field and so oopsy could say people's roles rather than names. jobs doesn't really have a need for either. So, maybe it could take an optional object that has nick name and default that both RaidbossOptions and OopsyOptions is shaped like. (Or an object with optional nick name and default?)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies if I derailed this PR with these comments. Mostly I just am trying to be cautious about adding unnecessary things to data since it's something shared with users. Happy to discuss more if you have time!

I'm guessing you're just very busy these days; please let me know if there's something I can do to help this along, as I'm still really excited about this change and being able to let users have more custom output for players.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've been very busy the last month or so, so I haven't had time to circle back around to this PR and figure out how to get things to pass through well.

I'm hoping to have time in the next week or two, but we'll see how work goes 🤷

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this in c77169a

resources/party.ts Outdated Show resolved Hide resolved
Comment on lines 185 to 187
id: '???',
job: 'NONE',
role: '???',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the fallbacks, do you think it would make sense to have all of these be optional other than the name/shortName. That way if somebody has a trigger that says ${player1.role} and something has gone awry, they'll get player1's name instead of ???.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do a priority as well, sure. Some sort of const array at the top and then loop through until we find a value should work?

Copy link
Owner

@quisquous quisquous Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was saying something different; there's only two states, either we know everything or we only know name. I'm suggesting to make all the fields but name/shortName optional and possibly undefined so that in the case where we only know name, we only need to fill in name and shortName. That way if somebody specifies a missing field (that would normally be filled in but maybe it's the OP bug so it's not) then instead of getting '???' or 'NONE' when that's not useful, they would at least get the name. In other words, only fill in real values and never use dummy values or said differently never add something to this object that you wouldn't want displayed in a trigger.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this in 5121b99

ui/raidboss/data/00-misc/test.ts Show resolved Hide resolved
@valarnin
Copy link
Collaborator Author

Closing.

@valarnin valarnin closed this Oct 22, 2023
quisquous added a commit that referenced this pull request Nov 2, 2023
This is #5551, with some additional changes on top to resolve a few
conversations.

Closes #5551.

---------

Co-authored-by: valarnin <valarnin@gmail.com>
github-actions bot pushed a commit that referenced this pull request Nov 2, 2023
#5861)

This is #5551, with some additional changes on top to resolve a few
conversations.

Closes #5551.

---------

Co-authored-by: valarnin <valarnin@gmail.com> 5efd9ee
github-actions bot pushed a commit that referenced this pull request Nov 2, 2023
#5861)

This is #5551, with some additional changes on top to resolve a few
conversations.

Closes #5551.

---------

Co-authored-by: valarnin <valarnin@gmail.com> 5efd9ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants