From: Georgios Atheridis Date: Sun, 15 Jan 2023 00:29:19 +0000 (+0000) Subject: fixed a bug in windows for local sound directory X-Git-Url: https://git.atheridis.org/?a=commitdiff_plain;h=c8e1930807a4ba827d4f32b44df50d5f2333f2af;p=forks%2Fpeks-announcer.git fixed a bug in windows for local sound directory --- diff --git a/announcer/constants.py b/announcer/constants.py index 15d87aa..265891c 100644 --- a/announcer/constants.py +++ b/announcer/constants.py @@ -6,7 +6,9 @@ DIR_NAME = "lol-announcer" if os.name == "posix": if "XDG_CONFIG_HOME" in os.environ and "XDG_CACHE_HOME" in os.environ: LOGS_DIR = os.path.join(os.environ["XDG_CACHE_HOME"], DIR_NAME, "logs") - SOUNDS_DIR_LOCAL = os.path.join(os.environ["XDG_CONFIG_HOME"], DIR_NAME, "sounds") + SOUNDS_DIR_LOCAL = os.path.join( + os.environ["XDG_CONFIG_HOME"], DIR_NAME, "sounds" + ) elif "HOME" in os.environ: HOME = os.environ["HOME"] LOGS_DIR = os.path.join(HOME, ".cache", DIR_NAME, "logs") @@ -17,8 +19,8 @@ if os.name == "posix": elif os.name == "nt": if "APPDATA" in os.environ: APPDATA = os.environ["APPDATA"] - LOGS_DIR = os.path.join(APPDATA, DIR_NAME) LOGS_DIR = os.path.join(APPDATA, DIR_NAME, "logs") + SOUNDS_DIR_LOCAL = os.path.join(APPDATA, DIR_NAME, "sounds") else: print("APPDATA is not set.", file=sys.stderr) sys.exit(1) diff --git a/announcer/events.py b/announcer/events.py index 8e235a6..120eace 100644 --- a/announcer/events.py +++ b/announcer/events.py @@ -90,10 +90,18 @@ class Event: self.enemy_team_players = self.team_order_players # Welcome announcement. - if self.game_time >= 26 and self.previous_game_time < 26 and self.game_time < 28: + if ( + self.game_time >= 26 + and self.previous_game_time < 26 + and self.game_time < 28 + ): self.new_events.append("Welcome") # Minions spawning soon. - if self.game_time >= 36 and self.previous_game_time < 36 and self.game_time < 38: + if ( + self.game_time >= 36 + and self.previous_game_time < 36 + and self.game_time < 38 + ): self.new_events.append("MinionsSpawningSoon") # Loop over all new events. @@ -102,11 +110,19 @@ class Event: event_name = event["EventName"] # Someone got first blood. - if event_name == "ChampionKill" and event_index < self.event_count - 1 and self.events[event_index + 1]["EventName"] == "FirstBlood": + if ( + event_name == "ChampionKill" + and event_index < self.event_count - 1 + and self.events[event_index + 1]["EventName"] == "FirstBlood" + ): event_index += 1 self.new_events.append("FirstBlood") # Someone got a multikill. - elif event_name == "ChampionKill" and event_index < self.event_count - 1 and self.events[event_index + 1]["EventName"] == "Multikill": + elif ( + event_name == "ChampionKill" + and event_index < self.event_count - 1 + and self.events[event_index + 1]["EventName"] == "Multikill" + ): multikill = self.events[event_index + 1]["KillStreak"] # Ally got a multikill. if event["KillerName"] in self.ally_team_players: @@ -160,37 +176,77 @@ class Event: elif event_name == "TurretKilled": turret_name = event["TurretKilled"] # Ally team got a turret kill. - if turret_name[7:9] == "T2" and self.player_team == "ORDER" or turret_name[7:9] == "T1" and self.player_team == "CHAOS": + if ( + turret_name[7:9] == "T2" + and self.player_team == "ORDER" + or turret_name[7:9] == "T1" + and self.player_team == "CHAOS" + ): self.new_events.append("AllyTurretKill") # Enemy team got a turret kill. - elif turret_name[7:9] == "T1" and self.player_team == "ORDER" or turret_name[7:9] == "T2" and self.player_team == "CHAOS": + elif ( + turret_name[7:9] == "T1" + and self.player_team == "ORDER" + or turret_name[7:9] == "T2" + and self.player_team == "CHAOS" + ): self.new_events.append("EnemyTurretKill") # A turret was killed. elif event_name == "InhibKilled": inhib_name = event["InhibKilled"] # Ally team got a turret kill. - if inhib_name[9:11] == "T2" and self.player_team == "ORDER" or inhib_name[9:11] == "T1" and self.player_team == "CHAOS": + if ( + inhib_name[9:11] == "T2" + and self.player_team == "ORDER" + or inhib_name[9:11] == "T1" + and self.player_team == "CHAOS" + ): self.new_events.append("AllyInhibitorKill") # Enemy team got a turret kill. - elif inhib_name[9:11] == "T1" and self.player_team == "ORDER" or inhib_name[9:11] == "T2" and self.player_team == "CHAOS": + elif ( + inhib_name[9:11] == "T1" + and self.player_team == "ORDER" + or inhib_name[9:11] == "T2" + and self.player_team == "CHAOS" + ): self.new_events.append("EnemyInhibitorKill") # An inhibitor is respawning soon. elif event_name == "InhibRespawningSoon": inhib_name = event["InhibRespawningSoon"] # Ally team's inhibitor is respawning soon. - if inhib_name[9:11] == "T1" and self.player_team == "ORDER" or inhib_name[9:11] == "T2" and self.player_team == "CHAOS": + if ( + inhib_name[9:11] == "T1" + and self.player_team == "ORDER" + or inhib_name[9:11] == "T2" + and self.player_team == "CHAOS" + ): self.new_events.append("AllyInhibitorRespawningSoon") # Enemy team's inhibitor is respawning soon. - elif inhib_name[9:11] == "T2" and self.player_team == "ORDER" or inhib_name[9:11] == "T1" and self.player_team == "CHAOS": + elif ( + inhib_name[9:11] == "T2" + and self.player_team == "ORDER" + or inhib_name[9:11] == "T1" + and self.player_team == "CHAOS" + ): self.new_events.append("EnemyInhibitorRespawningSoon") # An inhibitor has respawned. elif event_name == "InhibRespawned": inhib_name = event["InhibRespawned"] # Ally team's inhibitor has respawned. - if inhib_name[9:11] == "T1" and self.player_team == "ORDER" or inhib_name[9:11] == "T2" and self.player_team == "CHAOS": + if ( + inhib_name[9:11] == "T1" + and self.player_team == "ORDER" + or inhib_name[9:11] == "T2" + and self.player_team == "CHAOS" + ): self.new_events.append("AllyInhibitorRespawned") # Enemy team's inhibitor has respawned. - elif inhib_name[9:11] == "T2" and self.player_team == "ORDER" or inhib_name[9:11] == "T1" and self.player_team == "CHAOS": + elif ( + inhib_name[9:11] == "T2" + and self.player_team == "ORDER" + or inhib_name[9:11] == "T1" + and self.player_team == "CHAOS" + ): self.new_events.append("EnemyInhibitorRespawned") # Minions have spawned. elif event_name == "MinionsSpawning":