MArcomage

Free multiplayer on-line fantasy card game

Please log in


1 C
Supply units
Supply units

Discard lowest recruits cost lowest rarity Barbarian or Soldier from hand to gain
Stock: +3

Id
363
Name
Supply units
Rarity
Common
Keywords
Cost (B / G / R)
0 / 0 / 1
Modes
0
Level
10
Created
30. Jul, 2008
Modified
24. Jun, 2012
Played
3771 / 28255
Discarded
764 / 7039
Drawn
5293 / 43448

BB code

Effect

Discard lowest recruits cost lowest rarity Barbarian or Soldier from hand to gain
Stock: +3

Code

    $min = 1000;
    $storage = $min_array = ['Common' => array(), 'Uncommon' => array(), 'Rare' => array()];
    for ($i = 1; $i <= $t->handSize(); $i++) {
      $cur_card = $t->getCard($t->myData()->Hand[$i]);
      $rarity = $cur_card->getRarity();
      if ($i != $t->cardPos() && ($cur_card->hasKeyword('Barbarian') || $cur_card->hasKeyword('Soldier'))) {
        $recruits_cost = $cur_card->getResources('Recruits');
        $storage[$rarity][$i] = $recruits_cost;
        $min = min($recruits_cost, $min);
      }
    }
    if ((count($storage['Common']) + count($storage['Uncommon']) + count($storage['Rare'])) > 0) {
      foreach ($storage as $rarity => $rarity_cards) {
        foreach ($rarity_cards as $c_pos => $c_cost) {
          if ($c_cost == $min) {
            $min_array[$rarity][] = $c_pos;
          }
        }
      }

      shuffle($min_array['Common']);
      shuffle($min_array['Uncommon']);
      shuffle($min_array['Rare']);
      $min_array = array_merge($min_array['Common'], $min_array['Uncommon'], $min_array['Rare']);
      $discarded_pos = array_shift($min_array);
      $t->setCard('my', $discarded_pos, $t->drawCard($t->myDeck(), $t->myData()->Hand, $discarded_pos, 'drawCardRandom'));
      $t->myData()->addStock(3);
    }