Crates.io | word-chain-game |
lib.rs | word-chain-game |
version | 1.0.1 |
source | src |
created_at | 2023-12-26 10:40:21.550887 |
updated_at | 2024-01-04 08:45:16.307408 |
description | A word chain game helper |
homepage | https://github.com/quadratic-bit/words-game |
repository | https://github.com/quadratic-bit/words-game |
max_upload_size | |
id | 1080840 |
size | 30,656 |
A game of word chain made by me in 30 spare minutes because of the flight delay.
Upon executing the binary, you'll be prompted to enter a word. A "word" is a
case-insensitive sequence of Unicode Alphabetic
characters (or a hyphen -
).
[!NOTE] This is the only criteria for a word, as every other constraint limits the available languages and specific words players are allowed to use.
Every following word must start with the same letter the previous one ended with, and all words must be unique. Here's an example of a word chain:
$ words
> part
> torch
> horse
Usually, the game is played by multiple players, and everyone who cannot think of the next word loses, but this varies from country to country, so you are free to modify the rules however you wish.
If you try to enter a word that was already introduced, you'll get a warning:
> torch
[-] This word has already been used
You can also undo a couple of last words with !undo
, in case of typos:
> etherium
> !undo
[i] Previous word was cancelled: etherium
> ethereum
All available commands can be viewed by prompting ?
or by passing --help
to the executable
The binary name for Words game is words
.
To install the binary, run:
$ cargo install word-chain-game
This game is written in Rust, so you'll need to compile via cargo
:
$ git clone https://github.com/quadratic-bit/words-game
$ cd words-game
$ cargo build --release
$ ./target/release/words --help
The default UI language is english, but branch locale-ru
contains russian translation.
All string literals are stored in src/literals.rs
with
explanations, so changing UI language should be no problem.
In there, you can also change the default prompt >
.
There's also this array:
pub const ILLEGAL_STARTING_CHARACTERS: [char; 4] = ['-', 'ы', 'ь', 'ъ'];
which controls all characters that a word cannot start with (e.g. russian ы, ь, ъ and a hyphen). The player will receive a warning if a new word is constructed using only these characters, as no word can be a follow-up.
There are loads of words to come up with in such a game, so storing all of them
in a vector is not reasonable. But it is reasonable to store the last n
words
in their original order for the "undo" feature.
By default, this number is 10
,
but it can be changed in src/main.rs
:
const WORD_HISTORY_BUFFER_LENGTH: usize = 10;
You can add and run your tests from the tests/
forlder via:
$ cargo test