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

Plugin/WordMorph: minor refactoring/clean-up

This commit is contained in:
Pragmatic Software 2022-08-31 23:09:10 -07:00
parent f71e08cf7f
commit 82edbd2a18
2 changed files with 7 additions and 6 deletions

View File

@ -77,11 +77,13 @@ sub wordmorph {
return "Unknown direction `$args[0]`; usage: wordmorph hint [from direction]; from direction can be `left` or `right`";
}
my $end = $#{$self->{$channel}->{morph}};
if ($direction == LEFT) {
$self->{$channel}->{hintL}++;
if ($self->{$channel}->{hintL} > $#{$self->{$channel}->{morph}}) {
$self->{$channel}->{hintL} = $#{$self->{$channel}->{morph}};
if ($self->{$channel}->{hintL} > $end) {
$self->{$channel}->{hintL} = $end;
}
} else {
$self->{$channel}->{hintR}--;
@ -92,7 +94,6 @@ sub wordmorph {
}
my @hints;
my $end = $#{$self->{$channel}->{morph}};
$hints[0] = $self->{$channel}->{morph}->[0];
$hints[$end] = $self->{$channel}->{morph}->[$end];
@ -108,7 +109,7 @@ sub wordmorph {
$hints[$i] = $blank_hint;
}
for (my $i = $#{$self->{$channel}->{morph}} - 1; $i > $self->{$channel}->{hintR}; $i--) {
for (my $i = $end - 1; $i > $self->{$channel}->{hintR}; $i--) {
my $word1 = $self->{$channel}->{morph}->[$i];
my $word2 = $self->{$channel}->{morph}->[$i + 1];
$hints[$i] = $self->form_hint($word1, $word2);

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 => 4579,
BUILD_REVISION => 4580,
BUILD_DATE => "2022-08-31",
};