From bea5aa071bd4eb74d3df505bc852fa4b7d2c6846 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Thu, 21 Nov 2024 20:28:50 -0800 Subject: [PATCH] Plugin/Spinach: improve lie count log --- lib/PBot/Plugin/Spinach.pm | 14 ++++++++++---- lib/PBot/VERSION.pm | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/PBot/Plugin/Spinach.pm b/lib/PBot/Plugin/Spinach.pm index d13b6cbb..637544d4 100644 --- a/lib/PBot/Plugin/Spinach.pm +++ b/lib/PBot/Plugin/Spinach.pm @@ -681,6 +681,10 @@ sub cmd_spinach($self, $context) { return "$context->{nick}: You are not playing in this game. Use `j` to start playing now!"; } + if ($player->{lie_count} >= 2) { + return "/msg $context->{nick} You cannot change your lie again this round."; + } + $arguments = $self->normalize_text($arguments); my @truth_count = split /\s/, $self->{state_data}->{current_question}->{answer}; @@ -711,9 +715,7 @@ sub cmd_spinach($self, $context) { return "$context->{nick}: Your lie is too similar to the truth! Submit a different lie."; } - if (++$player->{lie_count} > 2) { - return "/msg $context->{nick} You cannot change your lie again this round."; - } + $player->{lie_count}++; my $changed = exists $player->{lie}; $player->{lie} = $arguments; @@ -1280,6 +1282,10 @@ sub run_one_state($self) { sub create_states($self) { $self->{pbot}->{logger}->log("Spinach: Creating game state machine\n"); + $self->{state_data} = { + players => [] + }; + $self->{previous_state} = ''; $self->{previous_result} = ''; $self->{current_state} = 'nogame'; @@ -1709,8 +1715,8 @@ sub showquestion($self, $state) { $state->{seen_questions}->{$state->{current_category}}->{$state->{current_question}->{id}} = 1; foreach my $player (@{$state->{players}}) { + $player->{lie_count} = 0; delete $player->{lie}; - delete $player->{lie_count}; delete $player->{truth}; delete $player->{good_lie}; delete $player->{deceived}; diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index cf39cc1f..8d0d05b9 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 => 4855, + BUILD_REVISION => 4856, BUILD_DATE => "2024-11-21", };