Skip to content

Commit

Permalink
Make Enum hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquegemignani committed Aug 2, 2023
1 parent e611827 commit 83f58e5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mercury_engine_data_structures/game_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
For checking which game is being parsed
"""
from enum import Enum
import enum
from functools import cached_property
from typing import Any, Callable

Expand All @@ -10,7 +10,7 @@
from mercury_engine_data_structures import crc


class Game(Enum):
class Game(enum.IntEnum):
SAMUS_RETURNS = 10
DREAD = 11

Expand Down Expand Up @@ -42,6 +42,9 @@ def __lt__(self, other):
return self.value < other.value
return NotImplemented

def __hash__(self):
return hash(("Game", self.value))

def hash_asset(self, msg: str) -> int:
if self == Game.SAMUS_RETURNS:
func = crc.crc32
Expand Down

0 comments on commit 83f58e5

Please sign in to comment.