From e3c07ef59f5f70f8a1f670d76fd69ba755775897 Mon Sep 17 00:00:00 2001 From: gashapwn Date: Tue, 6 Apr 2021 23:29:45 +0000 Subject: [PATCH] LPST.pm - refactored into a class ntvl.pl - created a test board --- LPST.pm | 55 ++++++++++++++++++++++++------------------------------- ntvl.pl | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 31 deletions(-) create mode 100644 ntvl.pl diff --git a/LPST.pm b/LPST.pm index e48bbb8..1406c6b 100644 --- a/LPST.pm +++ b/LPST.pm @@ -107,7 +107,7 @@ sub new { return bless $self, $class; } -package main; +package LPST; # # /--\ +1 @@ -704,37 +704,30 @@ sub get_block_cell($){ } keys(%board); } +sub new { + my $class = shift; + my $self = { @_ }; - -# Main starts here! -#================================================== -binmode(STDOUT, ":utf8"); - -# Creates a hash of the the form -# $board{cell_notation} = piece_enum -%board = map { - $_ => $EMPTY_CELL -} map { - my $l0; - $l0 = $_; - (map {$l0.$_} ("1".."11")) -} map { - $AXIS_RV{$_} -}(1...11); - -# my $m1 = "F7"; -my $m1 = "C10"; -my $m2 = "B3"; -my $c1 = $MG_SY; -my $c2 = $MG_A; - -$board{$m1} = $P1.$DIV.$c1; -$board{$m2} = $P2.$DIV.$c2; - -for my $el (get_block_cell($P1)){ - printf("%s\n", $el); + # Creates a hash of the the form + # $board{cell_notation} = piece_enum + %board = map { + $_ => $EMPTY_CELL + } map { + my $l0; + $l0 = $_; + (map {$l0.$_} ("1".."11")) + } map { + $AXIS_RV{$_} + }(1...11); + + return bless $self, $class; } -shade_all_mvmt($P1); -disp_board(); +return 1; + +# Is this needed? +# binmode(STDOUT, ":utf8"); + + + diff --git a/ntvl.pl b/ntvl.pl new file mode 100644 index 0000000..5c875a3 --- /dev/null +++ b/ntvl.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +package main; + +use warnings; +use strict; + +use lib './'; +use LPST; + +my $b; + +# my $m1 = "F7"; +# my $m1 = "C10"; +# my $m2 = "B3"; +# my $c1 = $MG_SY; +# my $c2 = $MG_A; + +# $board{$m1} = $P1.$DIV.$c1; +# $board{$m2} = $P2.$DIV.$c2; + +# for my $el (get_block_cell($P1)){ +# printf("%s\n", $el); +# } + +# shade_all_mvmt($P1); +# disp_board(); + +$b = LPST->new(); + +$b->shade_all_mvmt("P1"); +$b->disp_board();