$discarded = 0;
for ($i = 1; $i <= $t->handSize(); $i++) {
$my_card = $t->getCard($t->myData()->Hand[$i]);
if ($i != $t->cardPos() && $my_card->getRarity() != 'Rare' && ($my_card->hasKeyword('Barbarian') || $my_card->hasKeyword('Soldier'))) {
$t->setCard('my', $i, $t->drawCard($t->myDeck(), $t->myData()->Hand, $i, 'drawCardRandom'));
$discarded++;
}
}
$t->myData()->addWall(min($discarded, 5) * 8);