Utilisateur anonyme
-
8 févr. 2023 à 12:03
Utilisateur anonyme -
8 févr. 2023 à 14:17
Re - bonjour
j'avais deja posé une question y a moins d'1 jour, et j'ai eu ma solution (encore merci)
Cette fois ci j'ai rajouté un pokemon mais pareil j'ai encore un problème :
dès que on sélectionne Zoroak pour se battre avec lui, ça m'affiche une erreur. Idem si on le selectionne comme adversaire
Traceback (most recent call last):
line 254, in <module>
if PokAttack(party[1], party[0], party[1].move4) == 1:
line 74, in PokAttack
if move.typ == pok1.type1:
AttributeError: 'tuple' object has no attribute 'typ'
(code)
import random
print('--- Bienvenue dans notre Battle Pokemon ! --- ')
print('-- Vous aurez 6 pokemon a votre disposition -- ')
print('- Prenez le meilleur, gagnez tous vos fights ! -')
print(
"")
class Pokemon:
def __init__(self, nom, type1, type2, pv, atk, df, spatk, spdf, spd, move1, move2, move3, move4):
self.nom = nom
self.type1 = type1
self.type2 = type2
self.pv = pv
self.atk = atk
self.df = df
self.move1 = move1
self.move2 = move2
self.move3 = move3
self.move4 = move4
self.spatk = spatk
self.spdf = spdf
self.spd = spd
class Move:
def __init__(self, nom, form, typ, pwr):
self.nom = nom
self.form = form
self.typ = typ
self.pwr = pwr
Aqua_Tail = Move("Aqua Tail", "Physical", "Eau", 90)
Eau_Pulse = Move("Eau Pulse", "Special", "Eau", 60)
Bite = Move("Bite", "Physical", "Dark", 60)
Rapid_Spin = Move("Rapid Spin", "Physical", "Normal", 50)
Seed_Bomb = Move("Seed Bomb", "Physical", "Plante", 60)
Sludge_Bomb = Move("Sludge Bomb", "Special", "Poison", 90)
Razor_Leaf = Move("Razor Leaf", "Physical", "Plante", 55)
Double_Edge = Move("Double Edge", "Physical", "Normal", 120)
Flamethrower = Move("Flamethrower", "Special", "Feu", 90)
Slash = Move("Slash", "Physical", "Normal", 70)
Air_Slash = Move("Air Slash", "Special", "Vol", 75)
Feu_Fang = Move("Feu Fang", "Physical", "Feu", 65)
DGriffe = Move("Draco-Griffe", "Special", "Feu", 80)
DCharge = Move("Draco-Charge", "Physical", "Eau", 100)
Jet = Move("Jet de sable", "Physical", "Vol", 100)
Morsure = Move("Morsure", "Normal", "Plante", 60)
Ombre = Move("Ombre portée", "Physical", "Plante", 87)
DSouffle = Move("Draco-Souffle", "Physical", "Feu", 60)
PvrA = Move("Pouvoir Antique", "Special", "Vol", 100)
Chatiment = Move("Chatiment", "Physical", "Plante", 65)
Tranche_Nuit = Move("Tranche Nuit", "Physical", "Tenebres", 100)
Tricherie = Move("Tricherie", "Physical", "Tenebres", 100)
Ultralaser = Move("Ultralaser", "Special", "Normal", 90)
Explonuit =("Explonuit", "Special", "Tenebres", 95)
Pok1 = Pokemon("Blastoise", "Eau", None, 186, 148, 167, 150, 172, 143, Eau_Pulse, Aqua_Tail, Bite, Rapid_Spin)
Pok2 = Pokemon("Dracaufeu", "Feu", "Vol", 185, 149, 143, 177, 150, 167, Flamethrower, Air_Slash, Feu_Fang, Slash)
Pok3 = Pokemon("Carchacrok", "Sol", "Dragon", 108, 95, 130, 180, 130, 190, DGriffe, DCharge, Jet, Morsure)
Pok4 = Pokemon("Venusaur", "Plante", "Poison", 187, 147, 148, 167, 167, 145, Seed_Bomb, Sludge_Bomb, Double_Edge, Razor_Leaf)
Pok5 = Pokemon("Giratina", "Spectre", "Dragon", 150, 120, 100, 150, 130, 170, Ombre, DSouffle, PvrA, Chatiment)
Pok6 = Pokemon("Zoroak", "Tenebres", None, 120, 105, 60, 110, 140, 105, Tranche_Nuit, Tricherie, Ultralaser, Explonuit)
def PokAttack(pok1, pok2, move):
critChance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5]
randDegats = [85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
STABdmg = 1
gamestate = 0
if move.typ == pok1.type1:
STABdmg = 1.5
elif move.typ == pok1.type2:
STABdmg = 1.5
else:
pass
dmg = move.pwr
if move.form == "Physical":
degats = (((24 * dmg * (pok1.atk / pok2.df)) / 50) + 2) * random.choice(critChance) * (
random.choice(randDegats)) * STABdmg
else:
degats = (((24 * dmg * (pok1.spatk / pok2.spdf)) / 50) + 2) * random.choice(critChance) * (
random.choice(randDegats)) * STABdmg
if move.typ == "Feu" and pok2.type1 == "Eau":
degats *= 0.5
if move.typ == "Feu" and pok2.type1 == "Plante":
degats *= 1.8
if move.typ == "Feu" and pok2.type1 == "Feu":
degats *= 0.5
if move.typ == "Feu" and pok2.type1 == "Tenebres":
degats *= 0.5
if move.typ == "Plante" and pok2.type1 == "Eau":
degats *= 1.8
if move.typ == "Plante" and pok2.type1 == "Vol":
degats *= 0.5
if move.typ == "Plante" and pok2.type1 == "Tenebres":
degats *= 0.8
if move.typ == "Plante" and pok2.type1 == "Plante":
degats *= 0.5
if move.typ == "Plante" and pok2.type1 == "Feu":
degats *= 0.5
if move.typ == "Eau" and pok2.type1 == "Eau":
degats *= 0.5
if move.typ == "Eau" and pok2.type1 == "Tenebres":
degats *= 1.8
if move.typ == "Eau" and pok2.type1 == "Plante":
degats *= 0.5
if move.typ == "Eau" and pok2.type1 == "Feu":
degats *= 1.8
if move.typ == "Vol" and pok2.type1 == "Plante":
degats *= 1.8
if move.typ == "Vol" and pok2.type1 == "Tenebres":
degats *= 0.5
if move.typ == "Tenebres" and pok2.type1 == "Plante":
degats *= 1.8
if move.typ == "Tenebres" and pok2.type1 == "Feu":
degats *= 0.8
if move.typ == "Tenebres" and pok2.type1 == "Eau":
degats *= 1.8
if move.typ == "Tenebres" and pok2.type1 == "Vol":
degats *= 0.8
if move.typ == "Tenebres" and pok2.type1 == "Plante":
degats *= 1.8
degats = round(degats, 0)
degats = int(degats / 100)
print(f'{pok1.nom} a utilisé {move.nom}')
pok2.pv -= degats
print(f"{pok2.nom} a pris {degats} de degats !!")
if pok2.pv <= 0:
gamestate = 1
pok2.pv = 0
print(f'{pok2.nom} a perdu {pok2.pv} PV. \n')
return gamestate
party = []
pokedex = [Pok1, Pok2, Pok3, Pok4, Pok5, Pok6]
print(f'Choisissez votre Pokemon: (1) {Pok1.nom} (2) {Pok2.nom} (3) {Pok3.nom} (4) {Pok4.nom} (5) {Pok5.nom} (6) {Pok6.nom} ')
pokemonChoice = int(input())
if pokemonChoice == 1:
party.append(Pok1)
print(f"Vous avez choisi {Pok1.nom}.")
elif pokemonChoice == 2:
party.append(Pok2)
print(f"{Pok2.nom} a été sélectionné.")
elif pokemonChoice == 3:
party.append(Pok3)
print(f"Vous avez sélectionné {Pok3.nom}.")
elif pokemonChoice == 4:
party.append(Pok4)
print(f"Vous avez {Pok4.nom} en votre possession.")
elif pokemonChoice == 5:
party.append(Pok5)
print(f"Vous vous battrez avec {Pok5.nom}.")
elif pokemonChoice == 6:
party.append(Pok6)
print(f"{Pok6.nom} a été sélectionné.")
else:
choice = random.choice(pokedex)
party.append(choice)
print(f'Invalide. Un pokémon est choisi au hasard... {choice.nom}.\n')
print(
f'Choisissez votre adversaire : (1) {Pok1.nom} (2) {Pok2.nom} (3) {Pok3.nom} (4) {Pok4.nom} (5) {Pok5.nom} (6) {Pok6.nom} ')
pokemonChoice2 = int(input())
if pokemonChoice2 == 1:
party.append(Pok1)
print(f"Vous avez choisi de vous battre contre {Pok1.nom}.")
elif pokemonChoice2 == 2:
party.append(Pok2)
print(f"Vous avez choisi de vous battre contre {Pok2.nom}.")
elif pokemonChoice2 == 3:
party.append(Pok3)
print(f"Vous avez choisi de vous battre contre {Pok3.nom}.")
elif pokemonChoice2 == 4:
party.append(Pok4)
print(f"Vous avez choisi de vous battre contre {Pok4.nom}.")
elif pokemonChoice2 == 5:
party.append(Pok5)
print(f"Vous avez choisi de vous battre contre {Pok5.nom}.")
elif pokemonChoice2 == 6:
party.append(Pok6)
print(f"Vous avez choisi de vous battre contre {Pok6.nom}.")
else:
choice = random.choice(pokedex)
party.append(choice)
print(f'Invalide. Un Pokémon random a été choisi... {choice.nom}.\n')
gamestate = 0
while gamestate == 0:
if party[0].spd >= party[1].spd:
print(
f"Choisir un mouvement: (1) {party[0].move1.nom} (2) {party[0].move2.nom} (3) {party[0].move3.nom} (4) {party[0].move4.nom}")
moveChoice1 = int(input())
if moveChoice1 == 1:
if PokAttack(party[0], party[1], party[0].move1) == 1:
gamestate = 1
elif moveChoice1 == 2:
if PokAttack(party[0], party[1], party[0].move2) == 1:
gamestate = 1
elif moveChoice1 == 3:
if PokAttack(party[0], party[1], party[0].move3) == 1:
gamestate = 1
elif moveChoice1 == 4:
if PokAttack(party[0], party[1], party[0].move4) == 1:
gamestate = 1
if gamestate != 1:
randMove = random.randint(1, 4)
if randMove == 1:
if PokAttack(party[1], party[0], party[1].move1) == 1:
gamestate = 2
elif randMove == 2:
if PokAttack(party[1], party[0], party[1].move2) == 1:
gamestate = 2
elif randMove == 3:
if PokAttack(party[1], party[0], party[1].move3) == 1:
gamestate = 2
elif randMove == 4:
if PokAttack(party[1], party[0], party[1].move4) == 1:
gamestate = 2
else:
randMove = random.randint(1, 4)
if randMove == 1:
if PokAttack(party[1], party[0], party[1].move1) == 1:
gamestate = 2
elif randMove == 2:
if PokAttack(party[1], party[0], party[1].move2) == 1:
gamestate = 2
elif randMove == 3:
if PokAttack(party[1], party[0], party[1].move3) == 1:
gamestate = 2
elif randMove == 4:
if PokAttack(party[1], party[0], party[1].move4) == 1:
gamestate = 2
if gamestate != 2:
print(
f"Choisir un mouvement: (1) {party[0].move1.nom} (2) {party[0].move2.nom} (3) {party[0].move3.nom} (4) {party[0].move4.nom}")
moveChoice2 = int(input())
if moveChoice2 == 1:
if PokAttack(party[0], party[1], party[0].move1) == 1:
gamestate = 1
elif moveChoice2 == 2:
if PokAttack(party[0], party[1], party[0].move2) == 1:
gamestate = 1
elif moveChoice2 == 3:
if PokAttack(party[0], party[1], party[0].move3) == 1:
gamestate = 1
elif moveChoice2 == 4:
if PokAttack(party[0], party[1], party[0].move4) == 1:
gamestate = 1
if gamestate == 1:
print("c'est gagné")
elif gamestate == 2:
print("c'est fini - défaite")