libcord-tech / gauntlet

A keybinding tool for defending quickly in NationStates.
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Improve crossing and dossing filter #9

Closed esfalsa closed 1 year ago

esfalsa commented 1 year ago

Gauntlet's current method for creating a list of which nations to cross or doss from an activity page is to go through the happenings sequentially, add a nation to the list if the happening is a WA admit, and remove a nation from the list if the happening is a WA resignation. This doesn't quite work for nations that have joined and resigned from the WA, which are usually nations from the previous update or that have switched already.

Since the activity feed shows happenings starting with the most recent, Gauntlet will process the more recent WA resignation first and then the WA admit, so those nations will be counted even though they're no longer in the WA. Actually, it's a little worse than that; nations are currently removed from the list by splice()-ing the indexOf() the nation in the happening, which is problematic since indexOf can return -1. In those cases, Gauntlet is actually just removing the last nation it counted whenever it processes a WA resignation happening for a nation it hasn't yet counted.

This PR instead checks just the first WA happening for each nation present. If that happening is a WA admit, the nation is added to the list. I think this should work because we only need to consider the current WA status of each nation. I know this also doesn't count situations where the most recent WA happening is an application, but I'm not aware of any way to apply to the WA while already being a member (though I may be wrong about that).

roavin commented 1 year ago

Code looks good. Haven't tested; I assume you've done due dilligence.

roavin commented 1 year ago

Oh, and thank you for the detailed explanation!