From 441c390b09411a6a0ab409202006656c40c0f493 Mon Sep 17 00:00:00 2001 From: gashapwn Date: Sun, 4 Apr 2021 01:45:03 +0000 Subject: [PATCH] lpst.pl - added enums for player... tried to add a piece to a cell and board got fucked up... i think the hash that stores piece data is borked. will fix --- lpst.pl | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/lpst.pl b/lpst.pl index c1d11e1..b85bfe3 100644 --- a/lpst.pl +++ b/lpst.pl @@ -41,6 +41,12 @@ my $MG_AU = "Au"; # Automaton my $MG_SY = "Sy"; # Sylph my $MG_Q = "Q"; # Queen +# Players +my $P1 = "P1"; +my $P2 = "P2"; + +my $DIV = ":"; + my %AXIS = ( "A" => 1, "B" => 2, @@ -201,10 +207,24 @@ my %MOVE = ( ); # Special cells -my $EMPTY_CELL = 900; +my $EMPTY_CELL = "_"; my %board; +# Display pieces +#================================================== + +sub f_1($){ + my $p = shift; + my $s0; + + $p =~ s/($P1|$P2)$DIV//; + $p .= "_" if length($p) < 2; + $s0 = $HEX_2; + $s0 =~ s/$SUB_CHR{1,2}/$p/; + + return $s0; +} # Display lines #================================================== @@ -216,7 +236,13 @@ sub disp_1($$){ sub disp_2($$){ my ($r0, $c0) = (shift, shift); - return $HEX_2; + my $p; + + $p = $board{$r0}{$c0}; + + return f_1($p); + # my ($r0, $c0) = (shift, shift); + # return $HEX_2; } sub disp_3($$){ @@ -361,11 +387,15 @@ sub cell_index($){ my $l0; $l0 = $_; (map {$l0.$_} ("1".."11")) -} map{ +} map { $AXIS_RV{$_} }(1...11); -disp_board(); +$board{1}{1} = $P1.$DIV.$MG_A; + + +printf("%s\n", $board{3}{3}); +# disp_board(); # disp_0("C1"); # printf(">>%s, %s\n", cell_index("C1"));