$t->hisData()->attack(4);
$storage = ['Common' => array(), 'Uncommon' => array()];
$target_cards = array_merge($t->getList(['advanced'=>"Discard "]), $t->getList(['advanced'=>'Replace ']));
for ($i = 1; $i <= $t->handSize(); $i++) {
if (in_array($t->hisData()->Hand[$i], $target_cards)) {
$dis_card = $t->getCard($t->hisData()->Hand[$i]);
$dis_rarity = $dis_card->getRarity();
if ($dis_rarity != 'Rare') {
$storage[$dis_rarity][] = $i;
}
}
}
if ((count($storage['Common']) + count($storage['Uncommon'])) > 0) {
shuffle($storage['Common']); shuffle($storage['Uncommon']);
$storage_temp = array_merge($storage['Common'], $storage['Uncommon']);
$discarded_pos = array_pop($storage_temp);
$t->setCard('his', $discarded_pos, $t->drawCard($t->hisDeck(), $t->hisData()->Hand, $discarded_pos, 'drawCardDifferent'));
}