/Random-Pokemon-Generator

Source code for randompokemon.com

Primary LanguageJavaScriptGNU General Public License v2.0GPL-2.0

Random-Pokemon-Generator

Description

Forked from Nerdydrews Random Pokemon Generator. This is an alternative version which also has an REST API.

Demo: https://grape-deserted-stamp.glitch.me/api?t=all&n=5&r=kanto

Installation

Using just the webpage

  1. Clone the repository.
  2. Download and unzip the sprites into a sprites folder within the cloned repository.
  3. Use any local web server—it's all static.

REST API

  1. Clone the repository.
  2. Download and unzip the sprites into a sprites folder within the cloned repository.
  3. If not already done, install nodejs
  4. run the server with node backend.js
  5. go to http://localhost:3000 you should see the webpage.
  6. query the rest api with http://localhost:3000/api?query in which query, your request string is (see API Documentation)
  7. have fun

Nightbot Integration

(updated on 12.02.2024)

$(eval const r = decodeURIComponent(`$(querystring)`); if (r.includes("help")) { let a = "Use the command as the following: [Command] <number> <region>"; a; } else { const result=$(urlfetch json https://grape-deserted-stamp.glitch.me/api?t=all&n=$(1)&r=$(2)); let isError = Object.keys(result)[0] === "error"; if (isError) { let b =result["error"]; b;} else { `${result["name_List"]}`; } } )
// notes
1. use `` for decodeURIComponent
2. dont use "" on url fetch url
3. put the output of the message formated as `${foobar}`

Just to clarify this is an REST API Level 0 implementation - according to Richard Maturity Model

API Documentation

Some Taxonomy / Definitions

API Key and Alias:
use those as keys in a get request to perform the REST-API request.
Category:
An API Key can either influence the pool of random pokemon or toggles a property like an additional sprite.
Pool
Pool is defined as the set of pokemons that fits the given criteria. The random pokemon will then be drawn from that pool.
Properties
Properties like sprite (y/n) are additional data, that can be included into the resuls (like images).
Name Category API Key Alias Values Description Default Value Example
Amount of Random Pokemon Property number n 1-6 The number of random generated pokemon - n=5
Sprite Property sprites s Booleanmapping Imagine a Red Rectangle flirting with you furiously false s=false
Pokemon Region Pool region r RegionList The pokemon region e.g kanto, johto etc. all r=kanto
Pokemon Type Pool type t TypeList Type of the random pokemons. Only single values are allowed. No concatinations like (water,fire) all t=bug
Overpowered Pokemon Pool ubers u Booleanmapping Controls if Overpowered Pokémon (not used in standard play) are added into the pool. false u=true
Include Not fully envolved Pokemon Pool nfes nf Booleanmapping Controls, if Pokemon that are not fully envolved are added into the pool. false nf=false
Pokemon Nature Property natures na Booleanmapping Adds nature attributes to the drawn random pokemon false na=true
Pokemon Alternative Forms Pool forms f Booleanmapping Allow alternate forms, such as Mega Evolutions. false f=false

Type of Errors

Invalid Range
The value is not in the range of the key property e.g. amount (1-6)
Invalid Key
The key is not a valid api key.
No Amount Given
The number key (amount of to be generated pokemon) is mandatory. Please add 'n="number"' to your query.

BooleanMapping

yes, true --> true
no, false --> false

Valid Regions

all, kanto, johto, hoenn, sinohh, sinnoh_pt (platin), unova, unova_b2w2 (black & white 2), kalos, alola

Valid Types

all, bug, dark, dragon, electric, fairy, fighting, fire, flying, ghost, grass, ground, ice, normal, poison, psychic, rock, steel, water