/** * 道具变更下行协议 * @param $player_id * @param $change_prop 二维数组 传进去player_prop的内容 * 如果是位置变更 要加上 ['from_item_position'] 原始位置 ['from_grid'] 原始格子数 * player_prop里面的 item_position 赋值为新的位置编号 grid 赋值为新的格子编号 * @param $error_code 0 失败 1成功 * @param $cmd0 3 直接返回给flash 8 通过异步返回 * @param $flag 协议输出格式 0 直接输出 1 标志为粘包 2返回协议内容 3 附加粘包 * */ public static function prop_806($player_id, $change_prop, $func_id = 0, $error_code = 1, $cmd0 = 3, $flag = 3) { //后面三个参数不用了 $data['type'] = 1; $data['result'] = $error_code; $data['box'] = array(); if (!empty($change_prop)) { foreach ($change_prop as $prop) { $tmp_prop = array(); if ($prop['item_num'] <= 0) { //道具数量等于0的时候 只给位置信息就好了 $tmp_prop['item_position'] = $prop['item_position']; $tmp_prop['grid'] = $prop['grid']; } else { # 要求只有新发的道具的from_item_position=0,老道具都要求非0 $tmp_prop = $prop; $tmp_prop['from_item_position'] = $prop['from_item_position']; } $data['box'][] = Struct_Prop::get_item_box_operate_struct($tmp_prop); } } $data['func_id'] = $func_id; if (!IS_FRONT) { Protocol::input($player_id, 8, 8, 806, $data); Protocol::out(); } else { if (defined('FROM_GATEWAY')) { $cmd0 = 8; } Protocol::input($player_id, $cmd0, 8, 806, $data); } }
/** * 仓库存取 * @param $player_id * @param $player_prop_id */ public function store_prop($player_id, $player_prop_id) { $objPlayerPropData = $this->get_data('PlayerProp'); $arr_prop_detail = $objPlayerPropData->get_player_prop_detail($player_id, $player_prop_id); $out = array(0 => 8, 1 => 0, 2 => array(Struct_Prop::get_item_box_operate_struct(array('from_item_position' => $arr_prop_detail['item_position'], 'from_grid' => $arr_prop_detail['grid'], 'item_position' => $arr_prop_detail['item_position'], 'grid' => $arr_prop_detail['grid'])))); if (empty($arr_prop_detail)) { $this->out_error($player_id, '10107'); //参数错误 return $out; } if ($arr_prop_detail['item_position'] > 2) { $this->out_error($player_id, '80012'); //参数错误 return $out; } if ($arr_prop_detail['item_position'] == 1) { $aim_item_position = 2; } else { $aim_item_position = 1; } $objPropGame = $this->get_game("Prop"); $bag_pos = $objPropGame->get_empty_pos($player_id, 1, $aim_item_position); if (!$bag_pos) { if ($aim_item_position == 2) { $this->out_error($player_id, '80918'); } else { $this->out_error($player_id, '80001'); } return $out; //包裹已满! } $arr_aim_prop_detail = array(); $aim_grid = $bag_pos[0]; $this->start_trans(); $result = $this->prop_move_exe($player_id, $arr_prop_detail, $aim_item_position, $aim_grid, $arr_aim_prop_detail); if ($result === false) { $this->rollback(); return $out; //处理失败 } if ($result) { $this->commit(); $out[1] = 1; $out[2] = array(); $old_box = array(); $old_box['item_position'] = $arr_prop_detail['item_position']; $old_box['grid'] = $arr_prop_detail['grid']; $out[2][] = Struct_Prop::get_item_box_operate_struct($old_box); $new_box = $arr_prop_detail; $new_box['from_item_position'] = $arr_prop_detail['item_position']; $new_box['from_grid'] = $arr_prop_detail['grid']; $new_box['item_position'] = $aim_item_position; $new_box['grid'] = $aim_grid; $out[2][] = Struct_Prop::get_item_box_operate_struct($new_box); } return $out; }