Looking at the Charge code, I believe that it does not reduce the $total variable on each step, and also it checks the wrong variables for bricks, gems and recruits number ($bricks, $gems, $recruits instead oh $hisdata->Bricks etc.). So, this could lead to negative values, meaning some resource gets reduced more than it can be reduced and the other two resources are ignored.
Here's a snippet of the original code:
if ($total > 0)
for ($i = 1; $i <= $charge_damage; $i++)
{
$tmp = mt_rand(1,$total);
if ($tmp <= $bricks) $hisdata->Bricks--;
elseif ($tmp <= ($bricks + $gems)) $hisdata->Gems--;
elseif ($tmp <= ($bricks + $gems + $recruits)) $hisdata->Recruits--;
}
I think changing to something like this will fix the problem:
for ($i = 1; $i <= $charge_damage; $i++)
{
$b = $hisdata->Bricks;
$g = $hisdata->Gems;
$r = $hisdata->Recruits;
$total = $b + $g + $r;
$tmp = mt_rand(1, $total);
if ($tmp <= $b && $b > 0) $hisdata->Bricks--;
elseif ($tmp <= ($b + $g) && $g > 0) $hisdata->Gems--;
elseif ($tmp <= ($b + $g + $r) && $r > 0) $hisdata->Recruits--;
}