本文整理汇总了PHP中Extension::r_or_m方法的典型用法代码示例。如果您正苦于以下问题:PHP Extension::r_or_m方法的具体用法?PHP Extension::r_or_m怎么用?PHP Extension::r_or_m使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extension
的用法示例。
在下文中一共展示了Extension::r_or_m方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: booster
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;
}