MArcomage

Free multiplayer on-line fantasy card game

Please log in

Keywords > Banish

Icon

Banish

Effect

Discard highest rarity Durable, Persistent or Rebirth card from opponent's hand. Common cards can target common and uncommon cards, uncommon cards can target any rarity. Rare cards replace target card with a common zero cost card instead of discarding it.

Lore

Banish is a spell that was invented solely for the purpose to counter the durable materials and render them useless. Banish can be cast directly on target or can be used to enchant a weapon to hold the banish property.

Code

    // target card is discarded only if it has same or lower rarity than the played card
    $rarities = ['Common' => 0, 'Uncommon' => 1, 'Rare' => 2];
    $storage = ['Common' => array(), 'Uncommon' => array(), 'Rare' => array()];
    $played_rank = $rarities[$t->card()->getRarity()];
    $persistent = $this->getList(['advanced'=>'Replace a card in hand with self']);

    for ($i = 1; $i <= $t->handSize(); $i++) {
      $dis_card = $this->getCard($t->hisData()->Hand[$i]);
      $dis_rarity = $dis_card->getRarity();
      $dis_rank = $rarities[$dis_rarity];
      
      // pick only cards that can be discarded by played card
      if (($dis_card->hasKeyword('Durable') || $dis_card->hasKeyword('Rebirth') || in_array($t->hisData()->Hand[$i], $persistent)) && $dis_rank <= ($played_rank + 1)) {
        $storage[$dis_rarity][] = $i;
      }
    }
    
    if ((count($storage['Common']) + count($storage['Uncommon']) + count($storage['Rare'])) > 0) {
      // pick preferably cards with higher rarity, but choose random card within the rarity group
      shuffle($storage['Common']);
      shuffle($storage['Uncommon']);
      shuffle($storage['Rare']);
      $storage_temp = array_merge($storage['Common'], $storage['Uncommon'], $storage['Rare']);
      $discarded_pos = array_pop($storage_temp);
      
      if ($t->card()->getRarity() == 'Rare') {
        $new_card = $this->drawCard($this->getList(['rarity'=>'Common', 'cost'=>'Zero']), $t->hisData()->Hand, $discarded_pos, 'drawCardList');
      }
      else {
        $new_card = $this->drawCard($t->hisDeck(), $t->hisData()->Hand, $discarded_pos, 'drawCardDifferent');
      }
      $this->setCard('his', $discarded_pos, $new_card);
    }