JoeBussard / polywordleapi

the api for playing polywordle
0 stars 0 forks source link

Add custom word feature #29

Open JoeBussard opened 2 years ago

JoeBussard commented 2 years ago

I want to give users the ability to start a game that uses their own word of choice, and then send the link to that game to a friend for them to play.

JoeBussard commented 2 years ago

Added this in #51

JoeBussard commented 2 years ago

API endpoint is POST:/newgame/, and requires solution:word key:value pair as JSON or http header. TBD: Test custom solution endpoint

JoeBussard commented 2 years ago

The front end client decides what to do with the UUID returned by the API when a custom game is created. For example:

Alice will create a custom game for Bob. The solution to the custom game will be, "BOOKS". Alice's client sends a POST method request to /v1/newgame with solution:books as a JSON data payload. The server generates the game state and returns game_uuid:foo-bar-baz-qux. Alice's client now has the uuid for the custom game. She needs to send this to Bob's client. The handoff is complete once Bob's client has made a GET request to /v1/game/foo-bar-baz-qux.

Option 1: "copy paste"

Client interfaces have a text-box for inserting uuid's given to the user. Alice only needs to send Bob the UUID and Bob can paste it into his client interface to start the game.

Option 2: URL shortener

Alice's client creates a magic link for each custom game and clicking on the link takes you to the game with the UUID of the custom game loaded.

Option 3: URL contains uuid

Every time you load the client, the URL is in the format example.com/polywordle/<uuid>. Sending the link to a custom game is as simple as sending the link.

Option 4: Black box

The client (say a Discord bot) sends a message to Bob that Alice created a game for him. He doesn't have to do anything.

Either way, the API should only respond with the UUID of the custom game. Allow the client to choose how to use this information.