diff index.pl @ 8:8c6d2ce90677 boosterpack

[svn r11] saving for transference to cd
author rlm
date Fri, 19 Mar 2010 07:28:10 -0400
parents 4c495190076f
children
line wrap: on
line diff
     1.1 --- a/index.pl	Thu Sep 10 08:01:18 2009 -0400
     1.2 +++ b/index.pl	Fri Mar 19 07:28:10 2010 -0400
     1.3 @@ -1,150 +1,156 @@
     1.4 -#!C:/strawberry/perl/bin/perl.exe
     1.5 -
     1.6 -use List::Util qw(first max maxstr min minstr reduce shuffle sum);
     1.7 -use Storable;
     1.8 -use CGI::Ajax;
     1.9 -use CGI;
    1.10 -use Rule;
    1.11 -use Filter;
    1.12 -use Card;
    1.13 -my $q = new CGI;
    1.14 -
    1.15 -
    1.16 -
    1.17 -my $refstruct = retrieve 'CARD.perl';
    1.18 -my @pokes = @$refstruct;
    1.19 -
    1.20 -
    1.21 -
    1.22 -
    1.23 -
    1.24 -my %hash = ( 'gen_pack' => \&gen_pack, 'change_rules' => \&change_rules);
    1.25 -
    1.26 -
    1.27 -
    1.28 -
    1.29 -
    1.30 -
    1.31 -my $pjx = CGI::Ajax->new(%hash);
    1.32 -#$pjx->JSDEBUG(1);
    1.33 -#$pjx->DEBUG(1);
    1.34 -
    1.35 -print $pjx->build_html($q,\&gen); # this outputs the html for the page
    1.36 -
    1.37 -
    1.38 -
    1.39 -
    1.40 -
    1.41 -sub change_rules
    1.42 -{
    1.43 -	my $currentRuleref = retrieve 'rlm/booster.prefs';
    1.44 -	$currentRule = $$currentRuleref;
    1.45 -	$a = shift;
    1.46 -	$currentRule -> setSets(($a));
    1.47 -	store \$currentRule, 'rlm/booster.prefs'; 
    1.48 -	return $a;
    1.49 -  
    1.50 -	
    1.51 -}
    1.52 -
    1.53 -
    1.54 -
    1.55 -
    1.56 -
    1.57 -
    1.58 -
    1.59 -
    1.60 -
    1.61 -
    1.62 -sub gen_pack
    1.63 -{
    1.64 -	sub tag_analyze
    1.65 -	{
    1.66 -
    1.67 -	
    1.68 -	
    1.69 -	my @sets = $currentRule -> getSets();
    1.70 -	#print ERR @sets;
    1.71 -	
    1.72 -	my $card = shift;
    1.73 -	
    1.74 -	#print ERR $card->getPix();
    1.75 -	#print ERR "\n";
    1.76 -	return $card -> hasTags(@sets);
    1.77 -	
    1.78 -		
    1.79 -	}
    1.80 -		
    1.81 -	my $currentRuleref = retrieve 'rlm/booster.prefs';
    1.82 -	$currentRule = $$currentRuleref;
    1.83 -	
    1.84 -	my $mapRules = $currentRule -> getRarityMap();
    1.85 -	my %mapRules = %$mapRules;
    1.86 -	
    1.87 -	
    1.88 -	
    1.89 -	
    1.90 -	#print ERR "@pokes";
    1.91 -	@reduced = filter(\&tag_analyze, @pokes);
    1.92 -	@reduced = shuffle(@reduced);
    1.93 -	
    1.94 -	my @final_list = ();
    1.95 -	my $rnum = $mapRules{"Rare"};
    1.96 -	my $unum = $mapRules{"Uncommon"};
    1.97 -	my $cnum = $mapRules{"Common"};
    1.98 -	
    1.99 -	$holochoose = int(rand(3));
   1.100 -	##########3
   1.101 -	#my $rnum = 500;
   1.102 -	#my $unum      =500;
   1.103 -	#my $cnum = 500;
   1.104 -	#;
   1.105 -	##############
   1.106 -	for $crd(@reduced)
   1.107 -	{
   1.108 -		
   1.109 -		
   1.110 -		if ($holochoose==0 or $holochoose==1 ){if (($crd -> hasTags("Rare"))and  ($rnum>0)){push @r_list, $crd;  $rnum--;}}
   1.111 -		if ($holochoose==2){if (($crd -> hasTags("Rare Holo"))and  ($rnum>0)){push @r_list, $crd;  $rnum--;}}
   1.112 -		#if (($crd -> hasTags("Rare") or $crd -> hasTags("Rare Holo"))and  ($rnum>0)){push @r_list, $crd;  $rnum--;}
   1.113 -		if (($crd -> hasTags("Uncommon"))and  ($unum>0)){push @u_list, $crd;  $unum--;}
   1.114 -		if (($crd -> hasTags("Common"))and  ($cnum>0)){push @c_list, $crd;  $cnum--;}
   1.115 -		if ($rnum+$unum+$cnum == 0){last;}
   1.116 -	}
   1.117 -	
   1.118 -	@final_list = (@r_list,@u_list,@c_list);
   1.119 -	
   1.120 -	
   1.121 -	for $crd(@final_list)
   1.122 -	{
   1.123 -		$rob = $rob."<A HREF=\"javascript:popUp('".$crd->getPix()."')\"><img src = \"".$crd->getPix()."\"></img></A>";	
   1.124 -		
   1.125 -		
   1.126 -	}
   1.127 -	
   1.128 -	#print $rob;
   1.129 -
   1.130 -	#print ERR @reduced;
   1.131 -	#print ERR $rob;
   1.132 -	#print $rob;
   1.133 -	return $rob;
   1.134 -	#close ERR;
   1.135 -	
   1.136 -	
   1.137 -};
   1.138 -
   1.139 -
   1.140 -
   1.141 -
   1.142 -
   1.143 -sub gen
   1.144 -{
   1.145 -open FILE, "<index.html";
   1.146 -return do { local $/; <FILE> };
   1.147 -
   1.148 -};
   1.149 -
   1.150 -#print "done";
   1.151 -
   1.152 -#print &change_rules("Fossil");
   1.153 -#print &gen_pack;
   1.154 +#!/usr/bin/perl
   1.155 +
   1.156 +
   1.157 +  
   1.158 +use List::Util qw(first max maxstr min minstr reduce shuffle sum);
   1.159 +use Storable;
   1.160 +use CGI::Ajax;
   1.161 +use CGI;
   1.162 +use Rule;
   1.163 +use Filter;
   1.164 +use Card;
   1.165 +my $q = new CGI;
   1.166 +
   1.167 +
   1.168 +
   1.169 +my $refstruct = retrieve 'CARD.perl';
   1.170 +my @pokes = @$refstruct;
   1.171 +
   1.172 +open ERR, ">./error.log";
   1.173 +print ERR "hi";
   1.174 +
   1.175 +
   1.176 +my %hash = ( 'gen_pack' => \&gen_pack, 'change_rules' => \&change_rules);
   1.177 +
   1.178 +
   1.179 +
   1.180 +
   1.181 +
   1.182 +
   1.183 +my $pjx = CGI::Ajax->new(%hash);
   1.184 +#$pjx->JSDEBUG(1);
   1.185 +#$pjx->DEBUG(1);
   1.186 +
   1.187 +print $pjx->build_html($q,\&gen); # this outputs the html for the page
   1.188 +
   1.189 +
   1.190 +
   1.191 +
   1.192 +
   1.193 +sub change_rules
   1.194 +{
   1.195 +	my $currentRuleref = retrieve 'rlm/booster.prefs';
   1.196 +	$currentRule = $$currentRuleref;
   1.197 +	$a = shift;
   1.198 +	$currentRule -> setSets(($a));
   1.199 +	store \$currentRule, 'rlm/booster.prefs'; 
   1.200 +	return $a;
   1.201 +  
   1.202 +	
   1.203 +}
   1.204 +
   1.205 +
   1.206 +
   1.207 +
   1.208 +
   1.209 +
   1.210 +
   1.211 +
   1.212 +
   1.213 +
   1.214 +sub gen_pack
   1.215 +{
   1.216 +	
   1.217 +	
   1.218 +	
   1.219 +	
   1.220 +	sub tag_analyze
   1.221 +	{
   1.222 +
   1.223 +	
   1.224 +	
   1.225 +	my @sets = $currentRule -> getSets();
   1.226 +	print ERR @sets;
   1.227 +	
   1.228 +	my $card = shift;
   1.229 +	
   1.230 +	#print ERR $card->getPix();
   1.231 +	#print ERR "\n";
   1.232 +	return $card -> hasTags(@sets);
   1.233 +	
   1.234 +		
   1.235 +	}
   1.236 +		
   1.237 +	my $currentRuleref = retrieve 'rlm/booster.prefs';
   1.238 +	$currentRule = $$currentRuleref;
   1.239 +	
   1.240 +	my $mapRules = $currentRule -> getRarityMap();
   1.241 +	my %mapRules = %$mapRules;
   1.242 +	
   1.243 +	
   1.244 +	
   1.245 +	
   1.246 +	print ERR "@pokes";
   1.247 +	@reduced = filter(\&tag_analyze, @pokes);
   1.248 +	@reduced = shuffle(@reduced);
   1.249 +	
   1.250 +	my @final_list = ();
   1.251 +	my $rnum = $mapRules{"Rare"};
   1.252 +	my $unum = $mapRules{"Uncommon"};
   1.253 +	my $cnum = $mapRules{"Common"};
   1.254 +	
   1.255 +	$holochoose = int(rand(3));
   1.256 +	##########3
   1.257 +	#my $rnum = 500;
   1.258 +	#my $unum      =500;
   1.259 +	#my $cnum = 500;
   1.260 +	#;
   1.261 +	##############
   1.262 +	for $crd(@reduced)
   1.263 +	{
   1.264 +		
   1.265 +		
   1.266 +		if ($holochoose==0 or $holochoose==1 ){if (($crd -> hasTags("Rare"))and  ($rnum>0)){push @r_list, $crd;  $rnum--;}}
   1.267 +		if ($holochoose==2){if (($crd -> hasTags("Rare Holo"))and  ($rnum>0)){push @r_list, $crd;  $rnum--;}}
   1.268 +		#if (($crd -> hasTags("Rare") or $crd -> hasTags("Rare Holo"))and  ($rnum>0)){push @r_list, $crd;  $rnum--;}
   1.269 +		if (($crd -> hasTags("Uncommon"))and  ($unum>0)){push @u_list, $crd;  $unum--;}
   1.270 +		if (($crd -> hasTags("Common"))and  ($cnum>0)){push @c_list, $crd;  $cnum--;}
   1.271 +		if ($rnum+$unum+$cnum == 0){last;}
   1.272 +	}
   1.273 +	
   1.274 +	@final_list = (@r_list,@u_list,@c_list);
   1.275 +	
   1.276 +	
   1.277 +	for $crd(@final_list)
   1.278 +	{
   1.279 +		$rob = $rob."<A HREF=\"javascript:popUp('".$crd->getPix()."')\"><img src = \"".$crd->getPix()."\"></img></A>";	
   1.280 +		
   1.281 +		
   1.282 +	}
   1.283 +	
   1.284 +	#print $rob;
   1.285 +
   1.286 +	print ERR @reduced;
   1.287 +	print ERR $rob;
   1.288 +	print $rob;
   1.289 +	return $rob;
   1.290 +	close ERR;
   1.291 +	
   1.292 +	
   1.293 +};
   1.294 +
   1.295 +
   1.296 +
   1.297 +
   1.298 +
   1.299 +sub gen
   1.300 +{
   1.301 +open FILE, "<index.html";
   1.302 +return do { local $/; <FILE> };
   1.303 +
   1.304 +};
   1.305 +
   1.306 +#print "done";
   1.307 +
   1.308 +#print &change_rules("Fossil");
   1.309 +print ERR &gen_pack;