|
@@ -294,12 +294,17 @@ const onUpdate = (event) => {
|
|
|
|
|
|
// Lookup by name
|
|
// Lookup by name
|
|
if (lastPkmnSearch !== pokemonName || newParams) {
|
|
if (lastPkmnSearch !== pokemonName || newParams) {
|
|
|
|
+ let found;
|
|
|
|
+ if (pokemonName.trim().toLowerCase() === "!random") {
|
|
|
|
+ found = Array.from({ length: 10 }, () => database[Math.floor(Math.random() * database.length)]);
|
|
|
|
+ } else {
|
|
|
|
+ found = pokemonLookup.search(pokemonName, { limit: 10 }).map(({ item }) => item);
|
|
|
|
+ }
|
|
|
|
+
|
|
const searchList = document.getElementById("search-list");
|
|
const searchList = document.getElementById("search-list");
|
|
searchList.innerHTML = '';
|
|
searchList.innerHTML = '';
|
|
- pokemonLookup
|
|
|
|
- .search(pokemonName, { limit: 10 })
|
|
|
|
- // If scoring is impossible, totalScorer will just be identity
|
|
|
|
- .map(({ item }) => ({ ...item, ...calculator(item) }))
|
|
|
|
|
|
+ // If scoring is impossible, calculator will just return {}
|
|
|
|
+ found.map((info) => ({ ...info, ...calculator(info) }))
|
|
.forEach(item => {
|
|
.forEach(item => {
|
|
const li = document.createElement("li");
|
|
const li = document.createElement("li");
|
|
li.appendChild(renderPokemon(item))
|
|
li.appendChild(renderPokemon(item))
|