mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-06 20:19:33 +01:00
Spinach: Skipping now requires a majority
This commit is contained in:
parent
0f2d8ab21b
commit
5ed9c924a4
@ -13,7 +13,6 @@ no if $] >= 5.018, warnings => "experimental::smartmatch";
|
|||||||
use Carp ();
|
use Carp ();
|
||||||
use DBI;
|
use DBI;
|
||||||
use JSON;
|
use JSON;
|
||||||
use POSIX;
|
|
||||||
|
|
||||||
use Lingua::EN::Fractions qw/fraction2words/;
|
use Lingua::EN::Fractions qw/fraction2words/;
|
||||||
use Lingua::EN::Numbers qw/num2en num2en_ordinal/;
|
use Lingua::EN::Numbers qw/num2en num2en_ordinal/;
|
||||||
@ -101,13 +100,14 @@ sub load_questions {
|
|||||||
my $questions;
|
my $questions;
|
||||||
foreach my $key (keys %{$self->{questions}}) {
|
foreach my $key (keys %{$self->{questions}}) {
|
||||||
foreach my $question (@{$self->{questions}->{$key}}) {
|
foreach my $question (@{$self->{questions}->{$key}}) {
|
||||||
|
$question->{category} = uc $question->{category};
|
||||||
$self->{categories}{$question->{category}}{$question->{id}} = $question;
|
$self->{categories}{$question->{category}}{$question->{id}} = $question;
|
||||||
$questions++;
|
$questions++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $categories;
|
my $categories;
|
||||||
foreach my $category (sort keys %{$self->{categories}}) {
|
foreach my $category (sort { keys %{$self->{categories}{$b}} <=> keys %{$self->{categories}{$a}} } keys %{$self->{categories}}) {
|
||||||
my $count = keys %{$self->{categories}{$category}};
|
my $count = keys %{$self->{categories}{$category}};
|
||||||
$self->{pbot}->{logger}->log("Category [$category]: $count\n");
|
$self->{pbot}->{logger}->log("Category [$category]: $count\n");
|
||||||
$categories++;
|
$categories++;
|
||||||
@ -234,7 +234,7 @@ sub spinach_cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
when ('skip') {
|
when ('skip') {
|
||||||
return "Use `skip` to skip a question and return to the \"choose category\" stage. Half or more of the players must agree to skip.";
|
return "Use `skip` to skip a question and return to the \"choose category\" stage. A majority of the players must agree to skip.";
|
||||||
}
|
}
|
||||||
|
|
||||||
when ('abort') {
|
when ('abort') {
|
||||||
@ -550,7 +550,7 @@ sub spinach_cmd {
|
|||||||
return "$nick: You are not playing in this game. Use `j` to start playing now!";
|
return "$nick: You are not playing in this game. Use `j` to start playing now!";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $needed = ceil (@{$self->{state_data}->{players}} / 2);
|
my $needed = int (@{$self->{state_data}->{players}} / 2) + 1;
|
||||||
$needed -= $skipped;
|
$needed -= $skipped;
|
||||||
|
|
||||||
my $votes_needed;
|
my $votes_needed;
|
||||||
@ -1279,7 +1279,7 @@ sub choosecategory {
|
|||||||
my $comma = '';
|
my $comma = '';
|
||||||
foreach my $choice (@choices) {
|
foreach my $choice (@choices) {
|
||||||
my $count = keys %{$self->{categories}{$choice}};
|
my $count = keys %{$self->{categories}{$choice}};
|
||||||
$state->{categories_text} .= "$comma$i) " . uc $choice;
|
$state->{categories_text} .= "$comma$i) " . $choice;
|
||||||
$i++;
|
$i++;
|
||||||
$comma = "; ";
|
$comma = "; ";
|
||||||
}
|
}
|
||||||
@ -1396,7 +1396,7 @@ sub getlies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (@skips) {
|
if (@skips) {
|
||||||
my $needed = ceil (@{$state->{players}} / 2);
|
my $needed = int (@{$state->{players}} / 2) + 1;
|
||||||
$needed -= @skips;
|
$needed -= @skips;
|
||||||
return 'skip' if $needed <= 0;
|
return 'skip' if $needed <= 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user