# 文字打怪小游戏
class Villain:
object = {}
# object{}收集“反派”
def __init__(self, name, health, describe):
self.name = name
self.health, self.full_health = health, health
# full_health不变,用来比较动态血量
self.describe = describe
Villain.object[self.name] = self
@property
def check_health(self):
# 血量动态
if self.health >= .5 * self.full_health:
return '{} health is strong'.format(self.name)
if .5 * self.full_health > self.health >= .00000000000001:
return '{} is weaker'.format(self.name)
if self.health <= 0:
return 'You killed {}'.format(self.name)
@check_health.setter
def check_health(self, value):
self.health = value
def __call__(self, *args, **kwargs):
return
文字打怪小游戏
最新推荐文章于 2024-08-18 09:36:20 发布