Memo

デジタルと建築と音楽

Post_008

180410

 

import random as rnd
class Pokemon:

def __init__(self, No):
self.lv = 0

if No == 25:
self.name = "Pikachu"
elif No == 151:
self.name = "Myu"
else:
self.name = "Ketsuban"

self.hp = rnd.randint(50,100)
self.attack = rnd.randint(10,20)

def callback(self):
print '--------------'
print 'Lv.' , self.lv
print self.name
if self.hp < 0:
print 'HP' , 0
else:
print 'HP' , self.hp

print 'Attack' , self.attack

def AT(self,diffence):
diffence.hp -= self.attack

def Battle(self,diffence) :

for i in range(100):
print '-----------'
print self.name, 'の攻撃'
print self.attack, 'のダメージ'
diffence.hp -= self.attack

if diffence.hp < 0 :
print self.name, 'は倒れた'
break

else :

print '-----------'
print diffence.name, 'の攻撃'
print diffence.attack, 'のダメージ'
self.hp -= diffence.attack

if self.hp < 0 :
print diffence.name, 'は倒れた'
break

self.callback()
diffence.callback()

pokemon1 = Pokemon(25)
pokemon2 = Pokemon(151)

pokemon1.callback()
pokemon2.callback()

pokemon1.Battle(pokemon2)