Mercurial > boosterpack
view index.pl @ 6:4246c7ef6487 boosterpack
[svn r8] bug fix -- holos need to be one int three compared to rares
author | robert |
---|---|
date | Tue, 08 Sep 2009 17:20:52 -0400 |
parents | e91d6f908222 |
children | 4c495190076f |
line wrap: on
line source
1 #!C:/strawberry/perl/bin/perl.exe3 use List::Util qw(first max maxstr min minstr reduce shuffle sum);4 use Storable;5 use CGI::Ajax;6 use CGI;7 use Rule;8 use Filter;9 use Card;10 my $q = new CGI;14 my $refstruct = retrieve 'CARD.perl';15 my @pokes = @$refstruct;21 my %hash = ( 'gen_pack' => \&gen_pack, 'change_rules' => \&change_rules);28 my $pjx = CGI::Ajax->new(%hash);29 #$pjx->JSDEBUG(1);30 #$pjx->DEBUG(1);32 print $pjx->build_html($q,\&gen); # this outputs the html for the page38 sub change_rules39 {40 my $currentRuleref = retrieve 'rlm/booster.prefs';41 $currentRule = $$currentRuleref;42 $a = shift;43 $currentRule -> setSets(($a));44 store \$currentRule, 'rlm/booster.prefs';45 return $a;48 }59 sub gen_pack60 {61 sub tag_analyze62 {66 my @sets = $currentRule -> getSets();67 #print ERR @sets;69 my $card = shift;71 #print ERR $card->getPix();72 #print ERR "\n";73 return $card -> hasTags(@sets);76 }78 my $currentRuleref = retrieve 'rlm/booster.prefs';79 $currentRule = $$currentRuleref;81 my $mapRules = $currentRule -> getRarityMap();82 my %mapRules = %$mapRules;87 #print ERR "@pokes";88 @reduced = filter(\&tag_analyze, @pokes);89 @reduced = shuffle(@reduced);91 my @final_list = ();92 my $rnum = $mapRules{"Rare"};93 my $unum = $mapRules{"Uncommon"};94 my $cnum = $mapRules{"Common"};96 $holochoose = int(rand(3));97 ##########398 #my $rnum = 500;99 #my $unum =500;100 #my $cnum = 500;101 #;102 ##############103 for $crd(@reduced)104 {107 if ($holochoose==0 or $holochoose==1 ){if (($crd -> hasTags("Rare"))and ($rnum>0)){push @r_list, $crd; $rnum--;}}108 if ($holochoose==2){if (($crd -> hasTags("Rare Holo"))and ($rnum>0)){push @r_list, $crd; $rnum--;}}109 #if (($crd -> hasTags("Rare") or $crd -> hasTags("Rare Holo"))and ($rnum>0)){push @r_list, $crd; $rnum--;}110 if (($crd -> hasTags("Uncommon"))and ($unum>0)){push @u_list, $crd; $unum--;}111 if (($crd -> hasTags("Common"))and ($cnum>0)){push @c_list, $crd; $cnum--;}112 if ($rnum+$unum+$cnum == 0){last;}113 }115 @final_list = (@r_list,@u_list,@c_list);118 for $crd(@final_list)119 {120 $rob = $rob."<img src = \"".$crd->getPix()."\"></img>";121 }123 #print $rob;125 #print ERR @reduced;126 #print ERR $rob;127 #print $rob;128 return $rob;129 #close ERR;132 };138 sub gen139 {140 open FILE, "<index.html";141 return do { local $/; <FILE> };143 };145 #print "done";147 #print &change_rules("Fossil");148 #print &gen_pack;