Show Fillers | v1.1 | etcgfm v1.0.1 | up 10.18.13

  1. 3 years ago

    Required Mods

    This code allows you to show any category as a set of fillers (similar to your collecting sets). You can also set a count requirement, and it makes the fillers for the decks that meet the count, and put the rest in a pile. Using two slightly changed execution codes, you can even separate them (for example, to make it so your keeping decks automatically move to Secondary Collections when they reach X cards).


    This goes into your func.php, custom function page, or any pages that you will use the function on.

    function show_fillers( $tcg, $category, $count, $high = 0, $hide = 0, $break = 5, $puzzle = 0 ) {
    	$database = new Database;
    	$sanitize = new Sanitize;
    	$tcg = $sanitize->for_db($tcg);
    	$category = $sanitize->for_db($category);
    	$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
    	$tcgid = $tcginfo['id'];
    	$cards = $database->get_assoc("SELECT `cards` FROM `cards` WHERE `tcg`='$tcgid' AND 
    `category`='$category' LIMIT 1");
    	if ( $cards['cards'] === '' ) { echo '<p><em>There are currently no cards under this 
    category.</em></p>'; }
    	else {
    		$cards = explode(',',$cards['cards']);
    		array_walk($cards, 'trim_value');
    		$cards = array_unique($cards);
    		$deck = array( );
    	//Get decks
    		foreach ( $cards as $card ) {$deck[ ] = substr($card, 0, -2); }
    		$group = array_combine($cards,$deck);
    		$dec_u = array_unique($deck);
    		if($dec_u[0] == $dec_u[1]){$repeat = array_shift($dec_u);}
    		$etc  = array( ); 
    		foreach ( $dec_u as $check ) {
    			$mine = array( );
    			$got = array_keys($group, $check);
    			foreach ( $got as $no ) {$mine[ ] = substr($no, -2); }
    			$me = count($mine);
    		if($me >= $high){
    			$i = 0;
    			$def = range(1,$count);
    			$default = array( );
    			foreach($def as $no){if($no < 10){$default[ ] = '0'.$no;} else {$default[ ] = 
    		if($hide !== -1){
    			echo "<h3>".$check." (".$me."/".$count.")</h3>";
    			while($i < $count){
    				$number = $default[$i];
    				$card =$check.$number; $card = trim($card);
    				$pending = $database->num_rows("SELECT * FROM `trades` WHERE 
    `tcg`='$tcgid' AND `receiving` LIKE '%$card%'");
    				if( in_array($number,$mine)){echo '<img 
    src="'.$tcginfo['cardsurl'].$card.'.'.$tcginfo['format'].'" title="'.$card.'" />';}
    				elseif ( $pending > 0 ) {echo '<img 
    src="'.$tcginfo['cardsurl'].'pending.'.$tcginfo['format'].'" title="'.$card.'" />';}
    				else {echo '<img 
    src="'.$tcginfo['cardsurl'].'filler.'.$tcginfo['format'].'" title="'.$card.'" />'; }				
    				if (($i < $count)&&($puzzle !== 1)) { echo ' '; }
    				if ( $i % $break == 0 ) { echo '<br />'; }	
    			echo '<br/>';}
    		} else { foreach($mine as $one){$check = trim($check); $etc[ ] =$check.$one; }} }
    		if($hide !== 1){ foreach ( $etc as $low ) {
    echo '<img src="'.$tcginfo['cardsurl'].$low.'.'.$tcginfo['format'].'" title="'.$low.'" /> ';}}
    }	}

    Place this wherever you want the list to go.

    <? show_fillers( $tcg, $category, $count, $high, $hide, $break, $puzzle) ?>

    The required variables to change are $tcg, to whatever TCG you're using it on; $category to whatever category you're using it on, and $count to the number of cards in a deck. So, if they are 20 card decks, you put 20 (it needs it to tell you what you need).

    The optional variables are $high, $hide, $break, and $puzzle
    $high is the highest number of cards you want in your card pile. Think of it like "Any deck over $high will have fillers". That is automatically set to 0 (so all cards in the category are in fillers).

    $hide determines what shows up. "-1" will only show the card pile, while "1" will only show the fillers. Anything else will show both. It automatically set to 0 (shows both).

    $break determines how many cards per line, just like in the collecting. It is currently set to 5.

    $puzzle determines whether or not you want the images together as a puzzle or not. If it's not '1', then they won't be puzzles.

    Remember, for any optional variables, you MUST fill them out in the order given!
    You can stop wherever, but you must reach that point. So, if you want $high to stay 0, but $hide to be 1, you need to put [ex] ('Overdrive', 'keeping', 20, , 1).
    I try to put them in order of rarity of change.

    Update Notes
    Yes, everyone, it's version 1.1.
    New Features:
    - Making the fillers puzzles.

    Yeah that's it. Just made it so you could do puzzle fillers. Wasn't hard, so when I put this up, I thought, "Alright, I'll add it." I just added it to the end, so everything SHOULD work normally, and you should be able to just add to the codes to make them puzzle fillers.

    Upcoming Versions
    Nothing planned, but if people have any suggestions, feel free to offer them.

or Sign Up to reply!