From f680439d475ffa4fed64a8e390daa56934d5fbf8 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 31 Oct 2024 00:55:31 -0700 Subject: [PATCH] Plugin/Wordle: add `guesses` subcommand --- lib/PBot/Plugin/Wordle.pm | 17 ++++++++++++++++- lib/PBot/VERSION.pm | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/PBot/Plugin/Wordle.pm b/lib/PBot/Plugin/Wordle.pm index 853dc684..03a44d4c 100644 --- a/lib/PBot/Plugin/Wordle.pm +++ b/lib/PBot/Plugin/Wordle.pm @@ -30,7 +30,7 @@ sub unload($self) { } use constant { - USAGE => 'Usage: wordle start [length [wordlist]] | custom [wordlist] | guess | letters | show | info | giveup', + USAGE => 'Usage: wordle start [length [wordlist]] | custom [wordlist] | guess | 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}; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 80e4603e..09069d6c 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -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 {}