mirror of
https://github.com/kristoferssolo/2048.git
synced 2025-10-21 15:20:35 +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:
parent
cad0e87663
commit
79c3bee2a3
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)
|
DOWN = (0, 1)
|
||||||
LEFT = (-1, 0)
|
LEFT = (-1, 0)
|
||||||
RIGHT = (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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user