Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p-adams/gallows-humor
https://github.com/p-adams/gallows-humor
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/p-adams/gallows-humor
- Owner: p-adams
- Created: 2023-05-08T08:40:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-05-11T02:57:42.000Z (over 1 year ago)
- Last Synced: 2024-11-07T22:43:37.495Z (about 2 months ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Gallows Humor
Hangman game backend
### Local Import
`import { Game } from "./mod.ts";`
### Create Hangman Game
```
// if no guess word is provided at time of instantiation, a random word is selectedconst guessWord = "meow";
const hangmanGame = new Game(guessWord);
```### Process user guess
```
hangmanGame.process("m");
hangmanGame.process("o");
```### Get game progress
```
hangmanGame.dashes();
returns: m_o_
```Possible process statuses
```
ProcessStatus {
SUCCESS = "success",
INVALID_INPUT = "error:invalid_input",
ALREADY_GUESSED = "warning:already_guessed",
EXCEEDED_GUESS_LIMIT = "error:exceeded_guess_limit",
}
```### Determine Win
`hangman.isWin();`
### Use `guesses` method to keep score of failed guesses
```
hangmanGame.process("z");
hangmanGame.guesses(); // ["z"]
```### Determine Loss
```
hangmanGame.process("x"); // error:exceeded_guess_limit
```