Game::TextPatterns - generate patterns of text
use Game::TextPatterns; my $v = Game::TextPatterns->new( pattern => ".#\n#." ); $v->multiply(7,3) ->border(1,'#')->border(1,'.')->border(1,'#'); print $v->string;
Ta-da! You should now have an Angband checker type vault. (Doors not included. Monsters and items may cost extra.)
#################### #..................# #.################.# #.#.#.#.#.#.#.#.##.# #.##.#.#.#.#.#.#.#.# #.#.#.#.#.#.#.#.##.# #.##.#.#.#.#.#.#.#.# #.#.#.#.#.#.#.#.##.# #.##.#.#.#.#.#.#.#.# @ #.################.# #..................# ####################
Game::TextPatterns contains methods that generate and alter text patterns. Potential uses include the creation of ASCII art or the construction of vaults for roguelike games.
Columns (x, width) and Rows (y, height) are used in various places.
columns ... r o ###%#######+###### w #...the.pattern..# s #######+########## . #........#.......# . #.......@'...<...# . ##################
The pattern text can be most any string value.
These return new objects. Some require an existing object.
Returns a new object from an existing one with the current state of the pattern attribute.
Constructor. A pattern attribute must be specified.
MooX::Rebuild feature that returns a new object with the original pattern attribute.
Only one at the moment.
Required. Must be a string (which will be split on $/ into an array reference) or an array reference of strings or an object that has a pattern method that ideally returns one of the previous types.
$/
File::Slurper may help read pattern data directly from a file.
pattern can be called as a method to return the current pattern as an array reference. It may be a bad idea to modify the contents of that reference directly.
Call these on something returned by a constructor. Those that modify the pattern in-place can be chained with other methods.
TODO
Creates a border of the given width (1 by default) and character (# by default) around the pattern.
#
Returns the width (x, or number of columns) in the pattern. This is based on the length of the first line of the pattern.
Returns the cols and rows of the current pattern.
Flips the pattern by columns and by rows.
Flips the columns (vertical mirror) in the pattern.
Flips the rows (horizontal mirror).
Multiplies the existing data in the columns or rows, unless cols or rows is 1. With no rows set multiplies both the columns and rows by the given value.
1
Returns the height (y, or number of rows) in the pattern.
Returns the pattern as a string with rows joined by the sep value (a newline by default).
Please report any bugs or feature requests to bug-game-textpatterns at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Game-TextPatterns.
bug-game-textpatterns at rt.cpan.org
Patches might best be applied towards:
https://github.com/thrig/Game-TextPatterns
The newly being written thing (look for TODO or otherwise absent methods).
https://github.com/thrig/ministry-of-silly-vaults/
Consult the t/ directory under this module's distribution for example code.
t/
thrig - Jeremy Mates (cpan:JMATES) <jmates at cpan.org>
<jmates at cpan.org>
Copyright (C) 2018 by Jeremy Mates
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause
To install Game::TextPatterns, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Game::TextPatterns
CPAN shell
perl -MCPAN -e shell install Game::TextPatterns
For more information on module installation, please visit the detailed CPAN module installation guide.