Erreur ?
Résolu
Jou
-
Phil_1857 Messages postés 1872 Date d'inscription Statut Membre Dernière intervention -
Phil_1857 Messages postés 1872 Date d'inscription Statut Membre Dernière intervention -
import random class Pokemon: def __init__(self, nom, type1, type2, hp, atk, df, spatk, spdf, spd, move1, move2, move3, move4): self.nom = nom self.type1 = type1 self.type2 = type2 self.hp = hp self.atk = atk self.df = df self.spatk = spatk self.spdf = spdf self.spd = spd self.move1 = move1 self.move2 = move2 self.move3 = move3 self.move4 = move4 class Move: def __init__(self, nom, form, typ, pwr): self.nom = nom self.form = form self.typ = typ self.pwr = pwr Flamethrower = Move("Flamethrower", "Special", "Feu", 90) Slash = Move("Slash", "Physical", "Normal", 70) Air_Slash = Move("Air Slash", "Special", "Flying", 75) Feu_Fang = Move("Feu Fang", "Physical", "Feu", 65) 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) DGriffe = Move("Draco-Griffe", "Special", "Feu", 80) DCharge = Move("Draco-Charge", "Physical", "Eau", 100) Jet = Move("Jet de sable", "Physical", "Flying", 100) Morsure = Move("Morsure", "Normal", "Plante", 60) Ombre = Move("Ombre portée", "Physical", "Plante", 87), DSouffle = Move("Draco-Souffle", "Physical", "Feu", 110) PvrA = Move("Pouvoir Antique", "Special", "Flying", 111) Chatiment = Move("Chatiment", "Physical", "Plante", 112) Pok1 = Pokemon("Dracaufeu", "Feu", "Flying", 185, 149, 143, 177, 150, 167, Flamethrower, Air_Slash, Feu_Fang, Slash) Pok2 = Pokemon("Blastoise", "Eau", None, 186, 148, 167, 150, 172, 143, Eau_Pulse, Aqua_Tail, Bite, Rapid_Spin) Pok3 = Pokemon("Venusaur", "Plante", "Poison", 187, 147, 148, 167, 167, 145, Seed_Bomb, Sludge_Bomb, Double_Edge, Razor_Leaf) Pok4 = Pokemon("Carchacrok", "Sol", "Dragon", 108, 95, 130, 180, 130, 190, DGriffe, DCharge, Jet, Morsure) Pok5 = Pokemon("Giratina", "Spectre", "Dragon", 150, 120, 100, 150, 130, 170, Ombre, DSouffle, PvrA, Chatiment) def PokAttack(pok1, pok2, move): critChance = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.5] randDamage = [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": damage = (((22 * dmg * (pok1.atk / pok2.df)) / 50) + 2) * random.choice(critChance) * ( random.choice(randDamage)) * STABdmg else: damage = (((22 * dmg * (pok1.spatk / pok2.spdf)) / 50) + 2) * random.choice(critChance) * ( random.choice(randDamage)) * STABdmg if move.typ == "Feu" and pok2.type1 == "Eau": damage *= 0.5 if move.typ == "Feu" and pok2.type1 == "Plante": damage *= 1.8 if move.typ == "Feu" and pok2.type1 == "Feu": damage *= 0.5 if move.typ == "Plante" and pok2.type1 == "Eau": damage *= 1.8 if move.typ == "Plante" and pok2.type1 == "Flying": damage *= 0.5 if move.typ == "Plante" and pok2.type1 == "Plante": damage *= 0.5 if move.typ == "Plante" and pok2.type1 == "Feu": damage *= 0.5 if move.typ == "Eau" and pok2.type1 == "Eau": damage *= 0.5 if move.typ == "Eau" and pok2.type1 == "Plante": damage *= 0.5 if move.typ == "Eau" and pok2.type1 == "Feu": damage *= 1.8 if move.typ == "Flying" and pok2.type1 == "Plante": damage *= 1.8 damage = round(damage, 0) damage = int(damage / 100) print(f'{pok1.nom} used {move.nom}') pok2.hp -= damage print(f"{pok2.nom} takes {damage} damage !") if pok2.hp <= 0: gamestate = 1 pok2.hp = 0 print(f'{pok2.nom} has {pok2.hp} HP left. \n') return gamestate party = [] pokedex = [Pok1, Pok2, Pok3, Pok4, Pok5] print(f'Please choose a Pokemon to use: (1) {Pok1.nom} (2) {Pok2.nom} (3) {Pok3.nom} (4) {Pok4.nom} (5) {Pok5.nom} ') pokemonChoice = int(input()) if pokemonChoice == 1: party.append(Pok1) print(f"You have chosen {Pok1.nom}.") elif pokemonChoice == 2: party.append(Pok2) print(f"You have chosen {Pok2.nom}.") elif pokemonChoice == 3: party.append(Pok3) print(f"You have chosen {Pok3.nom}.") elif pokemonChoice == 4: party.append(Pok4) print(f"Vous avez choisi {Pok4.nom}.") elif pokemonChoice == 5: party.append(Pok5) print(f"Vous avez choisi {Pok5.nom}.") else: choicelol = random.choice(pokedex) party.append(choicelol) print(f'Invalid input. Random Pokemon chosen... {choicelol.nom}.\n') print( f'Please choose a Pokemon to battle against: (1) {Pok1.nom} (2) {Pok2.nom} (3) {Pok3.nom} (4) {Pok4.nom} (5) {Pok5.nom} ') pokemonChoice2 = int(input()) if pokemonChoice2 == 1: party.append(Pok1) print(f"You have chosen to battle {Pok1.nom}.") elif pokemonChoice2 == 2: party.append(Pok2) print(f"You have chosen to battle {Pok2.nom}.") elif pokemonChoice2 == 3: party.append(Pok3) print(f"You have chosen to battle {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}.") else: choicelol = random.choice(pokedex) party.append(choicelol) print(f'Invalide. Un Pokémon random a été choisi... {choicelol.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("ta gagné! c fini") elif gamestate == 2: print("t nul! C fini")
Salut ! voici mon code Pokemon. J'ai rajouté Giratina et Carchacrok, mais lorsqu'on commence à jouer, si on sélectionne un de ces 2 pokemon, ca affiche une erreur ensuite, mais je ne la trouve pas . Quelqu'un pourrait me l'expliquer svp
A voir également:
- Erreur ?
- Erreur 0x80070643 - Accueil - Windows
- Erreur 0x80070643 Windows 10 : comment résoudre le problème de la mise à jour KB5001716 - Accueil - Windows
- J'aime par erreur facebook notification - Forum Facebook
- Code erreur f3500-31 ✓ - Forum Bbox Bouygues
- Java code erreur 1603 ✓ - Forum Windows
3 réponses
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 584
bonjour,
regarde bien à la fin de la ligne 45.
UPDATE :
le code fonctionne quand on utilise Carchacrok comme poké de base, par contre, avec le dernier, Giratina, ca ne marche pas. Voici l'erreur formulée :
line 234, in <module>
f"Choisir un mouvement: (1) {party[0].move1.nom} (2) {party[0].move2.nom} (3) {party[0].move3.nom} (4) {party[0].move4.nom}")
AttributeError: 'tuple' object has no attribute 'nom
Merci :)
wooo ça marche !! merci !!!