magnusbakken / espn-fantasy-autopick

A Chrome extension that lets you automatically add active players to the current roster in an ESPN NBA/NHL fantasy league.
MIT License
11 stars 6 forks source link

Wrong reordering when ESPN re-renders slots after a slot is left completely empty #7

Closed magnusbakken closed 3 years ago

magnusbakken commented 3 years ago

When you move the player from the top UTIL slot in a way that leaves it empty, the ESPN page automatically moves the next player up to the top UTIL slot. The same thing probably affects any other slot type with multiple instances, but usually UTIL is the only such slot.

Example: problem-roster

Because there isn't room for everybody, the extension wants to move people around in the following way (preferring to keep LeBron on the bench because he's DTD): PG: Kyrie Irving SG: Malcolm Brogdon SF: Brandon Ingram PF: Domantas Sabonis C: Montrezl Harrell G: Dillon Brooks F: Miles Bridges UTIL: Collin Sexton UTIL: LaMelo Ball UTIL: Wendell Carter Jr.

Which is fine, but instead it ends up with this: problem-roster-bad-result

The reason is that when the extension moves Sabonis from UTIL to PF, LaMelo moves up from UTIL slot 2 to UTIL slot 1, and then Sexton replaces LaMelo instead of keeping both.

It's not very obvious what the best solution is. One possible solution is to treat all slots of the same type as the same target, so instead of assigning a particular destination slot ID for each player we would instead assign a destination slot type. The responsibility for finding the first such slot that doesn't have an active player would be shifted from the setup algorithm to the auto-move algorithm, but even this approach could fail in cases where all the available UTIL slots are currently filled with players that are active (playing on that day) but injured.

magnusbakken commented 3 years ago

Version 2.4.5+ retries automatic setup once if the result isn't as expected, which should fix this issue in most cases.