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