parent
c4bc5963cc
commit
d842968b2e
@ -0,0 +1,29 @@
|
||||
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
|
||||
|
Loading…
Reference in new issue