config('activity.clearrance_rate'), $l => config('activity.luck_rate'), $a => config('activity.luck_a_rate'), $b => config('activity.luck_b_rate'), ]; // get activities products' prices. $act_idx = tw_rand(0, count($acts)); echo "act_idx = $act_idx" . PHP_EOL; $act = $acts[$act_idx]; $rate = $rates[$act]; // all prices $prices = StoreProduct::where('is_del', 0) ->where('is_show', 1) ->where('cate_id', $act) ->field('price,cost') ->select() ->toArray(); // make choice whome participates this order- time. $robot_ids = array_keys($this->robots); $selected = []; $total = count($robot_ids); if ($total < 10) { $msg = "robots num is not enough. num=$total"; Log::error($msg); echo $msg . PHP_EOL; return; } $selnum = tw_rand($total / 3, $total - 5); for ($i = 0; $i < $selnum; $i++) { $idx = tw_rand(0, count($robot_ids)); $selected[] = $robot_ids[$idx]; // each win by rate. $price = tw_rand(0, count($prices)); $win = tw_rand(0, 100) < 80; if ($win) { $selected[$robot_ids[$idx]] = $price * $rate; } array_splice($robot_ids, $idx, 1); } } /** * 獲取機器人的榜單 * * @first: select first-N as the on-board * */ public function get_board($first = 16) { } }