rlm@8: #!/usr/bin/perl
rlm@8:
rlm@8:
rlm@8:
rlm@8: use List::Util qw(first max maxstr min minstr reduce shuffle sum);
rlm@8: use Storable;
rlm@8: use CGI::Ajax;
rlm@8: use CGI;
rlm@8: use Rule;
rlm@8: use Filter;
rlm@8: use Card;
rlm@8: my $q = new CGI;
rlm@8:
rlm@8:
rlm@8:
rlm@8: my $refstruct = retrieve 'CARD.perl';
rlm@8: my @pokes = @$refstruct;
rlm@8:
rlm@8: open ERR, ">./error.log";
rlm@8: print ERR "hi";
rlm@8:
rlm@8:
rlm@8: my %hash = ( 'gen_pack' => \&gen_pack, 'change_rules' => \&change_rules);
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8: my $pjx = CGI::Ajax->new(%hash);
rlm@8: #$pjx->JSDEBUG(1);
rlm@8: #$pjx->DEBUG(1);
rlm@8:
rlm@8: print $pjx->build_html($q,\&gen); # this outputs the html for the page
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8: sub change_rules
rlm@8: {
rlm@8: my $currentRuleref = retrieve 'rlm/booster.prefs';
rlm@8: $currentRule = $$currentRuleref;
rlm@8: $a = shift;
rlm@8: $currentRule -> setSets(($a));
rlm@8: store \$currentRule, 'rlm/booster.prefs';
rlm@8: return $a;
rlm@8:
rlm@8:
rlm@8: }
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8: sub gen_pack
rlm@8: {
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8: sub tag_analyze
rlm@8: {
rlm@8:
rlm@8:
rlm@8:
rlm@8: my @sets = $currentRule -> getSets();
rlm@8: print ERR @sets;
rlm@8:
rlm@8: my $card = shift;
rlm@8:
rlm@8: #print ERR $card->getPix();
rlm@8: #print ERR "\n";
rlm@8: return $card -> hasTags(@sets);
rlm@8:
rlm@8:
rlm@8: }
rlm@8:
rlm@8: my $currentRuleref = retrieve 'rlm/booster.prefs';
rlm@8: $currentRule = $$currentRuleref;
rlm@8:
rlm@8: my $mapRules = $currentRule -> getRarityMap();
rlm@8: my %mapRules = %$mapRules;
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8: print ERR "@pokes";
rlm@8: @reduced = filter(\&tag_analyze, @pokes);
rlm@8: @reduced = shuffle(@reduced);
rlm@8:
rlm@8: my @final_list = ();
rlm@8: my $rnum = $mapRules{"Rare"};
rlm@8: my $unum = $mapRules{"Uncommon"};
rlm@8: my $cnum = $mapRules{"Common"};
rlm@8:
rlm@8: $holochoose = int(rand(3));
rlm@8: ##########3
rlm@8: #my $rnum = 500;
rlm@8: #my $unum =500;
rlm@8: #my $cnum = 500;
rlm@8: #;
rlm@8: ##############
rlm@8: for $crd(@reduced)
rlm@8: {
rlm@8:
rlm@8:
rlm@8: if ($holochoose==0 or $holochoose==1 ){if (($crd -> hasTags("Rare"))and ($rnum>0)){push @r_list, $crd; $rnum--;}}
rlm@8: if ($holochoose==2){if (($crd -> hasTags("Rare Holo"))and ($rnum>0)){push @r_list, $crd; $rnum--;}}
rlm@8: #if (($crd -> hasTags("Rare") or $crd -> hasTags("Rare Holo"))and ($rnum>0)){push @r_list, $crd; $rnum--;}
rlm@8: if (($crd -> hasTags("Uncommon"))and ($unum>0)){push @u_list, $crd; $unum--;}
rlm@8: if (($crd -> hasTags("Common"))and ($cnum>0)){push @c_list, $crd; $cnum--;}
rlm@8: if ($rnum+$unum+$cnum == 0){last;}
rlm@8: }
rlm@8:
rlm@8: @final_list = (@r_list,@u_list,@c_list);
rlm@8:
rlm@8:
rlm@8: for $crd(@final_list)
rlm@8: {
rlm@8: $rob = $rob."getPix()."')\">getPix()."\">";
rlm@8:
rlm@8:
rlm@8: }
rlm@8:
rlm@8: #print $rob;
rlm@8:
rlm@8: print ERR @reduced;
rlm@8: print ERR $rob;
rlm@8: print $rob;
rlm@8: return $rob;
rlm@8: close ERR;
rlm@8:
rlm@8:
rlm@8: };
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8:
rlm@8: sub gen
rlm@8: {
rlm@8: open FILE, " };
rlm@8:
rlm@8: };
rlm@8:
rlm@8: #print "done";
rlm@8:
rlm@8: #print &change_rules("Fossil");
rlm@8: print ERR &gen_pack;