You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
892 B

class Character:
def __init__(self):
self.health = 100
self.energy = 50
self.position = (0, 0)
def move(self, direction):
if direction == 'forward':
self.position = (self.position[0], self.position[1] + 1)
elif direction == 'backward':
self.position = (self.position[0], self.position[1] - 1)
elif direction == 'left':
self.position = (self.position[0] - 1, self.position[1])
elif direction == 'right':
self.position = (self.position[0] + 1, self.position[1])
def attack(self):
print("攻击!")
def heal(self, amount):
self.health += amount
if self.health > 100:
self.health = 100
def take_damage(self, amount):
self.health -= amount
if self.health < 0:
self.health = 0