public function booster(&$upool) { $this->get_cards(); $nb_c = $this->get_data('c', 0); $nb_u = $this->get_data('u', 0); $nb_r = $this->get_data('r', 0); $nb_l = $this->get_data('l', 0); $result = array(); // Booster is generated in reverse order, as foils or transform take a common slot // land if (array_key_exists('L', $this->cards_rarity)) { for ($i = 0; $i < $nb_l; $i++) { $this->rand_card($this->cards_rarity['L'], $result, $upool); } } else { $nb_c += $nb_l; } // foil (break unicity) global $proba_foil; if ($nb_c > 0 && !$this->get_data('uniq', false) && rand(1, $proba_foil) == 1) { $nb_c--; $this->rand_card($this->cards, $result, $upool); } // timeshifted (for TSP) if ($nb_c > 0 && $this->get_data('timeshift', false)) { $ext = Extension::get('TSB'); $ext->get_cards(); if (array_key_exists('S', $ext->cards_rarity)) { $nb_c--; $this->rand_card($ext->cards_rarity['S'], $result, $upool); } else { echo "No timeShift found"; } } // transformable (for ISD/DKA) if ($nb_c > 0 && $this->get_data('transform', false)) { $r = ''; // Transform rarity $n = rand(1, 14); if ($n > 13) { $r = Extension::r_or_m($this->cards_tr); } elseif ($n > 10) { $r = 'U'; } else { $r = 'C'; } if (array_key_exists($r, $this->cards_tr)) { $nb_c--; $this->rand_card($this->cards_tr[$r], $result, $upool); } } // rare or mythic if (array_key_exists('R', $this->cards_rarity) || array_key_exists('M', $this->cards_rarity)) { for ($i = 0; $i < $nb_r; $i++) { $this->rand_card($this->cards_rarity[Extension::r_or_m($this->cards_rarity)], $result, $upool); } } else { $nb_c += $nb_r; } // uncommons if (array_key_exists('U', $this->cards_rarity)) { for ($i = 0; $i < $nb_u; $i++) { $this->rand_card($this->cards_rarity['U'], $result, $upool); } } else { $nb_c += $nb_u; } // commons (after all other exceptions have been managed) if (array_key_exists('C', $this->cards_rarity) && count($this->cards_rarity['C']) >= $nb_c) { for ($i = 0; $i < $nb_c; $i++) { $this->rand_card($this->cards_rarity['C'], $result, $upool); } } else { if ($nb_c > 0) { echo 'Not enough commons leftin ext ' . $ext . " ({$nb_c}/" . count($cards['C']) . ")\n"; } } return $result; }