mirror of
https://github.com/kristoferssolo/2048.git
synced 2026-02-04 14:02:03 +00:00
feat(game): add __mult__ and __imult__ methods for Direction
Returns tuple of values that were multiplied by a constant
This commit is contained in:
8
src/py2048/utils.py
Normal file → Executable file
8
src/py2048/utils.py
Normal file → Executable file
@@ -6,3 +6,11 @@ class Direction(Enum):
|
||||
DOWN = (0, 1)
|
||||
LEFT = (-1, 0)
|
||||
RIGHT = (1, 0)
|
||||
|
||||
def __mul__(self, num: int) -> tuple[int, int]:
|
||||
"""Multiply the direction by a constant."""
|
||||
return self.value[0] * num, self.value[1] * num
|
||||
|
||||
def __imul__(self, num: int) -> tuple[int, int]:
|
||||
"""Multiply the direction by a constant."""
|
||||
return self.value[0] * num, self.value[1] * num
|
||||
|
||||
Reference in New Issue
Block a user