- Notifications
You must be signed in to change notification settings - Fork8
A finnish version of a popular word guessing game, written in Rust.
License
Cadiac/sanuli
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A finnish version of a popular word guessing game implemented inRust.
Live version running atsanuli.fi.
FollowRust installation instructions.
To build the WASM basedyew UI, further wasm tooling is required
rustup target add wasm32-unknown-unknowncargo install --locked trunkcargo install wasm-bindgen-cli
Create word list files and populate them with uppercase words, one per line
touch common-words.txttouch daily-words.txttouch full-words.txttouch profanities.txttouch easy-words.txt
Start the UI in development mode
trunk serve
Four separate word list files in the root of this project containing all the words are required. The lists are not included in this repository.
The lists are:
full-words.txt
- Full list of all accepted 5 and 6 character words. The checks if a word real or not is done against this listdaily-words.txt
- List of daily words. The daily word is taken from row equal to the days from 2022-01-07.common-words.txt
- Subset of the full words list, intended for the default game mode. Note that all these wordsmust exist on thefull-words.txt
easy-words.txt
- Subset of the full words list, intended for easier game mode. Note that all these wordsmust exist on thefull-words.txt
profanities.txt
- Words filtered out when profanities filter is enabled
Beware that these areincluded in the release binary, and anyone can obtain the lists!
To create a word list, a dictionary like the "nykysuomen sanalista" byKotus,licensed withCC BY 3.0, can be used as a baseline to build from.
A parser for parsingkotus-sanalista_v1.xml
file fromKotus is included:
cargo run --bin parse-kotus-word-list your/path/to/kotus-sanalista_v1.xml
which creates afull-words-generated.txt
file in the working directory.
NOTE: Rust flag--cfg=web_sys_unstable_apis
is required for copying to clipboard to work.Clipboard API also only works in HTTPS context.
To set the flag manually with environment variables, run:
export RUSTFLAGS=--cfg=web_sys_unstable_apis
You can ignore this at manual development (as the clipboard API won't work without HTTPS anywaays)or run your trunk commands with it set.
For normal development, start the web server with
trunk serve
This should make the UI available at 0.0.0.0:8080 with hot reload on code changes.
To change the default port, use
trunk serve --port=9090
Pass the rust flags for building clipboard features & strip your home library paths from the binary.
RUSTFLAGS="--cfg=web_sys_unstable_apis --remap-path-prefix $HOME=~" trunk build --release
and copy the produceddist
directory to your target server.
The.wasm
binary is quite large, as it includes the full word lists and bunch of code.wasm-opt
frombinaryen tools can be tooptimized to further reduce the size of the binary.
wasm-opt -Os -o output.wasm input.wasm
replacing the input and output files with your binary name, ie.dist/index-fea16a946b74a1d4_bg.wasm
.
Some automation for this should be made.