public function add_charge_log($player_id, $level, $vip_level, $vip_special_level, $order_id, $gold, $u_money, $amount, $before = 0) { $item = array('player_id' => $player_id, 'player_level' => $level, 'vip_level' => $vip_level, 'vip_special_level' => $vip_special_level, 'order_id' => $order_id, 'gold' => $gold, 'u_money' => $u_money, 'after_amount' => $amount, 'amount' => $before); #推送数据中心 $center_data = array('pay_type' => 1, 'channel' => 4, 'money_coin' => $gold, 'order_id' => $order_id, 'time' => time()); Com_DataCenter::getInstance()->publish_data($player_id, 'pay', $center_data); Log_Common::getInstance()->add_resource_log($player_id, $level, $vip_level, $vip_special_level, 1032, 1, 2, $gold, $amount); return $this->add_log($item); }
/** * 触发每日福利活跃度任务 * @param unknown $player_id */ public function trigger_daily_boon_task($data) { if (empty($data)) { return false; } $data = json_decode($data, true); $player_id = $data["player_id"]; $task_type = $data["task_type"]; $trigger_val = $data["val"]; $update_type = $data["update_type"]; if (!$trigger_val) { return false; } Com_Log::write('xgame.trigger_daily_boon_task', "{$player_id}---{$task_type}--{$update_type}" . var_export($data, true)); $is_finish = 0; $this->start_trans(); $objDailyActiveReceiveData = $this->get_data('DailyActiveReceive'); $active_receive_info = $objDailyActiveReceiveData->get_daily_active_receive_info($player_id); if (isset($active_receive_info['group'])) { $group = $active_receive_info['group']; } else { $group = $this->get_active_group_id($player_id); $active_receive_info['group'] = $group; $ret = $objDailyActiveReceiveData->update_daily_active_receive($player_id, $active_receive_info); if (!$ret) { return false; } } $daily_active_config = $this->get_cache_table_data("daliy_active", array("group" => $group, "task_type" => $task_type)); if (empty($daily_active_config)) { return false; } $max_times = intval($daily_active_config[0]["time"]); $trigger_val = $trigger_val > $max_times ? $max_times : $trigger_val; $objDailyActiveData = $this->get_data('DailyActive'); $task_info = $objDailyActiveData->get_daily_active_info($player_id, $task_type); if (empty($task_info)) { $task_info = array("player_id" => $player_id, "group" => $group, "task_type" => $task_type, "val" => 0, "status" => 0, "add_time" => time()); } else { if ($task_info["status"] == 1) { return true; } } $old_val = $task_info["val"]; if ($update_type == 1) { $task_info["val"] += $trigger_val; } else { $task_info["val"] = $trigger_val; } $finish_times = $daily_active_config[0]["time"]; if ($task_info["val"] >= $finish_times) { $task_info["val"] = $daily_active_config[0]["time"]; $task_info["status"] = 1; $is_finish = 1; } $ret_active = true; $total_active_value = 0; if ($task_info["val"] > $old_val) { $active_value = intval($active_receive_info["active_value"]); $per_value = intval($daily_active_config[0]["per_value"]); if ($update_type == 2) { $add_active_value = ($trigger_val - $old_val) * $per_value; } else { $add_active_value = $trigger_val * $per_value; } $total_active_value = intval($active_value) + intval($add_active_value); $ret_active = $objDailyActiveReceiveData->update_daily_active_receive($player_id, array("active_value" => $total_active_value)); } $ret_task = $objDailyActiveData->update_daily_active($player_id, $task_type, $task_info); if ($ret_task && $ret_active) { $this->commit(); if ($total_active_value > 0) { #活动每日活跃度数据 $event_log_info = array('log_type' => 'daily_active', 'player_id' => $player_id, 'reg_time' => time(), 'active_point' => $total_active_value); $this->get_game('Event')->async_deal_event_log($event_log_info); $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip')); #数据中心每日活跃度数据 $log_data = array('player_id' => $player_id, 'channel' => 63, 'type' => 1, 'amount' => $active_value, 'item_num' => $add_active_value, 'after_amount' => $total_active_value, 'cmd_id' => 785, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip']); Log_Common::getInstance()->add_log($log_data); Com_Log::write('xgame.daily_active_add_log', var_export($log_data, true)); $this->get_game('VipSpecial')->add_vip_special_exp($player_id, 1133, $total_active_value); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130); } } else { $this->rollback(); return false; } return $is_finish; }
/** * 道具拆分 * @param $player_id * @param $player_prop_id * @param $prop_num * @return array|string */ public function prop_split($player_id, $player_prop_id, $prop_num) { $objPlayerPropData = $this->get_data('PlayerProp'); $arr_prop_detail = $objPlayerPropData->get_player_prop_detail($player_id, $player_prop_id); $out = array(0 => 4, 1 => 0, 2 => array(Struct_Prop::get_item_box_operate_struct(array('from_item_position' => $arr_prop_detail['item_position'], 'from_grid' => $arr_prop_detail['grid'], 'item_position' => $arr_prop_detail['item_position'], 'grid' => $arr_prop_detail['grid'])))); //要输出的协议结构 if (empty($arr_prop_detail) || empty($arr_prop_detail['player_prop_id']) || $prop_num < 1) { return $out; //参数错误 } if ($arr_prop_detail['item_num'] < 2 || $prop_num >= $arr_prop_detail['item_num']) { return $out; //参数错误 } $objPropGame = $this->get_game("Prop"); $bag_pos = $objPropGame->get_empty_pos($player_id, 1, $arr_prop_detail['item_position']); if (!$bag_pos) { $this->out_error($player_id, '80019'); return $out; //包裹已满! } $result = true; $objPlayerPropData->start_watch($player_id); $this->start_trans(); $new_prop_detail = array(); $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level')); $result = $objPlayerPropData->update_prop_num($player_id, $arr_prop_detail, $prop_num, "-", array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 809)); if ($result) { $new_prop_detail = $arr_prop_detail; $arr_prop_detail['item_num'] = $arr_prop_detail['item_num'] - $prop_num; $new_prop_detail['item_num'] = $prop_num; $new_prop_detail['grid'] = $bag_pos[0]; $result = $objPlayerPropData->insert_player_prop($new_prop_detail); } if ($result) { Com_AdCache::set_pipe(false); $this->commit(); if ($new_prop_detail) { $prop_config = Cache_Prop::getInstance()->get_prop_info($new_prop_detail['prop_id']); Log_Common::getInstance()->add_prop_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], 809, 1, $new_prop_detail['player_prop_id'], $new_prop_detail['prop_id'], $new_prop_detail['type'], $prop_config['name'], $new_prop_detail['quality'], $prop_num, $new_prop_detail['level'], 0, $new_prop_detail, $new_prop_detail['sub_type']); } $out[1] = 1; $out[2] = array(); $arr_prop_detail['from_item_position'] = $arr_prop_detail['item_position']; $arr_prop_detail['from_grid'] = $arr_prop_detail['grid']; $out[2][] = Struct_Prop::get_item_box_operate_struct($arr_prop_detail); $new_prop_detail['from_item_position'] = $arr_prop_detail['item_position']; $new_prop_detail['from_grid'] = $arr_prop_detail['grid']; $out[2][] = Struct_Prop::get_item_box_operate_struct($new_prop_detail); } else { $this->rollback(); //处理失败! } return $out; }
/** * 夺宝战斗结果 * @param unknown $player_id * @param unknown $battle_seq * @param unknown $winner_player_id * @param unknown $loser_player_id */ public function battle_result($player_id, $battle_seq, $winner_player_id, $loser_player_id) { $battle_seq = intval($battle_seq); $winner_player_id = intval($winner_player_id); $loser_player_id = intval($loser_player_id); $this->start_trans(); $grab_fail_award = ""; $get_piece_id = ""; $battle_result = 0; $grab_result = 0; $opponent_player_id = $winner_player_id; $phrase_id = 0; $player_info = array(); $opponent_player_info = array(); if ($winner_player_id == 0 && $loser_player_id == 0) { $battle_id_info = $this->get_data("GrabTreasure")->get_battle_id_info($battle_seq); $player_id = $battle_id_info['player_id']; $opponent_player_id = $battle_id_info['opponent_player_id']; $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); if (empty($opponent_player_info)) { $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); } Com_Log::debug_write('async_trigger_battle_test', "player_id={$player_id},{$player_info['sum_fpower']}={$opponent_player_info['sum_fpower']}"); if ($player_info['sum_fpower'] > $opponent_player_info['sum_fpower']) { $winner_player_id = $player_id; $loser_player_id = $opponent_player_id; $phrase_id = 16; } else { $winner_player_id = $opponent_player_id; $loser_player_id = $player_id; $phrase_id = 17; } } if ($player_id == $winner_player_id) { $battle_result = 1; $opponent_player_id = $loser_player_id; if (empty($opponent_player_info) || empty($player_info)) { $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); if (empty($opponent_player_info)) { $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level")); } } #抢碎片成功概率 $rate_config = $this->get_battle_success_rate($player_info, $opponent_player_info); $random_get_piece_result = Com_Random::probability($rate_config['success_rate'], 100); #新手引导成功率100% $player_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id, array("battle_log_id", "battle_need_piece_id", "battle_piece_quality", "quality_piece_ids", "is_guide")); if (intval($player_treasure_info["is_guide"]) == 1) { $random_get_piece_result = true; } $player_treasure_info["is_guide"] = 0; #抢碎片成功 if ($random_get_piece_result) { $grab_result = 1; $quality = $player_treasure_info["battle_piece_quality"]; $need_piece_id = $player_treasure_info["battle_need_piece_id"]; #挑战成功加碎片 $player_treasure_info["quality_piece_ids"][$quality][$need_piece_id] = $need_piece_id; #真实玩家 if ($opponent_player_info['is_dummy'] == 0) { $grab_piece_id = $need_piece_id; $opponent_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($opponent_player_id, array("quality_piece_ids")); #碎片存在 if (isset($opponent_treasure_info["quality_piece_ids"][$quality]) && !empty($opponent_treasure_info["quality_piece_ids"][$quality])) { if (isset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id])) { unset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id]); } else { $grab_piece_id = array_shift($opponent_treasure_info["quality_piece_ids"][$quality]); } #被抢者扣碎片 $re = $this->get_cross("GrabTreasure")->update_grab_treasure($opponent_player_id, $opponent_treasure_info); $this->write_check($re, 5010859); #抢者加碎片 $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info); $this->write_check($re, 5010867); #解除战斗中锁 $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id); $this->write_check($re, 5010862); #抢碎片日志 #{0}抢走了你的{1},简直不能忍! $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($grab_piece_id); $arr_replace = array(array('rep_type' => 0, 'rep_val' => $player_id, 'txt' => $player_info['name']), array('rep_type' => 7, 'txt' => $pieceConfig['name'])); $msg = Language_Message::make_message(123001, $arr_replace); $add_log["player_id"] = $opponent_player_id; $add_log["grab_player_id"] = $player_id; $add_log["grab_piece_id"] = $grab_piece_id; $add_log["quality"] = $quality; $add_log["add_time"] = time(); $add_log['rep_content'] = $msg; $add_log["is_allow_grab"] = 1; $re = $this->get_cross("GrabTreasureLog")->add_grab_treasure_log($battle_seq, $add_log); $this->write_check($re, 5010876); } else { $grab_result = 0; } } else { $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info); $this->write_check($re, 5010992); } if (intval($player_treasure_info['battle_log_id']) > 0) { $data = $this->get_cross('GrabTreasureLog')->get_grab_treasure_log($player_id, $player_treasure_info['battle_log_id']); if (!empty($data)) { $data['is_allow_grab'] = 0; $re = $this->get_cross('GrabTreasureLog')->update_grab_treasure_info($player_id, $player_treasure_info['battle_log_id'], $data); $this->write_check($re, 5010983); } } } if ($grab_result == 0) { $need_piece_id = ''; $grab_fail_award = $rate_config['fail_award']; $reward = $this->get_format_reward($grab_fail_award); if ($phrase_id > 0) { $attachment = array(); foreach ($reward as $prop) { $attachment[] = array("prop_id" => $prop['item_id'], "prop_num" => $prop['item_num']); } $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 1230); } else { $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '1230'), 1); if ($re !== true) { $this->write_check($re, 5011077); } } } } $is_battle_lock = $this->get_cross("GrabTreasure")->get_battle_lock($opponent_player_id); if ($is_battle_lock) { $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id); $this->write_check($re, 5010872); } $this->commit(); if ($battle_result == 1 && $grab_result == 0 && $phrase_id == 0) { $this->get_game('Reward')->add_reward_log(); } if ($battle_result == 0 && $phrase_id > 0) { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1); } #抢碎片增加日志 if ($grab_result == 1) { if ($opponent_player_info['is_dummy'] == 0) { Log_Common::getInstance()->add_prop_log($opponent_player_id, $opponent_player_info['level'], $opponent_player_info['vip'], $opponent_player_info['privilege_level'], 1231, 11, 0, $grab_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0); } $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($need_piece_id); Log_Common::getInstance()->add_prop_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], 1231, 10, 0, $need_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0); if ($phrase_id > 0) { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(18); $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1); } } $out = array('battle_result' => $battle_result, 'grab_result' => $grab_result, 'get_piece_id' => $need_piece_id, 'grab_fail_award' => $grab_fail_award); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040); #日常任务埋点 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 119, 119, 1); Protocol::input($player_id, 8, 12, 1230, $out); }
#Log_Reg::getInstance()->add_log($log_data); Log_Common::getInstance()->add_log($log_data); #给登录过1服的玩家进入2服奖励 #TenYear::getInstance('Game_BetaTestReward')->sync($arrData); if (1 == OPERATOR_ID && '2052410003' == SERVER_ID) { TenYear::getInstance('Game_InterTestReward')->sync($arrData); } //开放性测试奖励 if (1 == OPERATOR_ID && '2052310001' == SERVER_ID) { TenYear::getInstance('Game_BetaTestReward')->sync($arrData); } $ad_info = $strAdInfo > 0 ? 1 : 0; Com_DataCenter::getInstance()->publish_data($player_id, 'est', array('ad_info' => $ad_info, 'step' => 'create', 'time' => time())); $log_data = array('player_id' => $player_id, 'channel' => 1, 'client_ip' => $strIp, 'game_client_ip' => $client_ip, 'reg_time' => time(), 'ad_info' => $strAdInfo, 'player_level' => 1); #Log_Login::getInstance()->add_log($log_data); Log_Common::getInstance()->add_log($log_data, 'day'); $arr_cache = array('player_id' => $player_id, 'name' => $arrData["name"], 'user_account' => $strUserAccount, 'ad_info' => $arrData['ad_Info'], 'reg_time' => time(), 'career_type' => $arrData['career_type'], 'first_load' => 0); $objPlayer = TenYear::getInstance('Data_Player'); $objPlayer->set_rookie_loading_cache($player_id, $arr_cache); #广告系统用户推送激活 $activelog = Com_System::send_request(array('user_account' => $arrData['user_account']), 'active'); #广告系统用户推送每天首次登陆 $activelog = Com_System::send_request(array('user_account' => $arrData['user_account']), 'login'); #记录登陆登出信息 TenYear::getInstance('Data_Online')->set_online_list($player_id, array('login_time' => time(), 'logout_time' => time())); Com_DataCenter::getInstance()->publish_data($player_id, 'login', array('ad_info' => $ad_info, 'status' => 'on', 'keep_time' => 0, 'time' => time())); TenYear::getInstance('Game_DailySign')->init_daily_sign_info($player_id); #TenYear::getInstance('Game_PackageCode')->async_send_old_account_login_reward($player_id, $arrData['user_account'], $_SESSION['sid']); $rurl = $webUrl . '/index.php'; if ($bAjax) { echo "result=1&msg=" . urlencode($rurl);
/** * 捐献 * @param unknown $union_id * @param unknown $funds */ public function donate_silver($player_id, $union_id, $gold) { $union_id = intval($union_id); $gold = abs(intval($gold)); $objUnionPlayerData = $this->get_data('UnionPlayer'); $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id); if (empty($unionPlayerInfo)) { $this->throw_error('171001'); //该玩家未加入该公会 } $playerInfo = $this->get_data('Player')->get_player_info($player_id, array("ticket", "vip", "level", "gold", "privilege_level")); $this->start_trans(); $cost_gold = $gold; $ticket = 0; /* if($playerInfo['ticket']>0){ if($playerInfo['ticket']>=$gold){ $ticket = $gold; $this->get_data('Player')->check_player_resource($player_id,$playerInfo,'-','ticket',$gold); $cost_gold = 0; }else{ $ticket = $playerInfo['ticket']; $cost_gold = $gold-$playerInfo['ticket']; $this->get_data('Player')->check_player_resource($player_id,$playerInfo,'-','ticket',$playerInfo['ticket']); } } */ $arr_consume = array('price' => $gold, 'gold' => $cost_gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, "-", "gold", $cost_gold); $objUnionInfoData = $this->get_data('UnionInfo'); $unionInfo = $objUnionInfoData->get_union_info($union_id, array("union_level", "fund", "union_exp")); $unionBaseConfig = Cache_UnionBase::getInstance()->get_union_base_info($unionInfo['union_level']); //金币与公会资金比例 $add_fund = intval($gold * $unionBaseConfig["donate_union_gold"]); if (intval($unionInfo["fund"]) + $add_fund > $unionBaseConfig['max_union_gold']) { $this->throw_error('173202'); //大于公会可容纳最大资金 } $union_player_contribute = $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "union_player_contribute"); if (intval($union_player_contribute) + $gold > $unionBaseConfig['max_union_contribute']) { $this->throw_error('173203'); //大于单日可以捐赠最大金币 } //加锁 if (!Com_Lock::lock('lock|union_info|donate_silver|union_id=' . $union_id)) { //系统繁忙 $this->throw_error('170501'); } $add_union_exp = 0; $update_data = array(); $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10073); if ($playerInfo['vip'] >= $vip_table['vip_level']) { $unionBaseConfig = Cache_UnionBase::getInstance()->get_union_base_info($playerInfo['vip']); $add_union_exp = $gold * $unionBaseConfig['donate_union_exp']; $arr_union_reward = array(); $arr_union_reward[] = array("type" => "union_exp", "item_id" => 9, "item_num" => $add_union_exp); $success_add_exp = $this->get_game('UnionReward')->send_reward($player_id, $arr_union_reward, array("cmd_id" => 10073)); } $retPlayer = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, 1732, array(), $arr_consume); $total_fund = $unionInfo["fund"] + $add_fund; $update_data["fund"] = "+" . $add_fund; Com_Log::debug_write('update_union_info', "donate_silver|unoin_id={$union_id}" . json_encode($update_data)); $front_amount_dedicate = $unionPlayerInfo['total_dedicate']; $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $update_data); $add_player_dedicate = intval($gold * $unionBaseConfig["donate_union_contribution"]); $ret_add_player_dedicate = $this->add_player_dedicate($player_id, $add_player_dedicate); //钻石与公会贡献比例 if ($ret_add_player_dedicate && $retPlayer && $retUnionInfo) { $this->commit(); $this->get_game('Union')->Sync_Union_msg($union_id); if ($success_add_exp) { $this->get_game('UnionReward')->add_union_reward_log(); } } else { $this->rollback(); $this->throw_error('10101'); } //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $add_player_dedicate, 'amount' => $front_amount_dedicate, 'after_amount' => $unionPlayerInfo['total_dedicate'], 'cmd_id' => 1732); Log_Common::getInstance()->add_log($log_data); $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9001, $gold); //添加日志 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $gold); $arr_replace[] = array('rep_type' => 7, 'txt' => $add_player_dedicate); $arr_replace[] = array('rep_type' => 7, 'txt' => $add_fund); $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $union_id, 173404, $arr_replace); //公会成就捐献 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 18, $gold); return array($union_id, $gold, $add_fund, $add_player_dedicate, intval($success_add_exp)); }
public function set_inter_day_login() { $player_list = $this->get_data('Online')->get_online_list(); foreach ($player_list as $player_id => $v) { if (empty($player_id)) { continue; } if (1 == $v) { continue; } $arr_time = json_decode($v, true); if ($arr_time['login_time'] >= $arr_time['logout_time']) { $arrUser = $this->get_data('Player')->get_player_info($player_id, array('player_id', 'reg_time', 'ad_Info', 'level', 'vip', 'privilege_level')); $log_data = array('player_id' => $arrUser["player_id"], 'channel' => 1, 'client_ip' => Com_System::get_client_ip(), 'game_client_ip' => Com_System::get_client_ip(), 'reg_time' => $arrUser['reg_time'], 'ad_info' => $arrUser['ad_Info'], 'player_level' => $arrUser['level'], 'vip_level' => $arrUser['vip'], 'vip_special_level' => $arrUser['privilege_level']); Log_Common::getInstance()->add_log($log_data, 'day'); } } }
public function doAction() { $userInfo_json = base64_decode($_POST['data']); $arrData = json_decode($userInfo_json, true); $strAccount = isset($arrData["user_account"]) ? trim($arrData["user_account"]) : ""; #账号 $strOrderId = isset($arrData["order_id"]) ? trim($arrData["order_id"]) : ""; #订单号 $iGameMoney = isset($arrData["game_money"]) ? intval($arrData["game_money"]) : 0; #充值黄金 $iUMoney = isset($arrData["u_money"]) ? floatval($arrData["u_money"]) : 0; #充值U币(可以理解为人民币) $serverId = isset($arrData['server_id']) ? $arrData['server_id'] : 0; $player_id = isset($arrData['player_id']) ? $arrData['player_id'] : 0; $type = isset($arrData['type']) ? $arrData['type'] : 1; #1充值 2赠送3仅仅刷新VIP if (intval($iGameMoney) <= 0) { echo json_encode(array('status' => 0, 'data' => '充值金额有误')); exit; } if (!in_array($type, array(1, 2, 3))) { echo json_encode(array('status' => 8, 'data' => '类型错误')); #类型错误 exit; } if (!empty($strAccount)) { $player_id = $this->get_data('Account')->get_pid_byaccount($strAccount, true, $serverId); } if (empty($player_id)) { echo json_encode(array('status' => 0, 'data' => '账户不存在')); exit; } $objPlayerCharge = $this->get_data('PlayerCharge'); if ($type == 1) { $strOrderId = "gm" . time(); // $arrCharge = $objPlayerCharge->get_charge_info($strOrderId); // if(!empty($arrCharge)){ // echo json_encode(array('status'=>0, 'data'=>'订单不存在')); // exit; // } } $objPlayerData = $this->get_data('Player'); $arrPlayer = $objPlayerData->get_player_info($player_id, array('gold', 'level', 'vip', 'privilege_level')); $b_gold = $arrPlayer['gold']; #改变之前的钻石 // $iGold = $arrPlayer['gold']; // $player_level = $arrPlayer['level']; $result = false; #$this->get_data('Player')->check_player_resource($player_id, $player_info, '+', 'gold', $iGameMoney); $this->start_trans(); $iGold = $iGameMoney * 10; /* if ($iGameMoney) { $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 525); } */ $result = $objPlayerData->update_player_info($player_id, array('gold' => "+" . $iGold)); if ($result) { $after = $arrPlayer['gold'] + $iGold; if ($type == 1) { //充值 $result = $objPlayerCharge->add_charge($player_id, $strOrderId, $strAccount, $arrPlayer['level'], $iGold, $iGameMoney, $b_gold, $after); } else { //赠送 $result = $objPlayerCharge->add_present($player_id, $iGameMoney); } if ($type == 2) { //计入充值活动 $player_charge_dummy_info = array(); $player_charge_dummy_info["order_id"] = "gmorder" . time(); $player_charge_dummy_info["player_id"] = $player_id; $player_charge_dummy_info["user_account"] = $strAccount; $player_charge_dummy_info["player_level"] = $arrPlayer['level']; $player_charge_dummy_info["front_gold"] = $b_gold; $player_charge_dummy_info["gold"] = $iGold; $player_charge_dummy_info["after_gold"] = $after; $player_charge_dummy_info["u_money"] = $iGameMoney; $player_charge_dummy_info["add_time"] = time(); $player_charge_dummy_info["active"] = 0; $player_charge_dummy_info["active2"] = 0; $player_charge_dummy_info["active3"] = 0; $player_charge_dummy_info["active4"] = 0; $player_charge_dummy_info["active5"] = 0; $result = $this->get_data("Event")->insert_into_player_charge_dummy($player_charge_dummy_info); } } if ($result) { $this->commit(); if ($type == 1) { //充值记录 Log_Charge::getInstance()->add_charge_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], $strOrderId, $iGold, $iUMoney, $arrPlayer['gold'], $b_gold); } else { Log_Common::getInstance()->add_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'], $arrPlayer['privilege_level'], 100, 1, 2, $iGold, $arrPlayer['gold']); } // $logs[] = array('type'=>1,'item_id'=>2,'item_num'=>$iGold,'amount'=>$arrPlayer['gold']); // Log_Common::getInstance()->add_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'],$arrPlayer['privilege_level'], 100, 1, 2, $iGold, $arrPlayer['gold']); // Log_Common::getInstance()->add_multi_resource_log($player_id, $arrPlayer['level'], $arrPlayer['vip'],$arrPlayer['privilege_level'], 100, $logs); $data['status'] = 1; $data['data']['success'][] = $player_id; #同步更新面板数据 Protocol_Player::p2c_part_update($player_id, array('gold' => $iGold + $arrPlayer['gold'])); #vip升级 if ($type == 3) { #不参加 首次充值 $this->get_game('VipReward')->vip_upgrade($player_id, $iGold); } else { $this->get_game('VipReward')->vip_upgrade($player_id, $iGold); } #新服活动 if ($type < 3) { $pub_day = $this->get_data('NewServerActivity')->get_server_day(); if ($pub_day <= 7) { $this->get_game('NewServerActivity')->add_sign($player_id, $pub_day, $iGold); } } } else { $this->rollback(); $data['status'] = 0; } echo json_encode($data); define("FROM_GATEWAY", true); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260); Protocol::out(); return; }
public function tencent() { $server_state = Com_System::check_server_halt(); if (!$server_state['state']) { $result = array('ret' => 1001, 'msg' => $server_state['msg']); echo json_encode($result); exit; } $arrData = $this->_parseData; //平台登陆测试开关 $is_login_debug = isset($arrData['nologin']) ? $arrData['nologin'] : false; $key_list = array('openid', 'openkey', 'pf', 'pfkey'); $miss_key_arr = array(); foreach ($key_list as $key) { if (empty($arrData[$key])) { $miss_key_arr[] = $key; } //$_SESSION[$key] = $arrData[$key]; $this->public_tencent_params[$key] = $arrData[$key]; } if (!empty($miss_key_arr) && !$is_login_debug) { printf("Login param miss: [%s]\n", implode('|', $miss_key_arr)); exit; } /* 合服后处理待定 if($serverid != Config::check('serverId')) { //todo 后续合服需要调整(通过hefuServerIds) $hefuServerIds = Config::check('hefuServerIds'); if($hefuServerIds) { $hefuServerIds = explode(',',$hefuServerIds); if(!in_array($serverid,$hefuServerIds)) { printf("Config errro: [Platform_server_id_%s != Config_server_id_%s]\n", $serverid, Config::check('serverId')); exit; } } else { printf("Config errro: [Platform_server_id_%s != Config_server_id_%s]\n", $serverid, Config::check('serverId')); exit; } } */ $result = $this->get_game('Tencent')->isLogin($this->public_tencent_params); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l1,$_SESSION,$result,$arrData),true)."\n",FILE_APPEND); if (!empty($result) && $result['ret'] == 0 || $is_login_debug) { //$this->isSafari(); //游戏登陆 /* $res = $this->ipLimit(); if(!$res){ $this->isClose(); } */ //$_SESSION['account'] = $arrData['openid']; //$_SESSION['id'] = 0; //$_SESSION['time'] = 0; //$this->run(); //$code = UserRegister::getInstance()->login(); //Com_System::url_redirect(SERVER_DOMAIN.'/index.php'); } else { //todo 玩家重新登陆 printf("Login error! [msg=%s]\n", json_encode($result['msg'])); exit; } $rurl = MAIN_DOMAIN_URL; $strUserAccount = isset($arrData['openid']) ? trim($arrData['openid']) : ""; $iAdultFlag = isset($arrData["adult_flag"]) ? $arrData["adult_flag"] : 0; $iAdultGameTime = isset($arrData["game_time"]) ? $arrData["game_time"] : 0; $strClientIp = isset($arrData["ip"]) ? $arrData["ip"] : ""; $strAdInfo = isset($arrData["ad_info"]) ? trim($arrData["ad_info"]) : ""; $strTocken = isset($arrData['tocken']) ? $arrData['tocken'] : ""; $serverId = isset($arrData['serverid']) ? $arrData['serverid'] : 0; $active_type = isset($arrData['active_type']) ? $arrData['active_type'] : 1; $platform = isset($arrData['platform']) ? trim($arrData['platform']) : ""; $openid = isset($arrData['openid']) ? trim($arrData['openid']) : ""; $openkey = isset($arrData['openkey']) ? trim($arrData['openkey']) : ""; $pf = isset($arrData['pf']) ? trim($arrData['pf']) : ""; $pfkey = isset($arrData['pfkey']) ? trim($arrData['pfkey']) : ""; /* if($iAdultFlag == 0 && $iAdultGameTime >= (3*3600)) { $msg = Cache_Language::getInstance()->get_language_info(10306); Com_System::url_msg_redirect($msg['content'],$rurl); exit; } */ // $playerid = $this->get_data('Account')->get_pid_byaccount($strUserAccount, true, $serverId); // Com_Log::log("===============[start]==============",'login_test',1); // Com_Log::log("user_account:{$strUserAccount}",'login_test',1); $account_info = $this->get_data('Account')->get_account_info($strUserAccount); // Com_Log::log($account_info,'login_test',1); // Com_Log::log($_SESSION,'login_test',1); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l2,$_SESSION,$account_info,$arrData),true)."\n",FILE_APPEND); if (!$account_info || empty($account_info['name'])) { // $sessAccount = $_SESSION["account"]; // if(isset($_SESSION['player_id']) && $_SESSION['player_id'] // || $sessAccount && $strUserAccount != $sessAccount){ // // } // session_regenerate_id(); $_SESSION = array(); $_SESSION['sid'] = session_id(); $_SESSION["account"] = $strUserAccount; $_SESSION['client_ip'] = $strClientIp; $_SESSION['ad_Info'] = $strAdInfo; $_SESSION['server_id'] = $serverId; $_SESSION['vip'] = 0; $_SESSION['level'] = 0; $_SESSION['openid'] = $openid; $_SESSION['openkey'] = $openkey; $_SESSION['pf'] = $pf; $_SESSION['pfkey'] = $pfkey; $_SESSION['platform'] = $platform; foreach (array('app_custom', 'invkey', 'itime', 'iopenid', 'app_appbitmap') as $key) { if (!empty($arrData[$key])) { $_SESSION[$key] = $arrData[$key]; } } //todo 临时解决 if (isset($_SESSION['app_custom'])) { $tmp_str = urldecode($_SESSION['app_custom']); $_SESSION['app_custom'] = str_replace('|', '.', $tmp_str); } $ad_info = $strAdInfo > 0 ? 1 : 0; if (isset($account_info['player_id']) && $account_info['player_id']) { $playerid = $account_info['player_id']; // Com_DataCenter::getInstance()->publish_data($playerid,'login',array('ad_info'=>$ad_info,'status'=>'on','keep_time'=>0,'time'=>$this->current_time)); } else { $playerid = $this->get_data('Account')->add_account($strUserAccount, '', $serverId, $strAdInfo); ############################################################################### # 注册用户,上报数据 Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid); if (!($res = Com_TencentDataUpload::getInstance()->register_data_upload())) { Com_Log::write("uploadDataError", "register_data_upload failed!"); } ############################################################################### $log_data = array('player_id' => $playerid, 'channel' => 2, 'user_account' => $strUserAccount, 'ad_info' => $strAdInfo, 'client_ip' => $strClientIp, 'reg_time' => $this->current_time, 'type' => 0, 'add_time' => $this->current_time); Log_Common::getInstance()->add_log($log_data); //Com_DataCenter::getInstance()->publish_data($playerid,'est',array('ad_info'=>$ad_info,'step'=>'get','time'=>$this->current_time)); } $_SESSION['player_id'] = $playerid; $_SESSION['name'] = ''; #zhe shi hou hai mei ming zi $_SESSION['career_type'] = ''; #zhe shi hou hai mei ming zi $_SESSION['active_type'] = $active_type; $_SESSION['adult_flag'] = $iAdultFlag; $this->get_game('Online')->write_session(); $arr_cache = array('player_id' => $playerid, 'name' => '', 'user_account' => $strUserAccount, 'ad_info' => $strAdInfo, 'reg_time' => 0, 'career_type' => 0, 'first_load' => 0); $this->get_data('Player')->set_rookie_loading_cache($playerid, $arr_cache); # -------------------------------------------------------------------- # 活动日志记录 # -------------------------------------------------------------------- /** $event_log_info = array( 'log_type' => 'login', 'player_id' => $_SESSION['player_id'], 'login_time' => $this->current_time, 'logout_time' => 0, ); $this->get_game('Event')->async_deal_event_log($event_log_info); **/ if ($iAdultFlag == 0) { $this->get_game('Adlut')->add_timer($playerid); #放沉迷定时器 } $this->redis()->hash_set($this->user_tencent_table . ':' . $playerid, $this->public_tencent_params); /*######################################################################### # 玩家登陆成功,判断是否从任务集市进入,并保存传入参数到数据中心服redis # 如果不是从任务集市进入,则只写入最后一次登录的服务器ip和id等数据 if(isset($arrData['app_user_source']) && $arrData['app_user_source'] == "marketV3"){ $app_user_source = $arrData['app_user_source']; $app_contract_id = $arrData['app_contract_id']; $app_custom = $arrData['app_custom']; $arrTask = array( "player_id"=>$account_info['player_id'], "app_user_source"=>$app_user_source, "app_custom"=>$app_custom, "app_contract_id"=>$app_contract_id, "last_server_id"=>SERVER_ID, "last_server_ip"=>PROCESS_MAIN_IP, "last_server_host"=>SERVER_DOMAIN, "last_login_time"=>time() ); if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){ Com_Log::write("TencentTaskMarket","TaskMarket data failed!"); } }else{ $arrTask = array( "player_id"=>$account_info['player_id'], "last_server_id"=>SERVER_ID, "last_server_ip"=>PROCESS_MAIN_IP, "last_server_host"=>SERVER_DOMAIN, "last_login_time"=>time() ); if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){ Com_Log::write("TencentTaskMarket","TaskMarket data failed!"); } } ##########################################################################*/ Com_System::url_redirect(SERVER_DOMAIN . '/index.php'); } else { /* if($iAdultFlag == 0){ $flag = $this->get_data('Online')->get_adlut_ban($account_info['player_id']); if(!$flag){ $this->get_game('Adlut')->add_timer($account_info['player_id']); #放沉迷定时器 } if($flag){ $msg = Cache_Language::getInstance()->get_language_info(10306); Com_System::url_msg_redirect($msg['content'],$rurl); exit; } } */ $this->get_game('DailySign')->async_trigger_login_times($account_info['player_id']); $objPlayerData = $this->get_data('Player'); if ($account_info['player_id'] == $_SESSION['player_id']) { // Com_Log::log("account:{$account_info['player_id']} session:{$_SESSION['player_id']} sid:{$_SESSION['']}",'login_test',1); $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag); //上一次离线时长计算 $logout_time = $objPlayerData->get_player_info($account_info['player_id'], 'logout_time'); $last_offline_time = $this->current_time - $logout_time; $up_arr['last_offline_time'] = $last_offline_time; if ($last_offline_time >= 28800) { //8小时以上给奖励 $up_arr['offline_reward_status'] = 1; } else { $up_arr['offline_reward_status'] = 0; } //已经登录 $objPlayerData->update_player_info($account_info['player_id'], $up_arr); $_SESSION['openkey'] = $openkey; $_SESSION['pf'] = $pf; $_SESSION['pfkey'] = $pfkey; $_SESSION['platform'] = $platform; $_SESSION['openid'] = $openid; //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l3,$_SESSION,$account_info,$arrData),true)."\n",FILE_APPEND); $objOnline = $this->get_game('Online'); $objOnline->write_session(); $this->redis()->hash_set($this->user_tencent_table . ':' . $account_info['player_id'], $this->public_tencent_params); Com_System::url_redirect(SERVER_DOMAIN . '/index.php'); exit; } $arrUser = $objPlayerData->get_player_info($account_info['player_id']); ############################################################################### # 登录成功,上报数据 $playerid = $account_info['player_id']; Com_TencentDataUpload::getInstance()->init($platform, $serverId, $playerid, $openid); $level = $arrUser['level']; if (!($res = Com_TencentDataUpload::getInstance()->login_data_upload($level))) { Com_Log::write("uploadDataError", "login_data_upload failed!" . var_export($res) . "sss"); } ############################################################################### if ($arrUser['is_ban'] == 3) { #封号了 Com_System::url_msg_redirect("亲爱的魔法师,由于您的账号数据存在异常,魔法管理员已暂时将您的账号封停,如有疑问可联系客服咨询。", $rurl); exit; } if (empty($arrData['nologin']) && $arrUser['ban_time'] > $this->current_time) { Com_System::url_redirect(SERVER_DOMAIN . '/index.php' . "?ecode=-15"); } $oldPlayerId = isset($_SESSION['player_id']) ? $_SESSION['player_id'] : 0; if ($oldPlayerId) { //如果有老的playerid 则生成新的session_id // session_regenerate_id(); } $_SESSION = array(); $_SESSION['sid'] = session_id(); $_SESSION["player_id"] = $arrUser["player_id"]; $_SESSION['active_type'] = 0; $_SESSION['name'] = $arrUser["name"]; $_SESSION["account"] = $strUserAccount; $_SESSION['career_type'] = $arrUser['career_type']; $_SESSION['adult_flag'] = $iAdultFlag; $_SESSION['ad_Info'] = $arrUser['ad_Info']; $_SESSION['client_ip'] = $strClientIp; $_SESSION['server_id'] = $serverId; $_SESSION['vip'] = $arrUser['vip']; $_SESSION['level'] = $arrUser['level']; $_SESSION['openid'] = $openid; $_SESSION['openkey'] = $openkey; $_SESSION['pf'] = $pf; $_SESSION['pfkey'] = $pfkey; $_SESSION['platform'] = $platform; $objOnline = $this->get_game('Online'); $objOnline->write_session(); //file_put_contents(PROJECT_ROOT.'/uuzudo.log',var_export(array(l4,$_SESSION,$account_info,$arrData),true)."\n",FILE_APPEND); $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag); //上一次离线时长计算 $last_offline_time = $this->current_time - $arrUser['logout_time']; $up_arr['last_offline_time'] = $last_offline_time; if ($last_offline_time >= 28800) { //8小时以上给奖励 $up_arr['offline_reward_status'] = 1; } else { $up_arr['offline_reward_status'] = 0; } $objPlayerData->update_player_info($arrUser["player_id"], $up_arr); //更新下session $log_data = array('player_id' => $arrUser["player_id"], 'channel' => 1, 'client_ip' => $strClientIp, 'game_client_ip' => Com_System::get_client_ip(), 'reg_time' => $arrUser['reg_time'], 'ad_info' => $arrUser['ad_Info'], 'player_level' => $arrUser['level'], 'vip_level' => $arrUser['vip'], 'vip_special_level' => $arrUser['privilege_level']); #Log_Login::getInstance()->add_log($log_data); Log_Common::getInstance()->add_log($log_data, 'day'); $arr_cache = array('player_id' => $arrUser["player_id"], 'name' => $arrUser["name"], 'user_account' => $strUserAccount, 'ad_info' => $arrUser['ad_Info'], 'reg_time' => $arrUser['reg_time'], 'career_type' => $arrUser['career_type'], 'first_load' => $arrUser['first_load']); $this->get_data('Player')->set_rookie_loading_cache($arrUser["player_id"], $arr_cache); $ad_info = $strAdInfo > 0 ? 1 : 0; //Com_DataCenter::getInstance()->publish_data($arrUser["player_id"],'login',array('ad_info'=>$ad_info,'status'=>'on','keep_time'=>0,'time'=>$this->current_time)); if ($ad_info == 1) { #广告系统用户推送每天首次登陆 if (date('Ymd', $arrUser["reg_time"]) != date('Ymd') && date('Ymd') != date('Ymd', $arrUser["login_time"])) { $activelog = Com_System::send_request(array('user_account' => $arrUser['user_account']), 'login'); } } #记录登陆登出信息 $this->get_data('Online')->set_online_list($arrUser["player_id"], array('login_time' => $this->current_time, 'logout_time' => $arrUser['logout_time'])); // Com_Log::log("arrUser:{$arrUser["player_id"]} session:{$_SESSION['player_id']} sid:{$_SESSION['sid']}",'login_test',1); /*######################################################################### # 玩家登陆成功,判断是否从任务集市进入,并保存传入参数到数据中心服redis if(isset($arrData['app_user_source']) && $arrData['app_user_source'] == "marketV3"){ $app_user_source = $arrData['app_user_source']; $app_contract_id = $arrData['app_contract_id']; $app_custom = $arrData['app_custom']; $arrTask = array( "player_id"=>$account_info['player_id'], "app_user_source"=>$app_user_source, "app_custom"=>$app_custom, "app_contract_id"=>$app_contract_id, "last_server_id"=>SERVER_ID, "last_server_ip"=>PROCESS_MAIN_IP, "last_server_host"=>SERVER_DOMAIN, "last_login_time"=>time() ); if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){ Com_Log::write("TencentTaskMarket","TaskMarket data failed!"); } }else{ $arrTask = array( "player_id"=>$account_info['player_id'], "last_server_id"=>SERVER_ID, "last_server_ip"=>PROCESS_MAIN_IP, "last_server_host"=>SERVER_DOMAIN, "last_login_time"=>time() ); if(!$this->get_game('TencentTaskMarket')->set_tencent_task_data($openid,$arrTask)){ Com_Log::write("TencentTaskMarket","TaskMarket data failed!"); } } ##########################################################################*/ # -------------------------------------------------------------------- # 活动日志记录 # -------------------------------------------------------------------- /** $event_log_info = array( 'log_type' => 'login', 'player_id' => $_SESSION['player_id'], 'login_time' => $this->current_time, 'logout_time' => 0, ); $this->get_game('Event')->async_deal_event_log($event_log_info); **/ $this->redis()->hash_set($this->user_tencent_table . ':' . $arrUser["player_id"], $this->public_tencent_params); Com_System::url_redirect(SERVER_DOMAIN . '/index.php'); } }
public function add_to_action($player_id, $id) { $player_id = intval($player_id); $id = intval($id); $attr_mag = Cache_UnionTech::getInstance()->get_attr_list(); $attr = $this->get_attr_by_id($attr_mag, $id); $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'union_name', 'level', 'vip', 'privilege_level')); #判断是否能升级 $res = array(); #判断贡献是否足够 $myinfo = $this->get_player_info($player_info['union_id'], $player_id); $my_dedicate = isset($myinfo['total_dedicate']) ? $myinfo['total_dedicate'] : 0; $my_log = $this->get_data("UnionTech")->get_my_attr_log($player_id); $data = $this->get_data('UnionInfo')->get_union_info($player_info['union_id'], array('union_level', 'tech_level')); if (empty($data)) { $this->throw_error('170701'); } $tech_level = isset($data['tech_level']) && $data['tech_level'] > 0 ? $data['tech_level'] : 1; $max_level = $this->get_base_by_level($tech_level, true); #判断是否符合升级 if (!$this->check_in_attr($player_id, $tech_level, $id)) { $this->throw_error("1715008"); } #我的属性当前等级 $level = $this->get_attr_level_id($my_log, $attr['type_1'], $attr['type_2']); #计算消耗 $cost_num = $this->get_cost_add($level, $attr['cost']); #计算加成 $add_num = $this->get_cost_add($level, $attr['add_num']); if ($my_dedicate < $cost_num) { $res['res'] = 2; #公会贡献不足 $this->throw_error("1715006"); } else { $res['res'] = 1; $res['id'] = $id; $res['level'] = 8; $res['my_dedicate'] = $my_dedicate; #我的贡献 $old_level = $level; if (intval($max_level) > $level) { $this->add_attr_value($player_id, $attr['type_1'], $attr['type_name'], $add_num); $level = $this->update_my_attr_level($player_id, $attr['type_1'], $attr['type_2']); $myinfo['total_dedicate'] = $my_dedicate - $cost_num; $this->get_data("UnionPlayer")->update_union_player_info($player_info['union_id'], $player_id, $myinfo); //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 2, 'item_id' => 11, 'item_num' => $cost_num, 'amount' => $my_dedicate, 'after_amount' => $myinfo['total_dedicate'], 'cmd_id' => 1726); Log_Common::getInstance()->add_log($log_data); $res['res'] = 1; $my_dedicate -= $cost_num; #文斌埋的点 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9070); #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 32, 1); } else { $res['res'] = 0; $this->throw_error("1715008"); } $res['id'] = $id; $res['level'] = $level; $res['my_dedicate'] = $my_dedicate; #我的贡献 $res['cost_num'] = $this->get_cost_add($level, $attr['cost']); #消耗数量-贡献 $data = $this->get_game('Hero')->get_player_hero_info($player_id); Protocol::input($player_id, 8, 5, 501, $data); Protocol_Player::p2c_part_update($player_id, array('hero_info' => array(), 'attr' => array())); #添加日志 $log_data = array('player_id' => $player_id, 'channel' => 54, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'type' => 6, 'cmd_id' => 1726, 'item_id' => $id, 'item_level' => $old_level, 'after_amount' => $level, 'add_time' => time()); Log_Common::getInstance()->add_log($log_data); } return $res; }
/** * 声望升级异步处理 加到人身上也在异步处理哪 * @param $add_exp */ public function player_fame_upgrade($add_fame, $upgrade_fame_logs) { if ($add_fame >= $this->arrParams['fame_level_exp']) { if ($upgrade_fame_logs) { Log_Common::getInstance()->add_multi_resource_log($this->player_id, $this->arrParams['level'], $this->arrParams['vip'], $this->arrParams['privilege_level'], $this->arrParams['cmd_id'], $upgrade_fame_logs); } if ($this->is_trans()) { // Com_Log::write('xgame.player_fame_upgrade',"#"); $this->set_redis_pre_action('data|player:' . $this->player_id . '|fame_upgrade', array($this->get_game('PlayerUpgrade'), 'fame_upgrade'), array($this->player_id, array('fame_level' => $this->arrParams['fame_level'], 'fame' => $this->arrParams['fame'], 'fame_level_exp' => $this->arrParams['fame_level_exp'], 'privilege_level' => $this->arrParams['privilege_level'], 'level' => $this->arrParams['level'], 'vip' => $this->arrParams['vip']))); } else { $this->get_game('PlayerUpgrade')->fame_upgrade($this->player_id, array('fame_level' => $this->arrParams['fame_level'], 'fame' => $this->arrParams['fame'], 'fame_level_exp' => $this->arrParams['fame_level_exp'], 'privilege_level' => $this->arrParams['privilege_level'], 'level' => $this->arrParams['level'], 'vip' => $this->arrParams['vip'])); } } }
/** * @Purpose: * 通缉副本结算 * @Param $player_array 玩家数组 * @Param $passed 通关状态 * @Param $fb_id 副本ID * @Param $way 立即完成:ture */ public function fb_reward($player_array, $passed, $fb_id, $way = false) { $passed = intval($passed); if ($player_array[0] < 1 || $passed != 1) { if ($way) { $this->throw_error('10110'); #数据错误 } return array('0' => 0, '1' => array()); } $player_id = intval($player_array[0]); $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'privilege_level', 'level', 'vip', 'ticket', 'gold', 'ad_info', 'career_type')); $union_id = $player_info['union_id']; if ($way) { #获取玩家公会ID,验证公会信息 if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } } #获取玩家通缉榜数据 $data = $this->get_data("UnionWanted")->get_union_wanted_info($player_id); if (!$data) { if ($way) { $this->throw_error('10110'); #数据错误 } return array('0' => 0, '1' => array()); } if ($data['wanted_info'] && !is_array($data['wanted_info'])) { $wanted_info = json_decode($data['wanted_info'], true); } else { $wanted_info = $data['wanted_info']; } $fb_id = intval($fb_id); if (!$wanted_info['union_wanted_info'][$fb_id]) { if ($way) { $this->throw_error('10110'); #数据错误 } return array('0' => 0, '1' => array()); } $arr_consume = array(); if ($way) { $cost = $wanted_info['union_wanted_info'][$fb_id]['finish_expend']; if ($cost) { $deduct_coin = 0; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] < $cost) { $deduct_coin = $player_info['ticket']; } else { $deduct_coin = $cost; } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $deduct_coin); } if ($deduct_coin < $cost) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost - $deduct_coin); } $arr_consume = array('price' => $cost, 'gold' => $cost - $deduct_coin, 'ticket' => $deduct_coin, 'count' => 1); #数据中心推送 } } #获取玩家通缉榜天数据 $uwd_data = $this->get_data("UnionWanted")->get_union_wanted_daily_info($player_id, 'uwd', 'day'); if (!$uwd_data) { $this->throw_error('10110'); #数据错误 } $update_uwd = array(); if ($wanted_info['finish_times_max'] > 0 && $uwd_data['finished_times'] < $wanted_info['finish_times_max']) { $update_uwd['finished_times'] = ++$uwd_data['finished_times']; #$update_uwd['finish_times'] = --$uwd_data['finish_times']; /* #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10060); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } $free_times_vip_table = array(); if ($player_vip > 0) { #获取VIP配置表免费次数配置 $free_times_vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, 10060); } if ($uwd_data['used_free'] >= $free_times_vip_table['max_times'] + $uwd_data['use_free']) { $update_uwd['used_times'] = 1; $times_table = $this->get_cache_table_data('times_table', array('type' => 1, 'times' => $update_uwd['used_times'])); if ($times_table) { #通过刷新消耗配置表获得下次刷新需要消耗的货币数量 list($id, $value) = explode("|", $times_table['cost']); $update_uwd['use_expend'] = json_encode(array('id' => $id, 'num' => $value)); } }*/ } else { $this->throw_error('1719003'); //通缉次数不足 } #获取公会通缉榜等级 $wanted_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'wanted_level'); #创建通缉数据结构 $wanted_data = $this->create_wanted_struct($wanted_level); $data['wanted_info'] = $wanted_info; $data['wanted_info']['union_wanted_info'] = $wanted_data; $update_data['wanted_info'] = json_encode($data['wanted_info']); #获取玩家等级对应的任务基础奖励 $player_level = $player_info['level']; $level_base_reward = $this->get_reward_by_level($player_level); $wanted_fb = $wanted_info['union_wanted_info'][$fb_id]; #计算加成奖励 $wanted_info['union_wanted_info'][$fb_id]['union_award']['exp']['num'] = $this->calculation_reward($level_base_reward['exp'], $wanted_fb['union_award']['exp']['num'], $uwd_data['fortune_award_per']); $wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num'] = $this->calculation_reward($level_base_reward['player_exp'], $wanted_fb['union_award']['player_exp']['num'], $uwd_data['fortune_award_per']); $wanted_info['union_wanted_info'][$fb_id]['union_award']['contribution']['num'] = $this->calculation_reward($level_base_reward['contribution'], $wanted_fb['union_award']['contribution']['num'], $uwd_data['fortune_award_per']); #获取玩家公会ID $union_id = $player_info['union_id']; #获取公会数据 $union_info = $this->get_data("UnionInfo")->get_union_info($union_id); if ($union_info) { #更新公会经验 $union_info['union_exp'] = $wanted_info['union_wanted_info'][$fb_id]['union_award']['exp']['num']; } $today_contribution = 0; $update_player = array(); #获取玩家公会数据 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $front_amount_dedicate = $player_data['total_dedicate']; //贡献 if ($player_data) { $today_contribution = $wanted_info['union_wanted_info'][$fb_id]['union_award']['contribution']['num']; #更新玩家贡献 $player_data['total_dedicate'] += $today_contribution; $update_player = $player_data; } $player_exp_info = array(); //添加玩家副本奖励经验 if ($wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num']) { $player_exp_info[] = array('type' => 'exp', 'item_id' => '1', 'item_num' => $wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num']); } $this->start_trans(); #更新通缉副本 $update_res = $this->get_data("UnionWanted")->update_union_wanted($player_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } if (!empty($update_uwd)) { #更新玩家公会通缉榜天数据 $this->get_data("UnionWanted")->update_union_wanted_daily_data($player_id, 'uwd', $update_uwd); #同步更新玩家使用次数总表 $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'union_wanted_times', $update_uwd['finished_times']); $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if ($base_table) { $times_max = $base_table['daily_complete_times']; #更新公会引导状态 $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $update_uwd['finished_times'], $times_max, 2, 2); } } $success_add_exp = 0; if ($union_info['union_exp']) { $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if (empty($base_table)) { $this->throw_error('10109'); #配置表读取错误 } #完成的悬赏任务大于每日可完成的悬赏任务,则不再增加公会经验 $is_get_exp = true; if ($base_table['num_for_union_exp'] > 0) { $union_times = $this->get_data('PlayerDailyTime')->get_player_used_time($union_id, 'union_wanted_num'); if ($union_times < $base_table['num_for_union_exp']) { $add_res = $this->get_data('PlayerDailyTime')->pre_add_used_time($union_id, 'union_wanted_num'); } else { $is_get_exp = false; } } if ($is_get_exp) { #增加公会经验 $arr_union_reward = array(); $arr_union_reward[] = array("type" => "union_exp", "item_id" => 9, "item_num" => $union_info['union_exp']); $ret = $this->get_game('UnionReward')->send_reward($player_id, $arr_union_reward, array("cmd_id" => 1753)); if ($ret !== false) { $success_add_exp = $ret; } } } if (Com_Array::is_good_arr($player_exp_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $player_exp_info, array('cmd_id' => '1753'), 1); if ($result !== true) { $this->throw_error('10104'); } } if (!empty($update_player)) { $update_res = $this->get_game("UnionPlayer")->add_player_dedicate($player_id, $today_contribution); #更新玩家今日贡献 #$this->get_data("PlayerDailyTime")->add_used_time($player_id, "union_player_contribute", $today_contribution); #更新玩家公会 #$update_res = $this->get_data('UnionPlayer')->update_union_player_info($union_id, $player_id, $update_player); if (!$update_res) { $this->throw_error('10104'); } //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $today_contribution, 'amount' => $front_amount_dedicate, 'after_amount' => $player_data['total_dedicate'], 'cmd_id' => 1753); Log_Common::getInstance()->add_log($log_data); } if ($way && $wanted_info['union_wanted_info'][$fb_id]['finish_expend']) { #扣钻石 $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1753, array(), $arr_consume); #$update_res = $this->get_data('Player')->update_player_gold($player_id, "-" . $wanted_info['union_wanted_info'][$fb_id]['finish_expend'] ); if (!$update_res) { $this->throw_error('10104'); } } $this->commit(); $this->update_temporary_data($data); $this->get_game('Reward')->add_reward_log(); $this->get_game('UnionReward')->add_union_reward_log(); #更新公会成就任务 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 11, 1, 1); #更新公会福利大厅任务 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9030); #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 29, 1); //找回资源埋点 $this->get_game('GetBackCurrency')->add_function_day_times($player_id, 13); #增加公会记录 $code = 1719006; $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $today_contribution, 'rep_color' => "ffb901"); if ($success_add_exp > 0) { $arr_replace[] = array('rep_type' => 7, 'txt' => $success_add_exp, 'rep_color' => "ffb901"); $code = 1719005; } $player_exp = $wanted_info['union_wanted_info'][$fb_id]['union_award']['player_exp']['num']; $arr_replace[] = array('rep_type' => 7, 'txt' => $player_exp, 'rep_color' => "ffb901"); $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, $code, $arr_replace); if ($success_add_exp < 1) { unset($wanted_info['union_wanted_info'][$fb_id]['union_award']['exp']); } $union_award = $wanted_info['union_wanted_info'][$fb_id]['union_award']; if ($way) { if ($success_add_exp > 0) { Protocol_Reward::add($player_id, array('prop_id' => $union_award['exp']['id'], 'item_num' => $success_add_exp, 'item_position' => 1, 'grid' => 0)); } Protocol_Reward::add($player_id, array('prop_id' => $union_award['player_exp']['id'], 'item_num' => $union_award['player_exp']['num'], 'item_position' => 1, 'grid' => 0)); Protocol_Reward::add($player_id, array('prop_id' => $union_award['contribution']['id'], 'item_num' => $union_award['contribution']['num'], 'item_position' => 1, 'grid' => 0)); Protocol_Reward::out(); } else { $log_data = array('player_id' => $player_id, 'channel' => 55, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'ad_info' => $player_info['ad_info'], 'career_type' => $player_info['career_type'], 'type' => 2, 'module_id' => $fb_id, 'add_time' => time()); Log_Common::getInstance()->add_log_by_table($log_data, 'log_enter'); } return array('0' => 1, '1' => $union_award); }
public function send_reward($guild_id, $time_cost, $boss_max_hp, $boss_cur_hp, $roles) { $guild_id = intval($guild_id); $res = array(); $union_info = $this->get_data('UnionInfo')->get_union_info($guild_id); $union_level = isset($union_info['union_level']) ? $union_info['union_level'] : 1; $reward_set = $this->get_base_level($union_level); if (empty($reward_set)) { $this->throw_error("10222", 2010157); } $res['base'] = array(); #基础伤害奖励 $res['addition'] = array(); #排名奖励 $res['res'] = $boss_cur_hp == 0 ? 1 : 0; #是否成功 if (!empty($roles)) { #更新记录 $this->get_data('UnionBoss')->save_boss_log($guild_id, $roles); #排名奖励配置表 $rank_list = Cache_UnionBoss::getInstance()->get_rank_reward(); $rank_num = count($rank_list); $i = 0; foreach ($roles as $v) { if ($v[0] == 0) { continue; } $base_reward = $this->get_dps_reward($reward_set['boss_reward'], $reward_set['dedicate_reward'], $v[1]); $res['base'] = array($base_reward['exp']); $rankreward = 0; $rank_decate = 0; if ($i > $rank_num) { $rankreward = $rank_list[$rank_num - 1]['reward_per']; $rank_decate = $rank_list[$rank_num - 1]['dedicate_per']; } else { $rankreward = $rank_list[$i]['reward_per']; $rank_decate = $rank_list[$i]['dedicate_per']; } #vip加成奖励 $vip_exp = 0; $player_info = $this->get_data('Player')->get_player_info($v[0], array('privilege_level')); if ($player_info['privilege_level'] > 0) { $left_cd = $this->get_game('VipSpecial')->get_left_time($v[0]); if ($left_cd > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['privilege_level'], 10061); if (!empty($vip_set)) { $vip_exp = $vip_set['max_times']; } } } $rank = array('type' => 'exp', 'item_id' => 1, 'item_num' => ($vip_exp / 10000 + 1) * ceil($reward_set['boss_reward'] * $rankreward / 100)); $base_reward['dedicate']['item_num'] += ($vip_exp / 10000 + 1) * ceil($reward_set['dedicate_reward'] * $rank_decate / 100); $log = $res['base']; $log[] = $rank; #$log[] = $base_reward['dedicate']; $res['addition'] = array($rank); $res['addition'][] = $base_reward['dedicate']; $i++; if ($v[0] > 0) { $result = $this->get_game('Reward')->send_reward($v[0], $log, array('cmd_id' => '491', 'bind_flag' => 0), 1); if ($result === true) { $this->get_game('Reward')->add_reward_log(); //记录日志 #发奖励 Protocol::input($v[0], 8, 17, 1728, $res); #添加公会成就 if ($boss_cur_hp == 0 && $v[0] > 0) { $this->get_game('UnionAchieve')->async_trigger_union_achieve($v[0], 9, 1, 1); $this->get_game('UnionBoonHall')->async_trigger_union_task($v[0], 2, '9092'); } $player_data = $this->get_data('UnionPlayer')->get_union_player_info($guild_id, $v[0]); $front_amount_dedicate = $player_data['total_dedicate']; //贡献 $this->get_game('UnionPlayer')->add_player_dedicate($v[0], $base_reward['dedicate']['item_num']); //公会贡献-流水日志 $log_data = array('player_id' => $v[0], 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $base_reward['dedicate']['item_num'], 'amount' => $front_amount_dedicate, 'after_amount' => $player_data['total_dedicate'] + $base_reward['dedicate']['item_num'], 'cmd_id' => 491); Log_Common::getInstance()->add_log($log_data); } else { $this->throw_error(10110, 2010142); } } } /* #胜利发宝箱---策划要求暂时取消 if($boss_cur_hp==0){ #把宝箱数据发给会长 $data = $this->create_box($guild_id,$roles); $base_info = $this->get_data('Player')->get_player_info($union_info['create_player_id'],array('is_online')); if($base_info['is_online']>0){ Protocol::input($union_info['create_player_id'],8,17,1772,$data); }else{ #自动分配 $this->send_box_reward_role($guild_id); } $params = array(); $params['type'] = 170001; $params['id'] = $guild_id; $params['timeout'] = 180; $params['param1'] = $guild_id; $params['param2'] = 0; $params['param3'] = 0; $params['param4'] = 0; Protocol::input(0, 7, 4, 516, $params); } */ } return array('guild_id' => $guild_id); }
/** * 删除用户道具 * @param $player_id * @param $arrPlayerPropDetail * @param $isOne 是否是一个道具 * @param $log_param 日志需要的参数 array('cmd_id','level','vip') * @return bool|mixed */ public function delete_player_prop($player_id, $arrPlayerPropDetail, $isOne = true, $log_param = array()) { $logs = array(); $arr_async = array(); if ($isOne) { $bDealCheck = $this->delete_player_prop_byid($player_id, $arrPlayerPropDetail['player_prop_id']); if (!$arrPlayerPropDetail['name']) { $arrPropConfig = Cache_Prop::getInstance()->get_prop_info($arrPlayerPropDetail['prop_id']); $arrPlayerPropDetail['name'] = $arrPropConfig['name']; } $logs[$arrPlayerPropDetail['player_prop_id']] = $arrPlayerPropDetail; if ($arrPlayerPropDetail['type'] == 2 && $arrPlayerPropDetail['sub_type'] == 1) { $arr_async['potion_hot_cnt'] = -$arrPlayerPropDetail['item_num']; } if ($arrPlayerPropDetail['type'] == 2 && $arrPlayerPropDetail['sub_type'] == 6) { $arr_async['potion_dh_cnt'] = -$arrPlayerPropDetail['item_num']; } if ($arrPlayerPropDetail['type'] == 2 && $arrPlayerPropDetail['sub_type'] == 11) { $arr_async['mp_potion_cnt'] = -$arrPlayerPropDetail['item_num']; } } else { $delete_ids = array(); $bDealCheck = true; foreach ($arrPlayerPropDetail as $arrProp) { if (!isset($delete_ids[$arrProp['player_prop_id']])) { $delete_ids[$arrProp['player_prop_id']] = array('player_prop_id' => $arrProp['player_prop_id'], 'item_position' => $arrProp['item_position']); } //item_name if (!$arrProp['name']) { $arrPropConfig = Cache_Prop::getInstance()->get_prop_info($arrProp['prop_id']); $arrProp['name'] = $arrPropConfig['name']; } $logs[$arrProp['player_prop_id']] = $arrProp; if ($arrProp['type'] == 2 && $arrProp['sub_type'] == 1) { $arr_async['potion_hot_cnt'] = -$arrProp['item_num']; } if ($arrProp['type'] == 2 && $arrProp['sub_type'] == 6) { $arr_async['potion_dh_cnt'] = -$arrProp['item_num']; } if ($arrProp['type'] == 2 && $arrProp['sub_type'] == 11) { $arr_async['mp_potion_cnt'] = -$arrProp['item_num']; } } foreach ($delete_ids as $delete_id => $delete_info) { if ($bDealCheck) { $bDealCheck = $this->delete_player_prop_byid($player_id, $delete_id); } if (!$bDealCheck) { break; } } } if ($bDealCheck) { if (!isset($log_param['level']) || !isset($log_param['vip']) || !isset($log_param['privilege_level'])) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level')); $log_param['level'] = $player_info['level']; $log_param['vip'] = $player_info['vip']; $log_param['privilege_level'] = $player_info['privilege_level']; } if (!isset($log_param['cmd_id'])) { $log_param['cmd_id'] = 104; } $log_type = 5; if (in_array($log_param['cmd_id'], array(525, 13051))) { $log_type = 2; } if ($this->is_trans()) { if ($arr_async) { $this->set_redis_pre_action(null, array(Protocol_Player, 'p2c_part_update'), array($player_id, $arr_async)); } foreach ($logs as $val) { $this->set_redis_pre_action(null, array(Log_Common::getInstance(), 'add_prop_log'), array($player_id, $log_param['level'], $log_param['vip'], $log_param['privilege_level'], $log_param['cmd_id'], $log_type, $val['player_prop_id'], $val['prop_id'], $val['type'], $val['name'], $val['quality'], $val['item_num'], $val['level'], $val['item_num'], $val, $val['sub_type'])); } } else { if ($arr_async) { Protocol_Player::p2c_part_update($player_id, $arr_async); } foreach ($logs as $val) { Log_Common::getInstance()->add_prop_log($player_id, $log_param['level'], $log_param['vip'], $log_param['privilege_level'], $log_param['cmd_id'], $log_type, $val['player_prop_id'], $val['prop_id'], $val['type'], $val['name'], $val['quality'], $val['item_num'], $val['level'], $val['item_num'], $val, $val['sub_type']); } } } return $bDealCheck; }
/** * @Purpose: * 公会商店购买 * @Param $player_id 玩家ID * @Param $shop_id 商品ID * @Param $type 商品类型 * @Param $num 购买数量 */ public function union_shop_buy($player_id, $shop_id, $type, $num) { $player_id = intval($player_id); if ($num < 1) { $this->throw_error('10107'); #参数错误 } #获取玩家公会ID,验证公会信息 $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id'); if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取商店数据 $data = $this->get_data('UnionShop')->get_union_shop_info($union_id); if (!$data) { $this->throw_error('10110'); #数据错误 } $shop_type = ''; $type = intval($type); if ($type == 1) { $shop_type = 'prop_info'; $data['player_buy_info'] = Com_FmtData::cus_json_decode($data['player_buy_info']); } else { if ($type == 2) { $shop_type = 'buff_info'; } else { $this->throw_error('1715001'); #购买失败 } } if ($data[$shop_type] && !is_array($data[$shop_type])) { $data[$shop_type] = json_decode($data[$shop_type], true); } $shop_id = intval($shop_id); #BUFF存在 if ($type == 2 && $data[$shop_type][$shop_id]['record'][$player_id]) { $this->throw_error('1715001'); #购买失败 } #商品验证 if (!$data[$shop_type][$shop_id]) { $this->throw_error('1715005'); #道具不足 } #商品是否解锁 if ($data[$shop_type][$shop_id]['state'] != 1) { $this->throw_error('1715004'); #道具未解锁 } #购买职务验证 #获取玩家公会职务 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $job = $player_data['job_id']; if ($job > $data[$shop_type][$shop_id]['job_level']) { $this->throw_error('1715003'); #职务过低 } #获取公会商店等级 $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level'); #本次更新每个玩家可以购买的道具上限验证 $union_build_table = Cache_UnionBuild::getInstance()->get_union_build_info_two(array('build_type' => 'shop', 'build_lvl' => $shop_level)); if ($union_build_table['buy_limit'] > 0 && $data['player_buy_info'][$player_id] + $num > $union_build_table['buy_limit']) { $this->throw_error('1715009'); #本次刷新购买次数已满 } $time = time(); #道具数量验证 if ($data[$shop_type][$shop_id]['num'] < $num) { #刷新时间验证 if ($type == 1) { $next_refresh = 0; $update_prop_res = $this->check_shop_refresh($data['refresh_time'], $data[$shop_type], $next_refresh, $shop_level); if ($update_prop_res) { $update_data['refresh_time'] = $data['refresh_time']; #更新玩家购买次数 $data['player_buy_info'] = array(); } else { $this->throw_error('1715005'); #道具不足 } } else { if ($type == 2) { $record = $data[$shop_type][$shop_id]['record']; if (Com_Array::is_good_arr($record)) { foreach ($record as $pid => $re) { if ($time >= $re['expired_time']) { #增加商品数量 if ($data[$shop_type][$shop_id]['num'] + 1 < $data[$shop_type][$shop_id]['num_max']) { $data[$shop_type][$shop_id]['num']++; } else { $data[$shop_type][$shop_id]['num'] = $data[$shop_type][$shop_id]['num_max']; } #清除玩家购买记录 unset($data[$shop_type][$shop_id]['record'][$pid]); } } } #道具数量验证 if ($data[$shop_type][$shop_id]['num'] < $num) { $this->throw_error('1715005'); #道具不足 } /* #获取公会商店等级 $shop_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'shop_level'); #获取商店配置表 $shop_table = $this->get_cache_table_data('shop_table', array('level' => $shop_level, 'type' => $type)); if (!$shop_table || !$shop_table[0]['refresh_time']) { $this->throw_error('10109'); //配置表读取错误 } $next_time = $data[$shop_type][$shop_id]['next_refresh_time']; $refresh_time = $shop_table[0]['refresh_time'] * 3600; #更新下次刷新时间 $data[$shop_type][$shop_id]['next_refresh_time'] = $time + ($refresh_time - intval(($time - $next_time) % $refresh_time)); */ } else { $this->throw_error('1715005'); #道具不足 } } } #玩家贡献度验证 #获取玩家贡献度 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); if ($data[$shop_type][$shop_id]['contribution'] * $num > $player_data['total_dedicate']) { $this->throw_error('1715006'); #贡献度不足 } $player_name = $this->get_data('Player')->get_player_info($player_id, "name"); if ($type == 2) { #获取商店配置表 $shop_table = $this->get_cache_table_data('shop_table', array('level' => $shop_level, 'type' => $type)); if (!$shop_table || !$shop_table[0]['refresh_time']) { $this->throw_error('10109'); //配置表读取错误 } $refresh_time = $time + $shop_table[0]['refresh_time'] * 3600; #更新购买记录 $data[$shop_type][$shop_id]['record'][$player_id]['player_name'] = $player_name; $data[$shop_type][$shop_id]['record'][$player_id]['job'] = $job; $data[$shop_type][$shop_id]['record'][$player_id]['buy_time'] = $time; $data[$shop_type][$shop_id]['record'][$player_id]['expired_time'] = $refresh_time; } #扣除商品数量 $data[$shop_type][$shop_id]['num'] -= $num; #扣除贡献度 $front_amount_dedicate = $player_data['total_dedicate']; $dedicate = $data[$shop_type][$shop_id]['contribution'] * $num; $player_data['total_dedicate'] -= $dedicate; #增加公会记录 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $data[$shop_type][$shop_id]['name'], 'rep_color' => "ffb901"); $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, 1715007, $arr_replace); $this->start_trans(); if ($type == 1) { #发道具 $prop_info[] = array('type' => 'prop', 'item_id' => $data[$shop_type][$shop_id]['prop_id'], 'item_num' => $num); if (Com_Array::is_good_arr($prop_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '1715'), 1); if ($result !== true) { $this->throw_error('10104'); } } #记录玩家购买次数 $data['player_buy_info'][$player_id] += $num; $update_data['player_buy_info'] = json_encode($data['player_buy_info']); } $update_data[$shop_type] = json_encode($data[$shop_type]); #更新商店 $this->get_data('UnionShop')->update_union_shop($union_id, $update_data); #更新玩家贡献度 $this->get_data('UnionPlayer')->update_union_player_info($union_id, $player_id, $player_data); //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 2, 'item_id' => 11, 'item_num' => $dedicate, 'amount' => $front_amount_dedicate, 'after_amount' => $player_data['total_dedicate'], 'cmd_id' => 1715); Log_Common::getInstance()->add_log($log_data); $this->commit(); if ($type == 1) { $this->get_game('Reward')->add_reward_log(); } else { if ($type == 2) { #通知C++给玩家增加BUFF Protocol::input($player_id, 7, 4, 490, array('0' => $player_id, '1' => $data[$shop_type][$shop_id]['prop_id'])); } } $this->update_temporary_data($data); return array('0' => 1, '1' => $data[$shop_type][$shop_id]['prop_id']); }
/** * @Purpose: * 翅膀升级 * @Param $player_id 玩家ID * @Param $wing_id 翅膀ID * @Param $lucky_prop 消耗道具信息 */ public function wing_upgrade($player_id, $wing_id, $lucky_prop) { $player_id = intval($player_id); $wing_id = intval($wing_id); #获取玩家翅膀信息 $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key()); $data = $player_detail['wing_info']; if ($data[$wing_id]['show'] != 1 || $data[$wing_id]['activation'] != 2 || $data[$wing_id]['condition'][0] != 4) { $this->throw_error('150002'); #不可升级 } #获取下级数据 $wing_table = $this->get_cache_table_data('player_wing_table', array('id' => $wing_id, 'level' => $data[$wing_id]['lvl'] + 1)); if (!$wing_table[0]) { return array('0' => 2); #满级 } #获取玩家声望等级、金币 $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'fame_level', 'crystal', 'level', 'vip', 'ad_info', 'name', 'privilege_level')); if ($wing_table[0]['condition']) { list($type, $condition) = explode("|", $wing_table[0]['condition']); if ($type == 5) { if ($player_info['fame_level'] < $condition) { $this->throw_error('150004'); //声望不足 } } } $success_rate_add = 0; #升级道具验证 $material_prop = $this->format_table_field($wing_table[0]['expend_drop']); if (Com_Array::is_good_arr($material_prop)) { foreach ($material_prop as $id => $num) { if ($id >= 1 && $id <= 3) { #获取指定条件是否完成 } else { #获取玩家背包中的升级道具数量 $player_drop_num = $this->get_prop_num_by_player_bag($player_id, $id); if ($player_drop_num < intval($num)) { return array('0' => 3); #道具不足 } if (Com_Array::is_good_arr($lucky_prop)) { foreach ($lucky_prop as $prop) { #获取背包中幸运道具 $prop_num = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, $prop[0]); if ($prop[1] < 1 || $prop_num < $prop[1]) { return array('0' => 3); #道具不足 } #获取道具成功率加成 $prop_table = $this->get_cache_table_data('prop_table', $prop[0]); $success_rate_add += intval($prop_table['other']) * $prop[1]; } } } } } #升级前翅膀属性记录 $log_front_wing_attr = json_encode($data[$wing_id]['attr']); $log_front_level = $data[$wing_id]['lvl']; $log_front_attr = json_encode($data[$wing_id]); #概率升级 $upgrade = false; $rand = mt_rand(1, 100); if ($rand <= ($wing_table[0]['success_rate'] + $success_rate_add) / 100) { $upgrade = true; #数据更新 $data[$wing_id]['lvl'] = $wing_table[0]['level']; //技能分解 $skill_data = explode("|", $wing_table[0]['skill_id']); $data[$wing_id]['skill_id'] = $skill_data; /* if (Com_Array::is_good_arr($skill_data)) { unset($data[$wing_id]['skill_id']); foreach ($skill_data as $second_layer) { $data[$wing_id]['skill_id'][] = explode(":", $second_layer); } } */ $attr = $this->format_table_field($wing_table[0]['attr_add']); $data[$wing_id]['attr'] = $attr; $data[$wing_id]['fight'] = Formula_Fpower::calc_fpower($attr); $data[$wing_id]['fight'] += $data[$wing_id]['equipment_fight']; #玩家金币是否足够 $is_coin_num_res = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'crystal', $wing_table[0]['expend_coin'], 0); if ($is_coin_num_res !== true) { return array('0' => 5); #魔晶不足 } } else { #玩家金币是否足够 $is_coin_num_res = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'crystal', ceil($wing_table[0]['expend_coin'] / 2), 0); if ($is_coin_num_res !== true) { return array('0' => 5); #魔晶不足 } } $this->start_trans(); if ($upgrade) { $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $data)); if (!$update_res) { $this->throw_error('10104'); } } $deduct_coin = 0; #扣金币 if ($wing_table[0]['expend_coin']) { $deduct_coin = $wing_table[0]['expend_coin']; if (!$upgrade) { $deduct_coin = ceil($deduct_coin / 2); } $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1502); #$update_res = $this->get_data('Player')->update_player_silver($player_id, "-".$deduct_coin); if (!$update_res) { $this->throw_error('10104'); } } $deduct_prop = array(); #扣道具 if (Com_Array::is_good_arr($material_prop)) { $log = array('cmd_id' => 1502); foreach ($material_prop as $id => $num) { if ($id >= 1 && $id <= 3) { continue; } $deduct_num = $num; if (!$upgrade) { $deduct_num = ceil($deduct_num / 2); $deduct_prop[] = array($id, $deduct_num); } $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $id, $deduct_num, $log, 1, array('cmd_id' => 1502, 'level' => $player_info['level'], 'vip' => $player_info['vip'])); } if (Com_Array::is_good_arr($lucky_prop)) { foreach ($lucky_prop as $prop) { if ($prop[1] > 0) { #扣加成道具 $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $prop[0], $prop[1], $log, 1, array('cmd_id' => 1502, 'level' => $player_info['level'], 'vip' => $player_info['vip'])); } } } } if ($data[$wing_id]['fight'] > 0) { $this->get_data('RankList')->update_wing_rank($player_id, $wing_id, $data[$wing_id]['fight']); } $this->commit(); #更新临时数据区数据 $this->update_temporary_data($data); if (!$upgrade) { return array('0' => 0, '1' => 0, '2' => $deduct_prop, '3' => $deduct_coin); #升级失败 } #更新日志 $log_data = array('player_id' => $player_id, 'channel' => 7, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'type' => 6, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'cmd_id' => 1502, 'item_id' => $wing_id, 'item_name' => $data[$wing_id]['name'], 'front_attr' => $log_front_attr, 'after_attr' => json_encode($data[$wing_id]), 'add_time' => time()); Log_Common::getInstance()->add_log($log_data, 'day'); $log_data = array('player_id' => $player_id, 'channel' => 41, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'ad_info' => $player_info['ad_info'], 'cmd_id' => 1502, 'wing_id' => $wing_id, 'prop_id' => json_encode($material_prop), 'lucky_prop_id' => json_encode($lucky_prop), 'amount' => $log_front_wing_attr, 'after_amount' => json_encode($data[$wing_id]['attr']), 'amount_level' => $log_front_level, 'after_amount_level' => $data[$wing_id]['lvl'], 'add_time' => time()); Log_Common::getInstance()->add_log_by_table($log_data, 'log_wing_upgrade'); #公告广播 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id, 'rep_color' => "ffb901"); $arr_replace[] = array('rep_type' => 7, 'txt' => $data[$wing_id]['name'], 'rep_color' => "ffb901"); $arr_replace[] = array('rep_type' => 7, 'txt' => $data[$wing_id]['lvl'], 'rep_color' => "ffb901"); $this->get_game('SystemNotice')->push_sys_notice($player_id, 111, $data[$wing_id]['lvl'], $arr_replace); #更新翅膀升阶成就 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 27, $data[$wing_id]['lvl']); $player_detail['wing_info'] = $data; Protocol_Player::p2c_part_update($player_id, array('wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])))); return array('0' => 4); }
public function run() { $rurl = MAIN_DOMAIN_URL; $arrData = $this->_parseData; $strUserAccount = isset($arrData["account"]) ? trim($arrData["account"]) : ""; $iAdultFlag = isset($arrData["adult_flag"]) ? $arrData["adult_flag"] : 0; $iAdultGameTime = isset($arrData["game_time"]) ? $arrData["game_time"] : 0; $strClientIp = isset($arrData["ip"]) ? $arrData["ip"] : ""; $strAdInfo = isset($arrData["ad_info"]) ? trim($arrData["ad_info"]) : ""; $strTocken = isset($arrData['tocken']) ? $arrData['tocken'] : ""; $serverId = isset($arrData['sid']) ? $arrData['sid'] : 0; $active_type = isset($arrData['active_type']) ? $arrData['active_type'] : 1; if ($iAdultFlag == 0 && $iAdultGameTime >= 3 * 3600) { $msg = Cache_Language::getInstance()->get_language_info(10306); Com_System::url_msg_redirect($msg['content'], $rurl); exit; } $account_info = $this->get_data('Account')->get_account_info($strUserAccount); if (!$account_info || empty($account_info['name'])) { $_SESSION = array(); $_SESSION['sid'] = session_id(); $_SESSION["account"] = $strUserAccount; $_SESSION['client_ip'] = $strClientIp; $_SESSION['ad_Info'] = $strAdInfo; $_SESSION['server_id'] = $serverId; $_SESSION['vip'] = 0; $_SESSION['level'] = 0; $ad_info = $strAdInfo > 0 ? 1 : 0; if (isset($account_info['player_id']) && $account_info['player_id']) { $playerid = $account_info['player_id']; Com_DataCenter::getInstance()->publish_data($playerid, 'login', array('ad_info' => $ad_info, 'status' => 'on', 'keep_time' => 0, 'time' => $this->current_time)); } else { $playerid = $this->get_data('Account')->add_account($strUserAccount, '', $serverId, $strAdInfo); $log_data = array('player_id' => $playerid, 'channel' => 2, 'user_account' => $strUserAccount, 'ad_info' => $strAdInfo, 'client_ip' => $strClientIp, 'reg_time' => $this->current_time, 'type' => 0, 'add_time' => $this->current_time); Log_Common::getInstance()->add_log($log_data); Com_DataCenter::getInstance()->publish_data($playerid, 'est', array('ad_info' => $ad_info, 'step' => 'get', 'time' => $this->current_time)); } $_SESSION['player_id'] = $playerid; $_SESSION['name'] = ''; #zhe shi hou hai mei ming zi $_SESSION['career_type'] = ''; #zhe shi hou hai mei ming zi $_SESSION['active_type'] = $active_type; $_SESSION['adult_flag'] = $iAdultFlag; $this->get_game('Online')->write_session(); $arr_cache = array('player_id' => $playerid, 'name' => '', 'user_account' => $strUserAccount, 'ad_info' => $strAdInfo, 'reg_time' => 0, 'career_type' => 0, 'first_load' => 0); $this->get_data('Player')->set_rookie_loading_cache($playerid, $arr_cache); # -------------------------------------------------------------------- # 活动日志记录 # -------------------------------------------------------------------- /** $event_log_info = array( 'log_type' => 'login', 'player_id' => $_SESSION['player_id'], 'login_time' => $this->current_time, 'logout_time' => 0, ); $this->get_game('Event')->async_deal_event_log($event_log_info); **/ if ($iAdultFlag == 0) { $this->get_game('Adlut')->add_timer($playerid); #放沉迷定时器 } Com_System::url_redirect(SERVER_DOMAIN . '/index.php'); } else { if ($iAdultFlag == 0) { $flag = $this->get_data('Online')->get_adlut_ban($account_info['player_id']); if (!$flag) { $this->get_game('Adlut')->add_timer($account_info['player_id']); #放沉迷定时器 } if ($flag) { $msg = Cache_Language::getInstance()->get_language_info(10306); Com_System::url_msg_redirect($msg['content'], $rurl); exit; } } $client_ip = Com_System::get_client_ip(); $this->get_game('DailySign')->async_trigger_login_times($account_info['player_id']); $objPlayerData = $this->get_data('Player'); if ($account_info['player_id'] == $_SESSION['player_id']) { // Com_Log::log("account:{$account_info['player_id']} session:{$_SESSION['player_id']} sid:{$_SESSION['']}",'login_test',1); $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag, 'client_ip' => $client_ip); //上一次离线时长计算 $pinfo = $objPlayerData->get_player_info($account_info['player_id'], array('logout_time', 'heart_time', 'offline_reward_time')); $logout_time = max($pinfo['logout_time'], $pinfo['heart_time'], $pinfo['offline_reward_time']); $last_offline_time = $this->current_time - $logout_time; $up_arr['last_offline_time'] = $last_offline_time; $up_arr['offline_reward_time'] = $this->current_time; if ($last_offline_time >= 3600) { //1小时以上给奖励 $up_arr['offline_reward_status'] = 1; } else { $up_arr['offline_reward_status'] = 0; } //已经登录 $objPlayerData->update_player_info($account_info['player_id'], $up_arr); Com_System::url_redirect(SERVER_DOMAIN . '/index.php'); exit; } $arrUser = $objPlayerData->get_player_info($account_info['player_id']); if ($arrUser['is_ban'] == 3) { #封号了 Com_System::url_msg_redirect("亲爱的魔法师,由于您的账号数据存在异常,魔法管理员已暂时将您的账号封停,如有疑问可联系客服咨询。", $rurl); exit; } if (empty($arrData['nologin']) && $arrUser['ban_time'] > $this->current_time) { Com_System::url_redirect(SERVER_DOMAIN . '/index.php' . "?ecode=-15"); } $oldPlayerId = isset($_SESSION['player_id']) ? $_SESSION['player_id'] : 0; if ($oldPlayerId) { //如果有老的playerid 则生成新的session_id // session_regenerate_id(); } $_SESSION = array(); $_SESSION['sid'] = session_id(); $_SESSION["player_id"] = $arrUser["player_id"]; $_SESSION['active_type'] = 0; $_SESSION['name'] = $arrUser["name"]; $_SESSION["account"] = $strUserAccount; $_SESSION['career_type'] = $arrUser['career_type']; $_SESSION['adult_flag'] = $iAdultFlag; $_SESSION['ad_Info'] = $arrUser['ad_Info']; $_SESSION['client_ip'] = $strClientIp; $_SESSION['server_id'] = $serverId; $_SESSION['vip'] = $arrUser['vip']; $_SESSION['level'] = $arrUser['level']; $objOnline = $this->get_game('Online'); $objOnline->write_session(); $up_arr = array('session_id' => $_SESSION['sid'], 'adult_flag' => $iAdultFlag, 'client_ip' => $client_ip); //上一次离线时长计算 $logout_time = max($arrUser['logout_time'], $arrUser['heart_time'], $arrUser['offline_reward_time']); $last_offline_time = $this->current_time - $logout_time; $up_arr['last_offline_time'] = $last_offline_time; $up_arr['offline_reward_time'] = $this->current_time; if ($last_offline_time >= 3600) { //1个小时以上给奖励 $up_arr['offline_reward_status'] = 1; } else { $up_arr['offline_reward_status'] = 0; } $objPlayerData->update_player_info($arrUser["player_id"], $up_arr); //更新下session $log_data = array('player_id' => $arrUser["player_id"], 'channel' => 1, 'client_ip' => $strClientIp, 'game_client_ip' => $client_ip, 'reg_time' => $arrUser['reg_time'], 'ad_info' => $arrUser['ad_Info'], 'player_level' => $arrUser['level'], 'vip_level' => $arrUser['vip'], 'vip_special_level' => $arrUser['privilege_level']); #Log_Login::getInstance()->add_log($log_data); Log_Common::getInstance()->add_log($log_data, 'day'); $arr_cache = array('player_id' => $arrUser["player_id"], 'name' => $arrUser["name"], 'user_account' => $strUserAccount, 'ad_info' => $arrUser['ad_Info'], 'reg_time' => $arrUser['reg_time'], 'career_type' => $arrUser['career_type'], 'first_load' => $arrUser['first_load']); $this->get_data('Player')->set_rookie_loading_cache($arrUser["player_id"], $arr_cache); $ad_info = $strAdInfo > 0 ? 1 : 0; Com_DataCenter::getInstance()->publish_data($arrUser["player_id"], 'login', array('ad_info' => $ad_info, 'status' => 'on', 'keep_time' => 0, 'time' => $this->current_time)); if ($ad_info == 1) { #广告系统用户推送每天首次登陆 if (date('Ymd', $arrUser["reg_time"]) != date('Ymd') && date('Ymd') != date('Ymd', $arrUser["login_time"])) { $activelog = Com_System::send_request(array('user_account' => $arrUser['user_account']), 'login'); } } #记录登陆登出信息 $this->get_data('Online')->set_online_list($arrUser["player_id"], array('login_time' => $this->current_time, 'logout_time' => $arrUser['logout_time'])); // Com_Log::log("arrUser:{$arrUser["player_id"]} session:{$_SESSION['player_id']} sid:{$_SESSION['sid']}",'login_test',1); # -------------------------------------------------------------------- # 活动日志记录 # -------------------------------------------------------------------- /** $event_log_info = array( 'log_type' => 'login', 'player_id' => $_SESSION['player_id'], 'login_time' => $this->current_time, 'logout_time' => 0, ); $this->get_game('Event')->async_deal_event_log($event_log_info); **/ Com_System::url_redirect(SERVER_DOMAIN . '/index.php'); } }
/** * [train_upgrade 女神强化] * @param [type] $player_id [玩家ID] * @param [type] $fairy_id [女神ID] * @param [type] $auto_buy [是否自动购买] * @param [type] $improve_per [是否提高成功率] * @return [type] [0成功,1概率失败,2金币不足失败,3材料不足失败] */ public function train_upgrade($player_id, $fairy_id, $auto_buy, $improve_flag) { # 参数检查 $this->param_check_numeric(array($player_id, $auto_buy, $improve_flag), 0); # 获取玩家货币信息 $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level'))); if (empty($player_info)) { $this->throw_error('20002'); //没有玩家信息! } # 获取玩家女神信息 $fairy_info = $this->get_data('Fairy')->get_player_fairy_info($fairy_id); if (!$fairy_info) { $this->throw_error('10112'); //获取女神信息失败 } # 获取强化等级上限 $max_train_lv = Cache_FairyTrain::getInstance()->get_max_train_lv(); if (!empty($max_train_lv)) { $max_train_lv = $this->max_train_lv; } if ($fairy_info['train_level'] >= $max_train_lv) { $this->throw_error('80310'); //已满级 } # 获取升级到下一级的培养数据 $trainConfigs = $this->get_cache_table_data('fairy_train_table', array("lvl" => $fairy_info['train_level'])); if (!$trainConfigs[0] || empty($trainConfigs[0]['expend'])) { $this->throw_error('10109'); //配置表读取错误 } $train_config = $trainConfigs[0]; // 消耗需求 $cost_material = explode("|", $train_config['expend']); //升级下一级消耗 $costItemInfo = explode(':', $cost_material[0]); //道具消耗 $costGoldInfo = !empty($cost_material[1]) ? explode(':', $cost_material[1]) : 0; //金币消耗 #当期女神品阶是否达到强化品阶 if ($fairy_info['level'] < $train_config['fairy_lvl']) { $out_536 = array('result' => 5); Protocol::input($player_id, 3, 5, 536, $out_536); $message = array('texts' => array(array('code' => 536002, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); //536002 玩家的女神品阶没有达到当前强化需求 return; } # 强化所需材料检查 $cost_item_id = $costItemInfo[0]; $cost_item_num = intval($costItemInfo[1]); # 获取包裹中资源数量 $player_item_num = 0; # 添加了自动购买逻辑,故没有该材料时不能报错 $player_item_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $cost_item_id, 1); if (!empty($player_item_info)) { $items = array_values($player_item_info); foreach ($items as $key => $val) { $player_item_num += $val['item_num']; } } # 强化所需金币 $cost_silver_num = 0; $cost_silver_num = is_array($costGoldInfo) ? intval($costGoldInfo[1]) : 0; #勾选使用钻石提高成功率时钻石消耗 $cost_gold_num = 0; if ($improve_flag) { $cost_gold_num = $train_config['success_buy_gold']; } # 金币不足 if ($player_info['silver'] < $cost_silver_num) { $out_536 = array('result' => 2); Protocol::input($player_id, 3, 5, 536, $out_536); $message = array('texts' => array(array('code' => 10113, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); return; } # 钻石不足 if ($improve_flag && $player_info['gold'] < $cost_gold_num) { $out_536 = array('result' => 3); Protocol::input($player_id, 3, 5, 536, $out_536); $message = array('texts' => array(array('code' => 10108, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); return; } # 材料不足 玩家升级的女神之泪不足 if (!$auto_buy && $player_item_num < $cost_item_num) { $out_536 = array('result' => 4); Protocol::input($player_id, 3, 5, 536, $out_536); $message = array('texts' => array(array('code' => 536001, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); return; } # 成功率判断 $flag = false; $current_success_rate = $train_config['success_rate']; # 如果勾选了金币购买成功率 if ($improve_flag) { $current_success_rate += $train_config['success_buy_rate']; } # 成功率大于等于100%必定成功 if ($current_success_rate >= 100) { $flag = true; } else { # 根据概率值返回是否成功 if (Com_Random::probability($current_success_rate, 100)) { $flag = true; } } # 强化处理 $old_fairy_info = $fairy_info; $this->_train_handle($flag, $player_id, $cost_item_id, $cost_item_num, $player_item_num, $cost_silver_num, $cost_gold_num, $player_info, $fairy_info, $auto_buy, $improve_flag); # 强化成功 if ($flag) { #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 27, 1); $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 38, $fairy_info['train_level'], 8); } else { # 失败时提示消息 #失败返还一半消耗 $call_back_silver = floor($cost_silver_num / 2); $this->_return_faile_silver($player_id, $call_back_silver); $message = array('texts' => array(array('code' => 80910, 'content' => array(), 'params' => array()))); Protocol::input($player_id, 3, 7, 742, $message); } # 游戏日志记录 $log_data = array('player_id' => $player_id, 'channel' => 536, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'ad_info' => $player_info['ad_info'], 'cmd_id' => 536, 'player_fairy_id' => $fairy_id, 'fairy_code' => $fairy_info['fairy_code'], 'type' => $fairy_info['type'], 'old_train_level' => $old_fairy_info['train_level'], 'new_train_level' => $fairy_info['train_level'], 'old_train_attr' => json_encode($old_fairy_info['train_attr']), 'new_train_attr' => $flag ? $fairy_info['train_attr'] : json_encode($fairy_info['train_attr']), 'flag' => $flag ? 1 : 0); Log_Common::getInstance()->add_log_by_table($log_data, 'log_fairy_train'); $out_536['result'] = $flag ? 0 : 1; Protocol::input($player_id, 3, 5, 536, $out_536); }
/** * 同步公会加经验 * @param unknown $union_id * @param number $cmd_id */ public function add_union_reward_log() { if (!empty($this->arrPropLogs)) { foreach ($this->arrPropLogs as $item_id => $log) { if ($item_id == 9) { $this->get_data('PlayerDailyTime')->add_used_time($this->union_id, 'daily_add_union_exp', $log['item_num']); $this->get_data('UnionInfo')->set_union_weight($this->union_id, $this->arrUnion); if ($this->arrUnion['union_level'] > $this->arrParams['old_union_level']) { if ($this->arrUnion['union_level'] > 1) { $phrase_id = 1000 + $this->arrUnion['union_level']; $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $this->get_game('UnionPlayer')->send_mail($this->arrUnion['create_player_id'], $this->union_id, $phrase_config['title'], $phrase_config['content'], false); #祝贺{公会名}公会升级为{公会等级}级,成为服务器一大势力! $replace_info = array(); $replace_info[] = array('rep_type' => 7, 'txt' => $this->arrUnion['union_name']); $replace_info[] = array('rep_type' => 7, 'txt' => $this->arrUnion['create_player_name']); $replace_info[] = array('rep_type' => 7, 'txt' => $this->arrUnion['union_level']); $this->get_game('SystemNotice')->push_sys_notice($this->arrUnion['create_player_id'], 90, 0, $replace_info, $this->arrUnion['union_level']); $this->get_game('UnionAchieve')->async_trigger_union_achieve($this->arrUnion['create_player_id'], 1, $this->arrUnion['union_level'], 2); } $this->get_game('Union')->Sync_Union_msg($this->union_id, 0, 0, $this->arrUnion['union_level']); } } //公会经验-流水日志 $log_data = array('player_id' => $this->player_id, 'channel' => 17, 'type' => 1, 'item_id' => $item_id, 'item_num' => $log['item_num'], 'amount' => $log['amount'], 'after_amount' => $log['item_num'] + $log['amount'], 'cmd_id' => $this->arrParams['cmd_id'], 'content' => $this->union_id); Log_Common::getInstance()->add_log($log_data); } } }
public function CMD2_552() { $player_info = $this->get_data('Player')->get_player_info($this->_authuser['player_id'], array('level', 'vip', 'ad_info', 'career_type')); $log_data = array('player_id' => $this->_authuser['player_id'], 'channel' => 58, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'ad_info' => $player_info['ad_info'], 'career_type' => $player_info['career_type'], 'type' => $this->_param[1], 'city_id' => $this->_param[0], 'add_time' => time()); Log_Common::getInstance()->add_log_by_table($log_data, 'log_loading'); }
protected function batch_add_exp($player_id, $player_info, $add_exp) { if ($this->_begin_batch) { $this->_player_exps[$player_id] += $add_exp; } else { $player_info['exp'] += $add_exp; if ($player_info['level'] < 79 && $player_info['exp'] >= $player_info['level_exp']) { $this->get_game('PlayerUpgrade')->publish_upgrade($player_id, $player_info); $logs[] = array('type' => 1, 'item_id' => 1, 'item_num' => $add_exp, 'amount' => $player_info['exp'] - $add_exp, 'is_async' => 0); } else { $this->get_data('Player')->update_player_info($player_id, array('exp' => "+" . $add_exp)); $logs[] = array('type' => 1, 'item_id' => 1, 'item_num' => $add_exp, 'amount' => $player_info['exp'] - $add_exp); } Log_Common::getInstance()->add_multi_resource_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], 413, $logs); } }
/** * 战斗结算 * @param $guild_war_id 战斗id * @param $winner_role_id 胜利者 * @param $loser_role_id 失败者 * @param $out_flag 是否推送 C++异常是不推送 * @return null */ public function game_over($guild_war_id, $winner_role_id, $loser_role_id, $out_flag = true) { $guild_war_id = intval($guild_war_id); $winner_role_id = intval($winner_role_id); $loser_role_id = intval($loser_role_id); $time = $this->get_data('UnionGrabDomain')->get_revise_time($time); $day = date('Ymd', $time); if (!$guild_war_id) { return false; } $battle_info = $this->get_data('UnionGrabDomain')->get_battle_info($guild_war_id); if (!$battle_info || $battle_info['status']) { return false; } if (0 == $winner_role_id && 0 == $loser_role_id) { $out_flag = false; $attack_fpower = $this->get_data('Player')->get_player_info($battle_info['attack_player_id'], 'sum_fpower'); $defender_fpower = $this->get_data('Player')->get_player_info($battle_info['defender_player_id'], 'sum_fpower'); if ($attack_fpower >= $defender_fpower) { $is_win = 1; } else { $is_win = 0; } } else { if ($battle_info['attack_player_id'] == $winner_role_id && $battle_info['defender_player_id'] == $loser_role_id) { $is_win = 1; } elseif ($battle_info['defender_player_id'] == $winner_role_id && $battle_info['attack_player_id'] == $loser_role_id) { $is_win = 0; } else { return false; } } $player_id = $battle_info['attack_player_id']; $opp_player_id = $battle_info['defender_player_id']; $grab_player_info = $this->get_data('UnionGrabDomain')->get_player_info($day, $player_id); $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'level', 'union_id')); $opp_union_id = $this->get_data('Player')->get_player_info($opp_player_id, 'union_id'); $union_id = $player_info['union_id']; if (!$union_id || !$opp_union_id) { return false; } $grab_domain_info = $this->get_data('UnionGrabDomain')->get_domain_info($day); if (!$grab_domain_info || !in_array($union_id, $grab_domain_info['group_union']) || !in_array($opp_union_id, $grab_domain_info['group_union'])) { return false; } $grab_opp_union_info = $this->get_data('UnionGrabDomain')->get_union_info($day, $opp_union_id); if (1 != $grab_opp_union_info['status']) { //战斗标记未开启 return false; } if ($union_id != $grab_opp_union_info['opp_union_id']) { //不是敌方公会 return false; } if (!in_array($opp_player_id, $grab_opp_union_info['manor_info'])) { return false; } $grab_opp_manor_info = $this->get_data('UnionGrabDomain')->get_manor_info($day, $opp_player_id); if (isset($grab_opp_manor_info) && $grab_opp_manor_info['miss_star'] >= 3) { return false; //该领地已被我方占领 } $battle_star = $grab_player_info['battle_star']; if ($is_win) { $star = $battle_star - $grab_opp_manor_info['miss_star']; $update = array('miss_star' => $battle_star); $grab_win = $grab_opp_manor_info['win'] ? $grab_opp_manor_info['win'] : 0; } else { $star = 0; $grab_win = $grab_opp_manor_info['win'] + 1; } $update['is_fight'] = 0; $update['fight_player_id'] = 0; $update['fight_time'] = 0; $update['win'] = $grab_win; $battle_history = array('player_name' => $player_info['name'], 'hard' => $battle_star, 'result' => $is_win); $history = $grab_opp_manor_info['history'] ? $grab_opp_manor_info['history'] : array(); array_unshift($history, $battle_history); if (count($history) > 2) { array_pop($history); } $update['history'] = $history; $reward_conf = Cache_UnionGrabDomain::getInstance()->get_battle_reward($player_info['level']); if (!$reward_conf) { $this->throw_error(10222, 6010136); } $win_reward = ''; $arr_contri = explode(':', $reward_conf['reward_union']); $countribute = 0; $countribute_reward = ''; if ($is_win) { $win_reward = $reward_conf['reward_base']; if (11 == $arr_contri[0]) { $countribute = $arr_contri[1]; $countribute_reward = $arr_contri[0] . ':' . $countribute; } } else { $rewards = array(); $arr_reward = explode('|', $reward_conf['reward_base']); foreach ($arr_reward as $value) { $ar_re = explode(':', $value); $rewards[] = $ar_re[0] . ':' . intval($ar_re[1] / 2); } $win_reward = implode('|', $rewards); if (11 == $arr_contri[0]) { $countribute = intval($arr_contri[1] / 2); $countribute_reward = $arr_contri[0] . ':' . $countribute; } } $my_fight_log = array('battle_id' => $guild_war_id, 'player_id' => $player_id, 'union_id' => $union_id, 'opp_player_id' => $opp_player_id, 'opp_union_id' => $opp_union_id, 'battle_star' => $battle_star, 'result' => $is_win, 'win_star' => $star); #获取玩家公会数据 $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); $front_amount_dedicate = $player_data['total_dedicate']; //贡献 if ($countribute) { $base_reward = $win_reward . '|' . $countribute_reward; } else { $base_reward = $win_reward; } $send_reward = array(); $reward_detail = $this->get_game('Reward')->get_reward_detail($win_reward); $this->get_game('Reward')->gen_reward_array($reward_detail, $send_reward); $this->start_trans(); $result = $this->get_data('UnionGrabDomain')->set_manor_info($day, $opp_player_id, $update); if ($result) { $grab_player_update = array('battle_id' => 0, 'battle_star' => 0); if ($star) { $grab_player_update['star'] = '+' . $star; } $result = $this->get_data('UnionGrabDomain')->set_player_info($day, $player_id, $grab_player_update); } if ($result) { $result = $this->get_data('UnionGrabDomain')->set_battle_info($guild_war_id, array('status' => 1)); } if ($result && $star) { $result = $this->get_data('UnionGrabDomain')->set_union_info($day, $union_id, array('star' => '+' . $star)); } if ($result) { if ($send_reward && $out_flag) { $result = $this->get_game('Reward')->send_reward($player_id, $send_reward, array('cmd_id' => 2605)); if ($result !== true) { $this->throw_error($result, 6010135); } } elseif (!$out_flag) { if ($is_win) { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(9096); $content = sprintf($phrase_config['content'], $star); } else { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(9097); $content = $phrase_config['content']; } $attachment = array(); foreach ($reward_detail as $item_id => $item_num) { $attachment[] = array("prop_id" => $item_id, "prop_num" => $item_num); } $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $content, $attachment, $phrase_config['sender'], 2, 2605, 0); } } if ($result && $countribute) { $result = $this->get_game("UnionPlayer")->add_player_dedicate($player_id, $countribute); } if ($result) { $this->commit(); $this->get_game('Reward')->add_reward_log(); $this->get_data('UnionGrabDomain')->add_fight_log($my_fight_log); $out = array('result' => $is_win, 'star' => $star, 'base_reward' => $base_reward); if ($out_flag) { Protocol::input($player_id, 8, 26, 2605, $out); } if ($countribute) { //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $countribute, 'amount' => $front_amount_dedicate, 'after_amount' => $front_amount_dedicate + $countribute, 'cmd_id' => 2605); Log_Common::getInstance()->add_log($log_data); } } else { $this->rollback(); $this->throw_error('10104', 6010100); } return $result; }
public function CMD2_508() { $data = $this->get_game('UnionActivities')->enter_activities($this->_authuser['player_id'], $this->_param[0], $this->_param[1]); Protocol::input($this->_authuser['player_id'], 5, 4, 508, $data); $player_info = $this->get_data('Player')->get_player_info($this->_authuser['player_id'], array('level', 'vip', 'ad_info', 'career_type')); $log_data = array('player_id' => $this->_authuser['player_id'], 'channel' => 55, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'ad_info' => $player_info['ad_info'], 'career_type' => $player_info['career_type'], 'type' => 1, 'module_id' => $this->_param[1], 'add_time' => time()); Log_Common::getInstance()->add_log_by_table($log_data, 'log_enter'); }
public function use_temp_vip($player_id, $item_id) { $player_id = intval($player_id); $item_id = intval($item_id); $item_set = Cache_VipReward::getInstance()->get_vip_item($item_id); if (empty($item_id)) { return false; } $player_info = $this->get_data('Player')->get_player_info($player_id, array('vip', 'vip_exp', 'after_hero_hole', 'name')); if ($item_set['vip_level'] >= $player_info['vip']) { $data = array('add_time' => time() + $item_set['add_time'], 'vip_level' => $item_set['vip_level'], 'state' => 1); if ($this->get_data('VipReward')->update_temp_vip($player_id, $data)) { $update_data['vip'] = $item_set['vip_level']; $update_data['vip_temp_time'] = $data['add_time']; if ($item_set['vip_level'] > 0) { $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10057); if ($vip_table['vip_level'] > 0 && $item_set['vip_level'] >= $vip_table['vip_level']) { if ($player_info['after_hero_hole'] < 2) { #直接开启全部英雄位 $update_data['after_hero_hole'] = 2; } } } if ($this->get_data('Player')->update_player_info($player_id, $update_data)) { $param = array(array('rep_type' => 7, 'rep_val' => $item_set['vip_level']), array('rep_type' => 7, 'rep_val' => ceil($item_set['add_time'] / (24 * 3600)))); $attr_mag = array(); $attr_mag[] = Language_Message::make_message('80038', $param); $msg_out = array(0 => $attr_mag, 1 => 2000); Protocol::input($player_id, 8, 7, 742, $msg_out); Protocol_Player::p2c_part_update($player_id, array('vip' => $item_set['vip_level'], 'vip_temp_time' => $item_set['add_time'])); #广播通知 $replace_info = array(); $replace_info[] = array('rep_type' => 7, 'txt' => $player_info['name']); $replace_info[] = array('rep_type' => 7, 'txt' => $item_set['vip_level']); $this->get_game('SystemNotice')->push_sys_notice($player_id, 130, 0, $replace_info, $item_set['vip_level']); #vip增加背包格子数量 $out = $this->get_game('PlayerBag')->get_vip_bag_storage_num($player_id); Protocol::input($player_id, 8, 8, 844, $out); # 条件问卷查询推送 $this->get_game('ActivityQuestions')->get_cond_ids($player_id); #更新签到奖励 $this->get_game('DailySign')->async_trigger_daily_sign($player_id, $item_set['vip_level']); #添加日志 $log_data = array('player_id' => $player_id, 'channel' => 3, 'item_level' => $player_info['vip'], 'item_num' => $player_info['vip_exp'], 'amount' => 0, 'after_amount' => $player_info['vip_exp'], 'after_attr' => $update_data['vip']); Log_Common::getInstance()->add_log($log_data); return true; } else { $this->throw_error(10110, 2010088); return false; } return true; } else { return false; } } else { $this->throw_error(80037); } return true; }
/** * @Purpose: * 批量删除英雄 * @param $player_id 玩家ID * @param $hero_list 英雄列表(包括英雄ID,英雄品质) * @param $player_info 玩家信息 */ private function del_hero_list($player_id, $hero_list, $player_info) { if (Com_Array::is_good_arr($hero_list)) { $obj_player_hero_data = $this->get_data('PlayerHero'); $obj_player_prop_data = $this->get_data('PlayerProp'); $obj_player_bag_game = $this->get_game('PlayerBag'); $time = time(); foreach ($hero_list as $hero_id => $quality) { //获取英雄数据 $hero_data = $obj_player_hero_data->get_player_hero_info($player_id, $hero_id); $hero_data['rune_hole_list'] = Com_FmtData::cus_json_decode($hero_data['rune_hole_list']); if ($hero_data['rune_hole_list']) { foreach ($hero_data['rune_hole_list'] as $val) { //如果英雄有镶嵌的符文,则卸下符文 if ($val['state'] == 2) { $rune_data = $obj_player_prop_data->get_player_prop_detail($player_id, $val['id']); if ($rune_data) { $empty_pos = $this->get_game('Prop')->get_empty_pos($player_id, 1); if ($empty_pos === false) { $this->throw_error('80001'); //包裹已满 } $obj_player_bag_game->prop_set_position($rune_data, $this->bag_pos, $empty_pos[0]); //创建更变数据 $rune_data['item_position'] = $this->bag_pos; $rune_data['grid'] = $empty_pos[0]; $rtn_data[] = $rune_data; Protocol_Prop::prop_806($player_id, $rtn_data); } } } } //删除英雄 $hero_del_res = $obj_player_hero_data->delete_player_hero($player_id, $hero_id, $quality); if (!$hero_del_res) { $this->throw_error('10104'); } $this->get_data('RankList')->del_hero_from_rank($hero_id); //更新英雄培养数据 #$this->update_hero_culture_data($player_id, 0, $hero_data['hero_code']); #更新日志 $log_data = array('player_id' => $player_id, 'channel' => 18, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'type' => 5, 'cmd_id' => 512, 'item_id' => $hero_id, 'item_name' => $hero_data['name'], 'item_quality' => $quality, 'item_level' => $hero_data['level'], 'item_num' => 1, 'add_time' => $time); Log_Common::getInstance()->add_log($log_data); } } }
public function player_upgrade_fame($data) { if (empty($data)) { return false; } $data = json_decode($data, true); $player_id = $data['player_id']; $fame = $data['fame']; $old_fame_level = intval($data['fame_level']); $fame_level_exp = $data['fame_level_exp']; $level = $data['level']; $vip = $data['vip']; $privilege_level = $data['privilege_level']; $logs = array(); // Com_Log::write('xgame.player_fame_upgrade',var_export($data,true)); $update = array(); $max_level = Cache_PlayerFame::getInstance()->get_fame_max_level(); if ($old_fame_level >= $max_level) { return false; } $level = $this->get_update_fame_level($old_fame_level, $fame, $logs); $this->start_trans(); $update['fame'] = $level['fame'] < 0 ? 0 : $level['fame']; $update['fame_level'] = $level['fame_level']; $update['fame_level_exp'] = $level['fame_level_exp']; // Com_Log::write('xgame.player_fame_upgrade',"update"); // Com_Log::write('xgame.player_fame_upgrade',var_export($update,true)); $ret_attr = true; if ($update['fame_level'] > $old_fame_level) { $level_config = Cache_PlayerFame::getInstance()->get_player_fame_info($update['fame_level']); $fame_attr = array(); $fame_attr['atk_min'] = $level_config['atk_min']; $fame_attr['hp'] = $level_config['max_hp']; $fame_attr['arm'] = $level_config['arm']; $update_player_detail_data['fame_attr'] = $fame_attr; $obj_player_detail = $this->get_data('PlayerDetail'); $ret_attr = $obj_player_detail->update_player_detail($player_id, $update_player_detail_data); } $result = $this->get_data('Player')->update_player_info($player_id, $update); if ($result && $ret_attr) { $this->commit(); if ($logs) { Log_Common::getInstance()->add_multi_resource_log($player_id, $level, $vip, $privilege_level, 103, $logs); } $arr_player['fame'] = $update['fame']; $arr_player['fame_level'] = $update['fame_level']; $arr_player['fame_level_exp'] = $update['fame_level_exp']; $arr_player['fame_attr'] = array(); $arr_player['attr'] = array(); Protocol_Player::p2c_part_update($player_id, $arr_player); if ($update['fame_level'] > $old_fame_level) { if ($update['fame_level'] > 1) { #{玩家名}的声望达到了{声望名},真是厉害! $level_config = Cache_PlayerFame::getInstance()->get_player_fame_info($update['fame_level']); $replace_info = array(); $replace_info[] = array('rep_type' => 0, 'rep_val' => $player_id); $replace_info[] = array('rep_type' => 7, 'txt' => $level_config['title']); $this->get_game('SystemNotice')->push_sys_notice($player_id, 15, 0, $replace_info, $update['fame_level']); #升级提示 $hero_list = $level_config['hero_sid'] ? explode("|", $level_config['hero_sid']) : array(); $notice = array(); $notice['lvl'] = $level_config['lvl']; $notice['fame'] = $level_config['exp']; $notice['atk_min'] = $level_config['atk_min']; $notice['max_hp'] = $level_config['max_hp']; $notice['arm'] = $level_config['arm']; $notice['wing_lvl'] = intval($level_config['wing_lvl']); $notice['fairy_lvl'] = intval($level_config['fairy_lvl']); $notice['hero_list'] = $hero_list; $notice['title'] = $level_config['title']; Protocol::input($player_id, 8, 7, 747, $notice); if (!IS_FRONT) { Protocol::out(); } // Com_Log::debug_write('player_upgrade_fame', "player_id={$player_id}".json_encode($notice)); } } return false; } else { $this->rollback(); } return $update; }
public function strenglen_action($player_id, $id) { $player_id = intval($player_id); $id = intval($id); $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'name', 'silver', 'ticket', 'gold', 'player_id', 'level', 'vip', 'fame', 'privilege_level')); $level_info = $this->get_union_by_id($id); if ($player_info['union_id'] == 0) { $this->throw_error(171101); } if (empty($level_info)) { $this->throw_error('10222', 2010069); } if ($level_info['type_id'] == 2) { $vip_limit = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10040); if (!empty($vip_limit)) { if ($player_info['vip'] < $vip_limit['vip_level']) { $this->throw_error('11089'); } } } elseif ($level_info['type_id'] == 3) { $vip_limit = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10041); if (!empty($vip_limit)) { if ($player_info['vip'] < $vip_limit['vip_level']) { $this->throw_error('11089'); } } } #判断消耗 $res = array(); $res['res'] = 1; #1强化成功 2金币不足 3次数用完 $old = 0; $arr_consume = array(); if ($level_info['cost_type'] == 3) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', abs($level_info['cost_num'])); } elseif ($level_info['cost_type'] == 2 || $level_info['cost_type'] == 20) { #先扣除彩钻 $cost = abs($level_info['cost_num']); $ticket = 0; $gold = $cost; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] >= $cost) { $ticket = $cost; $gold = 0; } else { $ticket = $player_info['ticket']; $gold = $cost - $player_info['ticket']; } } $arr_consume = array('price' => $cost, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost, 1, 1); } else { $this->throw_error('10222', 2010070); } #判断今日次数 $union_conf = Cache_UnionBase::getInstance()->get_union_conf(); if (empty($union_conf)) { $this->throw_error(10222, 2010071); } else { if (isset($union_conf['max_bomb_time'])) { $used = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_bomb_count'); if ($used >= $union_conf['max_bomb_time']) { $this->throw_error(174401); } } else { $this->throw_error(10222, 2010072); } } $res['res'] = 1; $union_info = $this->get_data('UnionInfo')->get_union_info($player_info['union_id']); $res['bomb_exp'] = isset($union_info['bomb_exp']) ? $union_info['bomb_exp'] : 0; $res['max_exp'] = $level_info['max_exp']; $res['bomb_level'] = $level_info['level']; if ($res['res'] == 1) { #扣消耗 #$this->start_trans(); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1723, array(), $arr_consume); if (false !== $result) { #保存记录 $this->save_strength_log($player_info['union_id'], $player_id, $player_info['name'], $level_info); #福利大厅任务接口 if ($level_info['type_id'] == 3) { $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9040_2'); } $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9040_1'); $update = array(); $update['fund'] = (isset($union_info['fund']) ? $union_info['fund'] : 0) + $level_info['union_fund']; $update['bomb_exp'] = (isset($union_info['bomb_exp']) ? $union_info['bomb_exp'] : 0) + $level_info['bomb_exp']; $update['bomb_up_exp'] = (isset($union_info['bomb_up_exp']) ? $union_info['bomb_up_exp'] : 0) + $level_info['bomb_exp']; $update['bomb_level'] = isset($union_info['bomb_level']) ? $union_info['bomb_level'] : 1; #判断是否升级 $up = false; if ($update['bomb_up_exp'] >= $level_info['max_exp']) { $nowLvl = isset($union_info['bomb_level']) ? $union_info['bomb_level'] : 1; if ($union_info['union_level'] > $nowLvl) { $update['bomb_level'] = $nowLvl + 1; $update['bomb_up_exp'] -= $level_info['max_exp']; $level_info['max_exp'] = $this->get_max_exp($update['bomb_level']); $up = true; } else { $update['bomb_up_exp'] = $level_info['max_exp']; $update['bomb_level'] = $nowLvl; } } if ($up) { //添加日志 $arr_replace = array(); $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $player_info['union_id'], 173902, $arr_replace); $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 23, $update['bomb_level'], 2); } //添加日志 $arr_replace = array(); $type_name = ''; if ($level_info['type_id'] == 1) { $type_name = '初级强化'; } elseif ($level_info['type_id'] == 2) { $type_name = '中级强化'; } elseif ($level_info['type_id'] == 3) { $type_name = '高级强化'; $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 16, 1, 1); } $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'rep_val' => $type_name); #强化类型 $arr_replace[] = array('rep_type' => 7, 'rep_val' => $level_info['player_dedicate']); #公会贡献 $arr_replace[] = array('rep_type' => 7, 'rep_val' => $level_info['union_fund']); #公会资金 $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $player_info['union_id'], 173901, $arr_replace); #贡献玩家贡献-声望 $this->get_game('Reward')->send_reward($player_id, array(array('type' => Cache_FbLoot::getInstance()->get_item_key(14), 'item_id' => 14, 'item_num' => $level_info['fame'])), array('cmd_id' => '1723')); $myinfo = $this->get_data("UnionPlayer")->get_union_player_info($player_info['union_id'], $player_id); $myold = isset($myinfo['total_dedicate']) ? $myinfo['total_dedicate'] : 0; $myinfo['total_dedicate'] = $myold + $level_info['player_dedicate']; $this->get_game("UnionPlayer")->add_player_dedicate($player_id, $level_info['player_dedicate']); $this->get_data("UnionInfo")->update_union_info($player_info['union_id'], $update); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'union_bomb_count'); $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $used + 1, $union_conf['max_bomb_time'], 3, 3); $res['bomb_exp'] = $update['bomb_up_exp']; $res['max_exp'] = $level_info['max_exp']; $res['bomb_level'] = $update['bomb_level']; $res['id'] = $id; $res['total_dedicate'] = $myold + $level_info['player_dedicate']; $res['fund'] = $update['fund']; $res['fame'] = $player_info['fame'] + $level_info['fame']; #变形金刚让加一个声望字段 $this->get_game('Reward')->add_reward_log(); #$this->commit(); #任务埋点 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 12, 1, 1); //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $level_info['player_dedicate'], 'amount' => $myold, 'after_amount' => $myinfo['total_dedicate'], 'cmd_id' => 1723); Log_Common::getInstance()->add_log($log_data); $this->get_game('Union')->Sync_Union_msg($player_info['union_id']); } else { #$this->rollback(); $this->throw_error('10110', 2010073); } } return $res; }
/** * 更新人物资源的 统一接口 此方法配合check_player_resource使用 更新 $_resource_field 里要更新资源 * @param $player_id * @param $player_info player表里的信息 里面至少包含 player_id level vip $cur_key对应的字段 * @param $cmd_id cmd2 * @param array $other_update 其他一起更新的字段 * @param array $arr_consume array(price,gold,ticket,count) or array() 数据中心 prop数据(gold and ticket消耗) * @return bool */ public function update_player_resource($player_id, $player_info, $cmd_id, $other_update = array(), $arr_consume = array()) { if (empty($this->_resource_update_field)) { return false; } $update = array(); $logs = array(); // foreach($this->_resource_update_field as $cur_key=>$val){ // if ($cur_key == 'exp') { # 跳过经验 // # do nothing // } else { // $update[$cur_key] = $val; // } // } foreach ($this->_resource_update_field as $cur_key => $resources) { if ($cur_key == 'exp') { continue; } # 跳过经验 if ($resources) { $num = 0; foreach ($resources as $val) { $num += $val; } if ($num > 0) { $update[$cur_key] = "+" . abs($num); } else { $update[$cur_key] = "-" . abs($num); } } } // var_dump($update);exit; if (!empty($other_update)) { $update = array_merge($update, $other_update); } foreach ($this->_resource_log_field as $val) { if ($val['cur_key'] == 'exp') { # 补发经验 $re = $this->get_game('Reward')->send_reward($player_id, array(array('type' => 'exp', 'item_id' => 1, 'item_num' => $val['item_num'])), array('cmd_id' => $cmd_id)); } else { $item_id = Cache_Currency::getInstance()->get_index($val['cur_key']); $logs[] = array('type' => $val['type'] == "+" ? 1 : 2, 'item_id' => $item_id, 'item_num' => $val['item_num'], 'amount' => $val['amount']); } } $res = $this->update_player_info($player_id, $update); if ($res) { if ($this->is_trans()) { $obj = Log_Common::getInstance(); $this->set_redis_pre_action(null, array($obj, 'add_multi_resource_log'), array($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], $cmd_id, $logs, $arr_consume)); } else { // Com_Log::write('log_log',json_encode($logs)); Log_Common::getInstance()->add_multi_resource_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], $cmd_id, $logs, $arr_consume); } } $this->_resource_log_field = array(); $this->_resource_update_field = array(); return $res; }
/** * 公会建筑升级 */ public function build_upgrade($player_id, $union_id, $npc_sid) { $npc_sid = intval($npc_sid); $union_id = intval($union_id); $objUnionInfoData = $this->get_data('UnionInfo'); $unionInfo = $objUnionInfoData->get_union_info($union_id); $objUnionPlayerData = $this->get_data('UnionPlayer'); $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id); if (empty($unionPlayerInfo)) { $this->throw_error('171001'); //该玩家未加入该公会 } if ($unionPlayerInfo["job_id"] > 2) { $this->throw_error('170701'); //无权操作 } $build_type = $this->get_game('Union')->get_build_type($npc_sid); if (!$build_type) { $this->throw_error('173601'); //不存在该建筑 } //当前建筑ID对应的Redis字段 $redisLevelField = $build_type . "_level"; //当前建筑等级,默认等级为1级 $unionInfo[$redisLevelField] = intval($unionInfo[$redisLevelField]) ? $unionInfo[$redisLevelField] : 1; $front_upgrade_level = $unionInfo[$redisLevelField]; $objUnionBuildConfig = Cache_UnionBuild::getInstance(); $unionBuildLevelConfig = $objUnionBuildConfig->get_union_build_info($npc_sid, $unionInfo[$redisLevelField]); //1.公会资金2.经验 if ($unionBuildLevelConfig['lvl_up_cost_type'] != 1) { $this->throw_error('173603'); //该建筑不能升级 } $max_level = $objUnionBuildConfig->get_union_build_max_level($build_type); if ($unionInfo[$redisLevelField] >= $max_level) { $this->throw_error('173602'); //建筑已升级到最大等级 } if (empty($unionBuildLevelConfig)) { $this->throw_error('10222'); //配置错误 } $unionInfo[$redisLevelField] += 1; if ($unionInfo[$redisLevelField] > $unionInfo['union_level']) { $this->throw_error('173504'); //该建筑等级不能大于公会大厅等级 } //1.公会资金2.经验 if ($unionInfo['fund'] < $unionBuildLevelConfig['lvl_up_cost_num']) { $this->throw_error('173503'); } $unionInfo['fund'] = "-" . $unionBuildLevelConfig['lvl_up_cost_num']; //更改升级后的npc_sid $npc_sid = $this->get_game('Union')->get_build_sid($build_type, $unionInfo[$redisLevelField]); $unionInfo[$build_type . '_sid'] = $npc_sid; $this->start_trans(); Com_Log::debug_write('update_union_info', "build_upgrade|unoin_id={$union_id}" . json_encode($unionInfo)); $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $unionInfo); if ($retUnionInfo) { $this->commit(); $this->get_game('Union')->Sync_Union_msg($union_id); } else { $this->rollback(); $this->throw_error('10101'); } if ($build_type == "shop") { $this->get_game('UnionShop')->union_shop_upgrade($union_id, $unionInfo[$redisLevelField]); //公会成就商店升级 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 20, $unionInfo[$redisLevelField], 2); } else { if ($build_type == "hall") { //福利大厅 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 21, $unionInfo[$redisLevelField], 2); } else { if ($build_type == "wanted") { //通缉 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 14, $unionInfo[$redisLevelField], 2); } else { if ($build_type == "tech") { //魔法科技 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 22, $unionInfo[$redisLevelField], 2); //魔法科技-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 54, 'type' => 6, 'item_id' => 0, 'item_num' => $unionInfo[$redisLevelField] - $front_upgrade_level, 'amount' => $front_upgrade_level, 'after_amount' => $unionInfo[$redisLevelField], 'cmd_id' => 1732); Log_Common::getInstance()->add_log($log_data); } } } } //发邮件 /* $phrase_id = 1000 + $unionInfo[$redisLevelField]; $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id); $this->get_game('UnionPlayer')->send_mail($player_id,$union_id, $phrase_config['title'], $phrase_config['content'],false); */ //添加日志 //%player_name% 消耗了 %s 公会资金升级了公会建筑 %d //广播建筑升级 $arr_replace = array(); $arr_replace[] = array('rep_type' => 7, 'txt' => $unionBuildLevelConfig['build_name']); $arr_replace[] = array('rep_type' => 7, 'txt' => $unionInfo[$redisLevelField]); $msg = Language_Message::make_message(171015, $arr_replace); $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7); $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $unionBuildLevelConfig['lvl_up_cost_num']); $arr_replace[] = array('rep_type' => 7, 'txt' => $unionBuildLevelConfig['build_name']); $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $union_id, 173604, $arr_replace); return array($union_id, $npc_sid, $unionInfo[$redisLevelField]); }
/** * 触发成就任务 * @param unknown $player_id */ public function trigger_achieve_target($data) { if (empty($data)) { return; } $data = json_decode($data, true); $player_id = $data["player_id"]; $achieve_type = $data["achieve_type"]; $trigger_val = $data["val"]; $update_type = $data["update_type"]; Com_Log::write('xgame.trigger_achieve_target', "{$player_id}---{$achieve_type}" . json_encode($data)); $achieve_configs = Cache_AchieveConfig::getInstance()->get_achieve_config_by_type($achieve_type); $obj_player_counter = $this->get_data('PlayerAchieveCounter'); $achieve_counter_type_progress = $obj_player_counter->get_player_achieve_counter_info($player_id, array("finish_title_ids", "task_type_progress")); $obj_player_only = $this->get_data('PlayerAchieveOnly'); $objPlayerAchieve = $this->get_data('PlayerAchieve'); $push_achieve_prompt1 = array(); $push_achieve_prompt2 = array(); $push_achieve_prompt3 = array(); //2014-4-16是否添加过下一个要完成的值 $is_added_next_target_val = 0; $push_prompt_title_id = 0; $push_prompt_achieve_id = 0; $finish_num = 0; $loot_times = 0; $achieve_counter_data = $obj_player_counter->get_player_achieve_counter_info($player_id, array("task_type_progress")); $player_achieve_data = $objPlayerAchieve->get_player_achieve_info($player_id); foreach ($achieve_configs as $achieve_config) { $loot_times++; $title_id = $achieve_config['title_id']; $achieve_id = $achieve_config['achieve_id']; #当前勋章下所有成就 $player_achieve_info = $player_achieve_data[$title_id]; if (isset($achieve_counter_data["task_type_progress"][$achieve_type]['val']) && !in_array($achieve_type, array(6, 28, 29, 24, 35, 36, 40, 48))) { $player_achieve_info[$achieve_config['achieve_id']]['val'] = $achieve_counter_data["task_type_progress"][$achieve_type]['val']; } $oldval = $player_achieve_info[$achieve_config['achieve_id']]['val']; #2014-4-14修改把配置表类型移到代码中 $achieve_config["target_type"] = $update_type; //检查是否满足条件 $check_finish = $this->check_achieve_finish($player_id, $trigger_val, $achieve_config, $player_achieve_info); $newval = $player_achieve_info[$achieve_config['achieve_id']]['val']; $prop_id = intval($achieve_config['reward']); if ($player_achieve_info[$achieve_id]['state'] == 1) { $finish_num++; } if ($is_added_next_target_val == 0) { $add_trigger_type_info = array(); $add_trigger_type_info['type'] = $achieve_type; $add_trigger_type_info['update_type'] = $update_type; $add_trigger_type_info['val'] = $newval; $add_trigger_type_info['is_sys'] = 1; } //完成=>所有此类型 if ($finish_num == count($achieve_configs) && $is_added_next_target_val == 0) { $add_trigger_type_info['next_target_val'] = 999999999; $is_added_next_target_val = 1; } //全服唯一 if ($achieve_config['other_type'] == 1) { $achieve_only_info = $obj_player_only->get_player_achieve_only_info($achieve_id); if ($achieve_only_info) { continue; } } Com_Log::write('xgame.trigger_achieve_medal_test', "{$player_id}--{$achieve_type}--{$oldval}--{$newval}--{$check_finish}"); //未完成 if ($oldval == $newval && $check_finish != 1) { if ($check_finish !== 2 && $is_added_next_target_val == 0) { $add_trigger_type_info['next_target_val'] = $achieve_config['target_val']; $is_added_next_target_val = 1; } continue; //无变化不更新 } //未完成-变化 if ($check_finish == 0 && $is_added_next_target_val == 0) { $add_trigger_type_info['next_target_val'] = $achieve_config['target_val']; $is_added_next_target_val = 1; } $this->start_trans(); $ret_task = $objPlayerAchieve->update_player_achieve($player_id, $title_id, $player_achieve_info, $achieve_id); if (!$ret_task) { return false; } if ($check_finish == 0) { $this->commit(); continue; } $ret_only = true; //更新全服唯一成就完成信息 if ($achieve_config['other_type'] == 1) { $achieve_only_info = array("achieve_id" => $achieve_id, "player_id" => $player_id, "add_time" => time()); $ret_only = $obj_player_only->update_player_achieve_only($achieve_config['achieve_id'], $achieve_only_info); if (!$ret_only) { return false; } } $target_finish_num = 0; #获取配置表下当前勋章所有成就任务 $achieve_title_data = Cache_AchieveConfig::getInstance()->get_achieve_config_by_titleid2($title_id); $target_total_num = count($achieve_title_data); //玩家完成的成就任务 if ($player_achieve_info) { foreach ($player_achieve_info as $achieve_id => $val) { if (isset($achieve_title_data[$achieve_id])) { if ($val['state'] == 1) { $target_finish_num++; } } } } //当前成就列任务是否全部完成 if ($target_finish_num >= $target_total_num && $target_total_num > 0) { $field = "finish_title_ids"; $ret_counter = true; if ($title_id < 100 || $prop_id < 1) { $achieve_counter_data = $obj_player_counter->get_player_achieve_counter_info($player_id, $field); $achieve_counter_data[$title_id] = time(); //激活新的勋章/称号 $set_counter_data[$field] = $achieve_counter_data; $ret_counter = $obj_player_counter->update_player_achieve_counter($player_id, $set_counter_data); if (!$ret_counter) { return false; } } $reward = array(); //如果为勋章添加提升属性 if ($title_id < 100) { $finish_medal_id = array(); $finish_max_medal_id = 0; if (Com_Array::is_good_arr($achieve_counter_type_progress["finish_title_ids"])) { foreach ($achieve_counter_type_progress["finish_title_ids"] as $finish_title_id => $up_ts) { if ($finish_title_id < 100) { $finish_medal_id[] = $finish_title_id; } } } #防止后面勋章先完成 if (!empty($finish_medal_id)) { $finish_max_medal_id = max($finish_medal_id); } if ($title_id > $finish_max_medal_id) { $title_config = Cache_TitleConfig::getInstance()->get_title_config_by_id($title_id); $achieve_attr_1 = $this->get_format_achieve_attr($title_config['reward']); $update_player_detail_data['achieve_attr_1'] = $achieve_attr_1; $ret_attr_1 = $this->get_data('PlayerDetail')->update_player_detail($player_id, $update_player_detail_data); if (!$ret_attr_1) { return false; } $ret_player = $this->get_data('Player')->update_player_info($player_id, array("medal_id" => $title_id)); if (!$ret_player) { return false; } Com_Log::write('xgame.trigger_achieve_medal', "{$player_id}---{$achieve_type}---trigger_medal_id={$title_id}"); } $push_achieve_prompt2 = array(2, $title_config['icon'], $title_config['font_icon'], "", 0, $title_id, 0); } else { $title_config = Cache_TitleConfig::getInstance()->get_title_config_by_id($title_id); #if($title_config['operator_id'] !=0 && OPERATOR_ID!=$title_config['operator_id']) return false; if ($prop_id > 0) { $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($achieve_config['title_id']); $attachment = array(); $attachment[] = array("prop_id" => $prop_id, "prop_num" => 1); $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 766); } } $this->commit(); $push_prompt_achieve_id = $achieve_config['achieve_id']; $push_prompt_title_id = $title_id; Protocol_Player::p2c_part_update($player_id, array('attr' => array(), 'medal_id' => '')); if ($title_id < 100) { #{玩家名}获得了{勋章名},功成名就,指日可待! $replace_info = array(); $replace_info[] = array('rep_type' => 0, 'rep_val' => $player_id); $replace_info[] = array('rep_type' => 7, 'txt' => $title_config['title_name']); $this->get_game('SystemNotice')->push_sys_notice($player_id, 14, 0, $replace_info); } } else { if (!$ret_only) { return false; } $this->commit(); $push_prompt_achieve_id = $achieve_config['achieve_id']; $push_prompt_title_id = $title_id; } //任务完成添加成就点 if ($achieve_config['achieve_point'] > 0) { $player_info = $this->get_data('Player')->get_player_info($player_id, array("achieve_point", "level", "vip")); $front_amount_achieve_point = intval($player_info["achieve_point"]); $player_info["achieve_point"] += $achieve_config['achieve_point']; $ret_player = $this->get_data('Player')->update_player_info($player_id, $player_info); if (!$ret_player) { return false; } //主角成就日志 $log_data = array('player_id' => $player_id, 'channel' => 29, 'type' => 1, 'item_id' => 12, 'item_num' => $achieve_config['achieve_point'], 'amount' => $front_amount_achieve_point, 'after_amount' => $player_info['achieve_point'], 'cmd_id' => 768, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip']); Log_Common::getInstance()->add_log($log_data, 'day'); } } #特殊类型不保留下一步记录 if (!in_array($achieve_type, $this->special_task_type)) { if ($is_added_next_target_val == 1) { $add_trigger_type_info['upts'] = time(); $task_type_progress = $obj_player_counter->get_player_achieve_counter_info($player_id, array("task_type_progress")); $task_type_progress["task_type_progress"][$achieve_type] = $add_trigger_type_info; $ret = $obj_player_counter->update_player_achieve_counter($player_id, $task_type_progress); if (!$ret) { return false; } } } $func_open = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'func_open'); if (isset($func_open[14])) { if ($push_prompt_title_id > 0) { if ($push_achieve_prompt2) { Protocol::input($player_id, 8, 7, 768, array($push_achieve_prompt2)); Com_Log::debug_write('xgame.push_achieve_prompt', "{$player_id}---{$achieve_type}" . var_export($push_achieve_prompt2, true)); } else { if ($push_prompt_title_id < 100) { $achieve_config = Cache_AchieveConfig::getInstance()->get_achieve_config($push_prompt_achieve_id); $push_achieve_prompt = array(1, $achieve_config['icon'], $achieve_config['font_icon'], $achieve_config['target_info'], $achieve_config['achieve_point'], $push_prompt_title_id, $achieve_config['achieve_id']); } else { $title_config = Cache_TitleConfig::getInstance()->get_title_config_by_id($push_prompt_title_id); $push_achieve_prompt = array(3, $title_config['icon'], $title_config['font_icon'], $achieve_config['target_info'], 0, $push_prompt_title_id, 0); } Com_Log::debug_write('xgame.push_achieve_prompt', "{$player_id}---{$achieve_type}" . var_export($push_achieve_prompt, true)); Protocol::input($player_id, 8, 7, 768, array($push_achieve_prompt)); } } } if (!IS_FRONT) { Protocol::out(); } }