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

Plugin/Wordle: misc improvements:

* remove initial "? ? ? ? ?" text after first guess
* show count of guesses when solved
* remove "Wordle: " text
This commit is contained in:
Pragmatic Software 2024-03-07 10:20:53 -08:00
parent d8a67ae0c5
commit e251ccb7a1
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
2 changed files with 14 additions and 3 deletions

View File

@ -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);
}

View File

@ -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",
};