当前位置: 首页>>代码示例>>PHP>>正文


PHP Extension::r_or_m方法代码示例

本文整理汇总了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;
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:79,代码来源:extension.php


注:本文中的Extension::r_or_m方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。