Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### base
- import random
- class Pokemon:
- def __init__(self, hp, defense, special_defense):
- self.hp = hp
- self.defense = defense
- self.special_defense = special_defense
- class PhysicalAttack(Pokemon):
- def __init__(self, damage, hp, defense, special_defense):
- super().__init__(hp, defense, special_defense)
- self.damage = damage
- def attack(self):
- if self.defense > 50:
- self.damage = random.randint(10, 30)
- self.hp -= self.damage
- else:
- self.damage = random.randint(40, 50)
- self.hp -= self.damage
- class Status(Pokemon):
- def __init__(self, status, hp, defense, special_defense):
- super().__init__(hp, defense, special_defense)
- self.status = status
- def status(self):
- return self.hp
- class SpecialAttack(Pokemon):
- def __init__(self, damage, hp, defense, special_defense):
- super().__init__(hp, defense, special_defense)
- self.damage = damage
- def attack(self):
- if self.special_defense > 50:
- self.damage = random.randint(25, 30)
- self.hp -= self.damage
- else:
- self.damage = random.randint(70, 80)
- self.hp -= self.damage
- class Upgrade(Pokemon):
- def __init__(self, hp, defense, special_defense):
- super().__init__(hp, defense, special_defense)
- def upgrade(self):
- self.hp += 100
- ### battle
- import time
- from pokemons import *
- import random
- class Battle:
- def attack(self, attacker, pokemon):
- PhysicalAttack.attack(pokemon)
- print(f'{attacker.name} attacks {pokemon.name}! Pokemons hp {pokemon.hp}!')
- def special_attack(self, attacker, pokemon):
- SpecialAttack.attack(pokemon)
- print(f'{attacker.name} attacks by special attack {pokemon.name}! Pokemons hp {pokemon.hp}!')
- def status(self, pokemon1, pokemon2):
- hp1 = Status.status(pokemon1)
- hp2 = Status.status(pokemon2)
- print(f'{pokemon1.name} is {hp1}, {pokemon2.name} is {hp2}')
- def upgrade(self, pokemon):
- Upgrade.upgrade(pokemon)
- print(f'{pokemon.name} has an upgrade!')
- b = Battle()
- battle_list = [b.attack, b.special_attack]
- dragonite = Dragonite('Dragonite', 300, 30, 20)
- mismagius = Mismagius('Mismagius', 250, 60, 50)
- flag = 1
- first_player_count = 0
- second_player_count = 0
- while True:
- if dragonite.hp <= 0 or mismagius.hp <= 0:
- break
- if first_player_count >= 20:
- b.upgrade(dragonite)
- first_player_count = 0
- if second_player_count >= 20:
- b.upgrade(mismagius)
- second_player_count = 0
- if flag == 1:
- attack = random.choice(battle_list)
- if attack == b.attack:
- b.attack(dragonite, mismagius)
- first_player_count += random.randint(1, 10)
- flag = 2
- if attack == b.special_attack:
- b.attack(dragonite, mismagius)
- first_player_count += random.randint(1, 10)
- flag = 2
- if flag == 2:
- attack = random.choice(battle_list)
- if attack == b.attack:
- b.attack(mismagius, dragonite)
- second_player_count += random.randint(1, 10)
- flag = 1
- if attack == b.special_attack:
- b.attack(mismagius, dragonite)
- second_player_count += random.randint(1, 10)
- flag = 1
- b.status(dragonite, mismagius)
- time.sleep(1)
- if mismagius.hp <= 0:
- print('Dragonite won!')
- if dragonite.hp <= 0:
- print('Misamagius won!')
- ### pokemons
- from base import *
- class Dragonite(Pokemon):
- def __init__(self, name, hp, defense, special_defense):
- super().__init__(hp, defense, special_defense)
- self.name = name
- class Mismagius(Pokemon):
- def __init__(self, name, hp, defense, special_defense):
- super().__init__(hp, defense, special_defense)
- self.name = name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement