(Work In Progress)
Let's play Hangman!
Client: React (ES6)
Server: Spring Boot (Java)
Node and npm are installed locally (for now).
Words are parsed from the words_alpha.txt and put into a HashTable.
A random word is chosen from this HashTable every time a a new game is started.
The word itself is available via the API, rather a list of Guessable (link to server/datatypes/guessable) containers is sent. This list is the size of the words length.
Conditions:
- Business logic executed on server
- Lose if 10 incorrect guesses have been made
- Allow for basic stat-keeping (wins/losses)
There are a few important datatypes.
A Word contains:
- String: Content
- Set: Unique characters
- List: Guessables
A Guessable is a container holding:
- Character: Correct answer
- Integer: Index
- Boolean: status on whether it has been asked
GET /game
PUT /game { "letter": "b" }
GET /newgame
A Word is serialized as JSON and sent via the "/game" API. The JSON object sent omits content, unique characters, and each Guessable's character.
Ex.
Word as JSON w/o omissions
{
"content": "brewst",
"uniqueChars": [
"b",
"r",
"s",
"t",
"e",
"w"
],
"guesses": [
{
"answer": "b",
"isGuessed": false,
"index": 0
},
...
{
"answer": "t",
"isGuessed": false,
"index": 5
}
]
}
Word as JSON
{
"guesses": [
{
"isGuessed": false,
"index": 0
},
...
{
"isGuessed": false,
"index": 5
}
]
}
All game logic is executed through the server.
As a player can only make forward steps towards completion of the game, all that's needed GETs on the current game state and PUTs for selection of a letter.
Component Tree:
<App>
<Layout>
<Hangman />
<Word />
<Options />
<Stats />
</Layout>
</App>
WordBuilder
OptionsBuilder
Stats