Well, yes it can be done this way. But as I said the card filter does not support exact card cost, so basically you have to filter out all dragons and then remove those with inappropriate cost manually. Like this:
$tmp = 5 * $this->KeywordCount($mydata->Hand, "Dragon");
$mydata->Bricks+= $tmp; $mydata->Gems+= $tmp; $mydata->Recruits+= $tmp;
$all_dragons = $carddb->GetList(array('keyword'=>"Dragon"));
$good_dragons = array();
foreach ($all_dragons as $dragon_id)
{
if ($carddb->GetCard($dragon_id)->GetResources('') <= 60)
{
$good_dragons[] = $dragon_id;
}
}
$mydata->Hand = $this->DrawHand_list($good_dragons);
$mydata->NewCards = array(1=> 1, 1, 1, 1, 1, 1, 1, 1);
$nextcard = 0;
I don't like this approach performance-wise. You need to extract card definition for each dragon separately to determine their total cost. A better approach would be to take all card definitions at once, like this:
$tmp = 5 * $this->KeywordCount($mydata->Hand, "Dragon");
$mydata->Bricks+= $tmp; $mydata->Gems+= $tmp; $mydata->Recruits+= $tmp;
$all_dragons = $carddb->GetList(array('keyword'=>"Dragon"));
$all_dragons = $carddb->GetData($all_dragons);
$good_dragons = array();
foreach ($all_dragons as $card_data)
{
if (($card_data['bricks'] + $card_data['gems'] + $card_data['recruits']) <= 60)
{
$good_dragons[] = $card_data['id'];
}
}
$mydata->Hand = $this->DrawHand_list($good_dragons);
$mydata->NewCards = array(1=> 1, 1, 1, 1, 1, 1, 1, 1);
$nextcard = 0;