Commit f03e5f3b by BellCodeEditor

auto save

parent 36c28c1c
Showing with 11 additions and 9 deletions
# 英雄角色类 def combat(self,enemy): # 攻击
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
def combat(self,enemy): # 攻击
enemy.hp=enemy.hp-self.attack enemy.hp=enemy.hp-self.attack
info1=self.name+'对'+enemy.name+'发起攻击,' info1=self.name+'对'+enemy.name+'发起攻击,'
info2=self.name+'对'+enemy.name+'造成了'+str(self.attack)+'伤害,' info2=self.name+'对'+enemy.name+'造成了'+str(self.attack)+'伤害,'
...@@ -16,3 +8,12 @@ class Hero(object): ...@@ -16,3 +8,12 @@ class Hero(object):
yase = Hero("垭瑟") yase = Hero("垭瑟")
houyi= Hero("后羿") houyi= Hero("后羿")
yase.combat(houyi) yase.combat(houyi)
# 英雄角色类
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.name = name
\ 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