Commit c18a7185 by BellCodeEditor

auto save

parent d7576636
Showing with 218 additions and 0 deletions
class Hero:
def __init__(self,name,hp,attack):
self.name = name
self.level=1
self.hp=hp
self.attack=attack
def sj(self):
self.level = self.level+1
self.hp = self.hp+50
self.attack = self.attack+4
yase = Hero("亚瑟",300,30)
print(yase.hp)
yase.sj()
print(yase.hp)
print()
\ No newline at end of file
import random
h = '黑桃 红桃 方片 梅花'.split()
s = '2 3 4 5 6 7 8 9 10 J Q K A'.split()
p = []
for i in h:
for j in s:
p.append(i + j)
pool = random.sample(p, 21)
print("请在下面的牌中选一张记住:")
for i in range(3):
col1, col2, col3 = [], [], []
for i in range(7):
col1.append(pool[i*3])
col2.append(pool[i*3+1])
col3.append(pool[i*3+2])
print(col1[i], col2[i], col3[i])
n = int(input("你选的牌在第几列:"))
if n == 1:
pool = col2 + col1 + col3
elif n == 2:
pool = col1 + col2 + col3
elif n == 3:
pool = col1 + col3 + col2
else:
print("wrong number")
print()
print(f'你选的是{pool[10]}')
# 第六课 列表
#列表的创建
# list = ["王宣",18,2.00]
# print(list)
# #列表的增添
# 列表名.insert(索引,元素)#可以插入到索引位置
# 列表名.append("元素") #可以添加到列表的最后
# #列表的删除
# 列表名.pop(索引) #可以根据索引删除
# 列表名.remove("元素") #想删除哪个元素就填什么名字
# list = ["张飞","刘备","关羽","曹操","孙权","袁术"]
# for i in list:
# print(i)
# for i in range(len(list)):
# print(list[i])
#求和
# list1 = [1,2,3,4,5,6,7,8,9,10]
# sum = 0
# for i in list1:
# sum = sum + i
# print(sum)
# m=int(input("请输入m:"))
# n=int(input("请输入n:"))
# sum = 0
# for i in range(m,n+1):
# if i%2==1:
# sum = sum + i
# print(sum)
#第一步需要知道你想输入的序列是几位
#使用循环输入五次保存在空列表中
#第三步逆序输出
n = int(input())
l = []
for i in range(n):
a = int(input())
l.append(a)
c = []
for i in l:
if i not in c:
c.append(i)
print(c)
a = int(input("请输入a:"))
b = int(input("请输入b:"))
c = input("请输入符号:")
if c == "+":
print(a+b)
elif c == "-":
print(a-b)
elif c == "*":
print(a*b)
elif c=="/":
if b==0:
print("Divided by zero!")
else:
print(a/b)
else:
print("Invalid operator!")
class Hero:
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp = hp
self.max_hp = self.hp
self.attack=attack
def combat(self,enemy):
enemy.hp-=self.attack
info1=self.name+"对"+enemy.name+"发起进攻,"
info2="造成"+str(self.attack)+"点伤害,"
if enemy.hp>0:
info3=enemy.name+"还剩"+str(enemy.hp)+"血量"
info = info1+info2+info3
print(info)
else:
info3=enemy.name+"阵亡,游戏结束"
info=info1+info2+info3
print(info)
def cure(self):
self.hp = self.hp+60
if self.hp>self.max_hp:
self.hp = self.max_hp
print(self.name+"使用了治疗术,血量增加:",60,"当前血量为",self.hp)
class player(Hero):
def __init__(self,name,hp,attack):
super().__init__(name,hp,attack)
self.hp=hp
self.max_hp = self.hp
self.attack=attack
print("角色"+self.name+"创建成功")
print("当前等级,血量,攻击力分别为",self.level,self.hp,self.attack)
xy = Hero("徐翌恒",300,24)
zd = player("张段",280,26)
class Hero(object):
def __init__(self, name):
self.name = name
self.level = 1
self.hp = 250
self.attack = 40
self.max_hp = self.hp
print("角色" + self.name + "创建成功")
print("当前等级、血量、攻击力分别为:", self.level, self.hp, self.attack)
def cure(self): # 治疗
self.hp = self.hp + 60
if self.hp > self.max_hp:
self.hp = self.max_hp
print(self.name + "使用了治疗,血量增加:", 60, ",目前的血量为:", self.hp)
def combat(self, enemy): # 普通攻击
info1 = self.name + "对" + enemy.name + "发起进攻,"
info2 = "造成" + str(self.attack) + "点伤害,"
enemy.hp -= self.attack
if enemy.hp > 0:
info3 = enemy.name + "还剩下" + str(enemy.hp) + "血量"
info = info1 + info2 + info3
print(info)
else:
info3 = enemy.name + "阵亡,游戏结束"
info = info1 + info2 + info3
print(info)
exit()
class Player(Hero):
def __init__(self, hero_type, name):
super().__init__(name)
self.hp = 200
self.attack = 50
self.max_hp = self.hp
self.hero_type = hero_type
print("角色" + self.name + "创建成功,英雄类型为:", self.hero_type)
print("当前等级、血量、攻击力分别为:", self.level, self.hp, self.attack)
houyi = Player("射手", "后羿")
yase = Hero("垭瑟")
print(30 * '-')
print(' 战斗开始')
while True:
print("-" * 30)
choice = input("请选择释放英雄技能(1攻击/2治疗):")
\ 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