Collecting Doubles | v1.0 | etcgfm v1.0.1 | up 2.28.14

  1. 4 years ago
    Edited 3 years ago by Dite

    Required Mods
    None

    Purpose
    This is a code (and an optional alternative etcg/collecting.php) to show doubles from your collecting sets. It can be separated by worth.

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

    function collecting_doubles( $tcg, $worth = '' ) {
    	$database = new Database;
    	$sanitize = new Sanitize;
    	$tcg = $sanitize->for_db($tcg);
    	
    	$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
    	$tcgid = $tcginfo['id'];
    	$cardsurl = $tcginfo['cardsurl'];
    	$format = $tcginfo['format'];
    	
    	if ( $worth !== '' ) { $worth = intval($worth); }
    	if ( $worth !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '0' AND `worth` = '$worth' ORDER BY `sort`, `deck`"); }
    	else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '0' ORDER BY `sort`, `worth`, `deck`"); }
    	while ( $row = mysql_fetch_assoc($result) ) { 
    		$cards = explode(',',$row['cards']); 
    			
    		array_walk($cards, 'trim_value');
    		if(empty($doubles)){$doubles = array_diff_assoc($cards, array_unique($cards));}
    		else{$doubles = array_merge($doubles,array_diff_assoc($cards, array_unique($cards)));}		
    	}	sort($doubles);
    		if ( !empty($doubles) ) {
    			
    			foreach ( $doubles as $double ) {
    			
    				$double = trim($double);
    				echo '<img src="'.$cardsurl.''.$double.'.'.$format.'" alt="" title="'.$double.'" /> ';
    			
    			}
    		
    		}
    		else {
    		
    			echo '<p><em>There are currently no cards under this category.</em></p>';
    		
    		}
    }

    Execution
    Place this wherever you want the list to go.

    collecting_doubles($tcg, $worth = '')

    The only required variable to change is $tcg, to whatever TCG you're using it on.

    There is an optional variable $worth, which only checks decks with the specified worth.

    Upcoming Versions
    None planned.

    Optional Replacement Page
    Attached is an optional page that replaces the etcg/collecting.php.
    It basically just adds the doubles to your eTCG's View Collecting page under each deck. With that, it changes it so that the "Master" button only shows up with unique cards--doubles shouldn't count toward or against it (so, for a 20-card deck, having 18 cards and 2 doubles would not bring up the master baddge, but having 20 cards and 2 doubles will not remove it).
    Be sure to remove the doubles when you master the deck. They'll be moved with the mastery. They'll still count toward your card count, and on the deck list, but it won't show up on the deck there.

  2. 3 years ago

    I would love to download this collecting.php page, but I don't see an attachment anywhere? Am I just blind?

  3. Bloo

    20 Nov 2014 Administrator kablooey.net

    The attachment was probably lost during the forum transfer... (oops)

    I'll give Dite a poke. If all else fails, I can probably get it out of the old forum backups.

  4. Awesome! Thanks Bloo!

  5. Alright. The one I've attached should be right.

  6. 2 years ago
    Deleted 2 years ago by Saitaina

or Sign Up to reply!