update city
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
|
||||
|
||||
from typing import Union
|
||||
|
||||
class MagicStone(int):
|
||||
"""
|
||||
灵石,实际上是一个int类,代表持有的下品灵石的数量。
|
||||
@@ -15,4 +17,14 @@ class MagicStone(int):
|
||||
|
||||
def __str__(self) -> str:
|
||||
_upper, _middle, _value = self.exchange()
|
||||
return f"上品灵石:{_upper},中品灵石:{_middle},下品灵石:{_value}"
|
||||
return f"上品灵石:{_upper},中品灵石:{_middle},下品灵石:{_value}"
|
||||
|
||||
def __add__(self, other: Union['MagicStone', int]) -> 'MagicStone':
|
||||
if isinstance(other, int):
|
||||
return MagicStone(self.value + other)
|
||||
return MagicStone(self.value + other.value)
|
||||
|
||||
def __sub__(self, other: Union['MagicStone', int]) -> 'MagicStone':
|
||||
if isinstance(other, int):
|
||||
return MagicStone(self.value - other)
|
||||
return MagicStone(self.value - other.value)
|
||||
Reference in New Issue
Block a user