TheTrackerCouncil / SMZ3Randomizer

Tracker presents: a casual standalone version of the Super Metroid & A Link to the Past Crossover Randomizer with built-in automatic item tracking and Twitch integration
https://vivelin.net/projects/smz3
MIT License
25 stars 8 forks source link

Revise how we select responses based on counts #497

Open CPColin opened 2 months ago

CPColin commented 2 months ago

We've got a few bits of code that do the similar action of searching a Dictionary<int, SchrodingersString>? value for the highest key that is less than or equal to a target value:

It could be helpful to have an overload of the TrackerBase.Say() method that takes a Dictionary<int, SchrodingersString>? value directly and consolidates the logic that picks the matching response.

For the last item in the list above, doing this would mean we would no longer need separate TrackedNothing and TrackedNothingOutOfLogic responses, which could potentially mess with custom lines people have written.

Per Matt's suggestion below and Vivelin's thumbs-up, we should try to create a type like TieredSchrodingersString that we can pass around, instead of Dictionary<int, SchrodingersString>. We'll have to make sure such a type is still serializable to and from JSON and can still be merged across profiles.

Inspired by the code I forgot to write and had to add in #496.

MattEqualsCoder commented 2 months ago

I wonder if we should go as far as to create a new type for this to make coding around it simpler to implement. "TieredSchrodingersStrings" or something.

CPColin commented 2 months ago

That could be a good way to make it more clear what the intent is. I'll give it a try!