2 个版本
0.1.1 | 2022 年 5 月 8 日 |
---|---|
0.1.0 | 2022 年 5 月 7 日 |
#452 in 游戏
2MB
402 代码行
Shiritori-rs
Shiritori 是日本著名的连锁词游戏。
在线演示 (Wasm)
https://tnantoka.github.io/shiritori-wasm/
用法
shiritori = { git = "https://github.com/tnantoka/shiritori-rs.git" }
# for Wasm
getrandom = { version = "0.2.6", features = ["js"] }
use shiritori::game::{Game};
use shiritori::word::{WordList, WordListType};
let word_list = WordList::load(WordListType::Pokemon);
let mut game = Game::new(word_list);
game.current_turn(); # Word { text: "ピカチュウ", reading: "ピカチユウ" }
let judgement = game.next_turn("ウーラオス");
game.current_turn(); # Word { text: "スイクン", reading: "スクイン" }
judgement.game_over # true
judgement.winner # Player::You
judgement.reason # Reason::LastLetterIsInvalid
示例
$ cargo run --example hello pokemon
bot> ピカチュウ(ピカチユウ)
next: ウ
you> ウーラオス
bot> スイクン(スイクン)
You win
(last letter is invalid)
开发
更新单词列表
$ cargo run --bin generate
# pretty
$ cargo run --bin generate -- -p
致谢
- https://clrd.ninjal.ac.jp/unidic/
- unidic-cwj-3.1.0/lex_3_1.csv
- https://github.com/PokeAPI/pokeapi
- data/v2/csv/pokemon_species_names.csv
依赖项
~3–5MB
~90K SLoC