the problem & context

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

  1. this one is most effected by new vs old tcg version. talk to cross if you want to talk old tcg version.
  2. THIS IS IDOLISE SPECIFIC. The code assumes a 20-card stampcard. You can edit this by 1) adding an if statement for if the tcg id is for idolise, or 2) finding a way to change the stampcard amount based on tcgid. Not my tcg, not my problem.
  3. This script works by counting "Traded" and commas in your trade log. You cannot have commas in the date format (you can swap out by going to your TCG settings and changing format, and by finding and replacing your existing log). It also assumes your trade log is called 'tradelog' in etcg. Cannot be using archived logs (you can edit this to work around that).
  4. Because this counts commas, this assumes a 2-sided card trade. If you traded member cards, you must put member cards on both sides of the trade. Does not work for gifting.
  5. It will start counting based on what's already in your log. It may not match your amount because us humans can't read and count correctly all of the time. Don't freak out. People make mistakes. Just use it moving forward or audit your log or do whatever you want.
  6. I put "NEEDTOSUBMIT" in my logs when I hit a stampcard, then take out when I submit the stampcard. I also have a mod for myself that shows how many stampcards I need to submit based on this. You can remove this or change the language if you don't like that.

the mod

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!