TL;DR
有名なwordleの国名版をアンドロイドアプリにしました。ぜひ使ってみてね!
https://play.google.com/store/apps/details?id=com.chatram.wordle
なぜ作ったか
今年のはじめ辺りにバズっていたので、作れるかなと思って今年の3月くらいに作りました。
例
本家と同様、文字があっているけど位置が違うと黄色、文字も位置もあっていると緑になります。
仕組み
外務省のホームページを参考にして、国として認められているところの名前をマップにぶち込んで、ゲームが立ち上がるorリセットボタンを押されるたびにランダムでその中の国名が答えとして選ばれます。
入力部分にはひらがなとカタカナ以外は入力できないようにregexで弾いています。
// random
class Randomizer {
static var n = country_list.length;
static String Generate() {
List<String> array = [];
var rand = Random();
array.add(country_list[rand.nextInt(n)]);
// 字数が10字に満たない時に空文字列を入れる
if (array[0].length < 10) {
(array[0] += " " * (10 - (array[0].length)));
}
return array.join('');
}
}
// regex
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.allow(
// ひらがなとカタカナ以外を弾くregex
RegExp(r'^[\u3040-\u30FF]+$')),
],
最後に
最後まで読んでくれてありがとうございます!
興味があったら使ってみてください!
https://play.google.com/store/apps/details?id=com.chatram.wordle
小言
作り方が気になった場合(そうそう居ないとは思いますが)は、githubに公開しているので、historyから覗いて見てください。