Fisher-Yates shuffle
sub shuffle {
use integer;
my $array = shift;
my $i;
for ($i = @$array; -$i; ) {
my $j = int rand ($i+1);
@$array[$i,$j] = @$array[$j,$i];
}
}
my %card;
sub init_cards {
my $c = shift;
my @denom = ( 2 .. 9, qw/ t j q k a / );
my @suits = qw/ h d c s /;
my @dim = ( -width => CARDWIDTH, -height => CARDHEIGHT );
foreach my $d (@denom) {
foreach my $s (@suits) {
my $im = $c->Photo(-file => "cards/$d$s.gif", @dim);
$card{"$d$s"} = $im;
}
}
}