Commit 2d176c62 by BellCodeEditor

save project

parent ac4bf4bb
Showing with 12 additions and 2 deletions
...@@ -13,8 +13,8 @@ class Hero: ...@@ -13,8 +13,8 @@ class Hero:
def combat(self,enemy): def combat(self,enemy):
enemy.hp - self.attack enemy.hp - self.attack
info1 = self.name + '对' +enemy.name + '发动了抓击!' info1 = self.name + '对' +enemy.name + '发动了抓击!'
info2 = enemy.name + '收到了' + str(self.attack - enemy.defense*0.2) + '点伤害!' info2 = enemy.name + '收到了' + str(self.attack) + '点伤害!'+'防御减免'+ str(enemy.defense*0.2)+'点伤害。'
enemy.hp -= self.attack - enemy.defense*0.2 enemy.hp = enemy.hp - self.attack + enemy.defense*0.2
if enemy.hp > 0: if enemy.hp > 0:
info3 = enemy.name+'剩余'+str(enemy.hp)+'血量!' info3 = enemy.name+'剩余'+str(enemy.hp)+'血量!'
info = info1 + info2 + info3 info = info1 + info2 + info3
...@@ -26,6 +26,16 @@ b = Hero('后羿',250,30,25) ...@@ -26,6 +26,16 @@ b = Hero('后羿',250,30,25)
a.combat(b) a.combat(b)
class Player(Hero):
def __init__(self,name,hp,attack,defense):
super().__init__(name,hp,attack,defense)
self.hp = 250
self.attack = 30
self.defense = 25
player = Player('后羿',250,30,25)
print('玩家的血量值为'+str(player.hp))
print('玩家的攻击力为'+str(player.attack))
print('玩家的防御值为'+str(player.defense))
# a = Pokemon('妙蛙种子',45,49,49,45,65,65,'寄生种子') # a = Pokemon('妙蛙种子',45,49,49,45,65,65,'寄生种子')
# b = Pokemon('小火龙',39,52,43,65,60,50,'火花') # b = Pokemon('小火龙',39,52,43,65,60,50,'火花')
......
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