Commits

Anonymous committed c1239a4

Extract common constants.

  • Participants
  • Parent commits 7efcf6f

Comments (0)

Files changed (5)

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

 Changes
 inc/Test/Run/Builder.pm
 lib/Games/ABC_Path/Generator/App.pm
+lib/Games/ABC_Path/Generator/Constants.pm
 lib/Games/ABC_Path/Generator/FinalLayoutObj.pm
 lib/Games/ABC_Path/Generator.pm
 lib/Games/ABC_Path/Generator/RiddleObj.pm

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

 
 use base 'Games::ABC_Path::Solver::Base';
 
+use Games::ABC_Path::Generator::Constants;
+
 use Games::ABC_Path::Solver::Board '0.1.0';
 
 use Games::ABC_Path::MicrosoftRand;
     return;
 }
 
-my $LEN = 5;
-my $BOARD_SIZE = $LEN*$LEN;
-my $Y = 0;
-my $X = 1;
-
 sub _to_xy
 {
     my ($self, $int) = @_;
     return $xy->[$Y] * $LEN + $xy->[$X];
 }
 
-my @letters = ('A' .. 'Y');
-
 sub _fisher_yates_shuffle {
     my ($self, $deck) = @_;
     return unless @$deck; # must not be empty!
     die "Not found!";
 }
 
-
-my $NUM_CLUES = (2+5+5);
-
 =head2 $gen->calc_riddle()
 
 Calculates the riddle (final state + initial hints) and returns it as an object.

File abc-path/Games-ABC_Path-Generator/lib/Games/ABC_Path/Generator/Constants.pm

+package Games::ABC_Path::Generator::Constants;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Games::ABC_Path::Generator::Constants - constants in use by the generator.
+B<FOR INTERNAL USE!>.
+
+=cut
+
+our $VERSION = '0.0.1';
+
+=head1 VERSION
+
+Version 0.0.1
+
+=cut
+
+
+use base 'Exporter';
+
+our $LEN = 5;
+our $BOARD_SIZE = $LEN * $LEN;
+our $Y = 0;
+our $X = 1;
+our @letters = ('A' .. 'Y');
+our $NUM_CLUES = (2+$LEN+$LEN);
+
+our @EXPORT =
+(
+    qw($X $Y $NUM_CLUES @letters $LEN $BOARD_SIZE)
+);
+
+1;
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/> .
+
+=head1 BUGS
+
+Please report any bugs or feature requests to C<bug-games-abc_path-generator at rt.cpan.org>, or through
+the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-ABC_Path-Generator>.  I will be notified, and then you'll
+automatically be notified of progress on your bug as I make changes.
+
+
+
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+    perldoc Games::ABC_Path::Generator::Constants
+
+You can also look for information at:
+
+=over 4
+
+=item * RT: CPAN's request tracker (report bugs here)
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-ABC_Path-Generator>
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Games-ABC_Path-Generator>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Games-ABC_Path-Generator>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Games-ABC_Path-Generator/>
+
+=back
+
+
+=head1 ACKNOWLEDGEMENTS
+
+
+=head1 LICENSE AND COPYRIGHT
+
+Copyright 2011 Shlomi Fish.
+
+This program is distributed under the MIT (X11) License:
+L<http://www.opensource.org/licenses/mit-license.php>
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+
+=cut
+
+1; # End of Games::ABC_Path::Generator::Constants

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

 
 use base 'Games::ABC_Path::Solver::Base';
 
+use Games::ABC_Path::Generator::Constants;
+
 =head1 NAME
 
 Games::ABC_Path::Generator::FinalLayoutObj - represents a final layout.
 
 our $VERSION = '0.0.1';
 
-# TODO : Merge with Games::ABC_Path::Generator
-my $Y = 0;
-my $X = 1;
-my $NUM_CLUES = (2+5+5);
-my @letters = ('A' .. 'Y');
-my $LEN = 5;
-
 =head1 SYNOPSIS
 
     use Games::ABC_Path::Generator;

File abc-path/Games-ABC_Path-Generator/lib/Games/ABC_Path/Generator/RiddleObj.pm

 
 use base 'Games::ABC_Path::Solver::Base';
 
+use Games::ABC_Path::Generator::Constants;
+
 =head1 NAME
 
 Games::ABC_Path::Generator::RiddleObj - represents a riddle.
 
 our $VERSION = '0.0.1';
 
-# TODO : Merge with Games::ABC_Path::Generator
-my $Y = 0;
-my $X = 1;
-my $NUM_CLUES = (2+5+5);
-my @letters = ('A' .. 'Y');
-
 =head1 SYNOPSIS
 
     use Games::ABC_Path::Generator;