App-SweeperBot
view release on metacpan or search on metacpan
lib/App/SweeperBot.pm view on Meta::CPAN
# Square width and height.
use constant SQUARE_W => 16;
use constant SQUARE_H => 16;
# Top-left square location (15,104)
use constant SQUARE1X => 15;
use constant MIN_SQUARE1Y => 96;
use constant MAX_SQAURE1Y => 115;
# How far left of the smiley to click to focus on the board.
use constant FOCUS_X_OFFSET => 50;
my $Square1Y;
my %char_for = (
0 => 0,
unpressed => ".",
1 => 1,
2 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 7,
8 => 8,
bomb => "x",
bomb_hilight => "X",
flag => "*",
);
# 1 => Won, -1 => Lost, 0 => Still playing
my %smiley_type = (
'd28bcc05d38fd736f6715388a12cb0b96da9852432669671ee7866135f35bbb7' => 1,
'efef2037072c56fb029da1dd2cd626282173d0e1b2be39eab3e955cd2bcdc856' => 1,
'08938969d349a6677a17a65a57f2887a85d1a7187dcd6c20d238e279a5ec3c18' => -1,
'7cf1797ad25730136aa67c0a039b0c596f1aed9de8720999145248c72df52d1b' => -1,
'56f7c05869d42918830e80ad5bf841109d88e17b38fc069c3e5bf19623a88711' => 0,
'0955e50dda3f850913392d4e654f9ef45df046f063a4b8faeff530609b37379f' => 0,
);
# old - Bribes distro ImageMagick
# new - "Official" ImageMagick
# NB: This code is primarily tested under the bribes distribution of
# ImageMagick, because it plays nicely with PAR. YMMV with other
# versions.
my %contents_of_square = (
"0b6f3e019208789db304a8a8c8bd509dacf62050a962ae9a0385733d6b595427" => 0, # old
"cd348e1e78e4032f472c5c065c99d8289dffff7041096aa8746e29794a032698" => 0, # new
"35fc6aa19ab4b99bf7d4a750767ee329b773fb2709bec46204d0ffb0a2eae1e0" => "unpressed", # old
"880113df76cbba6336d3d1c93b035e904dbce5663acb35f9494eb292bda0226c" => "unpressed", # new
"7a66485db1fee47e7c33acff15df5b48feccbc0328ea6e68795e52ce43649e1a" => 1, # old
"99a8c67265186adef6cb5d4d4b37fefc120f096fa9df6fe0b4f90d6843fcc1e1" => 1, # new
"ab70100c9ac47c63edf679d838fbb10ca38a567a16132aaf42ed2fe159aa8605" => 2, # old
"3bb6ebdba9eead463b427b9cc94881626275b9efc9dfd552e174a017c601d9c2" => 2, # new
"799f98eb9f61f3e96def93145a6a065cf872e67647939a7e0f4c623f38f585c3" => 3, # old
"bdb6e1609d57dfa5559860e9856919ba82c844043e6a294387d975bf55208133" => 3, # new
"b5b29ae361a9acf85ac81abb440d5a3f7525fe80738a5770df90832d0367f7d6" => 4, # old
"56c72e77e03691789f10960bd4f728af2eb7a57dd04c977e6b2ab19b349e1943" => 4, # new
"bff653f26af9160d66965635c8306795ca2440cd1e4eebf0f315c7abd0242fc6" => 5, # old
"2ce52acf436da1971ed234b8607d4928add74c5c02d8a012fce56477b52ba251" => 5, # new
"931b3e6a380fd85ee808fd4ac788123a0873bb3c1c30ec1737cea8e624ff866a" => 6, # old
"36dc562ae36f15c7d3917e101a998736b3dc1a457872fea40e1f4bc896c3725c" => 6, # new
"e5531a6de436ac50d36096b9d1b17bad2c919923650ca48063119f9868eb3943" => 7, # old
"2d95bf5bb506232fe283d18d3fac1ac331ddc8116c7dde83e02a3aaae7da47e6" => 7, # new
"c18dd2d3747aa97a9f432993de175bd32f8e38a70a8c122c94c737f8909bc3ca" => 8,
"ad10157084c576142c0b0e811ddf9f935c3aab5925831fe3bf9a2da226c0c6d9" => "bomb",
"d748d75fb4fbff41cf54237a5e0fa919189a927f1776683f141a4e38feff06ab" => "bomb_hilight",
"e4305b6c2c750ebf0869a465f5e4f7721107bf066872edbcacd15c399ae60bff" => "flag", # old
"645d48aa778b2ac881a3921f3044a8ed96b8029915d9b300abbe91bef3427784" => "flag", # new
);
=head2 new
my $sweperbot = App::SweeperBot->new;
Creates a new C<App::SweeperBot> object. Does not use any
arguments passed, but will send them verbatim to an C<_init>
method if defined on a child class.
=cut
sub new {
my ($class, @args) = @_;
my $this = {};
bless($this, $class);
$this->EVERY::LAST::_init(@args);
return $this;
}
=head2 spawn_minesweeper
$sweeperbot->spawn_minesweeper;
Attempts to spawn a new minesweeper instance. Returns the
C<Win32::Process> object on success, or throws an exception
on error.
=cut
sub spawn_minesweeper {
Win32::Process::Create(
my $minesweeper,
"$ENV{SystemRoot}\\system32\\winmine.exe",
"",
0,
NORMAL_PRIORITY_CLASS,
"."
) or croak "Cannot spawn minesweeper! - ".
Win32::FormatError(Win32::GetLastError());
( run in 1.784 second using v1.01-cache-2.11-cpan-39bf76dae61 )