1
This commit is contained in:
parent
269a107ee9
commit
a0b5efdba5
@ -15,6 +15,18 @@ class MatchController{
|
||||
return $r;
|
||||
}
|
||||
|
||||
protected function getParameter($para_id)
|
||||
{
|
||||
$parameter_meta_cluster = require('../res/parameter@parameter.php');
|
||||
$parameter_meta = getParameterConfig($parameter_meta_cluster, $para_id);
|
||||
$p = array(
|
||||
'id' => $parameter_meta['id'],
|
||||
'param_name' => $parameter_meta['param_name'],
|
||||
'param_value' => $parameter_meta['param_value'],
|
||||
);
|
||||
return $p;
|
||||
}
|
||||
|
||||
protected function getRobot($robot_id, $num)
|
||||
{
|
||||
$address = '../res/robot@robot' . $num . '.php';
|
||||
@ -122,23 +134,31 @@ class MatchController{
|
||||
} else if (count($room_db['member_list']) < 10) {
|
||||
//判断是否添加机器人
|
||||
if ($flag == 1) {
|
||||
$p_min = $this->getParameter(16);
|
||||
$min_num = $p_min['param_value'];
|
||||
$p_max = $this->getParameter(17);
|
||||
$max_num = $p_max['param_value'];
|
||||
$randrobot_num = Rand($min_num, $max_num);
|
||||
$robot_num = min((10 - count($room_db['member_list'])), $randrobot_num);
|
||||
if (time() >= $join_time + $room_db['last_join_time']) {
|
||||
//添加机器人
|
||||
$num = count($room_db['member_list']);
|
||||
$random = Rand(1, 100);
|
||||
$robot_id = 1000 + ($num - 1) * 100 + $random;
|
||||
$rob = $this->getRobot($robot_id, $num);
|
||||
$tank_id = Rand(1, 9) + 15000;
|
||||
array_push ($room_db['member_list'], array(
|
||||
'account_id' => $rob['id'],
|
||||
'name' => $rob['name'],
|
||||
'avatar_url' => $rob['avatar_url'],
|
||||
'tank_id' => $tank_id,
|
||||
'tankskin_id' => 0
|
||||
));
|
||||
for ($i = 0; $i < $robot_num; $i++) {
|
||||
//添加机器人
|
||||
$num = count($room_db['member_list']);
|
||||
$random = Rand(1, 100);
|
||||
$robot_id = 1000 + ($num - 1) * 100 + $random;
|
||||
$rob = $this->getRobot($robot_id, $num);
|
||||
$tank_id = Rand(1, 9) + 15000;
|
||||
array_push ($room_db['member_list'], array(
|
||||
'account_id' => $rob['id'],
|
||||
'name' => $rob['name'],
|
||||
'avatar_url' => $rob['avatar_url'],
|
||||
'tank_id' => $tank_id,
|
||||
'tankskin_id' => 0
|
||||
));
|
||||
}
|
||||
$room_db['last_join_time'] = time();
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
//加入房间
|
||||
array_push ($room_db['member_list'], array(
|
||||
'account_id' => $_REQUEST['account_id'],
|
||||
|
Loading…
x
Reference in New Issue
Block a user