Commit 0eb3b1d3 by BellCodeEditor

save project

parent 9a581ef4
Showing with 50 additions and 2 deletions
......@@ -6,9 +6,57 @@ class Hero(object):
self.attack = 40
self.name = name
def combat(): # 攻击
???
def combat(self,enemy): # 攻击
enemy.hp-=self.attack
into1=self.name+'对'+enemy.name+'发起攻击'
into2='造成'+str(self.attack)+'点伤害'
if enemy.hp>0:
into3=enemy.name+'剩下'+str(enemy.hp)+'点血量'
into=into1+into2+into3
print(into)
else:
into3=enemy.name+'已死亡,游戏结束'
into=into1+into2+into3
print(into)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
class Player(Hero):
def __init__(self,name):
self.level=1
self.name=name
self.hp=200
self.attack=50
Player=Player('后羿')
print('血量:',Player.hp)
print('攻击:',Player.attack)
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