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