Commits

Anonymous committed 1373d66

Add get_letter_at_pos.

  • Participants
  • Parent commits 6573fa2

Comments (0)

Files changed (2)

abc-path/Games-ABC_Path-Generator/lib/Games/ABC_Path/Generator/FinalLayoutObj.pm

     return vec($self->_s, $index, 8) ;
 }
 
+=head2 my $letter = $layout->get_letter_at_pos({y => $y, x => $x});
+
+Returns the letter at $y and $x .
+
+=cut
+
+sub get_letter_at_pos
+{
+    my ($self, $pos) = @_;
+
+    return $letters[
+        $self->get_cell_contents(
+            $self->_xy_to_int(
+                [$pos->{'y'},$pos->{'x'}],
+            )
+        )-1,
+    ];
+}
+
+=head2 $layout->as_string($args);
+
+Represents the layout as string.
+
+=cut
+
 =head2 $layout->as_string($args);
 
 Represents the layout as string.

abc-path/Games-ABC_Path-Generator/t/riddle-obj.t

 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More tests => 6;
 use Test::Differences;
 
 use Games::ABC_Path::Generator;
         { y => 3, x => 1, },
         "get_A_xy is ok."
     );
+
+    # TEST
+    is ($layout->get_letter_at_pos({y => 0, x => 0,}),
+        'Y',
+        'get_letter_at_pos #1',
+    );
 }