List of Highest Cards | v1.0 | etcgfm v1.0.1 | up 10.24.13

  1. 4 years ago

    Required Mods
    Get Category

    Purpose
    This gives you a list of your decks in order of highest to lowest number of cards (separated by number of cards). You can also give it a "minimum" count, so that it only shows decks with over X cards.

    Preview

    Function
    There are two functions in one code.

    function highest( $tcg, $category, $l = 0) {
    	//Grabbing the deck names
    $list = get_category( $tcg, $category);
    $list = explode(", ", $list);
    $list = array_unique($list);
    $deck = array( );
    foreach ($list as $card) {$deck[ ] = substr($card, 0, -2); }
    	//Count cards of the deck
    $deck = array_count_values($deck);
    	//Sort results
    $d = array(); $n = array();
    foreach ($deck as $key => $val){$d[] = $key; $n[] = $val;}
    array_multisort($n, SORT_DESC, $d, SORT_ASC, $deck);
    $z = count($deck);
    
    $c = $n[0];
    while($c > $l){
    	$i = 0;
    	echo '<b>'.$c.' cards</b>: ';
    	while($i < $z){
    		$j = $i + 1;
    		if ($n[$i] === $c) {echo $d[$i]; if($n[$j] === $c){echo ', ';} }
    		$i++;}
    	echo '<br/>'; $c--;}
     }
    
    function highest2( $tcg, $categ1, $categ2, $l = 0) {
    	//Grabbing the deck names
    $list1 = get_category( $tcg, $categ1);
    $list2 = get_category( $tcg, $categ2);
    $list = $list1.', '.$list2;
    $list = explode(", ", $list);
    $list = array_unique($list);
    $deck = array( );
    foreach ($list as $card) {$deck[ ] = substr($card, 0, -2); }
    	//Count cards of the deck
    $deck = array_count_values($deck);
    	//Sort results
    $d = array(); $n = array();
    foreach ($deck as $key => $val){$d[] = $key; $n[] = $val;}
    array_multisort($n, SORT_DESC, $d, SORT_ASC, $deck);
    $z = count($deck);
    
    $c = $n[0];
    while($c > $l){
    	$i = 0;
    	echo '<b>'.$c.' cards</b>: ';
    	while($i < $z){
    		$j = $i + 1;
    		if ($n[$i] === $c) {echo $d[$i]; if($n[$j] === $c){echo ', ';} }
    		$i++;}
    	echo '<br/>'; $c--;}
     }

    Execution
    For viewing one category in a list, use

    function highest( $tcg, $category, $l = 0)

    If you would like to have two categories in the SAME list, use:

    highest2( $tcg, $categ1, $categ2, $l = 0)

    The required variables to change are $tcg and $category (or $categ1 and $categ2) to whatever TCG you're using it on. ($categ1 and $categ2 are both used like category).

    The only optional variable is $l, for a "lowest number". Basically, only decks with over $l cards are shown.

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

or Sign Up to reply!