$t->myData()->addStock(2);
$rarities = array();
$upgrades = ['Common' => 'Uncommon', 'Uncommon' => 'Rare'];
for ($i = 1; $i <= $t->handSize(); $i++) {
$cur_card = $t->getCard($t->myData()->Hand[$i]);
if ($cur_card->hasKeyword('Undead')) {
$rarities[$i] = $cur_card->getRarity();
}
}
foreach ($rarities as $i => $rarity) {
if (in_array($rarity, ['Common', 'Uncommon'])) {
$t->setCard('my', $i, $t->drawCard($t->getList(['rarity'=>$upgrades[$rarity], 'keyword'=>'Undead']), $t->myData()->Hand, $i, 'drawCardList'));
}
}