the problem: ok counting total trades on your post is great but how about making it so you don't have to.
the solution: use same counting logic to display trade count in trades as they're added to your log. flag every time you hit a stampcard. bam. lazy slytherin solution for when you've made +1,800 card trades in a < 2 month timeframe.
caveats: there's a lot
find this in your etcg/trades.php file (about line 280 for me):
$giving = implode(', ',$giving);
$receiving = implode(', ',$receiving);
$today = date("Y-m-d");
$log = "- Traded $trader: my $giving for $receiving";
We will replace all that code with this:
$giving = implode(', ',$giving);
$receiving = implode(', ',$receiving);
$today = date("Y-m-d");
$tcgid = intval($_POST['tcgid']);
$cardstraded = preg_match_all( "/,/", $receiving ) + 1;
$dabatase = new Database;
$sanitize = new Sanitize;
$tcgid = $sanitize->for_db($tcgid); //stannct
$logsstannct = $database->get_assoc("SELECT `tradelog` FROM `tcgs` WHERE `id`='$tcgid' LIMIT 1");
$logstradeamount = preg_match_all( "/Traded/", $logsstannct[tradelog] );
$logscommas = preg_match_all( "/,/", $logsstannct[tradelog] ) / 2;
$logsstannctarch = $database->get_assoc("SELECT `tradelogarch` FROM `tcgs` WHERE `id`='$tcgid' LIMIT 1");
$logstradeamountarch = preg_match_all( "/Traded/", $logsstannctarch[tradelogarch] );
$logscommasarch = preg_match_all( "/,/", $logsstannctarch[tradelogarch] ) / 2;
$logstradetotal = $logstradeamount + $logscommas + $logstradeamountarch + $logscommasarch;
$totalwithtrade = $logstradetotal + $cardstraded;
$stampcardcount = $logstradetotal / 20;
$needed = $totalwithtrade % 20;
if ($needed == 0) {
$stampcardcount = floor($stampcardcount) + 1;
$tradecount = "stampcard {$stampcardcount} NEEDTOSUBMIT";
}
elseif (floor($totalwithtrade / 20) > floor($stampcardcount)) {
$stampcardcount = floor($stampcardcount) + 1;
$tradecount = "stampcard {$stampcardcount} NEEDTOSUBMIT | $needed";
}
else {
$tradecount = $needed;
}
$log = "- Traded $trader: my $giving for $receiving | $tradecount";
Make some test trades to make sure it's working correctly, preferably in all 3 if scenarios (1: you hit a stampcard amount perfectly, 2: you hit over a stampcard amount, 3: you don't hit a stampcard).
If you were to modify this to accommodate TCGs with other stampcard amounts, you could make anywhere that says 20 a variable that is dependent on the tcgid. If this is of interest let me or someone else know and we can help make this happen!