3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-25 04:02:37 +01:00

Spinach: Add settings metadata: category_autopick and min_players

This commit is contained in:
Pragmatic Software 2019-04-23 18:41:57 -07:00
parent 0b0390dbd7
commit b2b74875e1

View File

@ -155,6 +155,10 @@ sub load_stopwords {
sub load_metadata { sub load_metadata {
my $self = shift; my $self = shift;
$self->{metadata}->load; $self->{metadata}->load;
if (not exists $self->{metadata}->hash->{settings}) {
$self->{metadata}->hash->{settings} = {};
}
} }
sub save_metadata { sub save_metadata {
@ -1577,7 +1581,7 @@ sub choosecategory {
if ($state->{ticks} % $tock == 0) { if ($state->{ticks} % $tock == 0) {
$state->{tocked} = 1; $state->{tocked} = 1;
if (exists $state->{random_category}) { if (exists $state->{random_category} or $self->{metadata}->{hash}->{settings}->{category_autopick}) {
delete $state->{random_category}; delete $state->{random_category};
my $category = $state->{category_options}->[rand (@{$state->{category_options}} - 2)]; my $category = $state->{category_options}->[rand (@{$state->{category_options}} - 2)];
$self->send_message($self->{channel}, "Category: $category!"); $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!"); $self->send_message($self->{channel}, "All players ready!");
$state->{result} = 'allready'; $state->{result} = 'allready';
return $state; return $state;