mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 03:33:06 +01:00
Spinach: Add settings metadata: category_autopick and min_players
This commit is contained in:
parent
0b0390dbd7
commit
b2b74875e1
@ -155,6 +155,10 @@ sub load_stopwords {
|
||||
sub load_metadata {
|
||||
my $self = shift;
|
||||
$self->{metadata}->load;
|
||||
|
||||
if (not exists $self->{metadata}->hash->{settings}) {
|
||||
$self->{metadata}->hash->{settings} = {};
|
||||
}
|
||||
}
|
||||
|
||||
sub save_metadata {
|
||||
@ -1577,7 +1581,7 @@ sub choosecategory {
|
||||
if ($state->{ticks} % $tock == 0) {
|
||||
$state->{tocked} = 1;
|
||||
|
||||
if (exists $state->{random_category}) {
|
||||
if (exists $state->{random_category} or $self->{metadata}->{hash}->{settings}->{category_autopick}) {
|
||||
delete $state->{random_category};
|
||||
my $category = $state->{category_options}->[rand (@{$state->{category_options}} - 2)];
|
||||
$self->send_message($self->{channel}, "Category: $category!");
|
||||
@ -2096,7 +2100,9 @@ sub getplayers {
|
||||
}
|
||||
}
|
||||
|
||||
if (@$players > 1 and not $unready) {
|
||||
my $min_players = $self->{metadata}->{hash}->{settings}->{min_players} // 2;
|
||||
|
||||
if (@$players >= $min_players and not $unready) {
|
||||
$self->send_message($self->{channel}, "All players ready!");
|
||||
$state->{result} = 'allready';
|
||||
return $state;
|
||||
|
Loading…
Reference in New Issue
Block a user