3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-22 18:52:40 +01:00

Plugin/Wordle: add guesses subcommand

This commit is contained in:
Pragmatic Software 2024-10-31 00:55:31 -07:00
parent e7d3a543c4
commit f680439d47
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 18 additions and 3 deletions

View File

@ -30,7 +30,7 @@ sub unload($self) {
}
use constant {
USAGE => 'Usage: wordle start [length [wordlist]] | custom <word> <channel> [wordlist] | guess <word> | letters | show | info | giveup',
USAGE => 'Usage: wordle start [length [wordlist]] | custom <word> <channel> [wordlist] | guess <word> | guesses | letters | show | info | giveup',
NO_WORDLE => 'There is no Wordle yet. Use `wordle start` to begin a game.',
DEFAULT_LIST => 'american',
@ -289,6 +289,18 @@ sub wordle($self, $context) {
return $result;
}
when ('guesses') {
if (not defined $self->{$channel}->{wordle}) {
return NO_WORDLE;
}
if (not $self->{$channel}->{guesses}->@*) {
return 'No guesses yet.';
}
return join("$color{reset} ", $self->{$channel}->{guesses}->@*) . "$color{reset}";
}
when ('letters') {
if (@args > 1) {
return "Usage: wordle letters";
@ -380,6 +392,7 @@ sub make_wordle($self, $channel, $length, $word = undef, $wordlist = DEFAULT_LIS
$self->{$channel}->{length} = $length;
$self->{$channel}->{wordle} = \@wordle;
$self->{$channel}->{guess} = '';
$self->{$channel}->{guesses} = [];
$self->{$channel}->{correct} = 0;
$self->{$channel}->{guess_count} = 0;
$self->{$channel}->{letters} = {};
@ -501,6 +514,8 @@ sub guess_wordle($self, $channel, $guess) {
$self->{$channel}->{guess} = $result;
push $self->{$channel}->{guesses}->@*, $result;
if ($correct == length $guess) {
$self->{$channel}->{correct} = 1;
my $guesses = $self->{$channel}->{guess_count};

View File

@ -25,8 +25,8 @@ use PBot::Imports;
# These are set by the /misc/update_version script
use constant {
BUILD_NAME => "PBot",
BUILD_REVISION => 4819,
BUILD_DATE => "2024-10-30",
BUILD_REVISION => 4820,
BUILD_DATE => "2024-10-31",
};
sub initialize {}