diff --git a/pysollib/actions.py b/pysollib/actions.py index febe015c2f..19fc611ad4 100644 --- a/pysollib/actions.py +++ b/pysollib/actions.py @@ -330,7 +330,7 @@ def mSelectRandomGame(self, type='all'): elif type == 'not played' and won+lost == 0: games.append(gi.id) if games: - game_id = self.app.getRandomGameId(games) + game_id = self.app.chooseRandomOutOfGames(games) if game_id and game_id != self.game.id: self.game.endGame() self.game.quitGame(game_id) diff --git a/pysollib/app.py b/pysollib/app.py index d04047a6c8..2db007d39f 100644 --- a/pysollib/app.py +++ b/pysollib/app.py @@ -1017,10 +1017,14 @@ def getGameSaveName(self, id): return None return re.sub(r"[\s]", "_", latin1_normalize(n)) - def getRandomGameId(self, games=None): - if games is None: - return self.miscrandom.choice(self.gdb.getGamesIdSortedById()) - return self.miscrandom.choice(games) + def _choice(self, lst): + return self.miscrandom.choice(lst) + + def chooseRandomOutOfGames(self, games): + return self._choice(games) + + def getRandomGameId(self): + return self._choice(self.gdb.getGamesIdSortedById()) def getAllUserNames(self): names = []