From 1cb6a114b8ce3e5d2f2aef7d9351cc7243e1d504 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 5 Mar 2024 22:00:55 -0800 Subject: [PATCH] Plugin/Battleship: fix bomb input constraints Players who have been removed or have lost can no longer attack. Fix attack range checks. --- lib/PBot/Plugin/Battleship.pm | 10 +++++++++- lib/PBot/VERSION.pm | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/PBot/Plugin/Battleship.pm b/lib/PBot/Plugin/Battleship.pm index 4c709f80..32bb19ef 100644 --- a/lib/PBot/Plugin/Battleship.pm +++ b/lib/PBot/Plugin/Battleship.pm @@ -378,6 +378,14 @@ sub cmd_battleship($self, $context) { return "You are not playing in this game."; } + if ($player->{lost}) { + return "You have been knocked out of this game. Try again next game."; + } + + if ($player->{removed}) { + return "You have been removed from this game. Try again next game."; + } + # no arguments provided if (not length $arguments) { if (delete $player->{location}) { @@ -399,7 +407,7 @@ sub cmd_battleship($self, $context) { $x = ord($x) - 65; - if ($x < 0 || $x > $self->{N_Y} || $y < 0 || $y > $self->{N_X}) { + if ($x < 0 || $x > $self->{N_Y} - 1 || $y < 1 || $y > $self->{N_X}) { return "$nick: Target out of range, try again."; } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index c040f502..38da3fb4 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 => 4704, + BUILD_REVISION => 4705, BUILD_DATE => "2024-03-05", };