SMZ3Randomizer icon indicating copy to clipboard operation
SMZ3Randomizer copied to clipboard

Revise how we select responses based on counts

Open CPColin opened this issue 1 year ago • 2 comments

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:

  • Itemdata.TryGetTrackingResponse()
  • AutoTracker.IncrementGTItems()
  • Tracker.TrackDungeonTreasure()
  • Tracker.CountHyperBeamShots()
  • Tracker.ClearArea() (the TrackedNothingOutOfLogic part)

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.

CPColin avatar Apr 28 '24 21:04 CPColin

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.

MattEqualsCoder avatar Apr 29 '24 15:04 MattEqualsCoder

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

CPColin avatar Apr 29 '24 15:04 CPColin

Matt suggested we use an options object to cut down on the number of Say() and SayOnce() overloads. That sounds like it would be a good idea to implement while doing these changes, so I'm noting it here, so I don't forget.

CPColin avatar Jul 07 '24 02:07 CPColin