Commit 7309beb0 by BellCodeEditor

auto save

parent ac795495
Showing with 30 additions and 5 deletions
......@@ -5,12 +5,38 @@ class Cat:
self.head = 1 # 头
self.earsNum = 2 # 耳朵
self.skin = "black"
def run(self):
print("小猫飞快的跑起来")
def skill():
??
def skill(self,food):
print("Oh,可怜的"+food+",我要吃了你")
role = Cat()
role.skill("老鼠")
\ No newline at end of file
class Hero:
def __init__(self,name):
self.level=1
self.name = name
self.hp = 3000
self.attack = 99999999
# def upgrade(self):
# self.level+=1
# self.hp+=40
# self.attack+=40
def combat(self,enemy):
enemy.hp -= self.attack
info1 = self.name + "攻击" + enemy.name +"\n"
info2 = enemy.name + "损失" + str(self.attack) + "生命值" + '\n'
if enemy.hp > 0 :
info3 = enemy.name + "还剩" + str(enemy.hp) + "生命值" + '\n'
else :
info3 = enemy.name + "阵亡,游戏结束"
info = info1 + info2 + info3
print(info)
luban = Hero('鲁班')
lan = Hero('澜')
lan.combat(luban)
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