-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpokemon.py
More file actions
57 lines (45 loc) · 1.6 KB
/
Copy pathpokemon.py
File metadata and controls
57 lines (45 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import random
class Pokemon:
def __init__(self, especie, level=None, nome=None):
self.especie = especie
self.level = level
if level:
self.level = level
else:
self.level = random.randint(1, 100)
if nome:
self.nome = nome
else:
self.nome = especie
self.ataque = self.level * 5
self.vida = self.level * 10
def __str__(self):
return "{}({})".format(self.nome, self.level)
def atacar(self, pokemon):
ataqueEfetivo = int((self.ataque * random.random() * 1.3))
pokemon.vida -= ataqueEfetivo
print("{} perdeu {} de vida".format(pokemon, ataqueEfetivo))
if pokemon.vida <= 0:
print("{} perdeu a batalha".format(pokemon))
return True
else:
return False
def defesa(self,pokemon):
print("{} defendeu {}".format(self.tipo, pokemon.tipo))
def fugiu(self,pokemon):
print("O Pokemon {} fugiu, {} ganhou".format(self.tipo, pokemon.tipo, self.especie))
class PokemonEletrico(Pokemon):
tipo = 'Elerico'
def atacar(self, pokemon):
print("{} atacou massivamente o {}".format(self, pokemon))
return super().atacar(pokemon)
class PokemonFogo(Pokemon):
tipo = 'Fogo'
def atacar(self, pokemon):
print("{} atacou com FOGO o {}".format(self, pokemon))
return super().atacar(pokemon)
class PokemonAgua(Pokemon):
tipo = 'Agua'
def atacar(self, pokemon):
print("{} atacou com jato de Agua o {}".format(self, pokemon))
return super().atacar(pokemon)