From e3251382494d1da5b09e05ba013a467368bdf3c2 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 7 Nov 2024 19:46:30 -0800 Subject: [PATCH] Plugin/Spinach: correct round1q3 state transition --- lib/PBot/Plugin/Spinach.pm | 17 +++++++++++------ lib/PBot/VERSION.pm | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/PBot/Plugin/Spinach.pm b/lib/PBot/Plugin/Spinach.pm index 07f1809a..bf9a03c0 100644 --- a/lib/PBot/Plugin/Spinach.pm +++ b/lib/PBot/Plugin/Spinach.pm @@ -724,7 +724,7 @@ sub cmd_spinach($self, $context) { when ('show') { if ($self->{current_state} =~ /(?:getlies|findtruth|showlies)$/) { $self->showquestion($self->{state_data}, 1); - return; + return ''; } return "$context->{nick}: There is nothing to show right now."; @@ -961,6 +961,7 @@ sub run_one_state($self) { # this shouldn't happen if (not defined $self->{current_state}) { $self->{pbot}->{logger}->log("Spinach state broke.\n"); + $self->send_message($self->{channel}, "Spinach state broke."); $self->{current_state} = 'nogame'; $self->{pbot}->{event_queue}->update_repeating('spinach loop', 0); return; @@ -983,7 +984,7 @@ sub run_one_state($self) { # dump new state data for logging/debugging if ($state_data->{newstate} and $self->{metadata}->get_data('settings', 'debug_state')) { - $self->{pbot}->{logger}->log("Spinach: New state: $self->{previous_state} ($state_data->{previous_result}) --> $self->{current_state}\n" . Dumper $state_data); + $self->{pbot}->{logger}->log("Spinach: New state: $self->{previous_state} ($state_data->{previous_result}) --> $self->{current_state}\n" . Dumper($state_data) . "\n"); } # run one state/tick @@ -1001,7 +1002,10 @@ sub run_one_state($self) { if (not exists $self->{states}{$self->{current_state}}{trans}{$state_data->{result}}) { $self->{pbot}->{logger}->log("Spinach: State broke: no such transistion to $state_data->{result} for state $self->{current_state}\n"); - # XXX: do something here + $self->send_message($self->{channel}, "Spinach state broke: no such transistion to $state_data->{result} for state $self->{current_state}"); + $self->{current_state} = 'nogame'; + $self->{pbot}->{event_queue}->update_repeating('spinach loop', 0); + return; } $self->{current_state} = $self->{states}{$self->{current_state}}{trans}{$state_data->{result}}; @@ -1521,6 +1525,7 @@ sub choosecategory($self, $state) { if (not @choices) { $self->{pbot}->{logger}->log("Out of questions with current settings!\n"); + $self->send_message($self->{channel}, "Out of questions with current settings! This will probably break something."); # XXX: do something useful here } @@ -2359,15 +2364,15 @@ sub r1q2showscore($self, $state) { } sub round1q3($self, $state) { - if ($state->{ticks} % 2 || $state->{reroll_category}) { + if ($state->{ticks} % 2 == 0 || $state->{reroll_category}) { $state->{init} = 1; $state->{max_count} = $self->{choosecategory_max_count}; $state->{counter} = 0; - $state->{result} = 'wait'; $self->send_message($self->{channel}, "Round 1/3, question 3/3! $state->{lie_points} for each lie. $state->{truth_points} for the truth.") unless $state->{reroll_category}; - } else { $state->{result} = 'next'; + } else { + $state->{result} = 'wait'; } return $state; } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index aced9730..85e3cdd8 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4841, + BUILD_REVISION => 4843, BUILD_DATE => "2024-11-07", };