Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pokemon of the day #699

Open
twentylemon opened this issue Mar 6, 2023 · 10 comments
Open

add pokemon of the day #699

twentylemon opened this issue Mar 6, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@twentylemon
Copy link
Member

Or something that gives a random pokemon (like /pokemon). Some random stats about it would be nice, like it's type and some nonsense about the LORE.

I wholeheartedly stole this idea from my alexas.

@jameshughes89
Copy link
Collaborator

I support this idea

@jameshughes89 jameshughes89 added the enhancement New feature or request label Mar 6, 2023
@Chippers255
Copy link
Collaborator

Excellent idea! It would also be good to give it a pokedex like ability such a /pokemon bulbasaur to get stats for a particular one.

@twentylemon
Copy link
Member Author

twentylemon commented Mar 6, 2023

For the command portion, https://pokeapi.co/ looks pretty good. It's free too.
https://pokeapi.co/api/v2/pokemon/* supports both ID and name which is nice, it includes things like base stats so duckbot can pass judgement on whether or not the pokemon is useless garbage. It also includes flavour text, eg for bulbasaur,

a snip from https://pokeapi.co/api/v2/pokemon/1

"species": {
  "name": "bulbasaur",
  "url": "https://pokeapi.co/api/v2/pokemon-species/1/"
},

then a snip from https://pokeapi.co/api/v2/pokemon-species/1/ gives

"flavor_text_entries": [
  {
    "flavor_text": "A strange seed was\nplanted on its\nback at birth.\fThe plant sprouts\nand grows with\nthis POKéMON.",
    "language": {
      "name": "en",
      "url": "https://pokeapi.co/api/v2/language/9/"
    },
    "version": {
      "name": "red",
      "url": "https://pokeapi.co/api/v2/version/1/"
    }
  },
  {
  "flavor_text": "A strange seed was\nplanted on its\nback at birth.\fThe plant sprouts\nand grows with\nthis POKéMON.",
  "language": {
    "name": "en",
    "url": "https://pokeapi.co/api/v2/language/9/"
  },
  "version": {
    "name": "blue",
    "url": "https://pokeapi.co/api/v2/version/2/"
  }
},

Some weird artifacts with \n and \f (I imagine these are directly from the games) which we'd want to remove, but otherwise, pog.

Wrapper libraries also exist, check the docs.

@twentylemon
Copy link
Member Author

twentylemon commented Mar 6, 2023

For pokemon of the day, we could use a deterministic shuffle of the list range(1, n) where n is the number of pokemon (ie, a random list of all pokemon ids), then pick some anchor date which we offset from (maybe duckbot's inception day) to be the first index in that new list. Then todaysPokemon = shuffle(range(1, n))[(today() - anchor()).days % n]

I'm not sure where to get n though. I'd rather not hard code it.
https://pokeapi.co/api/v2/pokemon?limit=100000&offset=0 is almost it. The end of it is outta whack though, it lists a bunch of utility IDs, see https://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_National_Pok%C3%A9dex_number

@jameshughes89
Copy link
Collaborator

Why have a shuffle though? Does having them come out of numeric order matter?

@twentylemon
Copy link
Member Author

I'd say randomness matters. It'd be boring if you could trivially predict the next pokemon of the day.

Either method though, you'd still need to know n.

@twentylemon
Copy link
Member Author

So, looking closer at https://pokeapi.co/api/v2/pokemon?limit=100000&offset=0
The last IDs are all 10000+, so we could use that to find n, filtering out the utility IDs and that's it.

@jameshughes89
Copy link
Collaborator

The numbering is a little unclear.

First line value is "count":1281 and then the URL numbering goes 1 -- 1009 and then 10001 -- 10271. So, the count seems correct, but the numbering is throwing me off.

@twentylemon
Copy link
Member Author

count is the size of the list. Each element has an ID embedded in the url though.

@twentylemon
Copy link
Member Author

Maybe relevant is the API also does pagination by default, so count might be less if there are multiple pages. It's semi-typical to include such data in a single page of results.

The query there though says "screw you, I want one page only."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants