3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-22 03:49:29 +01:00

Plugin/Spinach: fix subroutine signatures

This commit is contained in:
Pragmatic Software 2024-03-06 15:07:09 -08:00
parent 1cb6a114b8
commit 7d3cd3f215
No known key found for this signature in database
GPG Key ID: CC916B6E3C84ECCE
4 changed files with 16 additions and 16 deletions

View File

@ -1345,8 +1345,8 @@ sub create_states($self) {
$self->{states}{'gameover'}{trans}{next} = 'getplayers'; $self->{states}{'gameover'}{trans}{next} = 'getplayers';
} }
sub commify($self) { sub commify($self, $value) {
my $text = reverse $_[0]; my $text = reverse $value;
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text; return scalar reverse $text;
} }
@ -1662,7 +1662,7 @@ sub getnewquestion($self, $state) {
} }
} }
sub showquestion($self, $state, $show_category) { sub showquestion($self, $state, $show_category = undef) {
return if $state->{reroll_category}; return if $state->{reroll_category};
if (exists $state->{current_question}) { if (exists $state->{current_question}) {

View File

@ -28,34 +28,34 @@ sub initialize($self, %conf) {
$self->{stats} = PBot::Plugin::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{filename}); $self->{stats} = PBot::Plugin::Spinach::Stats->new(pbot => $self->{pbot}, filename => $self->{filename});
} }
sub sort_generic($self, $key) { sub sort_generic($self, $key, @rest) {
if ($self->{rank_direction} eq '+') { return $b->{$key} <=> $a->{$key}; } if ($self->{rank_direction} eq '+') { return $b->{$key} <=> $a->{$key}; }
else { return $a->{$key} <=> $b->{$key}; } else { return $a->{$key} <=> $b->{$key}; }
} }
sub print_generic($self, $key, $player) { sub print_generic($self, $key, $player, @rest) {
return undef if $player->{games_played} == 0; return undef if $player->{games_played} == 0;
return "$player->{nick}: $player->{$key}"; return "$player->{nick}: $player->{$key}";
} }
sub print_avg_score($self, $player) { sub print_avg_score($self, $player, @rest) {
return undef if $player->{games_played} == 0; return undef if $player->{games_played} == 0;
my $result = int $player->{avg_score}; my $result = int $player->{avg_score};
return "$player->{nick}: $result"; return "$player->{nick}: $result";
} }
sub sort_bad_lies($self) { sub sort_bad_lies($self, @rest) {
if ($self->{rank_direction} eq '+') { return $b->{questions_played} - $b->{good_lies} <=> $a->{questions_played} - $a->{good_lies}; } if ($self->{rank_direction} eq '+') { return $b->{questions_played} - $b->{good_lies} <=> $a->{questions_played} - $a->{good_lies}; }
else { return $a->{questions_played} - $a->{good_lies} <=> $b->{questions_played} - $b->{good_lies}; } else { return $a->{questions_played} - $a->{good_lies} <=> $b->{questions_played} - $b->{good_lies}; }
} }
sub print_bad_lies($self, $player) { sub print_bad_lies($self, $player, @rest) {
return undef if $player->{games_played} == 0; return undef if $player->{games_played} == 0;
my $result = $player->{questions_played} - $player->{good_lies}; my $result = $player->{questions_played} - $player->{good_lies};
return "$player->{nick}: $result"; return "$player->{nick}: $result";
} }
sub sort_mentions($self) { sub sort_mentions($self, @rest) {
if ($self->{rank_direction} eq '+') { if ($self->{rank_direction} eq '+') {
return $b->{games_played} - $b->{times_first} - $b->{times_second} - $b->{times_third} <=> $a->{games_played} - $a->{times_first} - $a->{times_second} - return $b->{games_played} - $b->{times_first} - $b->{times_second} - $b->{times_third} <=> $a->{games_played} - $a->{times_first} - $a->{times_second} -
$a->{times_third}; $a->{times_third};
@ -65,13 +65,13 @@ sub sort_mentions($self) {
} }
} }
sub print_mentions($self, $player) { sub print_mentions($self, $player, @rest) {
return undef if $player->{games_played} == 0; return undef if $player->{games_played} == 0;
my $result = $player->{games_played} - $player->{times_first} - $player->{times_second} - $player->{times_third}; my $result = $player->{games_played} - $player->{times_first} - $player->{times_second} - $player->{times_third};
return "$player->{nick}: $result"; return "$player->{nick}: $result";
} }
sub sort_expr($self) { sub sort_expr($self, @rest) {
my $result = eval { my $result = eval {
my $result_a = $self->{expr}->val( my $result_a = $self->{expr}->val(
{ {
@ -123,7 +123,7 @@ sub sort_expr($self) {
return $result; return $result;
} }
sub print_expr($self, $player) { sub print_expr($self, $player, @rest) {
return undef if $player->{games_played} == 0; return undef if $player->{games_played} == 0;
my $result = eval { my $result = eval {
@ -155,7 +155,7 @@ sub print_expr($self, $player) {
return "$player->{nick}: $result"; return "$player->{nick}: $result";
} }
sub rank($self, $arguments) { sub rank($self, $arguments, @rest) {
my %ranks = ( my %ranks = (
highscore => { highscore => {
sort => sub { $self->sort_generic('high_score', @_) }, sort => sub { $self->sort_generic('high_score', @_) },

View File

@ -75,7 +75,7 @@ sub add_player($self, $id, $nick, $channel) {
return $id; return $id;
} }
sub get_player_id($self, $nick, $channel, $dont_create_new) { sub get_player_id($self, $nick, $channel, $dont_create_new = undef) {
my ($account_id) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($nick); my ($account_id) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($nick);
$account_id = $self->{pbot}->{messagehistory}->{database}->get_ancestor_id($account_id); $account_id = $self->{pbot}->{messagehistory}->{database}->get_ancestor_id($account_id);

View File

@ -25,8 +25,8 @@ 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 => 4705, BUILD_REVISION => 4706,
BUILD_DATE => "2024-03-05", BUILD_DATE => "2024-03-06",
}; };
sub initialize {} sub initialize {}