fix bugs
This commit is contained in:
@@ -11,9 +11,11 @@ class MagicStone(int):
|
||||
self.value = value
|
||||
|
||||
def exchange(self) -> tuple[int, int, int]:
|
||||
_value, _upper = divmod(self.value, 100)
|
||||
_value, _middle = divmod(_value, 100)
|
||||
return _upper, _middle, _value
|
||||
# 期望顺序:返回 (上品, 中品, 下品)
|
||||
# 汇率:100 下品 = 1 中品;100 中品 = 1 上品
|
||||
_middle_total, _lower = divmod(self.value, 100)
|
||||
_upper, _middle = divmod(_middle_total, 100)
|
||||
return _upper, _middle, _lower
|
||||
|
||||
def __str__(self) -> str:
|
||||
_upper, _middle, _value = self.exchange()
|
||||
@@ -24,7 +26,21 @@ class MagicStone(int):
|
||||
return MagicStone(self.value + other)
|
||||
return MagicStone(self.value + other.value)
|
||||
|
||||
def __iadd__(self, other: Union['MagicStone', int]) -> 'MagicStone':
|
||||
if isinstance(other, int):
|
||||
self.value += other
|
||||
else:
|
||||
self.value += other.value
|
||||
return self
|
||||
|
||||
def __sub__(self, other: Union['MagicStone', int]) -> 'MagicStone':
|
||||
if isinstance(other, int):
|
||||
return MagicStone(self.value - other)
|
||||
return MagicStone(self.value - other.value)
|
||||
return MagicStone(self.value - other.value)
|
||||
|
||||
def __isub__(self, other: Union['MagicStone', int]) -> 'MagicStone':
|
||||
if isinstance(other, int):
|
||||
self.value -= other
|
||||
else:
|
||||
self.value -= other.value
|
||||
return self
|
||||
Reference in New Issue
Block a user