mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-20 02:49:49 +01:00
Spinach: reveal lies when skipping/rerolling; do not allow one word lies if truth contains more than one word
This commit is contained in:
parent
1b3def08e4
commit
a027f563ca
@ -189,16 +189,25 @@ sub load_metadata {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->{metadata}->load;
|
$self->{metadata}->load;
|
||||||
|
|
||||||
if (not exists $self->{metadata}->hash->{settings}) {
|
my $defaults = {
|
||||||
$self->{metadata}->hash->{settings} = {
|
|
||||||
category_choices => 7,
|
category_choices => 7,
|
||||||
category_autopick => 0,
|
category_autopick => 0,
|
||||||
min_players => 2,
|
min_players => 2,
|
||||||
stats => 1,
|
stats => 1,
|
||||||
seen_expiry => 432000,
|
seen_expiry => 432000,
|
||||||
min_difficulty => 0,
|
min_difficulty => 0,
|
||||||
max_difficulty => 25000
|
max_difficulty => 25000,
|
||||||
|
max_missed_inputs => 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (not exists $self->{metadata}->hash->{settings}) {
|
||||||
|
$self->{metadata}->hash->{settings} = $defaults;
|
||||||
|
} else {
|
||||||
|
foreach my $key (keys %$defaults) {
|
||||||
|
if (not exists $self->{metadata}->hash->{settings}->{$key}) {
|
||||||
|
$self->{metadata}->hash->{settings}->{$key} = $defaults->{$key};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,6 +750,13 @@ sub spinach_cmd {
|
|||||||
|
|
||||||
$arguments = $self->normalize_text($arguments);
|
$arguments = $self->normalize_text($arguments);
|
||||||
|
|
||||||
|
my @truth_count = split /\b/, $self->{state_data}->{current_question}->{answer};
|
||||||
|
my @lie_count = split /b/, $arguments;
|
||||||
|
|
||||||
|
if (@truth_count > 1 and @lie_count == 1) {
|
||||||
|
return "/msg $nick Your lie cannot be one word for this question. Please try again.";
|
||||||
|
}
|
||||||
|
|
||||||
my $found_truth = 0;
|
my $found_truth = 0;
|
||||||
|
|
||||||
if (not $self->validate_lie($self->{state_data}->{current_question}->{answer}, $arguments)) {
|
if (not $self->validate_lie($self->{state_data}->{current_question}->{answer}, $arguments)) {
|
||||||
@ -1079,7 +1095,7 @@ sub run_one_state {
|
|||||||
if ($self->{current_state} =~ /r\dq\d/) {
|
if ($self->{current_state} =~ /r\dq\d/) {
|
||||||
my $removed = 0;
|
my $removed = 0;
|
||||||
for (my $i = 0; $i < @{$self->{state_data}->{players}}; $i++) {
|
for (my $i = 0; $i < @{$self->{state_data}->{players}}; $i++) {
|
||||||
if ($self->{state_data}->{players}->[$i]->{missedinputs} >= 3) {
|
if ($self->{state_data}->{players}->[$i]->{missedinputs} >= $self->{metadata}->{hash}->{settings}->{max_missed_inputs}) {
|
||||||
$self->send_message($self->{channel}, "$color{red}$self->{state_data}->{players}->[$i]->{name} has missed too many prompts and has been ejected from the game!$color{reset}");
|
$self->send_message($self->{channel}, "$color{red}$self->{state_data}->{players}->[$i]->{name} has missed too many prompts and has been ejected from the game!$color{reset}");
|
||||||
splice @{$self->{state_data}->{players}}, $i--, 1;
|
splice @{$self->{state_data}->{players}}, $i--, 1;
|
||||||
$removed = 1;
|
$removed = 1;
|
||||||
@ -1588,6 +1604,7 @@ sub normalize_text {
|
|||||||
$text =~ s/-/ /g;
|
$text =~ s/-/ /g;
|
||||||
$text =~ s/["'?!]//g;
|
$text =~ s/["'?!]//g;
|
||||||
$text =~ s/\s+/ /g;
|
$text =~ s/\s+/ /g;
|
||||||
|
$text =~ s/^\s+|\s+$//g;
|
||||||
|
|
||||||
return substr $text, 0, 80;
|
return substr $text, 0, 80;
|
||||||
}
|
}
|
||||||
@ -1873,18 +1890,21 @@ sub getlies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
my @nolies;
|
my @nolies;
|
||||||
foreach my $player (@{$state->{players}}) {
|
my $reveallies = ". Revealing lies! ";
|
||||||
if (not exists $player->{lie}) {
|
my $lies = 0;
|
||||||
push @nolies, $player->{name};
|
my $comma = '';
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'next' if not @nolies;
|
|
||||||
|
|
||||||
my @keeps;
|
my @keeps;
|
||||||
my @rerolls;
|
my @rerolls;
|
||||||
my @skips;
|
my @skips;
|
||||||
foreach my $player (@{$state->{players}}) {
|
foreach my $player (@{$state->{players}}) {
|
||||||
|
if (not exists $player->{lie}) {
|
||||||
|
push @nolies, $player->{name};
|
||||||
|
} else {
|
||||||
|
$lies++;
|
||||||
|
$reveallies .= "$comma$player->{name}: $player->{lie}";
|
||||||
|
$comma = '; ';
|
||||||
|
}
|
||||||
|
|
||||||
if ($player->{reroll}) {
|
if ($player->{reroll}) {
|
||||||
push @rerolls, $player->{name};
|
push @rerolls, $player->{name};
|
||||||
}
|
}
|
||||||
@ -1898,13 +1918,17 @@ sub getlies {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 'next' if not @nolies;
|
||||||
|
|
||||||
|
$reveallies = "" if not $lies;
|
||||||
|
|
||||||
if (@rerolls) {
|
if (@rerolls) {
|
||||||
my $needed = int (@{$state->{players}} / 2) + 1;
|
my $needed = int (@{$state->{players}} / 2) + 1;
|
||||||
$needed += @keeps;
|
$needed += @keeps;
|
||||||
$needed -= @rerolls;
|
$needed -= @rerolls;
|
||||||
if ($needed <= 0) {
|
if ($needed <= 0) {
|
||||||
$state->{reroll_question} = 1;
|
$state->{reroll_question} = 1;
|
||||||
$self->send_message($self->{channel}, "The answer was: " . uc $state->{current_question}->{answer});
|
$self->send_message($self->{channel}, "The answer was: " . uc ($state->{current_question}->{answer}) . $reveallies);
|
||||||
return 'reroll';
|
return 'reroll';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1914,7 +1938,7 @@ sub getlies {
|
|||||||
$needed += @keeps;
|
$needed += @keeps;
|
||||||
$needed -= @skips;
|
$needed -= @skips;
|
||||||
if ($needed <= 0) {
|
if ($needed <= 0) {
|
||||||
$self->send_message($self->{channel}, "The answer was: " . uc $state->{current_question}->{answer});
|
$self->send_message($self->{channel}, "The answer was: " . uc ($state->{current_question}->{answer}) . $reveallies);
|
||||||
return 'skip';
|
return 'skip';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user