Starting a new game
Excellent! Now, let's focus on the functionality for starting a new game. Here, we need to implement the following steps:
- Extract the difficulty settings from the URL.
- Start a new game. This game should have an ID, which will be our
session id
. Plus, it should keep track of the list of articles, progress, navigation history, the total number of steps taken, and the difficulty. - Render the first Wikipedia article.
- Set up in-article navigation. We need to make sure that the links within the Wikipedia article will properly link back into our app, and not the Wikipedia website itself.
- Display information about the game session, such as the objective (start and end articles), number of steps taken, and so on.
We'll look at all of these steps next.
Extracting the difficulty settings from the page URL
This is the very first step. Remember that within our HandlerFunction
, we have access to the Request
object, req
. All the Request
objects expose a field called target
that references the...