update city

This commit is contained in:
bridge
2025-09-12 23:02:41 +08:00
parent e2f7afd6e3
commit 7933f20614
10 changed files with 201 additions and 78 deletions

View File

@@ -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)