fixed a bug in windows for local sound directory
authorGeorgios Atheridis <georgios@atheridis.org>
Sun, 15 Jan 2023 00:29:19 +0000 (00:29 +0000)
committerGeorgios Atheridis <georgios@atheridis.org>
Sun, 15 Jan 2023 00:29:19 +0000 (00:29 +0000)
announcer/constants.py
announcer/events.py

index 15d87aa1e31fcdfba9296ad088f725364c3e0d58..265891cd2e564d58ef968dc4c1b888ff4fdc5acf 100644 (file)
@@ -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)
index 8e235a6a2ea32146886a9e86c2ac88c69e96bf5a..120eace2f7cc6a5744a8a322ef210307ca0e980a 100644 (file)
@@ -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":