コード例 #1
0
 public function randReference()
 {
     $cnt = 0;
     // We need to select a reference by their weights
     // Loop through each reference and determine which one is the right choice
     foreach ($this->byReference as $refName => $refWeight) {
         $cnt += $refWeight;
     }
     // Now we randomize which one we'd choose
     $rnd = mt_rand(0, $cnt - 1);
     $cnt = 0;
     foreach ($this->byReference as $refName => $refWeight) {
         $cnt += $refWeight;
         if ($rnd < $cnt) {
             // Return the result
             $randGen = new RandomGen($refName);
             return $randGen->rand();
         }
     }
     return '~' . $this->generatorID . ':Reference Check Failed~';
 }