mirror of
https://github.com/kristoferssolo/2048.git
synced 2025-10-21 15:20:35 +00:00
refactor(game): remove dunder methods
This commit is contained in:
parent
585ddcd1d0
commit
ef09979dba
@ -95,18 +95,6 @@ class Block(pygame.sprite.Sprite):
|
|||||||
}
|
}
|
||||||
self.image.fill(color_map.get(self.value, COLORS.ERROR))
|
self.image.fill(color_map.get(self.value, COLORS.ERROR))
|
||||||
|
|
||||||
def __add__(self, other: "Block") -> None:
|
|
||||||
"""Add the value of two blocks and update the current block"""
|
|
||||||
logger.debug(f"Merging blocks ({id(self)}) and ({id(other)}) => ({id(self)}), {self.pos()}")
|
|
||||||
self.value += other.value
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def __iadd__(self, other: "Block") -> None:
|
|
||||||
"""Add the value of two blocks and updae the current block"""
|
|
||||||
logger.debug(f"Merging blocks ({id(self)}) and ({id(other)}) => ({id(self)}), {self.pos()}")
|
|
||||||
self.value += other.value
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Return a string representation of the block"""
|
"""Return a string representation of the block"""
|
||||||
return f"Block({id(self)}): ({self.pos()})"
|
return f"Block({id(self)}): ({self.pos()})"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user