Commits

Anonymous committed cc1042f

Add ::ResultsInASuccess.

  • Participants
  • Parent commits 63f27cc

Comments (0)

Files changed (3)

abc-path/Games-ABC_Path-Solver/MANIFEST

 lib/Games/ABC_Path/Solver/Move/LettersNotInVicinity.pm
 lib/Games/ABC_Path/Solver/Move.pm
 lib/Games/ABC_Path/Solver/Move/ResultsInAnError.pm
+lib/Games/ABC_Path/Solver/Move/ResultsInASuccess.pm
 lib/Games/ABC_Path/Solver/Move/TryingLetterForCell.pm
 lib/Games/ABC_Path/Solver.pm
 Makefile.PL

abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Board.pm

 
 use base 'Games::ABC_Path::Solver::Base';
 
-use Games::ABC_Path::Solver::Move;
 use Games::ABC_Path::Solver::Move::LastRemainingCellForLetter;
 use Games::ABC_Path::Solver::Move::LastRemainingLetterForCell;
 use Games::ABC_Path::Solver::Move::LettersNotInVicinity;
 use Games::ABC_Path::Solver::Move::ResultsInAnError;
+use Games::ABC_Path::Solver::Move::ResultsInASuccess;
 use Games::ABC_Path::Solver::Move::TryingLetterForCell;
 
 my $ABCP_VERDICT_NO = 0;
             else
             {
                 $self->_add_move(
-                    Games::ABC_Path::Solver::Move->new(
+                    Games::ABC_Path::Solver::Move::ResultsInASuccess->new(
                         {
-                            text => 
-                            sprintf(
-                                "Trying %s for (%d,%d) returns a success.", 
-                                $letters[$letter], $x+1,$y+1
-                            ),
+                            vars => { letter => $letter, coords => [$x,$y],},
                         }
                     )
                 );
 
 =head2 $board->get_moves()
 
-Returns the moves performed by the board. Each move is a 
-L<Games::ABC_Path::Solver::Move> object.
+Returns the moves performed by the board. Each move is an
+object of a L<Games::ABC_Path::Solver::Move> sub-class.
 
 =cut
 

abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Move/ResultsInASuccess.pm

+package Games::ABC_Path::Solver::Move::ResultsInASuccess;
+
+use strict;
+use warnings;
+
+use base 'Games::ABC_Path::Solver::Move';
+
+=head1 NAME
+
+Games::ABC_Path::Solver::Move::ResultsInASuccess - indicates that a trial
+selection resulted in an error.
+
+=head1 VERSION
+
+Version 0.0.1
+
+=cut
+
+our $VERSION = '0.0.1';
+
+=head1 SYNOPSIS
+
+    use Games::ABC_Path::Solver::Move::ResultsInASuccess;
+
+    my $move = Games::ABC_Path::Solver::Move::ResultsInASuccess->new(
+        {
+            vars =>
+            {
+                letter => $letter,
+                coords => [$x,$y],
+            },
+        }
+    );
+
+=head1 DESCRIPTION
+
+This is a move that a branch resulted in an error.
+
+=cut
+
+sub _get_text {
+    my $self = shift;
+
+    my $text = $self->_format;
+
+    $text =~ s/%\((\w+)\)\{(\w+)\}/
+        $self->_expand_format($1,$2)
+        /ge;
+
+    return $text;
+}
+
+sub _format {
+    return "Trying %(letter){letter} for %(coords){coords} returns a success.";
+}
+
+1;
+