aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/snakes
diff options
context:
space:
mode:
authorGravatar ToxicKidz <[email protected]>2021-05-13 13:34:06 -0400
committerGravatar ToxicKidz <[email protected]>2021-05-13 13:34:06 -0400
commit2aa1916d5c8e4832f26f6da4094238e9a0021d1c (patch)
tree2ce3195a019ef84fd0b2d6509f5deec7b25e19bc /bot/exts/evergreen/snakes
parentfix: Resolve Merge Conflicts (diff)
chore: Use pathlib.Path.read_text & write_text over open
Diffstat (limited to 'bot/exts/evergreen/snakes')
-rw-r--r--bot/exts/evergreen/snakes/_converter.py7
-rw-r--r--bot/exts/evergreen/snakes/_utils.py5
2 files changed, 4 insertions, 8 deletions
diff --git a/bot/exts/evergreen/snakes/_converter.py b/bot/exts/evergreen/snakes/_converter.py
index 0ca10d6c..26bde611 100644
--- a/bot/exts/evergreen/snakes/_converter.py
+++ b/bot/exts/evergreen/snakes/_converter.py
@@ -63,13 +63,10 @@ class Snake(Converter):
"""Build list of snakes from the static snake resources."""
# Get all the snakes
if cls.snakes is None:
- with (SNAKE_RESOURCES / "snake_names.json").open(encoding="utf8") as snakefile:
- cls.snakes = json.load(snakefile)
-
+ cls.snakes = json.loads((SNAKE_RESOURCES / "snake_names.json").read_text("utf8"))
# Get the special cases
if cls.special_cases is None:
- with (SNAKE_RESOURCES / "special_snakes.json").open(encoding="utf8") as snakefile:
- special_cases = json.load(snakefile)
+ special_cases = json.loads((SNAKE_RESOURCES / "special_snakes.json").read_text("utf8"))
cls.special_cases = {snake["name"].lower(): snake for snake in special_cases}
@classmethod
diff --git a/bot/exts/evergreen/snakes/_utils.py b/bot/exts/evergreen/snakes/_utils.py
index 9b38ffa2..8b39f217 100644
--- a/bot/exts/evergreen/snakes/_utils.py
+++ b/bot/exts/evergreen/snakes/_utils.py
@@ -114,8 +114,7 @@ ANGLE_RANGE = math.pi * 2
def get_resource(file: str) -> List[dict]:
"""Load Snake resources JSON."""
- with (SNAKE_RESOURCES / f"{file}.json").open(encoding="utf-8") as snakefile:
- return json.load(snakefile)
+ return json.loads((SNAKE_RESOURCES / f"{file}.json").read_text("utf-8"))
def smoothstep(t: float) -> float:
@@ -560,7 +559,7 @@ class SnakeAndLaddersGame:
self.state = "roll"
for user in self.players:
self.round_has_rolled[user.id] = False
- board_img = Image.open(str(SNAKE_RESOURCES / "snakes_and_ladders" / "board.jpg"))
+ board_img = Image.open(SNAKE_RESOURCES / "snakes_and_ladders" / "board.jpg")
player_row_size = math.ceil(MAX_PLAYERS / 2)
for i, player in enumerate(self.players):