MArcomage

Free multiplayer on-line fantasy card game

Please log in

Keywords > Skirmisher

Icon

Skirmisher

Effect

Harass - discard highest rarity Charge from opponent's hand. Common cards can target common and uncommon cards, uncommon and rare cards can target any rarity. Rare cards replace target card with a common zero cost card instead of discarding it. If there are no Charge cards in opponent's hand, highest rarity Recruits only attack card of the same or lower rarity as the played card is chosen instead.

Lore

Skirmishers are troops designed to counter enemy cavalry. Their combat capabilities may be inferior, but their role is crucial in any army. They are trained to protect their allies at all costs and down to the last man.

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 = $r_storage = ['Common' => array(), 'Uncommon' => array(), 'Rare' => array()];
    $played_rank = $rarities[$t->card()->getRarity()];
    $secondary_cards = $this->getList(['cost'=>'Green', 'advanced'=>'Attack:']);

    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('Charge') && $dis_rank <= ($played_rank + 1)) {
        $storage[$dis_rarity][] = $i;
      }
      elseif ($dis_rank <= $played_rank && in_array($t->hisData()->Hand[$i], $secondary_cards)) {
        $r_storage[$dis_rarity][] = $i;
      }
    }

    // use secondary storage if primary storage is empty
    if ((count($storage['Common']) + count($storage['Uncommon']) + count($storage['Rare'])) == 0) {
      $storage = $r_storage;
    }

    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);
    }