Commit b3fd397b by BellCodeEditor

auto save

parent da60e227
Showing with 32 additions and 11 deletions
# 英雄角色类
import random
r=random.randint(0,50)
t=random.randint(40,70)
p=random.randint(100,150)
t1=random.randint(50,75)
p1=random.randint(80,120)
class Hero(object):
def __init__(self, name):
self.level = 1
self.hp = 3500
self.attack = 388
self.hp = p
self.attack = t
self.name = name
def combat(self,enemy): # 攻击
def gj(self,enemy):
enemy.hp -= self.attack
info1 = self.name + '对' + enemy.name + '发起攻击,'
info2 = '造成' + str(self.attack) + '真实伤害,'
info2 = '造成' + str(self.attack-r1) + '真实伤害,'
c=self.attack-r1
if c < 20:
info4=enemy.name+"躲了过去,"
else:
info4=enemy.name+"没躲过去,"
if enemy.hp < 0:
info3 = enemy.name + '阵亡'
else:
info3 = enemy.name + '还剩下' + str(enemy.hp) + '点生命值'
print(info1 + info2 + info3)
print(info1 + info4 +info2 + info3)
yase = Hero("垭瑟")
houyi= Hero("后羿")
yase.combat(houyi)
\ No newline at end of file
class Player(Hero):
def __init__(self, name):
super().__init__(name)
self.hp = p1
self.attack = t1
lvbu = Hero("吕布")
guanyu= Player(Hero("关羽"))
print("游戏开始")
print("-<>"*30)
print("你是关羽,血量,攻击力分别是"+str(guanyu.hp)+" "+str(guanyu.attack)+" 对方是吕布,血量,攻击力分别是"+str(lvbu.hp)+" "+str(lvbu.attack))
if int(input("(1:攻击 2:加血)"))==1:
guanyu.gj(lvbu)
else:
pass
guanyu.gj(lvbu)
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