Commit 0a6316cc by BellCodeEditor

save project

parent 7c306bc9
Showing with 18 additions and 7 deletions
class Hero: class Hero:
def __init__(self,name,hp,attack): def __init__(self,name):
self.lever = 1 self.lever = 1
self.name =name self.name =name
self.hp = hp self.hp = 250
self.attack = attack self.attack = 40
yase = Hero('亚瑟',300,20)
houyi = Hero('后羿',240,300) def combat(self,enemy):
print(yase.hp) enemy.hp -= self.attack
print(houyi.hp) into1 = self.name + "对" + enemy.name + "进攻"
into2 = "造成了" + str(self.attack) + "点伤害"
if enemy.hp > 0:
into3 = enemy.name + "身命还剩:" + str(enemy.hp)
else:
into3 = enemy.name + "阵亡,游戏结束"
into = into1 + into2 + into3
print(into)
yase = Hero('亚瑟')
houyi = Hero('后羿')
yase.combat(houyi)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment