From e251ccb7a1eede1aa3497fb49275e56ff3cc54d9 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 7 Mar 2024 10:20:53 -0800 Subject: [PATCH] Plugin/Wordle: misc improvements: * remove initial "? ? ? ? ?" text after first guess * show count of guesses when solved * remove "Wordle: " text --- lib/PBot/Plugin/Wordle.pm | 15 +++++++++++++-- lib/PBot/VERSION.pm | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/PBot/Plugin/Wordle.pm b/lib/PBot/Plugin/Wordle.pm index 96ac9cc7..206c21d0 100644 --- a/lib/PBot/Plugin/Wordle.pm +++ b/lib/PBot/Plugin/Wordle.pm @@ -49,7 +49,7 @@ sub wordle($self, $context) { return NO_WORDLE; } - return "Wordle: " . $self->show_wordle($channel); + return $self->show_wordle($channel); } when ('giveup') { @@ -96,6 +96,7 @@ sub wordle($self, $context) { $self->{$channel}->{wordle} = \@wordle; $self->{$channel}->{guesses} = []; $self->{$channel}->{correct} = 0; + $self->{$channel}->{guess_count} = 0; push $self->{$channel}->{guesses}->@*, '? ' x $self->{$channel}->{wordle}->@*; @@ -161,6 +162,13 @@ sub guess_wordle($self, $channel, $guess) { return "I don't know that word. Try again." } + $self->{$channel}->{guess_count}++; + + if ($self->{$channel}->{guess_count} == 1) { + # remove initial "? ? ? ? ?" + shift $self->{$channel}->{guesses}->@*; + } + my @guess = split //, $guess; my @wordle = $self->{$channel}->{wordle}->@*; @@ -212,7 +220,10 @@ sub guess_wordle($self, $channel, $guess) { if ($correct == length $guess) { $self->{$channel}->{correct} = 1; - return "Correct! " . $self->show_wordle($channel); + + my $guesses = $self->{$channel}->{guess_count}; + + return "Correct in $guesses guess" . ($guesses != 1 ? 'es! ' : '! ') . $self->show_wordle($channel); } else { return $self->show_wordle($channel); } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index d193bb75..31535941 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4709, + BUILD_REVISION => 4710, BUILD_DATE => "2024-03-07", };