#colocar teste
import pokemons
import random
import copy
import pygame
import json


def init(): #inicializa todas as variaveis nessecarias para o sistema de batalha

    pygame.init()

    #inicializa ataques
    atakdex = []
    tackle = pokemons.atack("tackle",40,"Normal"," ",1/24,1,40) 
    atakdex.append(tackle)
    quickAttack = pokemons.atack("quick attack",40,"Normal",["priority"],1/24,1,40) 
    atakdex.append(quickAttack)
    ember = pokemons.atack("ember",40,"Fogo",["burn",0.1],1/24,1,40) 
    atakdex.append(ember)
    thunder = pokemons.atack("thunder",110,"Eletrico",["paralize",0.3],1/24,0.7,10) 
    atakdex.append(thunder)
    flamethrower  = pokemons.atack("Flamethrower ",90,"Fogo",["burn",0.1],1/24,0.7,10) 
    atakdex.append(flamethrower)
    splash = pokemons.atack("splash",0,"Normal"," ",0,1,40) 
    atakdex.append(splash)
    thunderWave = pokemons.atack("thunder wave",0,"Eletrico",["paralize",1],0,0.9,40) 
    atakdex.append(thunderWave)
    thunderShock = pokemons.atack("thunder shock",40,"Eletrico",["paralize",0.1],1/24,1,30) 
    atakdex.append(thunderShock)
    scratch = copy.copy(tackle)
    scratch.nome = "scratch"
    atakdex.append(scratch)
    aerialAce  = pokemons.atack("aerial ace ",110,"Voador"," ",1/24,1,15) 
    atakdex.append(aerialAce)
    hydroPump  = pokemons.atack("hydro pump",110,"Agua"," ",1/24,0.8,5) 
    atakdex.append(hydroPump)
    aquaTail  = pokemons.atack("aqua tail",90,"Agua"," ",1/24,0.9,10) 
    atakdex.append(aquaTail)
    bite  = pokemons.atack("bite",60,"Escuro"," ",1/24,1,25) 
    atakdex.append(bite)
    powerWhip  = pokemons.atack("power whip",120,"Grama"," ",1/24,0.85,10) 
    atakdex.append(powerWhip)
    powerWhip  = pokemons.atack("power whip",120,"Grama"," ",1/24,0.85,10) 
    atakdex.append(powerWhip)
    poisonPowder = pokemons.atack("poison powder",0,"Veneno",["poison",1],0,0.75,40) 
    atakdex.append(poisonPowder)
    seedBomb  = pokemons.atack("seed bomb",80,"Grama"," ",1/24,1,15) 
    atakdex.append(seedBomb)
    poisonJab  = pokemons.atack("poison jab",80,"Grama",["poison",0.3],1/24,1,20) 
    atakdex.append(poisonJab)
    firePunch = pokemons.atack("fire punch",75,"Fogo",["burn",0.1],1/24,1,15) 
    atakdex.append(firePunch)
    wingAttack= pokemons.atack("wing attack",75,"Voador"," ",1/24,1,35) 
    atakdex.append(wingAttack)
    dragonTail= pokemons.atack("dragon tail",75,"Dragao"," ",1/24,0.9,10) 
    atakdex.append(dragonTail)
    extremeSpeed= pokemons.atack("extreme speed",80,"Normal",["priority"],1/24,1,5) 
    atakdex.append(extremeSpeed)
    shadowBall= pokemons.atack("shadow ball",80,"Fantasma"," ",1/24,1,15) 
    atakdex.append(shadowBall)
    darkPulse= pokemons.atack("dark pulse",80,"Escuro"," ",1/24,1,15) 
    atakdex.append(darkPulse)
    lick= pokemons.atack("lick",30,"Fantasma",["paralize",0.3],1/24,1,30) 
    atakdex.append(lick)
    shadowPunch= pokemons.atack("shadow punch",60,"Fantasma"," ",1/24,1,20) 
    atakdex.append(shadowPunch)
    hurricane = pokemons.atack("hurricane",110,"Voador",["paralize",0.3],1/24,0.7,10) 
    atakdex.append(hurricane)
    crunch  = pokemons.atack("crunch",80,"Escuro"," ",1/24,1,15) 
    atakdex.append(crunch)
    bodySlam = pokemons.atack("body slam",80,"Normal",["paralize",0.3],1/24,1,15) 
    atakdex.append(bodySlam)
    psychic = pokemons.atack("psychic",90,"Psiquico"," ",1/24,1,10) 
    atakdex.append(psychic)
    psychoCut = pokemons.atack("psycho cut",70,"Psiquico",' ',1/8,1,20) 
    atakdex.append(psychoCut)
    psyshock = pokemons.atack("psyshock",80,"Psiquico",' ',1/24,1,10) 
    atakdex.append(psyshock)
    thief = pokemons.atack("thief",60,"Escuro",' ',1/24,1,25) 
    atakdex.append(thief)
    ancientPower = pokemons.atack("ancient power",60,"Pedra",' ',1/24,1,10) 
    atakdex.append(ancientPower)
    stoneEdge = pokemons.atack("stone edge",100,"Pedra",' ',1/8,1,5) 
    atakdex.append(stoneEdge)
    gunkShot = pokemons.atack("gunk shot",120,"Veneno",["poison",0.3],1/24,0.8,5) 
    sludgeBomb =pokemons.atack("sludge bomb",90,"Veneno",["poison",0.3],1/24,1,10)
    thunderFang =pokemons.atack("thunder fang",65,"Eletrico",["paralize",0.3],1/24,0.95,15)
    iceBeam =pokemons.atack("ice beam",90,"Gelo",["paralize",0.1],1/24,1,10)
    blizzard =pokemons.atack("blizzard",110,"Gelo",["paralize",0.1],1/24,0.7,5)
    sheerCold = pokemons.atack("sheer cold",9999999999,"Gelo"," ",1,0.3,5)
    surf = pokemons.atack("surf",90,"Agua"," ",1,1,15)
    airSlash =pokemons.atack("air slash",75,"Voador"," ",1,0.95,15)
    poisonFang = pokemons.atack("poison fang",65,"Veneno",["posion",0.3],1/24,0.95,15)
    thunderPunch = pokemons.atack("thunder punch",75,"Eletrico",["paralize",0.1],1/24,1,15)
    megaPunch = pokemons.atack('mega punch', 80, 'Lutador', ' ', 1/24, 0.85, 20)
    auraSphere =pokemons.atack("aura sphere", 80,"Lutador",' ',1/24, 1, 20)
    psychicNoise = pokemons.atack('psychic noise', 75, 'Psiquico', ' ', 1/24, 1, 10)
    zapCannon = pokemons.atack('zap cannon', 120, 'Eletrico', ["paralize", 1], 1/24, 0.5, 5)
    discharge = pokemons.atack('discharge', 80, 'Eletrico', ["paralize", 0.3], 1/24, 1, 15)
    flashCannon = pokemons.atack('flash cannon', 80, 'Metal', ' ', 1/24, 1, 10)
    closeCombat = pokemons.atack('close combat', 120, 'Lutador', ' ', 1/24, 1, 5)
    strength = pokemons.atack('strenght', 80, 'Normal', ' ', 1/24, 1, 15)
    crossChop = pokemons.atack('cross chop', 100, 'Lutador', ' ', 1/8, 0.8, 5)
    brickBreak = pokemons.atack('brick break', 75, 'Lutador', ' ', 1/24, 1, 15)
    waterPulse = pokemons.atack('water pulse', 90, 'Agua', ' ', 1/24, 1, 10)
    axeKick = pokemons.atack('axe kick', 120, 'Lutador', ' ', 1/24, 0.9, 10)
    megaKick = pokemons.atack('mega kick', 120, 'Normal', ' ', 1/24, 0.75, 5)
    suckerPunch = pokemons.atack('sucker punch', 70, 'Escuro', ["priority"], 1/24, 1, 5)
    icePunch = pokemons.atack('ice punch', 75, 'Gelo', ' ', 1/24, 1, 15)
    covet = pokemons.atack('covet', 60, 'Normal', ' ', 1/24, 1, 25)
    rockTomb =  pokemons.atack('rock tomb', 60, 'Pedra', ' ', 1/24, 0.95, 15)
    psystrike = pokemons.atack('psystrike', 100, 'Psiquico', ' ', 1/24, 1, 10)
    rockThrow = pokemons.atack('rock throw', 50, 'Pedra', ' ', 1/24, 0.9, 15)
    bulldoze = pokemons.atack('bulldoze', 60, 'Terrestre', ' ', 1/24, 1, 20)
    flareBlitz = pokemons.atack('flare blitz', 120, 'Fogo', ['burn', 0.1], 1/24, 1, 15)
    lavaPlume = pokemons.atack('lava plume', 80, 'Fogo', ['burn', 0.3], 1/24, 1, 15)
    doubleKick = pokemons.atack('double kick', 60, 'Lutador', ' ', 1/24, 1, 30)
    auroraBeam = pokemons.atack('aurora beam', 65, 'Gelo', ' ', 1/24, 1, 20)
    muddyWater = pokemons.atack('muddy water', 90, 'Agua', ' ', 1/24, 0.85, 10)
    earthquake = pokemons.atack('earthquake', 100, 'Terrestre', ' ', 1/24, 1, 10)
    uproar = pokemons.atack('uproar', 90, 'Normal', ' ', 1/24, 1, 10)
    leafStorm = pokemons.atack('leaf storm', 130, 'Grama', ' ', 1/24, 0.9, 5)
    zenHeadbutt = pokemons.atack('zen headbutt', 80, 'Psiquico', ' ', 1/24, 0.9, 15)
    triAttack = pokemons.atack('tri attack', 80, 'Normal', ['paralize', 0.2], 1/24, 1, 10)
    psybeam = pokemons.atack('psybeam', 65, 'Psiquico', ' ', 1/24, 1, 20)
    outrage = pokemons.atack('outrage', 120, 'Dragao', ' ', 1/24, 0.7, 10)
    headbutt = pokemons.atack('headbutt', 70, 'Normal', ' ', 1/24, 1, 15)
    leafBlade = pokemons.atack('leaf blade', 90, 'Grama', ' ', 1/8, 1, 15)
    hornAttack = pokemons.atack('horn attack', 65, 'Normal', ' ', 1/24, 1, 25)
    superpower = pokemons.atack('superpower', 120, 'Lutador', ' ', 1/24, 1, 5)
    sludgeWave = pokemons.atack('sludge wave', 95, 'Veneno', ['poison', 0.1], 1/24, 1, 10)
    spark = pokemons.atack('spark', 65, 'Eletrico', ['paralize', 0.3], 1/24, 1, 20)
    explosion = pokemons.atack('explosion', 250, 'Normal', ' ', 1/24, 1, 5)
    hyperBeam = pokemons.atack('hyper beam', 150, 'Normal', ' ', 1/24, 0.9, 5)
    gigaImpact = pokemons.atack('giga impact', 150, 'Normal', ' ', 1/24, 0.8, 5)
    

    #effeitos poison, burn, parali, priority

    #especiais
    superSplash = pokemons.atack("super splash",9999999999999999,"Normal",["priority"],1/24,1,99) 
    atakdex.append(superSplash)
    action = pokemons.atack("action",0,"Normal"," ",0,1,0) #dex (-1)
    atakdex.append(action)
    


    #inicializa pokemons
    pokedex = []
    pikachu = pokemons.pokemon("pikachu",["Eletrico"],assets=[pygame.image.load('assets/pokemon/pikachu_frente.png'),pygame.image.load('assets/pokemon/pikachu_costas.png'),pygame.image.load('assets/pokemon/pikachu_pequeno.png')],hp = 180,atk = 103,spd=166,defesa=(94+76)/2,moveset=[copy.copy(quickAttack),copy.copy(thunder),copy.copy(thunderWave),copy.copy(thunderShock)],hability="",condition=None) #dex 0
    pokedex.append(pikachu)
    charizard = pokemons.pokemon("charizard",["Fogo","Voador"],assets=[pygame.image.load('assets/pokemon/charizard_frente.png'),pygame.image.load('assets/pokemon/charizard_costas.png'),pygame.image.load('assets/pokemon/charizard_pequeno.png')],hp = 266,atk = (155+200)/2,spd=184,defesa=(144+157)/2,moveset=[copy.copy(scratch),copy.copy(aerialAce),copy.copy(ember),copy.copy(flamethrower)],hability="",condition=None) 
    pokedex.append(charizard)
    blastoise = pokemons.pokemon('blastoise',['Agua'],assets=[pygame.image.load('assets/pokemon/blastoise_frente.png'),pygame.image.load('assets/pokemon/blastoise_costas.png'),pygame.image.load('assets/pokemon/blastoise_pequeno.png')],hp = 268,atk = 155.0,spd=144,defesa=188.5,moveset=[copy.copy(tackle),copy.copy(hydroPump),copy.copy(aquaTail),copy.copy(bite)],hability='',condition=None)
    pokedex.append(blastoise)
    magikarp = pokemons.pokemon('magikarp',['Agua'],assets=[pygame.image.load('assets/pokemon/magikarp_frente.png'),pygame.image.load('assets/pokemon/magikarp_costas.png'),pygame.image.load('assets/pokemon/magikarp_pequeno.png')],hp = 150,atk = 26.5,spd=148,defesa=71.5,moveset=[copy.copy(splash),copy.copy(tackle),copy.copy(splash),copy.copy(tackle)],hability='',condition=None)
    venusaur = pokemons.pokemon('venusaur',['Grama', 'Veneno'],assets=[pygame.image.load('assets/pokemon/venosaur_frente.png'),pygame.image.load('assets/pokemon/venosaur_costas.png'),pygame.image.load('assets/pokemon/venosaur_pequeno.png')],hp = 270,atk = 168.0,spd=148,defesa=168.5,moveset=[copy.copy(powerWhip),copy.copy(poisonPowder),copy.copy(seedBomb),copy.copy(poisonJab)],hability='',condition=None)
    pokedex.append(venusaur)
    dragonite = pokemons.pokemon('dragonite',['Dragao', 'Voador'],assets=[pygame.image.load('assets/pokemon/dragonite_frente.png'),pygame.image.load('assets/pokemon/dragonite_costas.png'),pygame.image.load('assets/pokemon/dragonite_pequeno.png')],hp = 292,atk = 214,spd=148,defesa=179.0,moveset=[copy.copy(hyperBeam),copy.copy(wingAttack),copy.copy(dragonTail),copy.copy(extremeSpeed)],hability='',condition=None)
    pokedex.append(dragonite)
    gengar = pokemons.pokemon('gengar',['Fantasma', 'Veneno'],assets=[pygame.image.load('assets/pokemon/gengar_frente.png'),pygame.image.load('assets/pokemon/gengar_costas.png'),pygame.image.load('assets/pokemon/gengar_pequeno.png')],hp = 230,atk = 238,spd=202,defesa=120,moveset=[copy.copy(shadowBall),copy.copy(darkPulse),copy.copy(lick),copy.copy(shadowPunch)],hability='',condition=None)
    pokedex.append(gengar)
    snorlax = pokemons.pokemon('snorlax',['Normal'],assets=[pygame.image.load('assets/pokemon/snorlax_frente.png'),pygame.image.load('assets/pokemon/snorlax_costas.png'),pygame.image.load('assets/pokemon/snorlax_pequeno.png')],hp = 430,atk = 180,spd=58,defesa=202,moveset=[copy.copy(bodySlam),copy.copy(lick),copy.copy(crunch),copy.copy(tackle)],hability='',condition=None)
    pokedex.append(snorlax)
    alakazam = pokemons.pokemon('alakazam',['Psiquico'],assets=[pygame.image.load('assets/pokemon/alakazam_frente.png'),pygame.image.load('assets/pokemon/alakazam_costas.png'),pygame.image.load('assets/pokemon/alakazam_pequeno.png')],hp = 220,atk = 200,spd=220,defesa=150,moveset=[copy.copy(psychic),copy.copy(psyshock),copy.copy(psychoCut),copy.copy(thief)],hability='',condition=None)
    pokedex.append(alakazam)
    aerodactyl = pokemons.pokemon('aerodactyl',['Pedra', 'Voador'],assets=[pygame.image.load('assets/pokemon/aerodactyl_frente.png'),pygame.image.load('assets/pokemon/aerodactyl_costas.png'),pygame.image.load('assets/pokemon/aerodactyl_pequeno.png')],hp = 270,atk = 180,spd=238,defesa=130,moveset=[copy.copy(crunch),copy.copy(ancientPower),copy.copy(wingAttack),copy.copy(stoneEdge)],hability='',condition=None)
    pokedex.append(aerodactyl)
    arbok = pokemons.pokemon('arbok',['Veneno'],assets=[pygame.image.load('assets/pokemon/arbok_frente.png'),pygame.image.load('assets/pokemon/arbok_costas.png'),pygame.image.load('assets/pokemon/arbok_pequeno.png')],hp = 230,atk = 170,spd=150,defesa=130,moveset=[copy.copy(gunkShot),copy.copy(sludgeBomb),copy.copy(thunderFang),copy.copy(bite)],hability='',condition=None)
    pokedex.append(arbok)
    magikarpGod = pokemons.pokemon('magikarp',['Agua'],assets=[pygame.image.load('assets/pokemon/magikarp_frente.png'),pygame.image.load('assets/pokemon/magikarp_costas.png'),pygame.image.load('assets/pokemon/magikarp_pequeno.png')],hp = 150,atk = 26.5,spd=148,defesa=71.5,moveset=[copy.copy(superSplash),copy.copy(splash),copy.copy(splash),copy.copy(splash)],hability='',condition=None)
    pokedex.append(magikarpGod)
    gyarados = pokemons.pokemon('gyarados',['Agua', 'Voador'],assets=[pygame.image.load('assets/pokemon/gyarados_frente.png'),pygame.image.load('assets/pokemon/gyarados_costas.png'),pygame.image.load('assets/pokemon/gyarados_pequeno.png')],hp = 300,atk = 220,spd=150,defesa=160,moveset=[copy.copy(hydroPump),copy.copy(hurricane),copy.copy(aquaTail),copy.copy(crunch)],hability='',condition=None)
    pokedex.append(gyarados)
    articuno = pokemons.pokemon('articuno',['Gelo','Voador'],assets=[pygame.image.load('assets/pokemon/articuno_frente.png'),pygame.image.load('assets/pokemon/articuno_costas.png'),pygame.image.load('assets/pokemon/articuno_pequeno.png')],hp = 290,atk = 170,spd=157,defesa=200,moveset=[copy.copy(iceBeam),copy.copy(hurricane),copy.copy(blizzard),copy.copy(sheerCold)],hability='',condition=None)
    pokedex.append(articuno)
    cloyster = pokemons.pokemon('cloyster',['Agua','Gelo'],assets=[pygame.image.load('assets/pokemon/cloyster_frente.png'),pygame.image.load('assets/pokemon/cloyster_costas.png'),pygame.image.load('assets/pokemon/cloyster_pequeno.png')],hp = 210,atk = 100,spd=100,defesa=400,moveset=[copy.copy(iceBeam),copy.copy(hydroPump),copy.copy(tackle),copy.copy(surf)],hability='',condition=None)
    pokedex.append(cloyster)
    dewgong = pokemons.pokemon('dewgong',['Agua','Gelo'],assets=[pygame.image.load('assets/pokemon/dewgong_frente.png'),pygame.image.load('assets/pokemon/dewgong_costas.png'),pygame.image.load('assets/pokemon/dewgong_pequeno.png')],hp = 290,atk = 130,spd=130,defesa=160,moveset=[copy.copy(iceBeam),copy.copy(aquaTail),copy.copy(blizzard),copy.copy(surf)],hability='',condition=None)
    pokedex.append(dewgong)
    dragonair = pokemons.pokemon('dragonair',['Dragao'],assets=[pygame.image.load('assets/pokemon/dragonair_frente.png'),pygame.image.load('assets/pokemon/dragonair_costas.png'),pygame.image.load('assets/pokemon/dragonair_pequeno.png')],hp = 232,atk = 155,spd=130,defesa=130,moveset=[copy.copy(thunderWave),copy.copy(dragonTail),copy.copy(aquaTail),copy.copy(thunder)],hability='',condition=None)
    pokedex.append(dragonair)
    golbat = pokemons.pokemon('golbat',['Veneno','Voador'],assets=[pygame.image.load('assets/pokemon/golbat_frente.png'),pygame.image.load('assets/pokemon/golbat_costas.png'),pygame.image.load('assets/pokemon/golbat_pequeno.png')],hp = 260,atk = 130,spd=166,defesa=135,moveset=[copy.copy(airSlash),copy.copy(bite),copy.copy(poisonFang),copy.copy(quickAttack)],hability='',condition=None)
    pokedex.append(golbat)
    mew = pokemons.pokemon('mew',['Psiquico'],assets=[pygame.image.load('assets/pokemon/mew_frente.png'),pygame.image.load('assets/pokemon/mew_costas.png'),pygame.image.load('assets/pokemon/mew_pequeno.png')],hp = 310,atk = 184,spd=184,defesa=184,moveset=[copy.copy(psychic),copy.copy(ancientPower),copy.copy(auraSphere),copy.copy(psychicNoise)],hability='',condition=None)
    pokedex.append(mew)
    magneton = pokemons.pokemon('magneton',['Eletrico', 'Metal'],assets=[pygame.image.load('assets/pokemon/magneton_frente.png'),pygame.image.load('assets/pokemon/magneton_costas.png'),pygame.image.load('assets/pokemon/magneton_pequeno.png')],hp = 210,atk = 170,spd=130,defesa=150,moveset=[copy.copy(zapCannon),copy.copy(thunder),copy.copy(discharge),copy.copy(flashCannon)],hability='',condition=None)
    pokedex.append(magneton)
    hitmonchan = pokemons.pokemon('hitmonchan',['Lutador'],assets=[pygame.image.load('assets/pokemon/hitmonchan_frente.png'),pygame.image.load('assets/pokemon/hitmonchan_costas.png'),pygame.image.load('assets/pokemon/hitmonchan_pequeno.png')],hp = 210,atk = 193,spd=141,defesa=150,moveset=[copy.copy(closeCombat),copy.copy(firePunch),copy.copy(megaPunch),copy.copy(thunderPunch)],hability='',condition=None)
    pokedex.append(hitmonchan)
    hitmonlee = pokemons.pokemon('hitmonlee',['Lutador'],assets=[pygame.image.load('assets/pokemon/hitmonlee_frente.png'),pygame.image.load('assets/pokemon/hitmonlee_costas.png'),pygame.image.load('assets/pokemon/hitmonlee_pequeno.png')],hp = 210,atk = 142,spd=161,defesa=150,moveset=[copy.copy(axeKick),copy.copy(brickBreak),copy.copy(megaKick),copy.copy(suckerPunch)],hability='',condition=None)
    pokedex.append(hitmonlee)
    jynx = pokemons.pokemon('jynx',['Gelo', 'Psiquico'],assets=[pygame.image.load('assets/pokemon/jynx_frente.png'),pygame.image.load('assets/pokemon/jynx_costas.png'),pygame.image.load('assets/pokemon/jynx_pequeno.png')],hp = 240,atk = 150,spd=175,defesa=125,moveset=[copy.copy(blizzard),copy.copy(psychic),copy.copy(icePunch),copy.copy(covet)],hability='',condition=None)
    pokedex.append(jynx)
    slowbro = pokemons.pokemon('slowbro',['Agua', 'Psiquico'],assets=[pygame.image.load('assets/pokemon/slowbro_frente.png'),pygame.image.load('assets/pokemon/slowbro_costas.png'),pygame.image.load('assets/pokemon/slowbro_pequeno.png')],hp = 300,atk = 160,spd=58,defesa=200,moveset=[copy.copy(surf),copy.copy(psychic),copy.copy(psyshock),copy.copy(hydroPump)],hability='',condition=None)
    pokedex.append(slowbro)
    onix = pokemons.pokemon('onix',['Pedra', 'Terra'],assets=[pygame.image.load('assets/pokemon/onix_frente.png'),pygame.image.load('assets/pokemon/onix_costas.png'),pygame.image.load('assets/pokemon/onix_pequeno.png')],hp = 180,atk = 70,spd=130,defesa=300,moveset=[copy.copy(stoneEdge),copy.copy(tackle),copy.copy(dragonTail),copy.copy(rockTomb)],hability='',condition=None)
    pokedex.append(onix)

    weezing = pokemons.pokemon('weezing',['Veneno'],assets=[pygame.image.load('assets/pokemon/weezing_frente.png'),pygame.image.load('assets/pokemon/weezing_costas.png'),pygame.image.load('assets/pokemon/weezing_pequeno.png')],hp = 240,atk = 160,spd=112,defesa=220,moveset=[copy.copy(sludgeWave),copy.copy(thunder),copy.copy(explosion),copy.copy(tackle)],hability='',condition=None)
    pokedex.append(weezing)
    haunter = pokemons.pokemon('haunter',['Fantasma','Veneno'],assets=[pygame.image.load('assets/pokemon/haunter_frente.png'),pygame.image.load('assets/pokemon/haunter_costas.png'),pygame.image.load('assets/pokemon/haunter_pequeno.png')],hp = 200,atk = 180,spd=175,defesa=80,moveset=[copy.copy(lick),copy.copy(darkPulse),copy.copy(shadowBall),copy.copy(shadowPunch)],hability='',condition=None)
    pokedex.append(haunter)
    magmar = pokemons.pokemon('magmar',['Fogo'],assets=[pygame.image.load('assets/pokemon/magmar_frente.png'),pygame.image.load('assets/pokemon/magmar_costas.png'),pygame.image.load('assets/pokemon/magmar_pequeno.png')],hp = 240,atk = 180,spd=171,defesa=130,moveset=[copy.copy(firePunch),copy.copy(hyperBeam),copy.copy(lavaPlume),copy.copy(flamethrower)],hability='',condition=None)
    pokedex.append(magmar)
    machamp = pokemons.pokemon('machamp',['Lutador'],assets=[pygame.image.load('assets/pokemon/machamp_frente.png'),pygame.image.load('assets/pokemon/machamp_costas.png'),pygame.image.load('assets/pokemon/machamp_pequeno.png')],hp = 290,atk = 180,spd=103,defesa=153,moveset=[copy.copy(strength),copy.copy(closeCombat),copy.copy(brickBreak),copy.copy(crossChop)],hability='',condition=None)
    pokedex.append(machamp)
    
    lapras = pokemons.pokemon('lapras',['Agua', 'Gelo'],assets=[pygame.image.load('assets/pokemon/lapras_frente.png'),pygame.image.load('assets/pokemon/lapras_costas.png'),pygame.image.load('assets/pokemon/lapras_pequeno.png')],hp = 370,atk = 157,spd=112,defesa=160,moveset=[copy.copy(iceBeam),copy.copy(waterPulse),copy.copy(hydroPump),copy.copy(bodySlam)],hability='',condition=None)
    pokedex.append(lapras)
    mewtwo = pokemons.pokemon('mewtwo',['Psiquico'],assets=[pygame.image.load('assets/pokemon/mewtwo_frente.png'),pygame.image.load('assets/pokemon/mewtwo_costas.png'),pygame.image.load('assets/pokemon/mewtwo_pequeno.png')],hp = 322,atk = 240,spd=238,defesa=166,moveset=[copy.copy(psystrike),copy.copy(auraSphere),copy.copy(psychic),copy.copy(psychoCut)],hability='',condition=None)
    pokedex.append(mewtwo)
    golem = pokemons.pokemon('golem',['Terrestre', 'Pedra'],assets=[pygame.image.load('assets/pokemon/golem_frente.png'),pygame.image.load('assets/pokemon/golem_costas.png'),pygame.image.load('assets/pokemon/golem_pequeno.png')],hp = 270,atk = 160,spd=85,defesa=180,moveset=[copy.copy(earthquake),copy.copy(rockThrow),copy.copy(bulldoze),copy.copy(stoneEdge)],hability='',condition=None)
    pokedex.append(golem)
    flareon = pokemons.pokemon('flareon',['Fogo'],assets=[pygame.image.load('assets/pokemon/flareon_frente.png'),pygame.image.load('assets/pokemon/flareon_costas.png'),pygame.image.load('assets/pokemon/flareon_pequeno.png')],hp = 240,atk = 210,spd=121,defesa=145,moveset=[copy.copy(flareBlitz),copy.copy(flamethrower),copy.copy(ember),copy.copy(lavaPlume)],hability='',condition=None)
    pokedex.append(flareon)
    jolteon = pokemons.pokemon('jolteon',['Eletrico'],assets=[pygame.image.load('assets/pokemon/jolteon_frente.png'),pygame.image.load('assets/pokemon/jolteon_costas.png'),pygame.image.load('assets/pokemon/jolteon_pequeno.png')],hp = 240,atk = 160,spd=238,defesa=142,moveset=[copy.copy(thunder),copy.copy(discharge),copy.copy(doubleKick),copy.copy(thunderFang)],hability='',condition=None)
    pokedex.append(jolteon)
    vaporeon = pokemons.pokemon('vaporeon',['Agua'],assets=[pygame.image.load('assets/pokemon/vaporeon_frente.png'),pygame.image.load('assets/pokemon/vaporeon_costas.png'),pygame.image.load('assets/pokemon/vaporeon_pequeno.png')],hp = 370,atk = 160,spd=121,defesa=142,moveset=[copy.copy(hydroPump),copy.copy(auroraBeam),copy.copy(muddyWater),copy.copy(waterPulse)],hability='',condition=None)
    pokedex.append(vaporeon)
    exeggutor = pokemons.pokemon('exeggutor',['Grama', 'Psiquico'],assets=[pygame.image.load('assets/pokemon/exeggutor_frente.png'),pygame.image.load('assets/pokemon/exeggutor_costas.png'),pygame.image.load('assets/pokemon/exeggutor_pequeno.png')],hp = 300,atk = 200,spd=103,defesa=150,moveset=[copy.copy(seedBomb),copy.copy(uproar),copy.copy(psyshock),copy.copy(leafStorm)],hability='',condition=None)
    pokedex.append(exeggutor)
    arcanine = pokemons.pokemon('arcanine',['Fogo'],assets=[pygame.image.load('assets/pokemon/arcanine_frente.png'),pygame.image.load('assets/pokemon/arcanine_costas.png'),pygame.image.load('assets/pokemon/arcanine_pequeno.png')],hp = 290,atk = 190,spd=175,defesa=175,moveset=[copy.copy(ember),copy.copy(extremeSpeed),copy.copy(crunch),copy.copy(flamethrower)],hability='',condition=None)
    pokedex.append(arcanine)
    golduck = pokemons.pokemon('golduck',['Agua'],assets=[pygame.image.load('assets/pokemon/golduck_frente.png'),pygame.image.load('assets/pokemon/golduck_costas.png'),pygame.image.load('assets/pokemon/golduck_pequeno.png')],hp = 270,atk = 163,spd=157,defesa=146,moveset=[copy.copy(hydroPump),copy.copy(aquaTail),copy.copy(zenHeadbutt),copy.copy(waterPulse)],hability='',condition=None)
    pokedex.append(golduck)
    porygon = pokemons.pokemon('porygon',['Normal'],assets=[pygame.image.load('assets/pokemon/porygon_frente.png'),pygame.image.load('assets/pokemon/porygon_costas.png'),pygame.image.load('assets/pokemon/porygon_pequeno.png')],hp = 240,atk = 135,spd=76,defesa=135,moveset=[copy.copy(zapCannon),copy.copy(psybeam),copy.copy(discharge),copy.copy(triAttack)],hability='',condition=None)
    pokedex.append(porygon)
    kangaskhan = pokemons.pokemon('kangaskhan',['Normal'],assets=[pygame.image.load('assets/pokemon/kangaskhan_frente.png'),pygame.image.load('assets/pokemon/kangaskhan_costas.png'),pygame.image.load('assets/pokemon/kangaskhan_pequeno.png')],hp = 320,atk = 125,spd=166,defesa=148,moveset=[copy.copy(outrage),copy.copy(crunch),copy.copy(suckerPunch),copy.copy(headbutt)],hability='',condition=None)
    pokedex.append(kangaskhan)
    victreebel = pokemons.pokemon('victreebel',['Grass', 'Veneno'],assets=[pygame.image.load('assets/pokemon/victreebel_frente.png'),pygame.image.load('assets/pokemon/victreebel_costas.png'),pygame.image.load('assets/pokemon/victreebel_pequeno.png')],hp = 270,atk = 187,spd=130,defesa=125,moveset=[copy.copy(leafBlade),copy.copy(poisonJab),copy.copy(leafStorm),copy.copy(sludgeBomb)],hability='',condition=None)
    pokedex.append(victreebel)
    nidoking = pokemons.pokemon('nidoking',['Veneno', 'Ground'],assets=[pygame.image.load('assets/pokemon/nidoking_frente.png'),pygame.image.load('assets/pokemon/nidoking_costas.png'),pygame.image.load('assets/pokemon/nidoking_pequeno.png')],hp = 272,atk = 170,spd=157,defesa=140,moveset=[copy.copy(suckerPunch),copy.copy(poisonJab),copy.copy(sludgeWave),copy.copy(hornAttack)],hability='',condition=None)
    pokedex.append(nidoking)
    nidoqueen = pokemons.pokemon('nidoqueen',['Veneno', 'Ground'],assets=[pygame.image.load('assets/pokemon/nidoqueen_frente.png'),pygame.image.load('assets/pokemon/nidoqueen_costas.png'),pygame.image.load('assets/pokemon/nidoqueen_pequeno.png')],hp = 290,atk = 155,spd=141,defesa=160,moveset=[copy.copy(hornAttack),copy.copy(superpower),copy.copy(sludgeWave),copy.copy(poisonJab)],hability='',condition=None)
    pokedex.append(nidoqueen)
    electrode = pokemons.pokemon('electrode',['Eletrico'],assets=[pygame.image.load('assets/pokemon/electrode_frente.png'),pygame.image.load('assets/pokemon/electrode_costas.png'),pygame.image.load('assets/pokemon/electrode_pequeno.png')],hp = 230,atk = 140,spd=274,defesa=140,moveset=[copy.copy(discharge),copy.copy(explosion),copy.copy(spark),copy.copy(thunder)],hability='',condition=None)
    pokedex.append(electrode)
    electabuzz = pokemons.pokemon('electabuzz',['Eletrico'],assets=[pygame.image.load('assets/pokemon/electabuzz_frente.png'),pygame.image.load('assets/pokemon/electabuzz_costas.png'),pygame.image.load('assets/pokemon/electabuzz_pequeno.png')],hp = 240,atk = 163,spd=193,defesa=140,moveset=[copy.copy(thunder),copy.copy(thunderPunch),copy.copy(gigaImpact),copy.copy(thunderShock)],hability='',condition=None)
    pokedex.append(electabuzz)
    
    
    

    m = pygame.transform.scale(pygame.image.load('assets/missingno.png'), (pygame.image.load('assets/missingno.png').get_width()/6,pygame.image.load('assets/missingno.png').get_height()/6))
    missingNo = pokemons.pokemon("MissingNo",["Normal"],assets=[m,m,pygame.image.load('assets/empty.png')],hp = 1,atk = 1,spd=999999999999,defesa=1,moveset= atakdex,hability="",condition=" ") #dex Teste(-1)
    pokedex.append(missingNo)


    #iniciando time do player:

    Teams = [[copy.copy(pokedex[0]),copy.copy(pokedex[1]),copy.copy(pokedex[2]),copy.copy(pokedex[3]),copy.copy(pokedex[4]),copy.copy(pokedex[5])]]
    Teams += [[copy.copy(dewgong),copy.copy(cloyster),copy.copy(slowbro),copy.copy(jynx),copy.copy(lapras)]]
    Teams += [[copy.copy(onix),copy.copy(hitmonchan),copy.copy(hitmonlee),copy.copy(onix),copy.copy(machamp)]]
    Teams += [[copy.copy(gengar),copy.copy(golbat),copy.copy(haunter),copy.copy(arbok),copy.copy(gengar)]]
    Teams += [[copy.copy(gyarados),copy.copy(dragonair),copy.copy(dragonair),copy.copy(aerodactyl),copy.copy(dragonite)]]



    with open('save.json', 'r') as openfile: #leitura do arquivo save para o time do campeao
 
        lastVictor = json.load(openfile)
    
    
    champTeam = [copy.copy(pokedex[0]),copy.copy(pokedex[1]),copy.copy(pokedex[2]),copy.copy(pokedex[3]),copy.copy(pokedex[4]),copy.copy(pokedex[5])]


    pkmn1 = lastVictor["team"][0]
    pkmn2 = lastVictor["team"][1]
    pkmn3 = lastVictor["team"][2]
    pkmn4 = lastVictor["team"][3]
    pkmn5 = lastVictor["team"][4]
    pkmn6 = lastVictor["team"][5]
    champTeam = eval(f"[copy.copy({pkmn1}),copy.copy({pkmn2}),copy.copy({pkmn3}),copy.copy({pkmn4}),copy.copy({pkmn5}),copy.copy({pkmn6})]")

    champ = [lastVictor["name"][-1], champTeam]

    return pokedex, Teams, champ



def damageCalc(atack,user,reciver,who): #calcula o dano do ataque, contando criticos, devolvendo o dano e mensagens falando o que aconteceu

    atk = atack.dano
    roll = random.randint(217, 256)/255
    crit = random.random()
    STAB = 1
    Cdamage = 1
    effective = 1
    acerto = 1
    other =""
    person = ""
    

    if who == 0:
        person = "you"
        other = "thei"
    else:
        person = "thei"
        other = "you"

    mensagem = [ person + "r "+user.nome +" used " + atack.nome]

    if user.condition == "burned":
        atk /=2

    for i in user.tipo:
        if i == atack.tipo:
            STAB = 1.5

    if crit <= atack.crit:
        Cdamage = 2
        mensagem += ["it was a critical hit"]

    for i in reciver.tipo:
        effective *= superEffetivo(atack.tipo,i)
    
    if effective >=2:
        mensagem += ["it was super effective"] 
        pygame.mixer.Sound('assets/sound/effect/super_effective.mp3').play()

    elif effective == 0:
        mensagem += ["there was no effect"]
        pygame.mixer.Sound('assets/sound/effect/not_effective.mp3').play()
    elif effective <= 0.5:
        mensagem += ["it was not very effective"]
        pygame.mixer.Sound('assets/sound/effect/not_effective.mp3').play()
    else:
        pygame.mixer.Sound('assets/sound/effect/normal_atk.mp3').play()

    if random.random() > atack.acc:
        mensagem = [person + "r " + user.nome +" used " + atack.nome]+["it did not hit"]
        acerto = 0
    else:
        if atack.effeito[0] in ["burn", "paralize", "poison"] and random.random() <= atack.effeito[1]:
            reciver.condition = atack.effeito[0]+"ed"
            if reciver.condition == "paralizeed":
                reciver.condition ="paralized"
            mensagem = [other + "r " +" pokemon is now "+ atack.effeito[0]+"ed"]

    if paralisis(user) == 0:
        acerto = 0
        mensagem = [person + user.nome + " is paralized and cannot atack"]
    elif atack.nome == "explosion":
        user.hp = 0


    damage = ((2*100*Cdamage/5 + 2)*atk*user.atk/reciver.defesa/50 +2)*STAB*effective*roll*acerto
    if (atk == 0):
        damage = 0
    return round(damage), mensagem


#inspirado no codigo da prova 3(pokemon)
def superEffetivo(user,reciver): #devolve se um ataque e super effetivo

    modificadores = [
        #Fogo      Água      Elétrico  Grama   Normal   Voador     Terra     Veneno      Dragao     Fantasma     Escuro         Psiquico       Pedra       Gelo     lutador       MEtal        reciever/ataquer
        [0.5,      0.5,      1,        2,      1,       1   ,       1  ,       1,          0.5,        1,           1,          1,              0.5,       2,          1,          2,          ],# Fogo
        [2,        0.5,      1,        0.5,    1,       1   ,       2  ,       1,          0.5,        1,           1,          1,              2,         1,          1,          1,          ],# Água
        [1,        2,        0.5,      0.5,    1,       2   ,       0  ,       1,          0.5,        1,           1,          1,              1,         1,          1,          1,         ],# Elétrico
        [0.5,      2,        1,        0.5,    1,       0.5 ,       2  ,       0.5,        0.5,        1,           1,          1,              2,         1,          1,          0.5,         ],# Grama
        [1,        1,        1,        1,      1,       1   ,       1  ,       1,          1,          0,           1,          1,              0.5,       1,          1,          0.5,          ],# Normal
        [1,        1,        0.5,      2,      1,       1   ,       1  ,       1,          1,          1,           1,          1,              0.5,       1,          2,          0.5,          ],# Voador
        [2,        1,        2,        0.5,    1,       0   ,       1  ,       2,          1,          1,           1,          1,              2,         1,          1,          2,         ],# Terra
        [1,        1,        1,        2  ,    1,       1   ,       0.5,       0.5,        1,          0.5,         0.5,        1,              0.5,       1,          1,          0,          ],# Veneno
        [1,        1,        1,        1  ,    1,       1   ,       1  ,       1  ,        2,          1,           1,          1,              1,         1,          1,          0.5,        ],# Dragao
        [1,        1,        1,        1  ,    0,       1   ,       1  ,       1  ,        1,          2,           0.5,        2,              1,         1,          1,          1,        ],# Fantasma
        [1,        1,        1,        1  ,    1,       1   ,       1  ,       1  ,        1,          2,           0.5,        2,              1,         1,          0.5,        1,          ],# Escuro
        [1,        1,        1,        1,      1,       1   ,       1  ,       2,          1,          1,           0,          0.5,            1,         1,          2,          0.5,        ],# Psiquico
        [2,        1,        1,        1,      1,       2   ,       0.5,       1,          1,          1,           1,          1,              1,         2,          0.5,        0.5,          ],# Pedra
        [0.5,       0.5,     1,        2,      1,       2   ,       2  ,       1,          2,          1,           1,          1,              1,         0.5,        1,          0.5,          ],# Gelo
        [1,        1,        1,        1,      2,       0.5 ,       1  ,       0.5,        1,          0,           2,          0.5,            2,         2,          1,          2,         ],# Lutador
        [0.5,      0.5,      0.5,      1,      1,       1   ,       1  ,       1,          1,          1,           1,          1,              2,         2,          1,          0.5,       ],# Metal


        [1,        1,        1,        1,      1,       1   ,       1  ,       1,          1,          1,           1,          1,              1,         1,          1,     ],# Test


         

    ]

    tipos = {"Fogo":0,"Agua":1,"Eletrico":2,"Grama":3,"Normal":4,"Voador":5,"Terra":6,"Veneno":7,"Dragao":8, "Fantasma": 9,"Escuro":10, "Psiquico":11,"Pedra": 12,"Gelo": 13,"Lutador": 14}
    
    #atacante depois defensor
    return modificadores[tipos[user]][tipos[reciver]]


def paralisis(pokemon): #devolve se a paralisia para o pokemon
    
    if pokemon.condition == "paralized" and random.random() <= 0.25:
        return 0 #paralizado(nao ataca)
    
    return 1



def DOT(pokemon): #da o dano por rodada de burn e poison
    if pokemon.condition in ["poisoned", "burned"]:
        pokemon.hp -= round(pokemon.maxHp/8)
    


def checkDeath(pokemon): #devolve se o pokemon estiver morto e reseta suas condicoes se sim
    if pokemon.hp <= 0:
        pokemon.condition = None
    return pokemon.hp > 0 #true = vivo / false = morto



