| 1 | package Games::Domino; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | $Games::Domino::VERSION = '0.30'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | $Games::Domino::AUTHORITY = 'cpan:MANWAR'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | Games::Domino - Interface to the Domino game. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | Version 0.30 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Term::Screen::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use List::Util qw(shuffle); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Term::ANSIColor::Markup; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use Games::Domino::Tile; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | use Games::Domino::Player; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Games::Domino::Params qw(ZeroOrOne ZeroToSix); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use overload q{""} => 'as_string', fallback => 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | has 'stock' => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | has 'board' => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | has 'human' => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 4 | has 'computer' => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | has 'current' => (is => 'rw'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 4 | has 'board_l' => (is => 'rw', isa => ZeroToSix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | has 'board_r' => (is => 'rw', isa => ZeroToSix); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | has 'cheat' => (is => 'ro', isa => ZeroOrOne, default => sub { 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | has 'debug' => (is => 'rw', isa => ZeroOrOne, default => sub { 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | has 'action' => (is => 'rw', default => sub { [] }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | has 'screen' => (is => 'ro', default => sub { Term::Screen::Lite->new; }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | This is a very basic Domino game played by two players (Computer vs Human) at the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | moment. This is just an initial draft of Proof of Concept, also to get my head | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | around the game which I have never played in my life before.There is a cheat flag | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | which makes tiles for "Computer" visible to the other player "Human". Avoid this | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | flag if possible.By default the cheat flag is turned off.There is verbose switch | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | as well which is turned off by default. They are arranged like here before we | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | shuffle to start the the game. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | [0 | 0] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | [0 | 1] [1 | 1] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | [0 | 2] [1 | 2] [2 | 2] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | [0 | 3] [1 | 3] [2 | 3] [3 | 3] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | [0 | 4] [1 | 4] [2 | 4] [3 | 4] [4 | 4] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | [0 | 5] [1 | 5] [2 | 5] [3 | 5] [4 | 5] [5 | 5] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | [0 | 6] [1 | 6] [2 | 6] [3 | 6] [4 | 6] [5 | 6] [6 | 6] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | Below is the working code for the Domino game using the L<Games::Domino> package. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | The game script C<play-domino> is supplied with the distribution and on install, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | is available to play with. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | USAGE: play-domino [-h] [long options...] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | --verbose Play the game in verbose mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | --cheat Play the game in cheat mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | --usage show a short help message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | -h show a compact help message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | --help show a long help message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | --man show the manual | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $self->{human} = Games::Domino::Player->new({ name => 'H', show => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | ▶ | if ($self->cheat) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->{computer} = Games::Domino::Player->new({ name => 'C', show => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | $self->{computer} = Games::Domino::Player->new({ name => 'C' }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | $self->_init; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | =head2 play() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | Pick a tile from the current player. If no matching tile found then picks it from | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | the stock until it found one or the stock has only 2 tiles left at that time the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | game is over. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | sub play { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my ($self, $index) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
play: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $player = $self->current; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $name = $player->name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (defined $index) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($index =~ /^B$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->_pick_from_bank($player); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $tile = $player->_tile($index); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | print {*STDOUT} "[H] [P]: $tile [S]\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | splice(@{$player->{bank}}, $index-1, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $self->_save($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $tile = $player->pick($self->board_l, $self->board_r); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if (defined $tile) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | print {*STDOUT} "[C] [P]: $tile [S]\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $self->_save($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->_pick_from_bank($player); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | =head2 get_available_tiles() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | Returns all available tile's index. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | sub get_available_tiles { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_available_tiles: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | return $self->current->_available_indexes; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | =head2 is_valid_tile($index) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | Return 1/0 depending on whether the tile at the given C<$index> is valid or not. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | sub is_valid_tile { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | my ($self, $index) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_tile: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | return (defined($index) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
defined $index && ($index =~ /^B$/i || $self->current->_validate_index($index) && $self->current->_validate_tile($index, $self->board_l, $self->board_r))
$index =~ /^B$/i or $self->current->_validate_index($index) and $self->current->_validate_tile($index, $self->board_l, $self->board_r)
$self->current->_validate_index($index) and $self->current->_validate_tile($index, $self->board_l, $self->board_r)
MC/DC0%0/4
defined $index && ($index =~ /^B$/i || $self->current->_validate_index($index) && $self->current->_validate_tile($index, $self->board_l, $self->board_r))
defined $index
$index =~ /^B$/i
$self->current->_validate_index($index)
$self->current->_validate_tile($index, $self->board_l, $self->board_r)
Truth table0%0/5
A && B or C and D
A= defined $indexB= $index =~ /^B$/iC= $self->current->_validate_index($index)D= $self->current->_validate_tile($index, $self->board_l, $self->board_r)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | && (($index =~ /^B$/i) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ($self->current->_validate_index($index) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | && $self->current->_validate_tile($index, $self->board_l, $self->board_r)) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | =head2 is_over() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | Returns 1 or 0 depending whether the game is over or not.The game can be declared | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | over in the following circumstances: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | =over 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | =item * Any one of the two players have used all his tiles. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | =item * There are only two (2) tiles left in the bank. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | sub is_over { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_over: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | return ((scalar(@{$self->{stock}}) == 2) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | (scalar(@{$self->{human}->{bank}}) == 0) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | || | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | (scalar(@{$self->{computer}->{bank}}) == 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
scalar @{$self->{'stock'};} == 2 || scalar @{$self->{'human'}{'bank'};} == 0 || scalar @{$self->{'computer'}{'bank'};} == 0
scalar @{$self->{"stock"};} == 2 or scalar @{$self->{"human"}{"bank"};} == 0
MC/DC0%0/3
scalar @{$self->{'stock'};} == 2 || scalar @{$self->{'human'}{'bank'};} == 0 || scalar @{$self->{'computer'}{'bank'};} == 0
scalar @{$self->{"stock"};} == 2
scalar @{$self->{"human"}{"bank"};} == 0
scalar @{$self->{'computer'}{'bank'};} == 0
Truth table0%0/4
A or B || C
A= scalar @{$self->{"stock"};} == 2B= scalar @{$self->{"human"}{"bank"};} == 0C= scalar @{$self->{'computer'}{'bank'};} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | =head2 result() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | Declares who is the winner against whom and by how much margin. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | sub result { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
result: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my ($result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if (scalar(@{$self->stock}) == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $c_b = scalar(@{$self->computer->bank}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $h_b = scalar(@{$self->human->bank}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $msg = 'Bank has only 2 tiles left. '; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ($c_b < $h_b) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $result = $self->_result("${msg}. Therefore, computer is declared the winner, having less tiles than you.", $c_b, $h_b); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | elsif ($c_b > $h_b) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $result = $self->_result("${msg}. Therefore, you are declared the winner, having less tiles than computer.", $h_b, $c_b); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $result = $self->_result('${msg}. Therefore, game is declared draw as both players have the same number of tiles.', $h_b, $c_b); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $h = $self->human->value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $c = $self->computer->value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if (scalar(@{$self->human->bank}) == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $result = $self->_result('Congratulation, you are the winner as you have no tiles left.', $h, $c); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | elsif (scalar(@{$self->computer->bank}) == 0) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $result = $self->_result('Sorry, computer is the winner as it has no tiles left.', $c, $h); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ($h < $c) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $result = $self->_result('Congratulation, you are the winner as your remaining tiles value is less than computer.', $h, $c); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | elsif ($h > $c) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $result = $self->_result('Sorry, computer is the winner as it\'s remaining tiles value is less than yours.', $c, $h); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $result = $self->_result('Game is declared draw as both the players reamaining tiles value is the same.', $c, $h); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if ($self->debug) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $result = sprintf("STOCK : %s\n%s", $self->as_string, $result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return Term::ANSIColor::Markup->colorize($result); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | =head2 show() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | Returns the current state of the game. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub show { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
show: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $game = sprintf("%s\n", $self->_line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $game .= sprintf("[C]: %s\n", $self->computer->as_string); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $game .= sprintf("[H]: %s\n", $self->human->as_string); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $game .= "[G]: " . $self->_board . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $game .= sprintf("%s", $self->_line); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | return $game; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =head2 reset() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | Reset the game. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $self->human->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->computer->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->_init; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | =head2 as_string() | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | Returns all the unused tiles remained in the bank. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | return '[EMPTY]' unless scalar(@{$self->{stock}}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | my $domino = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | foreach (@{$self->{stock}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 14 | $domino .= sprintf("%s==", $_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | $domino =~ s/[\=]+\s?$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | $domino =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | return $domino; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub pause { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | my ($self, $message) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $message = "Press any key to continue..." unless defined $message; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | print {*STDOUT} $message; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->read_mode('cbreak'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ReadKey(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $self->read_mode; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | sub read_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | my ($self, $state) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_mode: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $state = 'normal' unless defined $state; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ReadMode $state; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | sub about_game { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
about_game: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | return qq { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | +-------------------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | | | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | | Games::Domino v$Games::Domino::VERSION | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | | | | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | +-------------------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | Tiles are numbered left to right starting with 1. Symbols used in this game are: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | [C]: Code for the computer player | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | [H]: Code for the human player | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | [P]: Personal tile | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | [B]: Tile picked from the bank | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | [S]: Successfully found the matching tile | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | [F]: Unable to find the matching tile | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | [G]: All matched tiles so far | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | +-------------------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | sub how_to_play { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
how_to_play: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | return qq { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | Example: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | [C] [P]: [5 | 6] [S] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | Computer picked the tile [5 | 6] from his own collection and successfully found | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | the matching on board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | [H] [P]: [6 | 6] [S] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | Human picked the tile [6 | 6] from his own collection and successfully found the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | matching on board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | [C] [B]: [2 | 6] [S] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | Computer randomly picked the tile [2 | 6] from the bank and successfully found the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | matching on board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | [C] [B]: [3 | 4] [F] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | Computer randomly picked the tile [3 | 4] from the bank and but failed to find the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | matching on board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | [H] [B]: [2 | 2] [S] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | Human randomly picked the tile [2 | 2] from the bank and successfully found the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | matching on board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | [H] [B]: [3 | 6] [F] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | Human randomly picked the tile [3 | 6] from the bank and but failed to find the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | matching on board. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | +-------------------------------------------------------------------------------+ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | sub _pick_from_bank { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | my ($self, $player) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pick_from_bank: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $name = $player->name; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | while (scalar(@{$self->{stock}}) > 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my $_tile = $self->_pick(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $player->save($_tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $tile = $player->pick($self->board_l, $self->board_r); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if (defined $tile) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | print {*STDOUT} "[$name] [B]: $tile [S]\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->_save($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | print {*STDOUT} "[$name] [B]: $_tile [F]\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | sub _save { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | my ($self, $tile) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_save: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if (!defined($self->{board}) || (scalar(@{$self->{board}}) == 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $self->{"board"} or scalar @{$self->{"board"};} == 0
MC/DC0%0/2
not defined $self->{"board"} or scalar @{$self->{"board"};} == 0
not defined $self->{"board"}
scalar @{$self->{"board"};} == 0
Truth table0%0/3
not(A) or B
A= not defined $self->{"board"}B= scalar @{$self->{"board"};} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | push @{$self->{board}}, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $self->{board_l} = $tile->left; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $self->{board_r} = $tile->right; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $self->_action($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $self->_next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if ($self->{board_r} == $tile->left) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | push @{$self->{board}}, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $self->{board_r} = $tile->right; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $self->_action($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $self->_next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | elsif ($self->{board_r} == $tile->right) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my $L = $tile->left; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $R = $tile->right; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $tile->right($L); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $tile->left($R); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | push @{$self->{board}}, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $self->{board_r} = $L; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $self->_action($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $self->_next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ($self->{board_l} == $tile->left) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $L = $tile->left; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | my $R = $tile->right; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $tile->right($L); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $tile->left($R); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | unshift @{$self->{board}}, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $self->{board_l} = $R; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $self->_action($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $self->_next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | elsif ($self->{board_l} == $tile->right) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | unshift @{$self->{board}}, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $self->{board_l} = $tile->left; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $self->_action($tile); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $self->_next; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | sub _action { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | my ($self, $tile) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_action: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | if (defined $self->{action} && scalar(@{$self->{action}}) == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"action"} and scalar @{$self->{"action"};} == 2
MC/DC0%0/2
defined $self->{"action"} and scalar @{$self->{"action"};} == 2
defined $self->{"action"}
scalar @{$self->{"action"};} == 2
Truth table0%0/3
A and B
A= defined $self->{"action"}B= scalar @{$self->{"action"};} == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | foreach (@{$self->board}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $_->color('blue'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $self->{action} = [ $tile ]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | push @{$self->{action}}, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ($self->current->name eq 'H') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $tile->color('green'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $tile->color('red'); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | sub _board { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_board: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $board = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if (scalar(@{$self->board})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | foreach (@{$self->board}) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $board .= sprintf("<%s><bold>%s</bold><\/%s>==", $_->color, $_, $_->color); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $board .= '<blue><bold>EMPTY</bold></blue>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $board =~ s/[\=]+\s?$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | $board =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | return Term::ANSIColor::Markup->colorize($board); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | sub _result { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | my ($self, $title, $a, $b) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_result: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $result = sprintf("<blue><bold>%s ", $title); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $result .= sprintf("Final score [</bold></blue><green><bold>%d</bold></green>", $a); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $result .= sprintf("<blue><bold>] against [</bold></blue><red><bold>%d</bold></red>", $b); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $result .= '<blue><bold>].</bold></blue>'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | sub _line { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_line: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return "="x81; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | sub _init { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | $self->{stock} = $self->_prepare(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | $self->{board} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | $self->{human}->save($self->_pick) for (1..7); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | $self->{computer}->save($self->_pick) for (1..7); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | $self->{current} = $self->{human}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | sub _pick { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 14 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pick: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 14 | return shift @{$self->{stock}}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | sub _prepare { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 1 | my $tiles = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 1 | my $tile = Games::Domino::Tile->new({ left => 0, right => 0, double => 1 }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 1 | push @$tiles, $tile; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 1 | foreach my $R (1..6) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 6 | my $L = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 6 | my $D = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 6 | ▶ | while ($R >= $L) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 27 | ▶ | ($R == $L)?($D = 1):($D = 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 27 | push @$tiles, Games::Domino::Tile->new({ left => $L, right => $R, double => $D }); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 27 | $L++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 1 | $tiles = [shuffle @{$tiles}]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | return $tiles; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | sub _next { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_next: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if ($self->current->name eq 'H') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $self->current($self->computer); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $self->current($self->human); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | =head1 REPOSITORY | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | L<https://github.com/manwar/Games-Domino> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | Please report any bugs or feature requests to C<bug-games-domino at rt.cpan.org>, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Domino>. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | I will be notified, and then you'll automatically be notified of progress on your | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | bug as I make changes. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | perldoc Games::Domino | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | You can also look for information at: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Domino> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | L<http://annocpan.org/dist/Games-Domino> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | L<http://cpanratings.perl.org/d/Games-Domino> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | =item * Search CPAN | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | L<http://search.cpan.org/dist/Games-Domino/> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | Copyright 2012 - 2016 Mohammad S Anwar. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | This program is free software; you can redistribute it and / or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | license at: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | Any use, modification, and distribution of the Standard or Modified Versions is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | governed by this Artistic License.By using, modifying or distributing the Package, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | not accept this license. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | If your Modified Version has been derived from a Modified Version made by someone | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | other than you,you are nevertheless required to ensure that your Modified Version | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | complies with the requirements of this license. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | This license does not grant you the right to use any trademark, service mark, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | Package with respect to any patent claims licensable by the Copyright Holder that | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | are necessarily infringed by the Package. If you institute patent litigation | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | (including a cross-claim or counterclaim) against any party alleging that the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | Package constitutes direct or contributory patent infringement,then this Artistic | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | License to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 4 | 1; # End of Games::Domino | |||||||||||||||||||||||||||||||||||||||||||||||||