Commits

Anonymous committed 7f1227e

Convert another move to a _format.

  • Participants
  • Parent commits aaf038b

Comments (0)

Files changed (3)

File abc-path/Games-ABC_Path-Solver/MANIFEST

 lib/Games/ABC_Path/Solver/Base.pm
 lib/Games/ABC_Path/Solver/Board.pm
 lib/Games/ABC_Path/Solver/Move/LastRemainingCellForLetter.pm
+lib/Games/ABC_Path/Solver/Move/LastRemainingLetterForCell.pm
 lib/Games/ABC_Path/Solver/Move/LettersNotInVicinity.pm
 lib/Games/ABC_Path/Solver/Move.pm
 lib/Games/ABC_Path/Solver.pm

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

 
 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;
 
 my $ABCP_VERDICT_NO = 0;
             {
                 $self->_set_conclusive_verdict_for_letter($letter, [$x, $y]);
                 $self->_add_move(
-                    Games::ABC_Path::Solver::Move->new(
+                    Games::ABC_Path::Solver::Move::LastRemainingLetterForCell->new(
                         {
-                            text => sprintf(
-                                "The only letter that can be at (%d,%d) is %s. Invalidating it for all other cells.", 
-                                $x+1,$y+1, $letters[$letter]
-                            ),
-                        }
+                            vars =>
+                            {
+                                coords => [$x,$y],
+                                letter => $letter,
+                            },
+                        },
                     )
                 );
             }

File abc-path/Games-ABC_Path-Solver/lib/Games/ABC_Path/Solver/Move/LastRemainingLetterForCell.pm

+package Games::ABC_Path::Solver::Move::LastRemainingLetterForCell;
+
+use strict;
+use warnings;
+
+use base 'Games::ABC_Path::Solver::Move';
+
+=head1 NAME
+
+Games::ABC_Path::Solver::Move::LastRemainingLetterForCell - an ABC Path move
+that indicates it's the last remaining letter for a given cell.
+
+=head1 VERSION
+
+Version 0.0.1
+
+=cut
+
+our $VERSION = '0.0.1';
+
+=head1 SYNOPSIS
+
+    use Games::ABC_Path::Solver::Move::LastRemainingLetterForCell;
+
+    my $move = Games::ABC_Path::Solver::Move::LastRemainingLetterForCell->new(
+        {
+            vars =>
+            {
+                coords => [1,2],
+                letter => 5,
+            },
+        }
+    );
+
+=head1 DESCRIPTION
+
+This is a move that indicates that the cell C<'coords'> has the last remaining
+letter as C<'letter'>.
+
+=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 "The only letter that can be at %(coords){coords} is %(letter){letter}. Invalidating it for all other cells.";
+}
+
+1;
+