diff --git a/bin/check_starter_zones.pl b/bin/check_starter_zones.pl new file mode 100644 index 00000000..58510cb9 --- /dev/null +++ b/bin/check_starter_zones.pl @@ -0,0 +1,73 @@ +use 5.010; +use strict; +use lib '/data/Lacuna-Server/lib'; +use Lacuna::DB; +use Lacuna; +use Lacuna::Util qw(format_date); +use Getopt::Long; +$|=1; + +our $quiet; + +GetOptions( + 'quiet' => \$quiet, +); + +out('Started'); +my $start = time; + +out('Loading DB'); +our $db = Lacuna->db; + +check_sz(); + + +my $finish = time; +out('Finished'); +out((($finish - $start)/60)." minutes have elapsed"); + + +############### +## SUBROUTINES +############### + + +sub check_sz { + my $sz_param = Lacuna->config->get('starter_zone'); + unless ($sz_param and $sz_param->{max_colonies}) { + out("No starter zone configured."); + return; + } + + my $empires = $db->resultset('Empire')->search({ id => { '>' => 1 }}); + +EMP: while (my $empire = $empires->next) + { + my $bodies = $empire->planets; + my $szb = 0; + while (my $body = $bodies->next) { + $szb++ if ($body->in_starter_zone); + if ($szb > $sz_param->{max_colonies}) { + $empire->send_predefined_message( + tags => ['Alert'], + filename => 'sz_exceeded.txt', + params => [ $sz_param->{max_colonies} ], + ); + out(sprintf("%s:%d has more than %d colonies in the starter zones.", + $empire->name, $empire->id, $sz_param->{max_colonies})); + next EMP; + } + } + } +} + +# UTILITIES + +sub out { + my $message = shift; + unless ($quiet) { + say format_date(DateTime->now), " ", $message; + } +} + + diff --git a/var/messages/zoning_board_warning.txt b/var/messages/zoning_board_warning.txt new file mode 100644 index 00000000..44a68e8a --- /dev/null +++ b/var/messages/zoning_board_warning.txt @@ -0,0 +1,9 @@ +Number of Starter Colonies Exceeded +~~~ +It has come to our attention that you have more than the allowed number of colonies in the starting area. This can not be allowed to continue, since we want to be sure new empires have an area to start off with. + +Please address this so that you only have %s number of colonies in the starting areas. + +Regards, + +TLE Zoning Board Enforcement Division