Commit 6a90ca8e by BellCodeEditor

save project

parent d410c2f7
Showing with 28 additions and 6 deletions
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 50
self.name = name
\ No newline at end of file
# 英雄角色类
import random
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 250
self.attack = 40
self.hp = random.randint(300,1000)
self.attack = random.randint(50,100)
self.name = name
def combat(self,enemy):
def combat(self,duifang):
duifang.hp = duifang.hp - self.attack
info1 = self.name +'攻击了' + duifang.name
info2 = duifang.name + '减少了' + str(self.attack) +'点血量'
......@@ -16,10 +17,25 @@ class Hero(object):
info=info1+info2+info3
print(info)
else:
info3 = duifang.name + '去世,拜拜了'
info3 = duifang.name + '去世了,您本次扣除段位分'+str(random.randint(10,50))+'分'
info=info1+info2+info3
print(info)
a = ['普通','神话','史诗']
class pleyer(Hero):
def __init__(self,name,attack,hp,typ):
super().__init__(name)
self.hp = hp
self.attack =attack
self.typ = typ
print(self.name+'角色创建成功'+'本角色为'+random.choice(a)+'等级')
print('本角色血量,攻击力,名字,身份为'+str(self.hp)+','+str(self.attack)+','+self.name+','+self.typ)
sabi = pleyer ('sabi',1,10,'丐帮帮主')
李锦隆= pleyer ('李锦隆',70,300,'刺客')
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
yase.combat(houyi)
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