note: Idolise made this pretty obsolete with the in-site mastery count :) we love to see it!

the problem & context

the problem: I don't want to manually count every time i want to see how many masteries I have (for bragging rights of course)

the solution: Automate it ofc. I don't think this existed before? But please correct me if I'm wrong bc i'm sure another code out there is better.

caveats: there is literally no practical use for this. It's mainly because I counted masteries one day to compare with Dhee and Mio and thought k lets not manually count again. Also, counts any masteries (so would include mini masteries in Idolise, for example)

the mod

in your mods.php file put:

function mastery_count($tcg) {
                $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'];
                $result = $database->query("SELECT `deck` FROM `collecting` WHERE `tcg`='$tcgid' AND `mastered`='1'");
                if (mysqli_num_rows($result) > 0) {
                  $deckcouNCT=mysqli_num_rows($result);
                }
                else {
                  $deckcouNCT = "You have not mastered any decks yet!";
                }
                return $deckcouNCT;
              }

Where you want to display the count, put:

<?php echo mastery_count('idolise'); ?>