/** * 获取邮件列表 * @param $player_id * @param $mail_id * @return null|array */ public function get_mail_info($player_id) { $player_id = intval($player_id); $objmail = $this->get_data('PlayerMail'); $data = $objmail->get_player_mail_info($player_id); Com_Array::multisort($data, array('createtime' => 'desc', 'state' => 'desc', 'isread' => 'asc')); $data = array_slice($data, 0, 50); $unread_num = 0; foreach ($data as $key => $val) { if ($val['expiretime'] <= time()) { unset($data[$key]); $ret = $objmail->del_player_mail($player_id, $val["mail_id"]); continue; } if ($val['isread'] == 0) { $unread_num++; } $countdown = $val['expiretime'] - time(); $data[$key]['countdown'] = $countdown < 0 ? 0 : $countdown; } Com_Log::write('xgame.mail', "{$player_id}\t" . json_encode($data)); #同步一下未读取数量 $this->get_data('PlayerMail')->set_unread_mail_num($player_id, $unread_num); #Com_Log::write('xgame.mail', "$player_id\t".json_encode($data)); return $data; }
private function get_redis_key($week_offset = 0) { $time = $this->current_time - $week_offset * 7 * 86400; $week_date = Com_Util::get_next_week_day($time, false); # 每周周日 $redis_key = $this->week_fame_sorted_set . "|" . $week_date; Com_Log::write('xgame.magic_parliament', "get_redis_key: time={$time}|get_reids_key:{$redis_key}"); return $redis_key; }
public function get_questionnaire_info($questionnaire_id) { if (empty($questionnaire_id)) { return false; } $sql = "select * from activity_questionnaire where questionnaire_id = {$questionnaire_id}"; $key = $this->get_cache_key(array('questionnaire_id' => $questionnaire_id), $this->prefix_activity_questionnaire_master); Com_Log::write('xgame.questionnaire', "get_start_plane:============:{$key}"); return $this->select_one($sql, $this->get_cache_key(array('questionnaire_id' => $questionnaire_id), $this->prefix_activity_questionnaire_master)); }
public function doAction() { $this->arrData = $this->_parseData; if ($this->veritySig()) { $step = $this->arrData['step']; $cmd = $this->arrData['cmd']; switch ($step) { case 1: $result = $this->award(); break; case 2: if ($cmd == "check_award") { $result = $this->check_award(); } else { if ($cmd == "award") { $result = $this->award(); } } break; case 3: $result = $this->check(); break; case 4: $result = $this->award(); break; default: $result = json_encode(array("ret" => 103, "msg" => "请求参数错误,缺少step")); break; } } else { $result = json_encode(array("ret" => 103, "msg" => "请求参数错误:签名不一致")); } //记录发放奖励的流水号 if (json_decode($result, true)['ret'] == 0) { $billno = $this->arrData['billno']; # 奖励流水号 $openid = $this->arrData['openid']; # 玩家openid $step = $this->arrData['step']; # 步骤号 $contractid = $this->arrData['contractid']; # 任务id $payitem = $this->arrData['payitem']; # 道具礼包id $cmd = $this->arrData['cmd']; $data = array("msg" => json_decode($result, true)['msg'], "zoneid" => json_decode($result, true)['zoneid'], "step" => $step, "contractid" => $contractid, "payitem" => $payitem, "cmd" => $cmd, "billno" => $billno, "time" => time()); $objTask = $this->get_game('TencentTaskMarket'); $ret = $objTask->set_tencent_bill_record($openid . ":" . $step, $data); if (!$ret) { Com_Log::write("TencentTaskMarket", "billno stored failed!" . json_encode($data)); } } echo $result; }
protected function adult_remind($player_id, $status) { if ($status == 1) { $msg = Language_Message::make_message('10223'); $type = 1; } else { $msg = Language_Message::make_message('10224'); $type = 2; } Com_Log::write("do_timeer." . $player_id, "msg:" . var_export($msg, true)); Protocol::input($player_id, 8, 7, 755, array(0 => $msg, 1 => $type)); }
/** * 发送聊天信息到37wan接口 * @param $params * @return int errno -3(接口超时),-2(签名验证错误),-1(参数错误),1(推送成功) */ public function report_msg($params) { $params = json_decode($params, true); $player_id = $params[3]; $player_info = $this->get_player_info($player_id); if ($params[0] != 0) { $dpf_player_info = $this->get_player_info($params[0]); } else { // $params[0] 为0的时候,是在世界或者公会聊天 $dpf_player_info['name'] = 'world'; } $post_data = array('game_key' => $this->game_key, 'server_id' => SERVER_ID, 'time' => $params[1], 'login_account' => $player_info['user_account'], 'actor' => $player_info['name'], 'to_login_account' => $params[0], 'to_actor' => $dpf_player_info['name'], 'content' => urlencode($params[2]), 'ip' => $player_info['client_ip']); $sign = $this->make_sign($post_data); $post_data['sign'] = $sign; $result = Com_TencentDataUpload::getInstance()->send_data($post_data, $this->api_url); echo '-------Upload data to 37wan-----status code-----' . $result; if ($result != 1) { //推送不成功,日志打印错误信息 Com_Log::write('uploadDataError', 'Upload data to 37wan failed! Errorcode' . $result); } }
protected function parser_dispatch() { $passport_key = SERVER_KEY; # 需要自行与平台约定 $timeExpire = 300; $arrData = $_REQUEST; if (empty($_REQUEST["action"]) || empty($_REQUEST["verify"])) { $this->throw_error(3, 'param lack.'); #缺少参数 } elseif (!in_array($_REQUEST["action"], $this->_actions)) { $this->throw_error(-1, 'param error.'); #参数错误 } unset($arrData['action'], $arrData["verify"]); # 不参与签名算法 ksort($arrData); $strAuth = ""; foreach ($arrData as $key => $value) { if (empty($strAuth)) { $strAuth .= $key . "=" . $value; } else { $strAuth .= "&" . $key . "=" . $value; } } $strAuth .= $passport_key; $strAuthMd5 = md5($strAuth); if ($strAuthMd5 != $_REQUEST["verify"]) { Com_Log::write('xgame.game_api', "sorted query string:\t{$strAuth}\tmd5sum:\t{$strAuthMd5}"); $this->throw_error(1, 'verify code error.'); # 校验码错误 } elseif (time() - intval($_REQUEST["timestamp"]) > $timeExpire) { $this->throw_error(2, 'request timeout.'); # 超时 } $this->_action = ucfirst($_REQUEST["action"]) . 'Action'; $this->_command = isset($_REQUEST['command']) ? $_REQUEST['command'] : 'doAction'; $this->_parseData = $arrData; # 无用的 }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $userInfo_array = json_decode($userInfo_json, true); Com_Log::write('xgame.questionnaire', json_encode($userInfo_array)); if ($userInfo_array['activity']['topic']) { foreach ($userInfo_array['activity']['topic'] as $key => $val) { $userInfo_array['activity']['topic'][$key]['topicContent'] = trim($val['topicContent']); $userInfo_array['activity']['topic'][$key]['topicOptions'] = json_decode($val['topicOptions'], true); } } $reward_info = array('base_reward' => $userInfo_array['activity']['reward'][0]['reward'], 'extra_reward' => $userInfo_array['activity']['reward'][0]['good_reward'], 'answer_reward' => $userInfo_array['activity']['reward'][0]['answer_reward']); $update_data = array('questionnaire_id' => $userInfo_array['activity']['id'], 'questionnaire_type' => $userInfo_array['activity']['questioninvType'], 'questionnaire_name' => $userInfo_array['activity']['name'], 'content' => serialize($userInfo_array['activity']['topic']), 'reward' => json_encode($reward_info), 'start_time' => $userInfo_array['activity']['questioninvStartTime'], 'stop_time' => $userInfo_array['activity']['questioninvEndTime'], 'start_level' => $userInfo_array['activity']['questioninvStartLevel'], 'end_level' => $userInfo_array['activity']['questioninvEndLevel'], 'start_vip' => $userInfo_array['activity']['questioninvStartVip'], 'end_vip' => $userInfo_array['activity']['questioninvEndVip'], 'start_charge_time' => $userInfo_array['activity']['questioninvStartPayTime'], 'end_charge_time' => $userInfo_array['activity']['questioninvEndPayTime'], 'charge_status' => $userInfo_array['activity']['activityBehavier'], 'start_word' => $userInfo_array['activity']['startMess'], 'end_word' => $userInfo_array['activity']['endMess'], 'status' => $userInfo_array['activity']['status']); foreach ($update_data as $k => $v) { $update_data[$k] = addslashes($v); } $result = $this->get_data('ActivityQuestions')->add_questionnaire($update_data); if ($result) { echo json_encode(array('status' => 1, 'data' => "success")); } else { echo json_encode(array('status' => 0, 'data' => 'fail')); } }
public function compose($player_id, $target_id, $comp_type, $comp_sub_type, $auto_buy, $onekey) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); # 参数校验,comp_sub_type允许为0 $this->param_check_numeric(array($player_id, $target_id, $comp_type, $comp_sub_type), 0); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level'))); # 一键合成不允许自动购买 if ($onekey) { $auto_buy = 0; } # 获取具体合成信息 $comp_info = Cache_ItemCompose::getInstance()->get_item_compose_info_by_target_id($target_id); if (empty($comp_info)) { $this->throw_error('90002'); # 没有配置该道具的合成信息 } $comp_type = $comp_info['comp_type']; $comp_sub_type = $comp_info['comp_sub_type']; /** 由于前端问题,传参此处可能报异常,反正这两个参数不实用,故忽略 if ($comp_info['comp_type'] != $comp_type || $comp_info['comp_sub_type'] != $comp_sub_type) { $this->throw_error('90003'); # 合成参数异常 } **/ # 检查消耗情况 $cost_material_info_hash = array(); # 消耗材料信息哈希,为了方便一次性查找所有消耗材料的持有数 for ($i = 1; $i <= 5; $i++) { if (!empty($comp_info['m' . $i . '_id']) && !empty($comp_info['m' . $i . '_amount'])) { $cost_material_info_hash[$comp_info['m' . $i . '_id']] = $comp_info['m' . $i . '_amount']; } } # -------------------------------------------------------------------- # 计算可一键合成的产物数量 # -------------------------------------------------------------------- $onekey_num_list = array(); # 每项材料可以满足合成条件几次 if (!empty($cost_material_info_hash)) { $material_hold_nums = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, array_keys($cost_material_info_hash)); foreach ($cost_material_info_hash as $m_id => $m_amount) { $onekey_num_list[$m_id] = intval($material_hold_nums[$m_id] / $m_amount); } } $onekey_num = min($onekey_num_list); # 木桶原理,能一键合成的产物数由最少材料项决定 if ($onekey) { if (empty($onekey_num)) { $this->throw_error('90004'); # 合成所需材料不足 } $onekey_num = min($onekey_num, intval($player_info['silver'] / $comp_info['cost'])); # 木桶原理,能一键合成的产物数还由玩家持有货币决定 if (empty($onekey_num)) { $this->throw_error('10113'); # 金币不足 } } else { if (empty($onekey_num) && empty($auto_buy)) { $this->throw_error('90004'); # 合成所需材料不足 } $onekey_num = 1; # 非一键合成一次只允许合成一件 } $this->start_trans(); # 消耗虚拟货币 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $comp_info['cost'] * $onekey_num, 1, 1); # 消耗材料 $arr_logs = array(); $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2202); foreach ($cost_material_info_hash as $m_id => $m_amount) { $hold_num = !empty($material_hold_nums[$m_id]) ? $material_hold_nums[$m_id] : 0; if (!empty($auto_buy) && $hold_num < $m_amount) { # 一定是单次合成 # 获取正确的单价 $price_info = $this->get_game('Shop')->shortcut_purchase_interface($m_id, 1); if (empty($price_info['item_price'])) { $this->throw_error('130001'); # 商城没有出售该道具 } # 策划价格配置多项时,选其中一项 list($cur_idx, $cur_val) = each($price_info['item_price']); $price = $cur_val; $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx); $cost_currency_value = intval($cur_val * ($m_amount - $hold_num)); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cur_idx); if ($hold_num > 0) { # 该方法在道具不足时会报错,无需外层再判断是否道具足够 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $material_hold_nums[$m_id], $arr_logs, 0, $log_param); $this->write_check($re, 3010156); } # 若有购买缺少材料,记录虚假商城购买日志 if ($cost_currency_value > 0) { $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $m_id, intval($m_amount - $hold_num), $cur_idx, $cost_currency_value, 2202); } } else { # 可能单次,可能一键 # 该方法在道具不足时会报错,无需外层再判断是否道具足够 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $m_amount * $onekey_num, $arr_logs, 0, $log_param); $this->write_check($re, 3010161); } } # TODO: 数据中心推送 $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2202'); $this->write_check($re, 3010167); #--------------------------------------------------------------------- # 按概率计算成功次数 #--------------------------------------------------------------------- $success_num = 0; for ($i = 1; $i <= $onekey_num; $i++) { if (Com_Random::probability($comp_info['succ_rate'], 10000)) { # 成功 $success_num += 1; } } if ($success_num) { # 成功 # 发送道具 $reward[] = array('type' => 'prop', 'item_id' => $target_id, 'item_num' => $success_num); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2202)); #send_reward失败时,会返回各种失败情况的错误码 $this->write_check_strict($re, 3010173); } # 记录合成日志 $this->commit(); # -------------------------------------------------------------------- # 通知道具变更,粘包806 # -------------------------------------------------------------------- $this->get_game('Reward')->add_reward_log(); # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志 if (!empty($arr_logs) && is_array($arr_logs)) { $ndata = array(); foreach ($arr_logs as $key => $val) { $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); } # -------------------------------------------------------------------- # 刷新2201协议 # -------------------------------------------------------------------- $data_2201 = $this->get_compose_info($player_id, $comp_type, $comp_sub_type); Protocol::input($player_id, 3, 22, 2201, $data_2201); # 记录行为 Com_Log::write('xgame.compose', "{$player_id}\t" . "{$target_id}\t" . "{$auto_buy}\t" . "{$onekey}\t" . "{$onekey_num}\t" . "{$success_num}\t"); # 日常任务埋点,宝石合成才触发,考虑宝石种类可能包含多种,不方便使用$arr_logs[0]['type'] == 3 && $arr_logs[0]['sub_type'] == 6类似条件 #if ($comp_type == $this->comp_type_for_gem) { # 改为任意合成都算 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 109, 109, $onekey_num); #} #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 12, $onekey_num); # -------------------------------------------------------------------- # 公告 # -------------------------------------------------------------------- $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 70), array('rep_type' => 2, 'rep_val' => $target_id)); $prop_info = Cache_Prop::getInstance()->get_prop_info($target_id); $this->get_game('SystemNotice')->push_sys_notice($player_id, 70, 0, $replace_info, 0, $prop_info['need_broad_cast']); $out_2202 = array('result' => 1); return $out_2202; }
/** * 随机需要合成的碎片 * @param number $number * @return Ambigous <multitype:, multitype:multitype:Ambigous <boolean, unknown> > */ public function rand_compose_pieces($number, $level, $no_need_prop_id = array(), $is_guide = 0) { $arr_prop_weight = array(); $arr_prop_pieces_weight = array(); $arr_prop_pieces_type_weight = array(); $rand_prop_list = array(); $arr_pieces_quality = array(); $arr_prop_quality = array(); $grabTreasureConfig = Cache_GrabTreasureBase::getInstance()->get_grab_treasure_list(); if (Com_Array::is_good_arr($grabTreasureConfig)) { foreach ($grabTreasureConfig as $key => $item) { if ($level < $item['min_lvl'] || $level > $item['max_lvl']) { unset($grabTreasureConfig[$key]); } } if (Com_Array::is_good_arr($grabTreasureConfig)) { foreach ($grabTreasureConfig as $item) { #道具权重 $arr_prop_weight[$item['id']] = $item['weight']; $arr_prop_quality[$item['quality']][$item['id']] = $item['weight']; $arr_pieces_num = explode(",", $item["pieces_num"]); $arr_pieces_weight = explode(",", $item["pieces_weight"]); $arr_piece_type = explode(",", $item["piece_type"]); $arr_pieces_type_weight = explode(",", $item["type_weight"]); #碎片数量权重 foreach ($arr_pieces_num as $key => $num) { $arr_prop_pieces_weight[$item['id']][$num] = $arr_pieces_weight[$key]; } #碎片道具权重 foreach ($arr_piece_type as $key => $piece_id) { $arr_prop_pieces_type_weight[$item['id']][$piece_id] = $arr_pieces_type_weight[$key]; $arr_pieces_quality[$piece_id] = $item['quality']; } } $real_number = 0; #随机的类型列表 $rand_prop_list = array(); $i = 0; while ($real_number < $number && $i <= 10) { ++$i; Com_Log::write("arr_prop_weight", "real_number:" . var_export($real_number, true)); Com_Log::write("arr_prop_weight", "number:" . var_export($number, true)); #新手引导第一个为品质2 if ($is_guide && empty($rand_prop_list)) { $rand_prop_id = Com_Random::get_probability_key($arr_prop_quality[2]); #去除已随机出来的 unset($arr_prop_quality[2][$rand_prop_id]); } else { $rand_prop_id = Com_Random::get_probability_key($arr_prop_weight); #去除已随机出来的 unset($arr_prop_weight[$rand_prop_id]); } if (isset($rand_prop_list[$rand_prop_id])) { # 该类型不允许重复 continue; } if (Com_Array::is_good_arr($no_need_prop_id) && in_array($rand_prop_id, $no_need_prop_id)) { # 该类型不允许重复 continue; } #随机碎片数量 $real_pieces = 0; $rand_piece_list = array(); #新手引导第一个中第一个碎片为空,其它碎片为已获得 if ($is_guide && empty($rand_prop_list)) { $piece_num = 0; foreach ($arr_prop_pieces_type_weight[$rand_prop_id] as $piece_id => $weight) { $piece_num++; if ($piece_num > 1) { $rand_piece_list[$piece_id] = $arr_pieces_quality[$piece_id]; } } } else { $rand_pieces = Com_Random::get_probability_key($arr_prop_pieces_weight[$rand_prop_id]); $j = 0; while ($real_pieces < $rand_pieces && $j <= 10) { $j++; #随机碎片道具 $rand_piece_id = Com_Random::get_probability_key($arr_prop_pieces_type_weight[$rand_prop_id]); #去除已随机出来的 unset($arr_prop_pieces_type_weight[$rand_prop_id][$rand_piece_id]); #该类型不允许重复 if (isset($rand_piece_list[$rand_piece_id])) { continue; } $rand_piece_list[$rand_piece_id] = $arr_pieces_quality[$rand_piece_id]; $real_pieces = count($rand_piece_list); } } $rand_prop_list[$rand_prop_id] = $rand_piece_list; $no_need_prop_id[] = $rand_prop_id; $real_number = count($rand_prop_list); } } } return $rand_prop_list; }
/** * 英雄战斗力计算 * @param $player_id 玩家ID * @param $hero_attr 英雄属性 * @param $fit_level 合体等级 * @param $rune_list 符文列表 * @param $attr_per 属性百分比 * @param $skill_list 技能列表 add by chengt * @param $union_attr 公会科技 * */ public function calc_fight($player_id, $hero_attr, $fit_level, $rune_list, $attr_per, $skill_list, $union_attr = false, $remote = array(), $remote_player = array()) { $life = $hero_attr['life']; $def = $hero_attr['def']; $attack = $hero_attr['attack']; #星级属性百分比加成 $life += intval($life * ($attr_per / 10000)); $def += intval($def * ($attr_per / 10000)); $attack += intval($attack * ($attr_per / 10000)); #战斗力计算前加上潜能属性 $life += $hero_attr['potential_life']; $attack += $hero_attr['potential_attack']; $def += $hero_attr['potential_def']; #合体属性加成 $life += $hero_attr['fit_life']; $def += $hero_attr['fit_def']; $attack += $hero_attr['fit_attack']; #合体属性百分比加成 if (Com_Array::is_good_arr($hero_attr['fit_attr_per'])) { $life += intval($life * ($hero_attr['fit_attr_per']['hp_per'] / 10000)); $def += intval($def * ($hero_attr['fit_attr_per']['arm_per'] / 10000)); $attack += intval($attack * ($hero_attr['fit_attr_per']['atk_per'] / 10000)); } #技能百分比加成 $life += intval($life * ($hero_attr['skill_life'] / 100)); $def += intval($def * ($hero_attr['skill_def'] / 100)); $attack += intval($attack * ($hero_attr['skill_attack'] / 100)); #成长值百分比加成 $attr_table = $this->get_hero_attr_table($hero_attr['hero_code']); $life += intval($life * $this->calc_grow_attar($hero_attr['grow_rate'], $attr_table['grow'])); $def += intval($def * $this->calc_grow_attar($hero_attr['grow_rate'], $attr_table['grow'])); $attack += intval($attack * $this->calc_grow_attar($hero_attr['grow_rate'], $attr_table['grow'])); if ($union_attr === false) { #获取英雄公会科技属性加成 $objPlayerDetail = $this->get_data('PlayerDetail'); // if(!empty($remote_player)){ // $objPlayerDetail->set_remote($remote_player); // } $union_attr = $objPlayerDetail->get_player_detail($player_id, 'union_hero_attr'); // $objPlayerDetail->clear_remote(); // unset($objPlayerDetail); } $hero_fight = 0; #公会科技加成 if (!empty($union_attr)) { // Com_Log::write("hero_calc_fight.".$player_id,"union_attr:".var_export($union_attr,true)); $union_fight = Formula_Fpower::calc_fpower($union_attr); $hero_fight += $union_fight; // Com_Log::write("hero_calc_fight.".$player_id,"union_fight:".var_export($union_fight,true)); } if (isset($hero_attr['fit_other_attr']) && Com_Array::is_good_arr($hero_attr['fit_other_attr'])) { $hero_attr['fit_other_attr']['hp'] = $life; $hero_attr['fit_other_attr']['arm'] = $def; $hero_attr['fit_other_attr']['atk_min'] = $attack; } else { $hero_attr['fit_other_attr'] = array('hp' => $life, 'arm' => $def, 'atk_min' => $attack); } // $fit_level = $fit_level - 1 < 0 ? 0 : $fit_level - 1; // $extra_fight_ratio = 1 + ($fit_level) / 9/* + $rune_level * 0.05*/; // Com_Log::write("hero_calc_fight.".$player_id,"fit_other_attr:".var_export($hero_attr['fit_other_attr'],true)); $fit_other_fight = Formula_Fpower::calc_fpower($hero_attr['fit_other_attr']); $hero_fight += $fit_other_fight; // Com_Log::write("hero_calc_fight.".$player_id,"extra_fight_ratio:".var_export($extra_fight_ratio,true)); Com_Log::write("hero_calc_fight." . $player_id, "fit_other_fight:" . var_export($fit_other_fight, true)); // $all_fight = intval($hero_fight * $extra_fight_ratio); $all_fight = $hero_fight; $rune_list = Com_FmtData::cus_json_decode($rune_list); if (Com_Array::is_good_arr($rune_list)) { $objPlayerProp = $this->get_data('PlayerProp'); // if(!empty($remote)){ // $objPlayerProp->set_remote($remote_player); // } foreach ($rune_list as $nune_data) { if ($nune_data['state'] == 2) { $arr_prop_detail = $objPlayerProp->get_player_prop_detail($player_id, $nune_data['id']); $rune_fight = intval(Formula_SkillFpower::$hero_run[$arr_prop_detail['quality']]); $all_fight += $rune_fight; // Com_Log::write("hero_calc_fight.".$player_id,"rune_fight:".var_export($rune_fight,true)); } } // $objPlayerProp->clear_remote(); // unset($objPlayerProp); } if ($skill_list) { if (is_string($skill_list)) { $skill_list = json_decode($skill_list, true); } foreach ($skill_list as $val) { if ($val['state'] > 0) { $skill_fight = intval(Formula_SkillFpower::$hero_skill[$val['lvl']]); $all_fight += $skill_fight; // Com_Log::write("hero_calc_fight.".$player_id,"skill_fight:".var_export($skill_fight,true)); } } } return $all_fight; }
public function get_event_reward($player_id, $event_id, $reward_id, $event_template) { $this->param_check_numeric(array($player_id, $event_id, $reward_id)); # 加锁失败 if (!Com_Lock::lock("lock|get_event_reward|player_id={$player_id}")) { $this->throw_error('170501'); # 系统繁忙 } $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level', 'map_id'))); if ($player_info['map_id'] == 2100) { $this->throw_error('12012'); # 请在完成序章后领取 } # 获取活动配置 $event_info = $this->get_data('Event')->get_event_info($event_id); if (empty($event_info) || empty($event_info['event_reward_info'])) { $this->throw_error('12004'); # 无效的活动,未找到活动配置信息 } $reward_id_array = explode(':', $event_info['event_reward_info']); if (!in_array($reward_id, $reward_id_array)) { $this->throw_error('12006'); # 无效的奖励,未找到活动奖励配置信息 } # NOTE: 因为允许在活动结束后领奖,所以领奖时不用活动开启时间段[open_date_head,open_date_tail]做检测 if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) { $this->throw_error('12005'); # 未到或已超过活动奖励领取时间 } # 获取奖励配置 $reward_info = $this->get_data('Event')->get_reward_info($reward_id); if (empty($reward_info) || empty($reward_info['cond_func'])) { $this->throw_error('12006'); # 无效的奖励,未找到活动奖励配置信息 } if (!empty($reward_info['valid_date_head']) || !empty($reward_info['valid_date_tail'])) { if ($reward_info['valid_date_head'] > $this->current_time || $reward_info['valid_date_tail'] < $this->current_time) { $this->throw_error('12007'); # 未到或已超过活动奖励有效时间 } } /** # -------------------------------------------------------------------- # 活动领奖周期内的领奖次数上限判断 # -------------------------------------------------------------------- if (!empty($event_info['event_reward_stint']) && !empty($event_info['event_reward_cycle'])) { # 向上取整获取最大领奖期数 $max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $event_info['event_reward_cycle']); for($i = 1; $i <= $max_cycle; $i++) { $cycle_head = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * ($i - 1); # 领奖周期首部时间 $cycle_tail = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * $i - 1; # 领奖周期尾部时间,减一是为了相邻两个区间没有交集 if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内 continue; } else { # 获取该周期内的领奖次数 list($reward_record, $reward_record_count) = $this->get_data('Event')->get_event_reward_record_part($player_id, $event_id, $cycle_head, $cycle_tail); if ($reward_record_count >= $event_info['event_reward_stint']) { $this->throw_error('12008'); # 已达到活动领奖周期内的领取次数上限 } break; } } } # -------------------------------------------------------------------- # 奖励领奖周期内的领奖次数上限判断,NOTO:没有考虑循环奖励的领取上限不仅由reward_gain_stint决定,还由循环达成数loop_num决定 # -------------------------------------------------------------------- if (!empty($reward_info['reward_gain_stint']) && !empty($reward_info['reward_gain_cycle'])) { # 向上取整获取最大领奖期数 $max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $reward_info['reward_gain_cycle']); for($i = 1; $i <= $max_cycle; $i++) { $cycle_head = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * ($i - 1); # 领奖周期首部时间 $cycle_tail = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * $i - 1; # 领奖周期尾部时间,减一是为了相邻两个区间没有交集 if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内 continue; } else { # 获取该周期内的领奖次数 list($reward_record, $reward_record_count) = $this->get_data('Event')->exactly_get_event_reward_record_part($player_id, $event_id, $reward_id, $cycle_head, $cycle_tail); if ($reward_record_count >= $reward_info['reward_gain_stint']) { $this->throw_error('12009'); # 已达到奖励领奖周期内的领取次数上限 } break; } } } **/ # 进度计算 $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']); $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params); # 剩余领奖次数计算 list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward_info, $ret); if (empty($real_remain_gain_num)) { $this->throw_error('12009'); # 已达到奖励领奖周期内的领取次数上限 } # -------------------------------------------------------------------- # 奖励达成条件判断 # -------------------------------------------------------------------- # 进度计算 $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']); $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params); if (empty($ret['status'])) { $this->throw_error('12010'); # 未达到奖励的领取条件 } # -------------------------------------------------------------------- # 发奖 + 消耗道具 + 并刷新奖励信息 # -------------------------------------------------------------------- $this->start_trans(); # 消耗道具 if (!empty($reward_info['consume_info'])) { $consume_currency = false; $arr_logs_consume = array(); $reward_item_info_arr = explode("|", $reward_info['consume_info']); $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2304); foreach ($reward_item_info_arr as $item_info) { list($item_id, $item_num) = explode(":", $item_info); $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id); if ($item_key == 'prop') { # 消耗道具 # deduct_prop_by_prop_id方法中有判断道具是否足够,故外层不判断 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $item_id, $item_num, $arr_logs_consume, 0, $log_param); $this->write_check($re, 3010311); } else { # 消耗资源 $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $item_key, $item_num); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $item_key, $item_num, 1, $item_id); $consume_currency = true; } } if ($consume_currency) { $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2304', array(), $arr_consume); $this->write_check($re, 3010332); } } # 奖励道具 $reward = array(); $reward_detail = array(); if (!empty($reward_info['reward_info'])) { $reward_item_info_arr = explode("|", $reward_info['reward_info']); foreach ($reward_item_info_arr as $item_info) { list($item_id, $item_num, $item_tag) = explode(":", $item_info); $reward_detail[$item_id] = $item_num; } } $this->get_game('Reward')->gen_reward_array($reward_detail, $reward); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2304', 'bind_flag' => 0)); $this->write_check_strict($re, 3010347); # 记录奖励领取日志 $re = $this->get_data('Event')->record_player_event_reward($player_id, $event_id, $reward_id, $this->current_time); $this->write_check($re, 3010351); $this->commit(); # 蛋疼的次数同步埋点 if ($event_template == 2) { # 充值回馈需要同步次数变更 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260); } # 粘806 + 通知道具变更信息 $ndata = array(); if (!empty($arr_logs_consume)) { foreach ($arr_logs_consume as $k => $v) { # 消耗的道具 $ndata[] = $v; } Protocol_Prop::prop_806($player_id, $ndata); } # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更 $ret = $this->get_game('Reward')->add_reward_log(true); #----------------------------------------------------------------- # 重新获取奖励项列表 #----------------------------------------------------------------- $event_reward_list = array(); $special_reward_list = array(); if (!empty($event_info['event_reward_info'])) { $reward_id_array = explode(':', $event_info['event_reward_info']); #echo "</br>===============".$event_info['event_id']."==================</br>"; #var_export($reward_id_array); $reward_info = $this->get_data('Event')->multi_get_reward_info($reward_id_array); #var_export($reward_info); # 对奖励列表升序排序 Com_Array::multisort($reward_info, array('reward_priority' => 'asc')); foreach ($reward_info as $reward) { #echo "</br>===============reward_id:".$reward['reward_id']."==================</br>"; # 获取奖励的具体道具列表 $reward_item_list = array(); if (!empty($reward['reward_info'])) { $reward_item_info_arr = explode("|", $reward['reward_info']); foreach ($reward_item_info_arr as $item_info) { list($item_id, $item_num, $item_tag) = explode(":", $item_info); $item_config = Cache_Prop::getInstance()->get_prop_info($item_id); $item_config['item_num'] = $item_num; $item_struct = Struct_Prop::get_prop_struct($item_config); $reward_item_list[$item_id] = $item_struct; if ($item_tag == $this->reward_item_tag_for_special) { $special_reward_list[$item_id] = $item_struct; } } } # 进度计算 $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward['reward_id'], 'reward_type' => $reward['reward_type'], 'reward_billing_cycle' => $reward['reward_billing_cycle']); $ret = $this->call_cond_func($player_id, $reward['cond_func'], $reward['cond_func_relation'], $sys_params); # 剩余领奖次数计算 list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward, $ret); # 领奖状态判定 if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) { $reward_status = 0; # 未到或已超过活动奖励领取时间 } elseif ((!empty($reward['valid_date_head']) || !empty($reward['valid_date_tail'])) && ($reward['valid_date_head'] > $this->current_time || $reward['valid_date_tail'] < $this->current_time)) { $reward_status = 0; # 未到或已超过活动奖励有效时间 } elseif (empty($real_remain_gain_num)) { # 用实际剩余领奖次数判断领奖状态 $reward_status = 0; } else { $reward_status = $ret['status']; } # 可领奖总数计算 if ($reward_status) { $can_receive_reward_num += 1; } $event_reward_list[] = array('reward_id' => $reward['reward_id'], 'reward_cond' => $reward['cond_desc'], 'reward_item_list' => $reward_item_list, 'reward_progress_head' => $ret['progress_head'], 'reward_progress_tail' => $ret['progress_tail'], 'reward_remain_gain_num' => $reward_remain_gain_num, 'reward_status' => $reward_status, 'reward_type' => $reward['reward_type'], 'consume_info' => $reward['consume_info'], 'reward_gain_stint' => $config_gain_stint); } } $out_2304 = array('event_tag' => $event_info['event_tag'], 'event_id' => $event_id, 'event_reward_list' => $event_reward_list, 'event_template' => $event_template); # 记录行为 Com_Log::write('xgame.event', "{$player_id}\t" . "get_event_reward\t" . "{$event_id}\t" . "{$reward_id}\t"); return $out_2304; }
public function equip_swallow($type, $player_id, $player_prop_id, $swallow_equips, $onekey = 0) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); $this->param_check_numeric(array($type, $player_id), 0); if (empty($swallow_equips)) { $this->throw_error('10107'); } # 参数错误 $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip')); # 828展示协议返回数据,828协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 $out_828 = array('player_ppid' => $player_prop_id, 'swallow_ppids' => $swallow_equips, 'swallow_list' => array()); $swallow_equips = explode(':', $swallow_equips); $swallow_equips = array_filter($swallow_equips); $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id); if (empty($player_prop_info)) { $this->throw_error('80013'); //玩家没有该装备! } # 获取允许吞噬的装备子类型列表 list($allow_swallow_sub_type, $allow_swallow_id) = $this->get_swallow_restriction_info($player_prop_info['sub_type']); # 828展示协议返回数据,828协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 $distinct_swallow_list = Cache_Forge::getInstance()->get_distinct_swallow_list(); foreach ($distinct_swallow_list as $swallow_info) { if (!empty($allow_swallow_id) && !in_array($swallow_info['swallow_id'], $allow_swallow_id)) { continue; } $out_828['swallow_list'][$swallow_info['swallow_id']] = array('swallow_id' => $swallow_info['swallow_id'], 'swallow_lv' => 0, 'swallow_exp' => 0); } if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) { if (!empty($type)) { # 实际吞噬 $this->throw_error('81106'); # 首充装备不允许吞噬 } else { $message = array('texts' => array(array('code' => 81106, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许吞噬 $out_828['swallow_ppids'] = ""; return $out_828; } } # 计算吞噬属性最大等级 $swallow_lv_max = $this->get_swallow_lv_max($player_prop_info['level']); $player_prop_details = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, $swallow_equips); if (empty($player_prop_details)) { $this->throw_error('80024'); //未选择有效的被吞噬装备 } # 被吞噬装备信息 $before_swallow_info = empty($player_prop_info['swallow_info']) ? array() : $player_prop_info['swallow_info']; $player_prop_id_slave = ""; $item_id_slave = ""; $onekey_prop_list = array(); # 保存允许一键吞噬的装备ID列表 $full_level_flag = false; # 是否满级,一键吞噬区分报错信息用 foreach ($swallow_equips as $pprop_id) { if (!empty($type)) { # 实际吞噬 if (!empty($allow_swallow_sub_type) && !in_array($player_prop_details[$pprop_id]['sub_type'], $allow_swallow_sub_type)) { $this->throw_error('80036'); # 被吞噬装备包含不允许吞噬的非法装备类型 } if ($player_prop_details[$pprop_id]['quality'] >= 4) { # 品质>=4的装备不允许被吞噬,秋水确定于20150811 $this->throw_error('80036'); # 被吞噬装备包含不允许吞噬的非法装备类型 } if (empty($player_prop_details[$pprop_id])) { $this->throw_error('80013'); # 玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $this->throw_error('81107'); # 首充装备不允许被吞噬 } if (!empty($player_prop_details[$pprop_id]['inlay_gems'])) { $this->throw_error('80041'); # 被吞噬装备镶嵌有宝石 } if (!empty($player_prop_details[$pprop_id]['star_map_id'])) { $this->throw_error('80042'); # 被吞噬装备镶嵌有觉醒石 } $item_swallow_info = Cache_Forge::getInstance()->get_swallow_map_config($player_prop_details[$pprop_id]['sub_type'], $player_prop_details[$pprop_id]['quality']); if (empty($item_swallow_info)) { $this->throw_error('80025'); # 该装备子类型没有配置对应的吞噬属性信息! } if (empty($item_swallow_info['swallow_id'])) { $this->throw_error('80026'); # 获取吞噬属性类型失败 } $exp_revise_info = Cache_Forge::getInstance()->get_swallow_exp_revise_config($player_prop_details[$pprop_id]['star_level']); if (empty($exp_revise_info) || empty($exp_revise_info['revise_ratio'])) { $this->throw_error('80044'); # 获取吞噬经验修正配置失败 } } else { # 非实际吞噬 if (!empty($onekey)) { # 一键勾选 if (!empty($allow_swallow_sub_type) && !in_array($player_prop_details[$pprop_id]['sub_type'], $allow_swallow_sub_type)) { continue; } if ($player_prop_details[$pprop_id]['quality'] >= 4) { # 品质>=4的装备不允许被吞噬,秋水确定于20150811 continue; } if (empty($player_prop_details[$pprop_id])) { continue; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { continue; } if (!empty($player_prop_details[$pprop_id]['inlay_gems'])) { continue; } if (!empty($player_prop_details[$pprop_id]['star_map_id'])) { continue; } $item_swallow_info = Cache_Forge::getInstance()->get_swallow_map_config($player_prop_details[$pprop_id]['sub_type'], $player_prop_details[$pprop_id]['quality']); if (empty($item_swallow_info) || empty($item_swallow_info['swallow_id'])) { continue; } $exp_revise_info = Cache_Forge::getInstance()->get_swallow_exp_revise_config($player_prop_details[$pprop_id]['star_level']); if (empty($exp_revise_info) || empty($exp_revise_info['revise_ratio'])) { continue; } } else { # 单项勾选,单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环 if (!empty($allow_swallow_sub_type) && !in_array($player_prop_details[$pprop_id]['sub_type'], $allow_swallow_sub_type)) { $message = array('texts' => array(array('code' => 80036, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 被吞噬装备包含不允许吞噬的非法装备类型 break; } if ($player_prop_details[$pprop_id]['quality'] >= 4) { # 品质>=4的装备不允许被吞噬,秋水确定于20150811 $message = array('texts' => array(array('code' => 80036, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 被吞噬装备包含不允许吞噬的非法装备类型 break; } if (empty($player_prop_details[$pprop_id])) { $message = array('texts' => array(array('code' => 80013, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 玩家没有该装备! break; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $message = array('texts' => array(array('code' => 81107, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许被吞噬 break; } if (!empty($player_prop_details[$pprop_id]['inlay_gems'])) { $message = array('texts' => array(array('code' => 80041, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 被吞噬装备镶嵌有宝石 break; } if (!empty($player_prop_details[$pprop_id]['star_map_id'])) { $message = array('texts' => array(array('code' => 80042, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 被吞噬装备镶嵌有觉醒石 break; } $item_swallow_info = Cache_Forge::getInstance()->get_swallow_map_config($player_prop_details[$pprop_id]['sub_type'], $player_prop_details[$pprop_id]['quality']); if (empty($item_swallow_info)) { $message = array('texts' => array(array('code' => 80025, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 该装备子类型没有配置对应的吞噬属性信息! break; } if (empty($item_swallow_info['swallow_id'])) { $message = array('texts' => array(array('code' => 80026, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 获取吞噬属性类型失败 break; } $exp_revise_info = Cache_Forge::getInstance()->get_swallow_exp_revise_config($player_prop_details[$pprop_id]['star_level']); if (empty($exp_revise_info) || empty($exp_revise_info['revise_ratio'])) { $message = array('texts' => array(array('code' => 80044, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 获取吞噬经验修正配置失败 break; } } } # 计算增加的吞噬属性ID $add_swallow_id = $item_swallow_info['swallow_id']; # 使用配置数据判断满经验,是为了当策划修改最大吞噬等级算法时,能忽略旧装备中保存的吞噬属性信息最大等级与最大经验两项,提高向前兼容性,Forwards Compatibility # 获取吞噬配置信息,一键勾选吞噬是不能报这个错 $swallow_config = Cache_Forge::getInstance()->get_swallow_config($add_swallow_id, $swallow_lv_max); if (isset($player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp']) && $player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] >= $swallow_config['swallow_exp'] - 1) { if (!empty($type)) { # 实际吞噬 $this->throw_error('80021'); # 该装备的该项吞噬属性已满! } else { $full_level_flag = true; if (empty($onekey)) { # 单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环 $message = array('texts' => array(array('code' => 80021, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); break; } else { # 一键勾选获取吞噬信息不弹提示属性满的消息 continue; } } } $player_prop_id_slave .= "{$pprop_id}:"; $item_id_slave .= $player_prop_details[$pprop_id]['prop_id'] . ":"; $onekey_prop_list[] = $pprop_id; # 计算增加属性值 && 修正经验值 $add_swallow_exp = self::$swallow_quality_to_exp_map[$player_prop_details[$pprop_id]['quality']]; $add_swallow_exp = ceil($add_swallow_exp * $exp_revise_info['revise_ratio'] / 10000); if (isset($player_prop_info['swallow_info'][$add_swallow_id])) { $player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] += $add_swallow_exp; } else { $player_prop_info['swallow_info'][$add_swallow_id] = array('swallow_id' => $add_swallow_id, 'swallow_lv' => 0, 'swallow_exp' => $add_swallow_exp); } # 最大经验值保护 if ($player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] >= $swallow_config['swallow_exp'] - 1) { $player_prop_info['swallow_info'][$add_swallow_id]['swallow_exp'] = $swallow_config['swallow_exp'] - 1; } } #var_export($player_prop_info); # 根据吞噬属性的exp,刷新吞噬属性的lv if (!empty($player_prop_info['swallow_info'])) { foreach ($player_prop_info['swallow_info'] as $sid => $sinfo) { $swallow_config = Cache_Forge::getInstance()->get_swallow_config_by_exp($sinfo['swallow_id'], $sinfo['swallow_exp']); if (!empty($swallow_config)) { $player_prop_info['swallow_info'][$sid]['swallow_lv'] = $swallow_config['swallow_lv']; #$player_prop_info['swallow_info'][$sid]['swallow_param'] = $swallow_config['swallow_param']; # 不缓存任何配置数据,提高策划修改配置表时的兼容性 } $out_828['swallow_list'][$sid] = array('swallow_id' => $sid, 'swallow_lv' => $player_prop_info['swallow_info'][$sid]['swallow_lv'], 'swallow_exp' => $player_prop_info['swallow_info'][$sid]['swallow_exp']); } $player_prop_info['swallow_version'] = 2; # 新功能版本号,用来区分新旧装备,一遍向下兼容接口有条件刷新 } if (empty($type)) { # 修正被吞噬的装备列表,去除吞噬属性达到上限及之后的其它装备 $out_828['swallow_ppids'] = empty($onekey_prop_list) ? "" : implode(":", $onekey_prop_list); if (empty($out_828['swallow_ppids']) && !empty($onekey)) { # 没有能被吞噬的装备 $code = $full_level_flag ? 80021 : 80043; $message = array('texts' => array(array('code' => $code, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 没有可以被吞噬的装备[装备镶嵌有觉醒石,宝石,装备为首充装备,装备获取不到吞噬配置] } return $out_828; } $out_829 = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => array())); $this->start_trans(); # 更新吞噬信息 $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('swallow_info' => $player_prop_info['swallow_info'])); $this->write_check($re, 3010177); # 扣除被吞噬装备 foreach ($player_prop_details as $k => $v) { $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $v, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 829)); $this->write_check($re, 3010182); } $this->commit(); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_info['player_prop_id'], 'item_id_master' => $player_prop_info['prop_id'], 'item_type' => $player_prop_info['type'], 'item_sub_type' => $player_prop_info['sub_type'], 'item_quality' => $player_prop_info['quality'], 'item_level' => $player_prop_info['level'], 'item_star_level' => $player_prop_info['star_level'], 'player_prop_id_slave' => rtrim($player_prop_id_slave, ":"), 'item_id_slave' => rtrim($item_id_slave, ":"), 'before_swallow_info' => $before_swallow_info, 'after_swallow_info' => $player_prop_info['swallow_info'], 'swallow_id_1' => 0, 'before_swallow_level_1' => 0, 'after_swallow_level_1' => 0, 'swallow_id_2' => 0, 'before_swallow_level_2' => 0, 'after_swallow_level_2' => 0, 'swallow_id_3' => 0, 'before_swallow_level_3' => 0, 'after_swallow_level_3' => 0, 'swallow_id_4' => 0, 'before_swallow_level_4' => 0, 'after_swallow_level_4' => 0); if (!empty($before_swallow_info)) { foreach ($before_swallow_info as $sid => $sinfo) { $log_info["swallow_id_{$sid}"] = $sid; $log_info["before_swallow_level_{$sid}"] = $sinfo['swallow_lv']; } } foreach ($player_prop_info['swallow_info'] as $sid => $sinfo) { $log_info["swallow_id_{$sid}"] = $sid; $log_info["after_swallow_level_{$sid}"] = $sinfo['swallow_lv']; } Log_Forge::getInstance()->add_log($log_info, 'swallow'); # 刷新玩家属性 if ($player_prop_info['item_position'] == 3) { $this->get_game('EquipAttr')->equip_attr($player_id); } # 通知道具变更806 $ndata = array(); $ndata[] = $player_prop_info; foreach ($player_prop_details as $key => &$val) { $val['item_num'] -= 1; $out_829[1]['grid_list'][] = $val['grid']; $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); # 刷装备814[锻造面板]与827[可吞噬道具列表] $equips = $this->get_data('PlayerProp')->get_player_prop_by_item_position($player_id, 1); Com_Array::multisort($equips, array('quality' => 'desc', 'level' => 'desc')); $emp = array(); $fmp = array(); if (!empty($equips)) { foreach ($equips as $k => $v) { if ($v['type'] == 1) { $emp[] = $v['grid']; } } # 过滤不允许该装备吞噬的装备 $equips = $this->filter_unvalid_props($player_prop_info, $equips); foreach ($equips as $k => $v) { $fmp[] = $v['grid']; } } $equip_list = array('item_position' => 1, 'grid_list' => $emp); $allow_swallow = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => $fmp)); Protocol::input($player_id, 3, 8, 829, $out_829); Protocol::input($player_id, 3, 8, 814, array($equip_list)); Protocol::input($player_id, 3, 8, 827, $allow_swallow); # 记录行为 Com_Log::write('xgame.forge_swallow', "{$player_id}\t" . "swallow\t" . "{$type}\t" . "{$player_prop_id}\t" . implode(",", $swallow_equips)); # 日常任务埋点 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 108, 108, 1); # 每日活跃任务埋点 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2001, 1, 1); return $out_829; }
/** * 添加多种资源 资源是指 黄金 钻石 等这些资源 * @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; }
/** * 给索尔有名字查player_id */ public function CMD2_7003() { Com_Log::write('CMD2_7003.' . $this->_authuser['player_id'], var_export($this->_param[0], true)); $player_id = $this->get_data("Account")->get_pid_byname($this->_param[0]); Protocol::input($this->_authuser['player_id'], 3, 7, 7003, array(0 => intval($player_id))); }
public function payback() { $result = $this->objTencent->verityToken($this->auth, $this->script_name); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay2',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND); if ($result['ret'] != 0) { return $result; } $senddata = explode('*', $this->auth['payitem']); $goodsid = $senddata[0]; $price = (int) $senddata[1]; $num = (int) $senddata[2]; /** 所有道具 */ $payGoods = $this->objTencent->payGoods(); if (empty($payGoods[$goodsid])) { return array('ret' => 1, 'msg' => '道具不存在' . $goodsid); } /** @var is_double 是否双倍 */ //$this->is_double = (int) $payGoods[$goodsid]['double']; /** @var $is_cash 是否钻石充值 */ $this->is_cash = (int) $payGoods[$goodsid]['is_cash']; $cash = $price * $num; $this->cash = $cash; // 档次 $this->price = $price; // Token缓存 $tokenKey = $this->objTencent->tokenTable . ':pay:' . $this->player_id; $tokenField = $goodsid; $buy_info_json = $this->redis()->hash_get($tokenKey, $tokenField); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay3',$this->player_id,$this->auth,json_decode($buy_info_json,'array')),true)."\n",FILE_APPEND); $this->redis()->hash_delete($tokenKey, $tokenField); if ($buy_info_json) { $buy_info = json_decode($buy_info_json, 'array'); if ($buy_info['token'] != $this->auth['token']) { return array('ret' => 3, 'msg' => 'token不存在'); } $timeout = $this->objTencent->tokenTypes['pay']['timeout']; if (time() > $timeout + $buy_info['create_time']) { return array('ret' => 2, 'msg' => 'token已过期'); } //charge log $insertData = array('uid' => $this->player_id, 'passport' => $this->auth['openid'], 'tokentype' => 'pay', 'token' => $this->auth['token'], 'create_time' => $buy_info['create_time'], 'content' => $buy_info['url_params'], 'senddata' => $this->auth['payitem'], 'verity_time' => time()); $objPlayerCharge = $this->get_data('PlayerCharge'); $arrCharge = $objPlayerCharge->get_charge_info($this->auth['billno']); if (!empty($arrCharge)) { return array('ret' => 2, 'msg' => '订单号已经存在'); } $arrPlayer = $this->get_data('Player')->get_player_info($this->player_id, array('gold', 'level', 'vip', 'privilege_level', 'qq_blue_points')); $b_gold = $arrPlayer['gold']; #改变之前的钻石 if ($tokenField == 18) { #$this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'qq_blue_points', $cash); } else { $this->get_data('Player')->check_player_resource($this->player_id, $arrPlayer, '+', 'gold', $cash); } $iGold = $cash * 10; $this->start_trans(); $result = $this->get_data('Player')->update_player_resource($this->player_id, $arrPlayer, 111, array('is_pay' => 1)); if ($result) { $after = $arrPlayer['gold']; $result = $objPlayerCharge->add_charge($this->player_id, $this->auth['billno'], $this->auth['openid'], $arrPlayer['level'], $cash, $cash, $b_gold, $after); } if ($result) { $this->commit(); Log_Charge::getInstance()->add_charge_log($this->player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $this->auth['billno'], $cash, $cash, $arrPlayer['gold'], $b_gold); $data['status'] = 0; if ($tokenField != 18) { # 充值回馈活动,蛋疼的次数埋点 $this->get_game('PlayerFunc')->sync_func_tips($this->player_id, 1260); #vip升级 $this->get_game('VipReward')->vip_upgrade($this->player_id, $cash); #新服活动 $pub_day = $this->get_data('NewServerActivity')->get_server_day(); if ($pub_day <= 7) { $this->get_game('NewServerActivity')->add_sign($this->player_id, $pub_day, $cash); } } } else { $this->rollback(); return array('ret' => 1, 'msg' => '充值失败'); } } else { return array('ret' => 1, 'msg' => '充值失败'); } ############################################################################### # 充值成功,上报数据,上报字段信息: # modifyfee是充值金额,上报单位为Q分,1Q币=100Q分 # modifycoin对应为玩家充值变化的钻石数 # totalcoin对应充值完成之后,玩家总钻石数 # level为玩家等级 $arrData = $this->auth; $platform = $arrData['platform']; $serverId = $arrData['serverid']; $openid = $arrData['openid']; $playerid = $this->player_id; $level = $arrPlayer['level']; $modifycoin = $after - $b_gold; $chargeData = array('modifyfee' => $cash * 10, 'modifycoin' => $modifycoin, 'totalcoin' => $after, 'level' => $level); Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid); if (!($res = Com_TencentDataUpload::getInstance()->recharge_data_upload($chargeData))) { Com_Log::write("uploadDataError", "recharge_data_upload failed!"); } ############################################################################### //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array('pay4',$this->player_id,$this->auth,$result),true)."\n",FILE_APPEND); return array('ret' => 0, 'msg' => 'OK'); }
public function CMD2_517() { $params = array(); $params['type'] = $this->_param[0]; $params['id'] = $this->_param[1]; $params['timeout'] = $this->_param[2]; $params['param1'] = $this->_param[3]; $params['param2'] = $this->_param[4]; $params['param3'] = $this->_param[5]; $params['param4'] = $this->_param[6]; $data = $this->get_game('PlayerFunc')->start_time($params); Protocol::input($this->_authuser['player_id'], 5, 4, 517, $data); if ($this->_param[0] == 755) { $this->get_game('Adlut')->do_timer($this->_param[1]); } Com_Log::write('516---send-log', json_encode($params)); }
/** *技能列表 跟在登陆协议后面发给前端 401 登录, 同步玩家协议信息时亦使用该方法 * @param $player_id * @return array */ public function skill_list($player_id, $player_info_all = null, $arr_player_detail_all = null, $out_fairy_info_flag = true) { if (is_null($player_info_all) || !isset($player_info_all['level']) || !isset($player_info_all['career_type'])) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'career_type')); } else { $player_info = $player_info_all; } # 获取已激活技能 if (is_null($arr_player_detail_all) || !isset($player_info_all['skill_info']) || !isset($player_info_all['skill_rune_info']) || !isset($player_info_all['skill_starmap_info'])) { $arr_player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('skill_info', 'skill_rune_info', 'skill_starmap_info')); } else { $arr_player_detail = $arr_player_detail_all; } $skill_info = $arr_player_detail['skill_info']; # 获取职业全部技能(包括已激活和未激活) $skill_info_all = array(); $skill_not_use = array(); $skill_in_use = array(); $skill_list_distinct = Cache_Skill::getInstance()->get_distinct_skill_list($player_info['career_type']); if (empty($skill_list_distinct)) { Com_Log::write('xgame.all.error', "skill list failed : [player_id={$player_id}|career_type=" . $player_info['career_type'] . "]"); #$this->throw_error('60022'); # 没有符合玩家职业的技能配置信息,由于是登录和同步用,抛错可能造成不能登录或同步失败 } else { foreach ($skill_list_distinct as $val) { if ($val['display'] == 0) { continue; } $si = array('skill_id' => $val['sid'], 'level' => 1, 'keyboard' => $val['keyboard'], 'in_use' => 0, 'career_type' => $val['career_type']); # 是否启用判断 in_use: 0未启用;1已启用 if (!empty($skill_info[$val['sid']]['keyboard'])) { $si['level'] = $skill_info[$val['sid']]['level']; $si['in_use'] = 1; $skill_in_use[$val['keyboard']] = $si; } else { $skill_not_use[$val['keyboard']][$val['career_type']] = $si; } $skill_info_all[$val['keyboard']][$val['career_type']] = $si; } } # 技能快捷面板信息数组 必须确保技能快捷面板信息数组满5个元素,无论其技能是否已激活 $skill_shortcut_info = array(); for ($i = 1; $i <= 5; $i++) { if (!empty($skill_in_use[$i])) { $skill_shortcut_info[$i] = $skill_in_use[$i]; } else { $skill_shortcut_info[$i] = $skill_not_use[$i][$player_info['career_type']]; # 未启用的技能取本身职业而非进阶职业 } } $out = array(); $out['skill_infos'] = array(); for ($j = 1; $j <= 5; $j++) { $replace_num = count($skill_info_all[$j]); $skill_id = $skill_shortcut_info[$j]['skill_id']; if (!empty($skill_shortcut_info[$j]['in_use'])) { list($rune_info, $auto_active_rune_cote) = $this->get_skill_rune_list_info($skill_id, 1, $skill_shortcut_info[$j]['level'], $arr_player_detail['skill_rune_info'][$skill_id], 401); $out['skill_infos'][] = array('skill_id' => $skill_id, 'skill_level' => $skill_shortcut_info[$j]['level'], 'replace_num' => $replace_num, 'skill_status' => 1, 'rune_infos' => $rune_info); } else { $out['skill_infos'][] = array('skill_id' => $skill_id, 'skill_level' => 1, 'replace_num' => $replace_num, 'skill_status' => 0, 'rune_infos' => array()); } } # 技能等级加成处理 $this->handle_skill_level_addition($player_id, $out['skill_infos'], $player_info_all, $arr_player_detail_all); // Com_Log::debug_write('xgame.skill', "$player_id get skill list : ".json_encode($out)); // Com_Log::write("xgame.skill_list.".$player_id,var_export($out['skill_infos'],true)); if ($out_fairy_info_flag) { if ($player_info['level'] > 4) { #减轻玩家刚激活时候的压力 $fairy_list = $this->get_data('Fairy')->get_player_fairy_list($player_id); #对老号的女神数据修复检测 $this->get_game('Fairy')->data_repair($player_id, $fairy_list); } else { $fairy_list = array(); } $out['fairy_info'] = array(); if (!empty($fairy_list)) { foreach ($fairy_list as $keys => $val) { if (!empty($val['combination_list'])) { foreach ($val['combination_list'] as $value) { //获取有镶嵌的属性ID if ($value['state'] > 1) { $val['triggers'][] = $value['state']; } } $out['fairy_info'][] = $val; } } } } return $out; }
public function do_func_open($player_id, $type, $condition_id, $player_info = null) { if (!isset($this->funconfig[$type][$condition_id])) { $this->funconfig[$type][$condition_id] = Cache_FuncConfig::getInstance()->get_func_config_by_open_type_condition_id($type, $condition_id); } $func_list = $this->funconfig[$type][$condition_id]; if ($func_list) { $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, array('func_open')); $func_open = $player_detail['func_open']; $out = array(); $guide_out = array(); $send_fairy = array(); $guide_id = array(); $arr_player_task = array(); $meditation_open_status = false; // Com_Log::write('guide_'.$player_id,"func_list:".var_export($func_list,true)); foreach ($func_list as $val) { if (SERVER_ID > 1 && $val['issue'] == 0) { continue; } if (!isset($func_open[$val['func_id']])) { if (1110 == $val['func_id']) { continue; } $func_open[$val['func_id']] = 1; $out[0][] = array('operate' => 1, 'func_id' => $val['func_id'], 'open' => 1, 'guide' => 0, 'cd' => 0, 'tip' => $this->get_game('PlayerFunc')->get_func_tips($player_id, $val['func_id'], null, $func_open)); if ($val['func_id'] == 44) { # 同步冥想开启状态 $meditation_open_status = true; } if ($val['func_id'] == 30) { #开启暗女神 try { $this->get_game('Fairy')->add_fairy($player_id, 201); } catch (Exception $e) { // Com_Log::write("task_fairy_send_error","send fairy 101 error player_id:{$player_id} ##".var_export($e,true)); } } if ($val['func_id'] == 33) { #开启光女神 try { $this->get_game('Fairy')->add_fairy($player_id, 101); } catch (Exception $e) { // Com_Log::write("task_fairy_send_error","send fairy 111 error player_id:{$player_id} ##".var_export($e,true)); } } if ($val['func_id'] == 20) { #送一个英雄 try { $result = $this->get_game('Hero')->add_hero($player_id, 3001); } catch (Exception $e) { $result = false; Com_Log::write("task_hero_send_error", "send hero 111 error player_id:{$player_id} ##" . var_export($e, true)); } } // if($val['func_id'] == 161){#开启随机任务 // $task_info = $this->get_game('TaskRandom')->get_random_tasks($player_id); // $data = $this->get_game('TaskRandom')->get_task_random_list($player_id,$task_info,$player_info); // Protocol::input($player_id,8,10,1022,$data); // } if ($val['guide_id'] > 0) { Com_Log::write('guide_' . $player_id, "func_open:{$val['guide_id']}"); Protocol_Guide::add($val['guide_id'], 1); if ($val['task_guide'] == 1) { if (empty($arr_player_task)) { $arr_player_task = $this->get_data('PlayerTask')->get_task_info($player_id); } $this->get_game('TaskMain')->do_guide_task($player_id, $val['guide_id'], 1, $arr_player_task, $guide_out); } } } } $result = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('func_open' => $func_open)); if ($result && !empty($arr_player_task)) { $result = $this->get_data('PlayerTask')->set_task_info($player_id, $arr_player_task); //更新任务 } if ($result) { Com_Log::write("do_func_open." . $player_id, "out:" . var_export($out, true)); if ($out) { Protocol::input($player_id, 8, 7, 741, $out); } if ($guide_out) { Protocol::input($player_id, 8, 10, 1002, array(0 => $guide_out)); } Protocol_Guide::out($player_id, $player_info); if ($meditation_open_status) { Protocol_Player::p2c_part_update($player_id, array('meditation_open_status' => array('func_open' => $func_open))); } } return $result; } return true; }
public function get_player_challenge_rank_info($player_id) { $data = $this->get_data('Challenge')->get_player_challenge_rank_info($player_id); Com_Log::write('PlayerChallengeRank', "{$player_id}\t" . json_encode($data)); return $data; }
public static function print_stack_trace($log_file_name, $endline = "\n") { $trace = debug_backtrace(); $num = 0; $ans = 'message:' . $endline . 'stact trace back :' . $endline; foreach ($trace as $line) { if ($num > 3) { break; } $ans .= '#' . $num . ' ' . $line['file'] . '[' . $line['line'] . '] '; if ($line['type'] == '->' || $line['type'] == '::') { $ans .= $line['class'] . $line['type'] . $line['function'] . '()'; } else { $ans .= $line['function'] . '()'; } if (!empty($line['args'])) { $ans .= $endline . 'parameters:' . $endline . print_r($line['args'], true); } if (!empty($line['object'])) { $ans .= $endline . 'object:' . $endline . print_r($line['object'], true); } $ans .= $endline; $num++; } if ($log_file_name == null) { return $ans; } else { Com_Log::write($log_file_name, $ans); } }
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; }
/** * 异常处理回调函数 */ protected function failure_callback($e) { $msg = "Mongo Exception: " . $e->getFile() . " line:" . $e->getLine() . " " . $e->getMessage(); #$msg = "Mongo Error: " . $e->getMessage(); Com_Log::write('mongo.error', $msg); }
public function update_vip_special_info($player_id, $data) { $player_id = intval($player_id); if (!$player_id) { return false; } if (!is_array($data) || empty($data)) { return false; } $redis = $this->redis(); $hash = $this->get_adcache_key($player_id); $setData = array(); $incData = array(); foreach ($data as $key => $value) { if (is_array($value)) { $setData[$key] = json_encode($value); } else { $svalue = (string) $value; if ($svalue[0] == '+' || $svalue[0] == '-') { $incData[$key] = intval($value); } else { $setData[$key] = $value; } } } if (!empty($setData)) { $this->redis()->hash_set($hash, $setData); } if (!empty($incData)) { foreach ($incData as $field => $value) { $this->redis()->hash_incr($hash, $field, $value); } } return true; #下面的事务有问题待查 if ($this->is_trans()) { Com_Log::write("nut", '--------1'); if (!empty($setData)) { $this->redis()->hash_set($hash, $setData); } if (!empty($incData)) { foreach ($incData as $field => $value) { $this->redis()->hash_incr($hash, $field, $value); } } $arrResults = $redis->commit(); if (!empty($arrResults)) { foreach ($arrResults as $result) { if ($result === false) { return false; } } } } else { Com_Log::write("nut", '--------2'); $redis->start_trans(true); if (!empty($setData)) { #$redis->hash_set($hash, $setData); } if (!empty($incData)) { foreach ($incData as $field => $value) { #$redis->hash_incr($hash, $field, $value); } } return true; $arrResults = $redis->commit(); if (!empty($arrResults)) { foreach ($arrResults as $result) { if ($result === false) { return false; } } } } return true; }
/** * 更新玩家信息 * * @param array $objDataInfo * @return unknown */ public function update_userInfo($objDataInfo) { $noclude = array('server_id', 'serverId'); $condition = array(); foreach ($objDataInfo as $k => $v) { if (!in_array($k, $noclude)) { $condition[$k] = $v; } } $result = $this->get_data('Player')->update_player_basic_info($objDataInfo['player_id'], $condition); if ($result) { $data['role_id'] = $objDataInfo['player_id']; $is_ban = $objDataInfo['is_ban']; $ban_memo = $objDataInfo['ban_memo']; if ($is_ban == 2) { $data['dead_time'] = strtotime($objDataInfo['ban_time']); $res['type'] = 1; $res['list'] = array($data); Protocol::input(0, 7, 4, 455, $res); Com_Log::write("GM_ban_info", "type:禁言" . ",player_id:" . $objDataInfo['player_id'] . ",ban_momo:" . $ban_memo . ",ban_time:" . $objDataInfo['ban_time']); } else { if ($is_ban == 3) { Com_Log::write("GM_ban_info", "type:封禁" . ",player_id:" . $objDataInfo['player_id'] . ",ban_momo:" . $ban_memo . ",ban_time:" . $objDataInfo['ban_time']); } else { if ($is_ban == 0) { $data['dead_time'] = 0; $res['type'] = 0; $res['list'] = array($data); Protocol::input(0, 7, 4, 455, $res); } } } } Protocol::out(); return $result; }
/** * 心跳同步 更新session expires * * @return unknown */ public function heart_sync($player_id) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'crystal', 'fame_level', 'career_type', 'gold', 'player_id', 'user_account', 'reg_time', 'ad_Info', 'level', 'vip', 'privilege_level', 'session_id', 'adult_flag', 'login_time', 'heart_time')); if (empty($player_info)) { return false; } $sessID = $player_info['session_id']; if (empty($sessID)) { return false; } $objSession = TenYear::getInstance('session'); $objSession->set_expire($sessID); $this->online_time($player_id, $player_info); //计算在线时长 if (OPERATOR_ID == 82) { $objT = $this->get_game('Tencent'); $seesion_info = $objT->get_param($player_id); $objT->isLogin(); } $data = $this->get_game('PlayerFunc')->red_icon($player_id, $player_info); Protocol::input($player_id, 8, 70, 7002, array(0 => $data, 1 => 1)); $time = date('H:i'); if ($time < '00:20') { $log_data = array('player_id' => $player_info["player_id"], 'channel' => 1, 'client_ip' => Com_System::get_client_ip(), 'game_client_ip' => Com_System::get_client_ip(), 'reg_time' => $player_info['reg_time'], 'ad_info' => $player_info['ad_Info'], 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level']); Log_Common::getInstance()->add_log($log_data, 'day'); if ($player_info['ad_Info']) { Com_System::send_request(array('user_account' => $player_info['user_account']), 'login'); } } if ($time >= '05:05' && $time <= '05:15') { Com_Log::write("heart_sync." . $player_id, "start"); $syn_item['count_boss_oakland'] = 0; $syn_item['count_monsters_oakland'] = 0; $syn_item['count_chest_oakland'] = 0; SynPlayer::set_syn_data($syn_item); $data = SynPlayer::get_data(); Protocol::input($player_id, 7, 4, 417, array(0 => $data['m'], 1 => $data['u'])); } if ($player_info['level'] > 9) { $data = $this->get_game('Quit')->get_close_info($player_id); Protocol::input($player_id, 8, 7, 792, $data); $data = $this->get_game('Strengthen')->get_guide_list($player_id); Protocol::input($player_id, 8, 18, 1808, $data); } return true; }
/** * 如果玩家没有出序章 在遇到C++服务器重启的时候 重置这写玩家的任务 */ public function reset_task() { Com_Log::write('x_reset', "=============================[start]========================="); $keys = Com_AdCache::factory('player')->keys("data|player:*"); if (!empty($keys)) { $syndata['city_id'] = 2100; $syndata['city_x'] = 3382; $syndata['city_y'] = 3538; $role_init_data = array(); foreach ($keys as $key) { $player_info = Com_AdCache::factory('player')->hash_get($key, array('player_id', 'level', 'vip', 'map_id', 'career_type')); // if($player_info['player_id'] != 980564) continue; if ($player_info['level'] >= 10) { continue; } Com_Log::write('x_reset', "player_id:{$player_info['player_id']}"); if (!isset($role_init_data[$player_info['career_type']]) && empty($role_init_data[$player_info['career_type']])) { $role_init_data[$player_info['career_type']] = Cache_RoleAttrInit::getInstance()->get_role_attr_init($player_info['career_type']); } if ($player_info['map_id'] == 2100 && $player_info['level'] < 10) { $this->init_set_task($player_info['player_id'], explode(":", $role_init_data[$player_info['career_type']]['default_task_id'])); // $this->get_data('PlayerTaskLog')->del_player_task_log($player_info['player_id']); $syndata['level'] = 1; $level_exp = Cache_RoleExp::getInstance()->get_role_exp(1); $syndata['level_exp'] = intval($level_exp['need_exp']); $syndata['exp'] = 0; $this->get_data('Player')->update_player_info($player_info['player_id'], $syndata); $update_fields = $this->get_game('PlayerSkill')->extend_set($player_info['player_id'], $player_info['career_type'], 1, false); $update_fields['guide'] = ''; try { $update_fields['wing_info'] = $this->get_game('PlayerWing')->create_player_wing($player_info['player_id'], false); $update_fields['equip_wing'] = 0; } catch (Exception $e) { Com_Log::write('reset_del', "del wing error ##" . var_export($e, true)); } $this->get_data('PlayerDetail')->update_player_detail($player_info['player_id'], $update_fields); try { $this->get_game('Fairy')->set_fairy_state_interface($player_info['player_id']); } catch (Exception $e) { Com_Log::write('reset_del', "del fairy error ##" . var_export($e, true)); } $props = $this->get_data('PlayerProp')->get_player_all_prop($player_info['player_id']); if ($props) { foreach ($props as $ppid => $val) { Com_Log::write('reset_del', "del prop player_id:{$player_info['player_id']} ##" . var_export($val, true)); $result = $this->get_data('PlayerProp')->delete_player_prop($player_info['player_id'], $val, true, array('cmd_id' => 107, 'level' => $player_info['level'], 'vip' => $player_info['vip'])); if (!$result) { Com_Log::write('reset_del', "del prop error ##" . var_export($val, true)); } } } } } } Com_Log::write('x_reset', "=============================[end]========================="); }
public function wing_equip_swallow($type, $player_id, $player_prop_id, $swallow_equips, $onekey = 0) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); $this->param_check_numeric(array($type, $player_id), 0); if (empty($swallow_equips)) { $this->throw_error('10107'); } # 参数错误 $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'career_type')); $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key()); # 1515展示协议返回数据,1515协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 $out_1515 = array('player_ppid' => $player_prop_id, 'swallow_ppids' => $swallow_equips, 'item_struct' => array()); $swallow_equips = explode(':', $swallow_equips); $swallow_equips = array_filter($swallow_equips); $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id); $before_player_prop_info = $player_prop_info; if (empty($player_prop_info)) { $this->throw_error('80013'); //玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) { if (!empty($type)) { # 实际吞噬 $this->throw_error('81106'); # 首充装备不允许吞噬 } else { $message = array('texts' => array(array('code' => 81106, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许吞噬 $out_1515['swallow_ppids'] = ""; return $out_1515; } } # 计算吞噬属性最大等级 $swallow_lv_max = $this->get_we_swallow_lv_max($player_prop_info['vocation_limit'], $player_detail); $swallow_config_max = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($swallow_lv_max); if (empty($swallow_config_max)) { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } $player_prop_details = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, $swallow_equips); if (empty($player_prop_details)) { $this->throw_error('80024'); //未选择有效的被吞噬装备 } # 被吞噬装备信息 $before_swallow_info = empty($player_prop_info['we_swallow_info']) ? array() : $player_prop_info['we_swallow_info']; $player_prop_id_slave = ""; $item_id_slave = ""; $onekey_prop_list = array(); # 保存允许一键吞噬的装备ID列表 foreach ($swallow_equips as $pprop_id) { if (!empty($type)) { # 实际吞噬 if (empty($player_prop_details[$pprop_id])) { $this->throw_error('80013'); # 玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $this->throw_error('81107'); # 首充装备不允许被吞噬 } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { $this->throw_error('80044'); # 装备品质未达到被吞噬要求 } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $this->throw_error('80045'); # 装备已达到最大吞噬等级 } } else { # 非实际吞噬 if (!empty($onekey)) { # 一键勾选 if (empty($player_prop_details[$pprop_id])) { continue; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { continue; } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { continue; } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { continue; } } else { # 单项勾选,单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环 if (empty($player_prop_details[$pprop_id])) { $message = array('texts' => array(array('code' => 80013, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 玩家没有该装备! break; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $message = array('texts' => array(array('code' => 81107, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许被吞噬 break; } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { $message = array('texts' => array(array('code' => 80044, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 装备品质未达到被吞噬要求 break; } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $message = array('texts' => array(array('code' => 80045, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 装备已达到最大吞噬等级 break; } } } $player_prop_id_slave .= "{$pprop_id}:"; $item_id_slave .= $player_prop_details[$pprop_id]['prop_id'] . ":"; $onekey_prop_list[] = $pprop_id; # 计算增加属性值 && 修正经验值 $add_swallow_exp = self::$swallow_quality_to_exp_map[$player_prop_details[$pprop_id]['quality']] * (1 + intval($player_prop_details[$pprop_id]['level'] / 5) / 4); if (isset($player_prop_info['we_swallow_info'])) { $player_prop_info['we_swallow_info']['swallow_exp'] += $add_swallow_exp; } else { $player_prop_info['we_swallow_info'] = array('swallow_lv' => 0, 'swallow_exp' => $add_swallow_exp, 'swallow_attr' => array()); } } # 根据吞噬属性的exp,刷新吞噬属性的lv if (!empty($player_prop_info['we_swallow_info'])) { $swallow_config = Cache_Forge::getInstance()->get_we_swallow_config_by_exp($player_prop_info['we_swallow_info']['swallow_exp']); if (!empty($swallow_config)) { $player_prop_info['we_swallow_info']['swallow_lv'] = min($swallow_config['swallow_lv'], $swallow_lv_max); # 根据最大lv,修正经验值 if ($player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $player_prop_info['we_swallow_info']['swallow_exp'] = $swallow_config_max['swallow_exp'] - 1; } } else { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } } # 根据吞噬等级,计算吞噬加成附加属性 $we_swallow_revise_info = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($player_prop_info['we_swallow_info']['swallow_lv']); if (empty($we_swallow_revise_info)) { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } foreach ($player_prop_info['addition_attr'] as $attr_key => $attr_val) { $attr_val = ceil($attr_val * $we_swallow_revise_info['attr_revise_ratio'] / 10000) + $we_swallow_revise_info[$attr_key]; $player_prop_info['we_swallow_info']['swallow_attr'][$attr_key] = $attr_val; } if (empty($type)) { # 修正被吞噬的装备列表,去除吞噬属性达到上限及之后的其它装备 $out_1515['swallow_ppids'] = empty($onekey_prop_list) ? "" : implode(":", $onekey_prop_list); $out_1515['item_struct'] = Struct_Prop::get_prop_struct($player_prop_info); if (empty($out_1515['swallow_ppids']) && !empty($onekey)) { # 没有能被吞噬的装备 $message = array('texts' => array(array('code' => 80046, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 没有可以被吞噬的装备 } return $out_1515; } $out_1516 = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => array())); $this->start_trans(); # 更新吞噬信息 $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('we_swallow_info' => $player_prop_info['we_swallow_info'], 'we_swallow_version' => $this->we_swallow_version)); $this->write_check($re, 3010177); # 扣除被吞噬装备 foreach ($player_prop_details as $k => $v) { $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $v, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 1516)); $this->write_check($re, 3010182); } # 刷新玩家翅膀战力与镶嵌装备的附加属性及战力 if ($player_prop_info['item_position'] == $this->wing_pos) { $wing_attr = $player_detail['wing_info'][$player_prop_info['vocation_limit']]; # 修正缓存的翅膀装备吞噬信息 $wing_attr['equipment'][$player_prop_info['sub_type']]['we_swallow_info'] = $player_prop_info['we_swallow_info']; $wing_attr['equip_attr'] = $this->get_game('PlayerWing')->get_wing_equip_attr($wing_attr['equipment']); # 减去吞噬之前的战力 Struct_Prop::get_item_additions($before_player_prop_info); $wing_attr['fight'] -= $before_player_prop_info['fpower']; $wing_attr['equipment_fight'] -= $before_player_prop_info['fpower']; if ($wing_attr['fight'] < 0) { $wing_attr['fight'] = 0; } if ($wing_attr['equipment_fight'] < 0) { $wing_attr['equipment_fight'] = 0; } # 加上吞噬之后的战力 $player_prop_info_cp = $player_prop_info; Struct_Prop::get_item_additions($player_prop_info_cp); $wing_attr['fight'] += $player_prop_info_cp['fpower']; $wing_attr['equipment_fight'] += $player_prop_info_cp['fpower']; # 更新wing_info $player_detail['wing_info'][$player_prop_info['vocation_limit']] = $wing_attr; $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info'])); $this->write_check($re, 3010242); #更新翅膀排行 if ($player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight'] > 0) { $wing_fight = $player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight']; $this->get_data('RankList')->update_wing_rank($player_id, $player_prop_info['vocation_limit'], $wing_fight); } } $this->commit(); # 成就相关埋 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 39, $player_prop_info['we_swallow_info']['swallow_lv'], 8); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_info['player_prop_id'], 'item_id_master' => $player_prop_info['prop_id'], 'item_type' => $player_prop_info['type'], 'item_sub_type' => $player_prop_info['sub_type'], 'item_quality' => $player_prop_info['quality'], 'item_level' => $player_prop_info['level'], 'item_star_level' => $player_prop_info['star_level'], 'player_prop_id_slave' => rtrim($player_prop_id_slave, ":"), 'item_id_slave' => rtrim($item_id_slave, ":"), 'before_swallow_info' => $before_swallow_info, 'after_swallow_info' => $player_prop_info['we_swallow_info'], 'before_swallow_lv' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_lv'], 'after_swallow_lv' => $player_prop_info['we_swallow_info']['swallow_lv'], 'before_swallow_exp' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_exp'], 'after_swallow_exp' => $player_prop_info['we_swallow_info']['swallow_exp']); Log_Forge::getInstance()->add_log($log_info, 'we_swallow'); # 通知翅膀属性变更 if ($player_prop_info['item_position'] == $this->wing_pos) { #同步翅膀属性 $str = $this->get_game('PlayerWing')->get_activation_wing_interface($player_id, $player_detail['wing_info']); Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])))); } # 通知道具变更806 $ndata = array(); $ndata[] = $player_prop_info; foreach ($player_prop_details as $key => &$val) { $val['item_num'] -= 1; $out_1516[1]['grid_list'][] = $val['grid']; $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); # 刷装备1506[翅膀装备强化面板]与1514[可吞噬道具列表] $out_1506 = $this->get_game('PlayerWing')->equipment_intensify_panel($player_id, 4); $out_1514 = $this->get_wing_equips_for_swallow($player_id, $player_prop_id); Protocol::input($player_id, 3, 15, 1506, $out_1506); Protocol::input($player_id, 3, 15, 1514, $out_1514); # 记录行为 Com_Log::write('xgame.forge_we_swallow', "{$player_id}\t" . "we_swallow\t" . "{$type}\t" . "{$player_prop_id}\t" . implode(",", $swallow_equips)); return $out_1516; }
public function get_daily_task_step_type_list($player_level, $number) { if ($number <= 0) { return false; } # 首先确定等级区间 $min_level = 0; $sql = "select distinct min_level from task_daily_cond order by min_level desc"; $records = $this->select_all($sql, $this->get_cache_key(array('task_daily_cond' => 1, 'sort' => 'desc'), $this->prefix_task_daily_cond)); foreach ($records as $record) { if ($player_level >= $record['min_level']) { $min_level = $record['min_level']; break; } } #$sql = "select * from task_daily_cond where min_level <= $player_level and max_level >= $player_level"; $sql = "select * from task_daily_cond where min_level = {$min_level}"; $type_list = $this->select_all($sql, $this->get_cache_key(array('min_level' => $min_level), $this->prefix_task_daily_cond)); # 列表结构转为哈希结构,为了使用哈希结构方便判断某种任务类型是否允许重复 $type_hash = array(); $type_weight_hash = array(); # 任务权重哈希,随机取task_step_type用 $task_flag_hash = array(); # 记录每一类task_flag,用来随机一个 foreach ($type_list as $index => $type_info) { $type_hash[$type_info['task_step_type']] = $type_info; if (empty($type_info['task_flag'])) { $type_weight_hash[$type_info['task_step_type']] = $type_info['rand_weight']; } else { $task_flag_hash[$type_info['task_flag']][$type_info['task_step_type']] = $type_info['rand_weight']; } } $rand_type_list = array(); # 随机的类型列表 # -------------------------------------------------------------------- # 先从非空task_flag下,每类task_flag选一个 # -------------------------------------------------------------------- if (!empty($task_flag_hash)) { foreach ($task_flag_hash as $tf => $ti) { $rand_type = Com_Random::get_probability_key($ti); $rand_type_list[] = $rand_type; } } # -------------------------------------------------------------------- # 再从为空task_flag下,按权重随机缺少的个数 # -------------------------------------------------------------------- $need_number = $number - count($rand_type_list); if ($need_number <= 0) { $rand_type_list = array_slice($rand_type_list, 0, $number); } else { $i = 1; while ($i++ <= $need_number) { $rand_type = Com_Random::get_probability_key($type_weight_hash); if (empty($type_hash[$rand_type]['allow_repeat'])) { # 该类型不允许重复 unset($type_weight_hash[$rand_type]); # 去重 } if (!empty($rand_type)) { # 当$type_weight_hash消耗完时,会返回false $rand_type_list[] = $rand_type; } } } $real_number = count($rand_type_list); # 实际包含的类型计数 # 对于偶发性的刷新到很多同类型的任务的问题添加调试日志 Com_Log::write('xgame.debug', "Daily task debug in " . __CLASS__ . ":\t{$player_level}\t{$number}\t{$real_number}\t" . json_encode($task_flag_hash) . "\t" . json_encode($type_weight_hash) . "\t" . json_encode($rand_type_list)); return array($rand_type_list, $real_number); }
public function add_union_base_todb($arr_detail) { $arr_field = array(); if ($arr_detail) { foreach ($arr_detail as $key => $value) { if (isset($this->_field[$key])) { if (is_array($value)) { $arr_field[$key] = json_encode($value); } else { $arr_field[$key] = $value; } } else { unset($arr_field[$key]); } } $insertSql = "insert into {$this->table_name}(" . implode(",", array_keys($arr_field)) . ") values('" . implode("','", $arr_field) . "')"; Com_Log::write('xgame.add_union_base_todb', $insertSql); $ret = $this->query($insertSql); return $ret; } }