summaryrefslogtreecommitdiff
path: root/lib/TextPrinter.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TextPrinter.pm')
-rw-r--r--lib/TextPrinter.pm46
1 files changed, 13 insertions, 33 deletions
diff --git a/lib/TextPrinter.pm b/lib/TextPrinter.pm
index d786b86..7ef8572 100644
--- a/lib/TextPrinter.pm
+++ b/lib/TextPrinter.pm
@@ -3,45 +3,25 @@ use strict;
use warnings;
use Term::ANSIColor;
-{
-my %colours = (
- 'black' => [
- map { color($_,'on_black') }
- 'dark yellow','dark green','dark blue'
- ],
- 'white' => [
+my @colours = (
+ color('reset'), # filler
+ (
map { color($_,'on_white') }
- 'green', 'blue', 'yellow'
- ],
+ 'blue', 'green',
+ ),
+ (
+ map { color($_,'on_black') }
+ 'dark yellow','dark green',
+ ),
);
-my $strip_length = 0;
-
-sub rotate {
- my ($arr) = @_;
-
- my $el = shift @$arr;
- push @$arr, $el;
- return;
-}
-
-sub next_colour {
- my ($which) = @_;
+sub draw_cell {
+ my ($cell) = @_;
- if ($strip_length < 1) {
- $strip_length = 1+int(rand(7));
- rotate($colours{$which});
- }
- --$strip_length;
- return $colours{$which}->[0];
-}
+ print $colours[$cell->[0]],
+ $cell->[1];
}
-
-sub draw_cell {
- print next_colour(shift eq '*' ? 'black' : 'white'),
- chr(65+int(rand(26)));
-}
{
my $white = color('black','on_white');
my $reset = color('reset');