mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-22 11:59:43 +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:
parent
d8a67ae0c5
commit
e251ccb7a1
@ -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);
|
||||
}
|
||||
|
@ -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",
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user