Merge pull request #142 from Silver-Volt4/main

hotfix random_play
This commit is contained in:
Loup 2023-05-26 02:07:20 +05:30 committed by GitHub
commit d8de5c4457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -682,6 +682,12 @@
}
],
"versions": {
"1.0.1": {
"api_version": 7,
"commit_sha": "3ef572f",
"released_on": "25-05-2023",
"md5sum": "f093c09b3e9439755a515ae6751e1f7e"
},
"1.0.0": {
"api_version": 7,
"commit_sha": "d91fea3",

View file

@ -67,11 +67,11 @@ class RandomPlaylist:
all_games: list[ba.GameActivity]
usable_games: list[ba.GameActivity]
last_game: ba.GameActivity
last_game: str
def __init__(self, sessiontype):
self.sessiontype = sessiontype
self.usable_games = [
self.usable_games: list[ba.GameActivity] = [
gt
for gt in RandomPlaylist.all_games
if gt.supports_session_type(self.sessiontype)
@ -87,7 +87,7 @@ class RandomPlaylist:
while True:
game = choice(self.usable_games)
if game == self.last_game:
if game.name == self.last_game:
# Don't repeat the same game twice
if has_only_one_game:
# ...but don't freeze the game when there's only one game
@ -95,6 +95,7 @@ class RandomPlaylist:
else:
break
self.last_game = game.name
game_map = choice(game.get_supported_maps(self.sessiontype))
settings = {
s.name: s.default for s in game.get_available_settings(self.sessiontype)