- 论坛徽章:
- 0
|
其实我是想做 随机数据
for my $drop_data (@$drop_rate_table) {
$count++;
if ($rate < $drop_data->{accum}) {
$ret = $drop_data;
push(@$drop_items, $drop_data);
$drop_data->{sum} = $lot_sum;
$drop_data->{cand_pos} = $count;
$drop_data->{cand_num} = scalar(@$drop_rate_table);
$dup_cache->{$drop_data->{item}->{id}} = 1;
last;
}
}
外面 还有一层方法控制 循环多少次
$drop_rate_table里面是
[
{
'accum' => 21,
'cand_num' => 6,
'cand_pos' => 3,
'item' => {
'id' => '1',
'item_id' => '100100',
'item_num' => '1',
'item_type' => '9',
'lot' => '10',
'refinery_soul' => '30',
'state' => 1
},
'sum' => 76
},
...很多
]
这些数据
当 满足需求的时候 会吧 $drop_data 放到 @$drop_item里面
并且 $dup_cache 里面 记录被选择过了的ID
{
'1' => '1',
'2' => '1',
....
}
现在就是想下次循环的时候 上次被记录的数据被剔除
回复 4# substr函数
|
|