Advertisement
Falexom

Untitled

Jul 1st, 2023
1,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.98 KB | None | 0 0
  1. ### base
  2. import random
  3.  
  4.  
  5. class Pokemon:
  6.     def __init__(self, hp, defense, special_defense):
  7.         self.hp = hp
  8.         self.defense = defense
  9.         self.special_defense = special_defense
  10.  
  11.  
  12. class PhysicalAttack(Pokemon):
  13.     def __init__(self, damage, hp, defense,  special_defense):
  14.         super().__init__(hp,  defense, special_defense)
  15.         self.damage = damage
  16.  
  17.     def attack(self):
  18.         if self.defense > 50:
  19.             self.damage = random.randint(10, 30)
  20.             self.hp -= self.damage
  21.         else:
  22.             self.damage = random.randint(40, 50)
  23.             self.hp -= self.damage
  24.  
  25.  
  26. class Status(Pokemon):
  27.     def __init__(self, status, hp,  defense,  special_defense):
  28.         super().__init__(hp,  defense,  special_defense)
  29.         self.status = status
  30.  
  31.     def status(self):
  32.         return self.hp
  33.  
  34.  
  35. class SpecialAttack(Pokemon):
  36.     def __init__(self, damage, hp, defense,  special_defense):
  37.         super().__init__(hp,  defense,  special_defense)
  38.         self.damage = damage
  39.  
  40.     def attack(self):
  41.         if self.special_defense > 50:
  42.             self.damage = random.randint(25, 30)
  43.             self.hp -= self.damage
  44.         else:
  45.             self.damage = random.randint(70, 80)
  46.             self.hp -= self.damage
  47.  
  48.  
  49. class Upgrade(Pokemon):
  50.     def __init__(self, hp, defense, special_defense):
  51.         super().__init__(hp, defense, special_defense)
  52.  
  53.     def upgrade(self):
  54.         self.hp += 100
  55.  
  56. ### battle
  57. import time
  58.  
  59. from pokemons import *
  60. import random
  61.  
  62.  
  63. class Battle:
  64.     def attack(self, attacker, pokemon):
  65.         PhysicalAttack.attack(pokemon)
  66.         print(f'{attacker.name} attacks {pokemon.name}! Pokemons hp {pokemon.hp}!')
  67.  
  68.     def special_attack(self, attacker, pokemon):
  69.         SpecialAttack.attack(pokemon)
  70.         print(f'{attacker.name} attacks by special attack {pokemon.name}!  Pokemons hp {pokemon.hp}!')
  71.  
  72.     def status(self, pokemon1, pokemon2):
  73.         hp1 = Status.status(pokemon1)
  74.         hp2 = Status.status(pokemon2)
  75.         print(f'{pokemon1.name} is {hp1}, {pokemon2.name} is {hp2}')
  76.  
  77.     def upgrade(self, pokemon):
  78.         Upgrade.upgrade(pokemon)
  79.         print(f'{pokemon.name} has an upgrade!')
  80.  
  81.  
  82. b = Battle()
  83. battle_list = [b.attack, b.special_attack]
  84. dragonite = Dragonite('Dragonite', 300, 30, 20)
  85. mismagius = Mismagius('Mismagius', 250, 60, 50)
  86.  
  87. flag = 1
  88. first_player_count = 0
  89. second_player_count = 0
  90.  
  91. while True:
  92.     if dragonite.hp <= 0 or mismagius.hp <= 0:
  93.         break
  94.  
  95.     if first_player_count >= 20:
  96.         b.upgrade(dragonite)
  97.         first_player_count = 0
  98.     if second_player_count >= 20:
  99.         b.upgrade(mismagius)
  100.         second_player_count = 0
  101.  
  102.     if flag == 1:
  103.         attack = random.choice(battle_list)
  104.         if attack == b.attack:
  105.             b.attack(dragonite, mismagius)
  106.             first_player_count += random.randint(1, 10)
  107.             flag = 2
  108.  
  109.         if attack == b.special_attack:
  110.             b.attack(dragonite, mismagius)
  111.             first_player_count += random.randint(1, 10)
  112.             flag = 2
  113.  
  114.     if flag == 2:
  115.         attack = random.choice(battle_list)
  116.         if attack == b.attack:
  117.             b.attack(mismagius, dragonite)
  118.             second_player_count += random.randint(1, 10)
  119.             flag = 1
  120.         if attack == b.special_attack:
  121.             b.attack(mismagius, dragonite)
  122.             second_player_count += random.randint(1, 10)
  123.             flag = 1
  124.  
  125.     b.status(dragonite, mismagius)
  126.     time.sleep(1)
  127.  
  128. if mismagius.hp <= 0:
  129.     print('Dragonite won!')
  130.  
  131. if dragonite.hp <= 0:
  132.     print('Misamagius won!')
  133.  
  134. ### pokemons
  135. from base import *
  136.  
  137.  
  138. class Dragonite(Pokemon):
  139.     def __init__(self, name, hp, defense,  special_defense):
  140.         super().__init__(hp,  defense,  special_defense)
  141.         self.name = name
  142.  
  143.  
  144. class Mismagius(Pokemon):
  145.     def __init__(self, name, hp, defense, special_defense):
  146.         super().__init__(hp, defense, special_defense)
  147.         self.name = name
  148.  
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement