Commit 9fe9d09d by BellCodeEditor

auto save

parent b949b556
Showing with 16404 additions and 81 deletions
import random import pygame
class Hero:
def __init__(self,name,hp,attack,max_hp): pygame.init()
self.level = 1
self.name = name screen = pygame.display.set_mode((600,800))
self.hp = hp
self.attack = attack screen.done()
self.max_hp = self.hp
def combat(self,enmey):
info1 = self.name + '对' + enmey.name + '发起进攻,'
info2 = '造成' + self.attack + '点伤害,'
enmey.hp -= self.attack
if enmey.hp >0:
info3 = enmey.name + '还剩下' + enmey.hp + '点生命值'
info = info1 + info2 + info3
print(info)
else:
info3 = enmey.name + '阵亡,游戏结束'
info = info1 + info2 + info3
print(info)
exit()
def cure(self):
self.hp = self.hp + 60
if self.hp > self.max_hp:
self.hp = self.max_hp
class Player(Hero):
def __init__(self,name,hero_type):
super(Player,self).__init__(name)
self.hp = 200
self.attack = 50
self.hero_type = hero_type
print('角色'+self.name+'已经创建','英雄类型为'+self.hero_type)
print('当前等级,血量,攻击力为'+self.name + self.attack)
def cure(self):
hp = random.randint(0,3)
player = Player('后羿','射手')
yase = Hero('亚瑟')
print('-'*30)
print(' 战斗开始!')
while True:
print('-'*30)
a = input('请输入技能(1攻击/2治疗)')
if a == 'q':
print('游戏结束')
break
elif a == '1':
player.combat(yase)
elif a == '2':
player.cure()
else:
print('请重新输入')
continue
enmey.choice = random.randint(1,3)
if enmey.choice == '1' :
player.cure()
else:
player.combat(yase)
#def upgrade(self):
#self.level = self.level+1
#self.hp = self.hp+50
#self.attack = self.attack
#yase = Hero('亚瑟',300,20)
#yase.upgrade()
\ No newline at end of file
凄凄切切群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
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