Commit 73cd0100 by BellCodeEditor

save project

parent 80d792b3
Showing with 14 additions and 12 deletions
import random
class Monster():
def __init__(self, name,hp,attack,attack_info,treatment):
def __init__(self, name,hp,attack,attack_info):
self.level = 1
self.name = name
self.hp = hp
self.max_hp = self.hp
self.attack = attack
self.attack_info = attack_info
self.treatment = treatment
def combat(self,enemy): # 攻击
enemy.hp -= self.attack
......@@ -27,28 +26,31 @@ class Monster():
exit()
def cure(self): # 治疗
self.hp = self.hp + self.treatment
blood = random.randint(2,4)
self.hp = self.hp + blood
if self.hp > self.max_hp :
self.hp = self.max_hp
print(self.name+"饮用露珠,血量增加:",self.treatment,",目前的血量为:",self.hp, "\n" , "-"*30)
print(self.name,"磕了口药,血量增加",blood,",",self.name,"目前的血量为",self.hp)
def meet(self,enemy):
pass
name = input("取个响亮的名字吧_")
print("你是_" + name + "\n" + "-"*30)
player = Monster(name,20,3,"挥动拳头",4)
flowey = Monster("flowey",10,2,"射出'友谊颗粒'",2)
frogey = Monster("frogey",8,3,"用舌头弹了一下",3)
player = Monster(name,20,4,"挥动拳头")
flowey = Monster("flowey",30,4,"射出'友谊颗粒'")
frogy = Monster("frogy",25,3,"用舌头弹了一下")
print("角色创建成功-" + player.name)
print("角色属性:" + str(player.hp) + " " + str(player.attack) + " " + str(player.treatment) + "(血量 攻击力 治疗值)")
print("角色属性:" + str(player.hp) + " " + str(player.attack) + "随机2-4(血量 攻击力 治疗值)")
print("输入'exit'来结束游戏" + "\n" + "-"*30)
def battle(enemy):
print("你遇到了" + enemy.name)
print(" 战斗开始")
print("-" * 30)
print(" 战斗开始")
while True:
print("-"*30)
choice = input("请选择行动方式(1_攻击 /2_治疗)_")
if choice == "exit" :
print("游戏结束")
......@@ -58,7 +60,7 @@ def battle(enemy):
elif choice == "2":
player.cure()
else:
print("输入无效!"+ "\n" + "-"*30)
print("输入无效!")
continue
a_choice = random.randint(1,2)
if a_choice == 1:
......@@ -66,4 +68,4 @@ def battle(enemy):
elif a_choice == 2:
enemy.cure()
battle(flowey)
\ No newline at end of file
battle(frogy)
\ 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