3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-25 05:19:29 +01:00

Plugin/Wordle: fix not detecting duplicate letters

This commit is contained in:
Pragmatic Software 2024-03-09 20:29:25 -08:00
parent 26a2b36122
commit 5d3507421e
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
3 changed files with 7 additions and 3 deletions

View File

@ -953,6 +953,7 @@ sub add_message_to_output_queue($self, $channel, $message, $delay = 0) {
hostmask => $message->{hostmask}, hostmask => $message->{hostmask},
output => $message->{message}, output => $message->{message},
command => $message->{command}, command => $message->{command},
keyword => $message->{keyword},
checkflood => $message->{checkflood} checkflood => $message->{checkflood}
}; };

View File

@ -127,6 +127,7 @@ sub wordle($self, $context) {
host => 'localhost', host => 'localhost',
hostmask => "$botnick!wordle\@localhost", hostmask => "$botnick!wordle\@localhost",
command => 'wordle', command => 'wordle',
keyword => 'wordle',
checkflood => 1, checkflood => 1,
message => "$context->{nick} started a custom $result", message => "$context->{nick} started a custom $result",
}; };
@ -284,7 +285,6 @@ sub guess_wordle($self, $channel, $guess) {
for (my $i = 0; $i < @wordle; $i++) { for (my $i = 0; $i < @wordle; $i++) {
if ($guess[$i] eq $wordle[$i]) { if ($guess[$i] eq $wordle[$i]) {
$seen{$guess[$i]}++;
$correct++; $correct++;
push @result, "*$guess[$i]*"; push @result, "*$guess[$i]*";
$self->{$channel}->{letters}->{$guess[$i]} = LETTER_CORRECT; $self->{$channel}->{letters}->{$guess[$i]} = LETTER_CORRECT;
@ -307,7 +307,10 @@ sub guess_wordle($self, $channel, $guess) {
$self->{$channel}->{letters}->{$guess[$i]} = LETTER_PRESENT; $self->{$channel}->{letters}->{$guess[$i]} = LETTER_PRESENT;
} else { } else {
push @result, "$guess[$i]"; push @result, "$guess[$i]";
$self->{$channel}->{letters}->{$guess[$i]} = LETTER_INVALID;
if ($self->{$channel}->{letters}->{$guess[$i]} == 0) {
$self->{$channel}->{letters}->{$guess[$i]} = LETTER_INVALID;
}
} }
} }
} }

View File

@ -25,7 +25,7 @@ use PBot::Imports;
# These are set by the /misc/update_version script # These are set by the /misc/update_version script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 4714, BUILD_REVISION => 4715,
BUILD_DATE => "2024-03-09", BUILD_DATE => "2024-03-09",
}; };