Use a list for the games;

Preserves games sorting, and lets the campaigns return games in their active state order
This commit is contained in:
DevilXD committed 2022-01-08 15:03:09 +01:00
1 parent 1134dfcef3
commit 79e685ed0b
2 files changed
+5 -5

No files matched your search

+1 -1
View File
@@ -252,7 +252,7 @@ class GameSelector:
def set_games(self, games: Iterable[Game]): def set_games(self, games: Iterable[Game]):
self._games.clear() self._games.clear()
self._games.update((str(g), g) for g in sorted(games, key=lambda g: g.name)) self._games.update((str(g), g) for g in games)
self._list.delete(0, "end") self._list.delete(0, "end")
self._list.insert("end", *self._games.keys()) self._list.insert("end", *self._games.keys())
self._list.config(width=0) # autoadjust listbox width self._list.config(width=0) # autoadjust listbox width
+4 -4
View File
@@ -8,7 +8,7 @@ from yarl import URL
from time import time from time import time
from itertools import chain from itertools import chain
from functools import partial from functools import partial
from typing import Any, Callable, Iterable, Optional, Union, List, Dict, Set, cast, TYPE_CHECKING from typing import Any, Callable, Iterable, Optional, Union, List, Dict, cast, TYPE_CHECKING
try: try:
import aiohttp import aiohttp
@@ -176,7 +176,7 @@ class Twitch:
WebsocketTopic("User", "Drops", self._user_id, self.process_drops), WebsocketTopic("User", "Drops", self._user_id, self.process_drops),
WebsocketTopic("User", "CommunityPoints", self._user_id, self.process_points), WebsocketTopic("User", "CommunityPoints", self._user_id, self.process_points),
]) ])
games: Set[Game] = set() games: List[Game] = []
selected_game: Optional[Game] = None selected_game: Optional[Game] = None
self.change_state(State.INVENTORY_FETCH) self.change_state(State.INVENTORY_FETCH)
while True: while True:
@@ -189,8 +189,8 @@ class Twitch:
# we have no use in processing upcoming campaigns here # we have no use in processing upcoming campaigns here
continue continue
for drop in campaign.timed_drops.values(): for drop in campaign.timed_drops.values():
if drop.can_earn: if drop.can_earn and (game := campaign.game) not in games:
games.add(campaign.game) games.append(game)
if drop.can_claim: if drop.can_claim:
await drop.claim() await drop.claim()
self.change_state(State.GAME_SELECT) self.change_state(State.GAME_SELECT)