App-Games-Keno

 view release on metacpan or  search on metacpan

lib/App/Games/Keno.pm  view on Meta::CPAN

package App::Games::Keno;
use Moose;
use Types::Standard qw(Int ArrayRef HashRef Bool);
use Carp            qw(croak carp);
use List::Compare   qw (get_intersection);
use List::Util      qw(any uniq);
use Scalar::Util    qw(looks_like_number);

# ABSTRACT: Plays Keno

=head1 NAME 
  
App::Games::Keno
  
=head1 SYNOPSIS
 
This package plays a game of Keno.  The number range is 1 to 80 and the payout amounts are for 1 to 10 spots.

lib/App/Games/Keno.pm  view on Meta::CPAN

	croak "Need spots or number of spots"
	  if ( !defined $self->spots && !defined $self->num_spots );

	if ( !defined $self->verbose ) { $self->verbose(0); }
	if ( $self->verbose < 0 || $self->verbose > 2 ) {
		warn "'" . $self->verbose . "' is not a valid verbose level, using '0'";
		$self->verbose(0);
	}

	if ( defined $self->spots ) {
		if ( any { !looks_like_number($_) } @{ $self->spots } ) {
			croak "One of the spots you chose doesn't look like a number.";
		}
		if ( any { $_ < 1 || $_ > 80 } @{ $self->spots } ) {
			croak "You chose a spot that is out of the 1 to 80 range";
		}
		if ( scalar @{ $self->spots } != uniq @{ $self->spots } ) {
			croak "You appear to have chosen two or more of the same spots";
		}
		if ( scalar @{ $self->spots } < 1 ) {
			croak "You must choose at least one spot";



( run in 0.325 second using v1.01-cache-2.11-cpan-64827b87656 )