/** * 添加多个 * @param $player_id * @param $level * @param $vip_level * @param $data * @return bool */ public function add_multi_guide_log($player_id, $level, $vip_level, $data) { if (Com_Array::is_arr2($data)) { foreach ($data as $param) { $this->add_guide_log($player_id, $level, $vip_level, $param['type'], $param['task_id'], $param['step'], $param['status']); } } else { $this->add_guide_log($player_id, $level, $vip_level, $data['type'], $data['task_id'], $data['step'], $data['status']); } return true; }
public function replace_buff_data($data) { if (Com_Array::is_arr2($data)) { $set_data = array(); foreach ($data as $val) { $set_data[$val['buff_sid']] = json_encode($val); } if (!empty($set_data)) { $cache_key = $this->get_cache_key($val['player_id']); $result = $this->redis()->hash_set($cache_key, $set_data); } } else { $cache_key = $this->get_cache_key($data['player_id']); $result = $this->redis()->hash_set($cache_key, $data['buff_sid'], json_encode($data)); } return $result; }
public function create_sql($table, $data) { $content = ''; if (Com_Array::is_arr2($data)) { $content = "insert into " . $table; $i = 0; foreach ($data as $key => $value) { $value = $this->get_pub_data($value); if ($i == 0) { $content .= "(`" . implode("`,`", array_keys($value)) . "`) values"; } $content .= "('" . implode("','", $value) . "'),"; $i++; } $content = rtrim($content, ',') . ";\n"; } else { if (is_array($data)) { $data = $this->get_pub_data($data); $content = 'insert into ' . $table . "(`" . implode("`,`", array_keys($data)) . "`) values('" . implode("','", $data) . "');\n"; Com_Log::write('game_log', $content); } } return $content; }
/** * 添加多种资源 资源是指 黄金 钻石 等这些资源 * @param $player_id 用户id * @param $level 用户等级 * @param $vip_level vip等级 * @param $cmd_id cmd2 指令 * @param $data array('type',item_id,item_num,amount) 具体含义 参照 add_resource_log 里的 $item * @param $arr_consume array('price',gold,ticket,count) or array() 同 Data/Player.php update_player_resource 里的 $arr_consume * @return bool */ public function add_multi_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $data, $arr_consume = array()) { $arr_async = array(); if (Com_Array::is_arr2($data)) { foreach ($data as $param) { if ($param['item_num'] > 0) { $this->add_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $param['type'], $param['item_id'], $param['item_num'], $param['amount'], $param['front_attr'], $param['after_attr']); } $key = Cache_Currency::getInstance()->get_key($param['item_id']); if (isset($param['is_async']) && $param['is_async'] == 0) { #这时候是不推送的 做不推送的操作 具体啥操作 待定 } else { if ($param['type'] == 1) { $arr_async[$key] = $param['amount'] + $param['item_num']; } elseif ($param['type'] == 2) { $arr_async[$key] = $param['amount'] - $param['item_num']; ############################################################################### # 道具消费,上报数据 if (OPERATOR_ID == 82) { $playerData = TenYear::getInstance("Data_player")->get_player_info($player_id, array("session_id")); $arrUpload = TenYear::getInstance("Game_online")->get_session($playerData['session_id']); $platform = $arrUpload['platform']; $serverId = $arrUpload['server_id']; $openid = $arrUpload['openid']; Com_TencentDataUpload::getInstance()->init($platform, $serverId, $player_id, $openid); $arr_consume_upload = array("level" => $level, "itemid" => $data['item_id'], "itemtype" => $data['type'], "itemcnt" => $data['item_num']); if (!($res = Com_TencentDataUpload::getInstance()->consume_data_upload($arr_consume_upload))) { Com_Log::write("uploadDataError", "consume_data_upload failed!"); } } ############################################################################### } } } } else { if ($data['item_num'] > 0) { $this->add_resource_log($player_id, $level, $vip_level, $vip_special_level, $cmd_id, $data['type'], $data['item_id'], $data['item_num'], $data['amount'], $data['front_attr'], $data['after_attr']); } $key = Cache_Currency::getInstance()->get_key($data['item_id']); if (isset($data['is_async']) && $data['is_async'] == 0) { #检查否同步前端 #这时候是不推送的 做不推送的操作 具体啥操作 待定 } else { if ($data['type'] == 1) { $arr_async[$key] = $data['amount'] + $data['item_num']; } elseif ($data['type'] == 2) { $arr_async[$key] = $data['amount'] - $data['item_num']; } } } if ($arr_consume) { $params['act'] = $cmd_id; $params['level'] = $level; $params['price'] = $arr_consume['price']; $params['gold'] = $arr_consume['gold']; $params['black_gold'] = $arr_consume['ticket']; $params['count'] = $arr_consume['count']; $params['time'] = time(); Com_DataCenter::getInstance()->publish_data($player_id, 'prop', $params); } # 先注释了 if ($arr_async) { Protocol_Player::p2c_part_update($player_id, $arr_async); #同步资 } return true; }
/** * 格式化参数扩展 * @param $params * @param $code * @return array */ public static function format_param_ex($params, $code) { $out = array(); if (!empty($params)) { #获取错误语言配置表 $language_table = Cache_Language::getInstance()->get_language_info($code); if ($language_table['params']) { $language_params = self::format_table_field($language_table['params']); } foreach ($params as $param) { if (Com_Array::is_arr2($param)) { $p = array(); foreach ($param as $val) { if ($language_params[$val['txt']]) { $val['txt'] = $language_params[$val['txt']]; } $tmp = array('txt' => $val['txt'], 'rep_type' => $val['rep_type'], 'rep_val' => '', 'rep_param' => '', 'underLine' => '', 'color' => '', 'size' => ''); if ($val['rep_type'] == 1) { if (!empty($val['rep_val'])) { $tmp['rep_val'] = $val['rep_val']; $tmp['rep_param'] = $val['rep_chapter'] . "," . $val['rep_task_id']; } } elseif ($val['rep_type'] == 2) { if (!empty($val['rep_val'])) { $tmp['rep_val'] = $val['rep_val']; $tmp['rep_param'] = $val['rep_num'] . "," . $val['rep_player_id'] . "," . $val['rep_pid']; } } elseif ($val['rep_type'] == 3) { if (!empty($val['rep_pid'])) { $tmp['rep_val'] = $val['rep_val']; $tmp['rep_param'] = "1," . $val['rep_player_id'] . "," . $val['rep_pid']; } } elseif ($val['rep_type'] == 4) { if (!empty($val['rep_pid'])) { $tmp['rep_val'] = $val['rep_val']; $tmp['rep_param'] = "1," . $val['rep_player_id'] . "," . $val['rep_pid']; } } elseif ($val['rep_type'] == 10 || $val['rep_type'] == 9 || $val['rep_type'] == 12) { if (!empty($val['rep_val'])) { $tmp['rep_val'] = $val['rep_val']; if (Com_Array::is_good_arr($val['rep_param'])) { foreach ($val['rep_param'] as $rp) { if (!is_int($rp)) { $rp = '$' . $rp; } $tmp['rep_param'] .= ($tmp['rep_param'] ? "," : "") . $rp; } } else { $tmp['rep_param'] = $val['rep_num'] . "," . $val['rep_player_id'] . "," . $val['rep_pid']; } } } else { if (!empty($val['rep_val'])) { $tmp['rep_val'] = $val['rep_val']; if (isset($val['rep_color'])) { $val['rep_color'] = ""; $tmp['color'] = $val['rep_color']; } } } $p[] = $tmp; } $out[] = $p; } else { $p = array(); if ($language_params[$param['txt']]) { $param['txt'] = $language_params[$param['txt']]; } if ($param['rep_type'] == 1) { $rep = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'rep_val' => $param['rep_val'], 'rep_param' => ''); if (isset($param['rep_map_id'])) { $rep['rep_param'] = $param['rep_chapter'] . "," . $param['rep_map_id']; $rep['underline'] = $param['rep_underline']; $param['rep_color'] = ""; $rep['color'] = $param['rep_color']; } $p[] = $rep; } elseif ($param['rep_type'] == 2) { $p[] = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'value' => $param['rep_val'], 'rep_param' => $param['rep_num'] . "," . $param['rep_player_id'] . "," . $param['rep_pid']); } elseif ($param['rep_type'] == 3) { $p[] = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'value' => $param['rep_val'], 'rep_param' => "1," . $param['rep_player_id'] . "," . $param['rep_pid']); } elseif ($param['rep_type'] == 4) { $p[] = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'value' => $param['rep_val'], 'rep_param' => "1," . $param['rep_player_id'] . "," . $param['rep_pid']); } elseif ($param['rep_type'] == 0) { $param['rep_color'] = ""; $p[] = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'value' => $param['rep_val'], 'rep_param' => '', 'underline' => '1', 'color' => $param['rep_color']); } elseif ($param['rep_type'] == 10 || $param['rep_type'] == 9 || $param['rep_type'] == 12) { if (!empty($param['rep_val'])) { if (Com_Array::is_good_arr($param['rep_param'])) { foreach ($param['rep_param'] as $rp) { if (!is_int($rp)) { $rp = '$' . $rp; } $rep_param .= ($rep_param ? "," : "") . $rp; } } } $param['rep_color'] = ""; $p[] = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'value' => $param['rep_val'], 'rep_param' => $rep_param, 'underline' => '1', 'color' => $param['rep_color']); } else { $param['rep_color'] = ""; $p[] = array('txt' => strval($param['txt']), 'rep_type' => $param['rep_type'], 'value' => $param['rep_val'], 'rep_param' => '', 'underline' => '', 'color' => $param['rep_color']); } $out[] = $p; } } } return $out; }