Pokémon Team & Gym Badge Generator
`;
return;
}
badges.forEach(badge => {
const item = document.createElement('div');
item.className = 'badge-item';
item.textContent = badge.name;
item.title = `${badge.name} (${badge.type})`;
badgeDisplay.appendChild(item);
});
};
const handleGenerateClick = () => {
errorMessage.style.display = 'none';
if (pokemonData.length === 0) {
errorMessage.textContent = 'Pokémon data is missing. Please paste the data array into the script.';
errorMessage.style.display = 'block';
resultsContainer.style.display = 'none';
return;
}
const { team, chosenMonoType } = generateTeam();
if (team.length === 0) {
errorMessage.textContent = 'No Pokémon match the selected criteria. Please try a different combination!';
errorMessage.style.display = 'block';
resultsContainer.style.display = 'none';
return;
}
if (team.length < 6) {
errorMessage.textContent = 'Warning: Could not find 6 Pokémon matching your criteria. Try broader filters!';
errorMessage.style.display = 'block';
}
const badges = generateBadges(team, chosenMonoType);
renderTeam(team);
renderBadges(badges);
resultsContainer.style.display = 'block';
copyBtn.style.display = 'inline-block';
};
copyBtn.addEventListener('click', () => {
const teamText = Array.from(teamDisplay.querySelectorAll('.pokemon-card'))
.map(card => {
const name = card.querySelector('.pokemon-name').textContent;
const types = Array.from(card.querySelectorAll('.type-badge')).map(b => b.textContent).join('/');
return `- ${name} (${types})`;
}).join('\n');
const badgeText = Array.from(badgeDisplay.querySelectorAll('.badge-item'))
.filter(item => item.style.display !== 'none')
.map(item => item.textContent).join(', ');
copyTextarea.value = `My Pokémon Team\n${teamText}\n\nMy Badges\n${badgeText}`;
copyTextarea.select();
document.execCommand('copy');
copyBtn.textContent = 'Copied!';
setTimeout(() => { copyBtn.textContent = 'Copy Team'; }, 2000);
});
generateBtn.addEventListener('click', handleGenerateClick);
});
Other Random Generators You May Like
Feeling brave? Use your random Pokémon pull, then challenge yourself with our Pokémon team building generators built for creative trainers.