public function close() { if (!$this->_isExit) { $this->_isExit = true; //锁组件被启动 自动解锁 if (defined('LOCKRUN')) { Com_Lock::unLock(); } $this->push_cache(); $this->session_close(); $this->cache_close(); $this->db_close(); // if(IS_FRONT){ // Com_Log::log("action={$_POST['action']}|command={$_POST['command']}\ninclude files=".var_export(get_included_files(), true), 'corefile', 1); // } //DEBUG组件被启动 自动输出 if (defined('LOGRUN')) { Com_Log::output(); } if (IS_FRONT) { ob_end_flush(); } // global $scriptStartTime; // if($scriptStartTime){ // save_xhprof(); // } } }
public function CMD2_2021() { //加锁 $lockKey = __FUNCTION__ . $this->_authuser['player_id']; if (!Com_Lock::lock($lockKey)) { $this->check_error('1714001'); //加锁失败 } $data = $this->get_game('GetBackCurrency')->get_back_all($this->_authuser['player_id'], $this->_param[0]); Com_Lock::unLock($lockKey); Protocol::input($this->_authuser['player_id'], 3, 20, 2021, $data); }
public function buy($player_id, $shop_tag_id, $shop_sub_tag_id, $item_id, $item_num, $currency_type) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); $this->param_check_numeric(array($player_id, $shop_tag_id, $shop_sub_tag_id, $item_id, $item_num, $currency_type)); # 加锁失败 if (!Com_Lock::lock("lock|shop_buy|player_id={$player_id}")) { $this->throw_error('170501'); # 系统繁忙 } # 获取商城道具信息 $item_info = Cache_Shop::getInstance()->get_shop_item_info($shop_tag_id, $shop_sub_tag_id, $item_id); if (empty($item_info)) { $this->throw_error('130001'); # 商城没有出售该道具 } # 限时校验 if (!empty($item_info['sell_start_time']) && $item_info['sell_start_time'] > $this->current_time || !empty($item_info['sell_end_time']) && $item_info['sell_end_time'] < $this->current_time) { $this->throw_error('130002'); # 商城道具限时售卖尚未开始或已经结束 } # 限量校验 if (!empty($item_info['personal_deal_limit'])) { # 获取当日个人累计交易数量 $daily_start_time = mktime(0, 0, 0); $daily_end_time = mktime(23, 59, 59); $already_deal_num = $this->get_data('Shop')->get_daily_personal_deal_num($daily_start_time, $daily_end_time, $item_id, $player_id); if ($already_deal_num + $item_num > $item_info['personal_deal_limit']) { $this->throw_error('130003'); # 商城道具个人购买数量超过限额 } } if (!empty($item_info['whole_deal_limit'])) { # 获取当日全服累计交易数量 $daily_start_time = mktime(0, 0, 0); $daily_end_time = mktime(23, 59, 59); $already_deal_num = $this->get_data('Shop')->get_daily_whole_deal_num($daily_start_time, $daily_end_time, $item_id); if ($already_deal_num + $item_num > $item_info['whole_deal_limit']) { $this->throw_error('130004'); # 商城道具全服购买数量超过限额 } } # 获取消耗资源类型与值 $cost_currency_value = 0; if (!empty($item_info['item_price'])) { $item_price = explode("|", $item_info['item_price']); foreach ($item_price as $price_string) { list($cur_type, $cur_value) = explode(":", $price_string); if ($cur_type == $currency_type) { $cost_currency_value = $cur_value; break; } } } if (empty($cost_currency_value)) { $this->throw_error('130005'); # 商城道具购买价格为零 } $price = 0; # 计算价格与折扣,对于限时折扣,可能存在临界情况,玩家看到限时折扣尚未结束,实际服务端已经结束限时折扣的情况 if (!empty($item_info['discount'])) { $item_info = $this->flush_time_limit_discount($item_info); # 刷新后折扣可能变为0 if (!empty($item_info['discount'])) { $price = ceil($cost_currency_value * $item_info['discount'] / 10000); $cost_currency_value = $price * $item_num; } else { $price = $cost_currency_value; $cost_currency_value = $cost_currency_value * $item_num; } } else { $price = $cost_currency_value; $cost_currency_value = $cost_currency_value * $item_num; } # 消耗虚拟货币校验 $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); $cost_currency_key = Cache_Currency::getInstance()->get_key($currency_type); $this->start_trans(); # 消耗虚拟货币 $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $item_num); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $currency_type); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1302', array(), $arr_consume); $this->write_check($re, 3010162); # 发送道具 $reward = array(); $reward[] = array('type' => 'prop', 'item_id' => $item_id, 'item_num' => $item_num); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '1302')); #send_reward失败时,会返回各种失败情况的错误码 $this->write_check_strict($re, 3010168); $sendarrLogs = $this->get_game('Reward')->get_prop_log(); # 记录商城交易日志 $deal_log = array('player_id' => $player_id, 'deal_time' => $this->current_time, 'item_id' => $item_id, 'item_num' => $item_num, 'item_status' => $item_info['item_status'], 'cost_currency_type' => $currency_type, 'cost_currency_value' => $cost_currency_value, 'discount' => $item_info['discount']); $re = $this->get_data('Shop')->record_shop_deal_log($deal_log); $this->write_check($re, 3010183); $this->commit(); # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更 $this->get_game('Reward')->add_reward_log(); # 通知玩家信息变更[必须放在commit之后] // Protocol_Player::p2c_part_update($player_id, array($cost_currency_key => '')); $this->get_game('TaskTrigger')->async_trigger_task($player_id, 11, $item_id, $item_num); //收集道具任务触发 $out = array('result' => 1); # 日常活跃度处理 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 4000); $prop_info = Cache_Prop::getInstance()->get_prop_info($item_id); # -------------------------------------------------------------------- # 公告 # -------------------------------------------------------------------- $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 100), array('rep_type' => 2, 'rep_val' => $item_id, 'rep_player_id' => $player_id, 'rep_pid' => $sendarrLogs[0]['player_prop_id'])); $this->get_game('SystemNotice')->push_sys_notice($player_id, 100, 0, $replace_info, 0, $prop_info['need_broad_cast']); # -------------------------------------------------------------------- # 活动日志记录 # -------------------------------------------------------------------- $event_log_info = array('log_type' => 'shop', 'player_id' => $player_id, 'reg_time' => $this->current_time, 'item_id' => $item_id, 'item_num' => $item_num); $this->get_game('Event')->async_deal_event_log($event_log_info); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'item_id' => $item_id, 'item_name' => $prop_info['name'], 'item_quality' => $prop_info['quality'], 'item_num' => $item_num, 'resource_id' => $currency_type, 'resource_num' => $cost_currency_value, 'cmd2_id' => 1302); Log_Shop::getInstance()->add_log($log_info); return $out; }
/** * 邀请加入公会 * @param unknown $player_id * @param unknown $invite_id */ public function send_invite_union_notice($player_id, $invite_id, $keyword) { $player_id = intval($player_id); $invite_id = intval($invite_id); if ($invite_id == 0) { $keyword = addslashes(trim($keyword)); $invite_id = $this->get_data("Account")->get_pid_byname($keyword); if (empty($invite_id)) { $this->throw_error('70118'); //未查找到该用户 } } //加锁 if (!Com_Lock::lock('lock|union_invite|invite_id=' . $invite_id)) { //系统繁忙 //$this->throw_error('170501'); } $objPlayerData = $this->get_data('Player'); $player_info = $objPlayerData->get_player_info($player_id, array("union_id", "name", "union_name", "level")); if (!$player_info['union_id']) { $this->throw_error('171101'); //没有加入公会 } $objUnionPlayerData = $this->get_data('UnionPlayer'); $unionPlayeInfo = $objUnionPlayerData->get_union_player_info($player_info['union_id'], $player_id); if ($unionPlayeInfo['job_id'] > 2) { $this->throw_error('178501'); //没有加入公会 } $objPlayerData = $this->get_data('Player'); $invite_info = $objPlayerData->get_player_info($invite_id, array("union_id", "level", "is_online")); if (empty($invite_info['level'])) { $this->throw_error('70110'); //不存在该用户 } $unionCreatConfig = Cache_UnionCreat::getInstance()->get_union_creat(2); if ($invite_info['level'] < $unionCreatConfig['level_need']) { $this->throw_error('170110'); //level等级不足 } if (intval($invite_info['union_id']) > 0) { $this->throw_error('178502'); //已加入公会 } $unionInfo = $this->get_data('UnionInfo')->get_union_info($player_info['union_id'], array("union_level")); $arr_replace = array(array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id), array('rep_type' => 7, 'txt' => $player_info['level']), array('rep_type' => 7, 'txt' => $unionInfo['union_level']), array('rep_type' => 7, 'txt' => $player_info['union_name'])); #某玩家(LV.8)邀请你加入8 级公会[公会第一] $msg = Language_Message::make_message(178505, $arr_replace); $add_data = array(); $add_data['union_id'] = $player_info['union_id']; $add_data['rep_content'] = $msg; $add_data['add_time'] = time(); $this->get_data("UnionInvite")->add_union_invite($invite_id, $add_data); $this->get_data('NewsTips')->update_player_tips($invite_id, 12, array("num" => 1)); /* if(intval($invite_info['is_online'])==0){ $this->throw_error('178503'); //对方离线 } Protocol::input($invite_id,8,17,1786,array($player_info['name'],$player_id,$player_info['union_name'],$player_info['union_id'])); */ return array('result' => 1); }
public function upgrade_player_skill($player_id, $skill_id) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_skill); $this->param_check_numeric(array($player_id, $skill_id)); # 加锁失败 if (!Com_Lock::lock("lock|skill_upgrade|player_id={$player_id}")) { $this->throw_error('170501'); # 系统繁忙 } $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level', 'career_type'))); $get_field = Protocol_Player::get_player_attr_detail_key(); $get_field[] = 'skill_starmap_info'; $get_field[] = 'skill_info'; $get_field[] = 'skill_rune_info'; $get_field[] = 'dower_info'; $arr_player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, $get_field); $before_level = isset($arr_player_detail['skill_info'][$skill_id]) ? $arr_player_detail['skill_info'][$skill_id]['level'] : 0; # 更新技能等级与快捷键盘 if (isset($arr_player_detail['skill_info'][$skill_id])) { $arr_player_detail['skill_info'][$skill_id]['level'] += 1; } else { $arr_player_detail['skill_info'][$skill_id]['level'] = 1; $arr_player_detail['skill_info'][$skill_id]['keyboard'] = 0; } $skill_config = Cache_Skill::getInstance()->get_skill_infobysl($skill_id, $arr_player_detail['skill_info'][$skill_id]['level'], 1); // Com_Log::write('xgame.skill.debug', "skill==============".$player_id.":".$player_info['level']."|".var_export($skill_config, true)); if ($skill_config['level'] > $skill_config['max_level']) { $this->throw_error('60012'); //技能等级已满级 } if ($skill_config['unlock'] > $player_info['level']) { $this->throw_error('60001'); //还未到解锁等级 } # 消耗资源 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $skill_config['levelup_cost_silver'], 1, 1); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'crystal', $skill_config['levelup_cost_skill_point'], 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '602'); $this->write_check($re, 3010335); # 更新技能信息 $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, $arr_player_detail); $this->write_check($re, 3010339); $out_602 = array('result' => 1, 'skill_id' => intval($skill_id), 'after_lv' => intval($arr_player_detail['skill_info'][$skill_id]['level']), 'next_lvup_flag' => 2, 'rune_list' => array(), 'skill_point' => intval($player_info['crystal']), 'skill_list' => array()); # 下一级技能是否可升级 $skill_config_n = Cache_Skill::getInstance()->get_skill_infobysl($skill_id, $out_602['after_lv'] + 1); if (!empty($skill_config_n)) { if ($player_info['level'] >= $skill_config_n['unlock'] && $player_info['silver'] >= $skill_config_n['levelup_cost_silver'] && $player_info['crystal'] >= $skill_config_n['levelup_cost_skill_point'] && $skill_config_n['level'] <= $skill_config_n['max_level']) { $out_602['next_lvup_flag'] = 1; } } //符文 刷新 list($out_602['rune_list'], $auto_active_rune_cote) = $this->get_skill_rune_list_info($skill_id, 1, $arr_player_detail['skill_info'][$skill_id]['level'], $arr_player_detail['skill_rune_info'][$skill_id]); $out_602['skill_list'] = $this->list_skill($player_info, $arr_player_detail); //同步人物属性 $arr_part_update['skill_infos'] = ''; $arr_part_update['player_data'] = array('player_detail' => $arr_player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])); Protocol_Player::p2c_part_update($player_id, $arr_part_update); $this->handle_skill_refer_achieve($player_id); # 日常活跃度处理 if ($arr_player_detail['skill_info'][$skill_id]['level'] > 1) { # 不包含激活,目前没有手动激活,只有自动激活 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2400); } #技能升级任务触发 add by chengt $this->get_game('TaskTrigger')->async_trigger_task($player_id, 16, 16, 1); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'skill_id' => $skill_id, 'before_level' => $before_level, 'after_level' => $arr_player_detail['skill_info'][$skill_id]['level']); Log_Skill::getInstance()->add_log($log_info, 'skill'); return $out_602; }
public function CMD2_1239() { //加锁 $lockKey = __FUNCTION__ . $this->_authuser['player_id']; if (!Com_Lock::lock($lockKey)) { //失败 $this->check_error('1714001'); } //鼓舞 $data = $this->get_game('KFDuel')->inspire($this->_authuser['player_id'], $this->_param[0]); Com_Lock::unLock($lockKey); Protocol::input($this->_authuser['player_id'], 3, 11, 1239, $data); }
public function get_event_reward($player_id, $event_id, $reward_id, $event_template) { $this->param_check_numeric(array($player_id, $event_id, $reward_id)); # 加锁失败 if (!Com_Lock::lock("lock|get_event_reward|player_id={$player_id}")) { $this->throw_error('170501'); # 系统繁忙 } $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level', 'map_id'))); if ($player_info['map_id'] == 2100) { $this->throw_error('12012'); # 请在完成序章后领取 } # 获取活动配置 $event_info = $this->get_data('Event')->get_event_info($event_id); if (empty($event_info) || empty($event_info['event_reward_info'])) { $this->throw_error('12004'); # 无效的活动,未找到活动配置信息 } $reward_id_array = explode(':', $event_info['event_reward_info']); if (!in_array($reward_id, $reward_id_array)) { $this->throw_error('12006'); # 无效的奖励,未找到活动奖励配置信息 } # NOTE: 因为允许在活动结束后领奖,所以领奖时不用活动开启时间段[open_date_head,open_date_tail]做检测 if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) { $this->throw_error('12005'); # 未到或已超过活动奖励领取时间 } # 获取奖励配置 $reward_info = $this->get_data('Event')->get_reward_info($reward_id); if (empty($reward_info) || empty($reward_info['cond_func'])) { $this->throw_error('12006'); # 无效的奖励,未找到活动奖励配置信息 } if (!empty($reward_info['valid_date_head']) || !empty($reward_info['valid_date_tail'])) { if ($reward_info['valid_date_head'] > $this->current_time || $reward_info['valid_date_tail'] < $this->current_time) { $this->throw_error('12007'); # 未到或已超过活动奖励有效时间 } } /** # -------------------------------------------------------------------- # 活动领奖周期内的领奖次数上限判断 # -------------------------------------------------------------------- if (!empty($event_info['event_reward_stint']) && !empty($event_info['event_reward_cycle'])) { # 向上取整获取最大领奖期数 $max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $event_info['event_reward_cycle']); for($i = 1; $i <= $max_cycle; $i++) { $cycle_head = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * ($i - 1); # 领奖周期首部时间 $cycle_tail = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * $i - 1; # 领奖周期尾部时间,减一是为了相邻两个区间没有交集 if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内 continue; } else { # 获取该周期内的领奖次数 list($reward_record, $reward_record_count) = $this->get_data('Event')->get_event_reward_record_part($player_id, $event_id, $cycle_head, $cycle_tail); if ($reward_record_count >= $event_info['event_reward_stint']) { $this->throw_error('12008'); # 已达到活动领奖周期内的领取次数上限 } break; } } } # -------------------------------------------------------------------- # 奖励领奖周期内的领奖次数上限判断,NOTO:没有考虑循环奖励的领取上限不仅由reward_gain_stint决定,还由循环达成数loop_num决定 # -------------------------------------------------------------------- if (!empty($reward_info['reward_gain_stint']) && !empty($reward_info['reward_gain_cycle'])) { # 向上取整获取最大领奖期数 $max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $reward_info['reward_gain_cycle']); for($i = 1; $i <= $max_cycle; $i++) { $cycle_head = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * ($i - 1); # 领奖周期首部时间 $cycle_tail = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * $i - 1; # 领奖周期尾部时间,减一是为了相邻两个区间没有交集 if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内 continue; } else { # 获取该周期内的领奖次数 list($reward_record, $reward_record_count) = $this->get_data('Event')->exactly_get_event_reward_record_part($player_id, $event_id, $reward_id, $cycle_head, $cycle_tail); if ($reward_record_count >= $reward_info['reward_gain_stint']) { $this->throw_error('12009'); # 已达到奖励领奖周期内的领取次数上限 } break; } } } **/ # 进度计算 $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']); $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params); # 剩余领奖次数计算 list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward_info, $ret); if (empty($real_remain_gain_num)) { $this->throw_error('12009'); # 已达到奖励领奖周期内的领取次数上限 } # -------------------------------------------------------------------- # 奖励达成条件判断 # -------------------------------------------------------------------- # 进度计算 $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']); $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params); if (empty($ret['status'])) { $this->throw_error('12010'); # 未达到奖励的领取条件 } # -------------------------------------------------------------------- # 发奖 + 消耗道具 + 并刷新奖励信息 # -------------------------------------------------------------------- $this->start_trans(); # 消耗道具 if (!empty($reward_info['consume_info'])) { $consume_currency = false; $arr_logs_consume = array(); $reward_item_info_arr = explode("|", $reward_info['consume_info']); $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2304); foreach ($reward_item_info_arr as $item_info) { list($item_id, $item_num) = explode(":", $item_info); $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id); if ($item_key == 'prop') { # 消耗道具 # deduct_prop_by_prop_id方法中有判断道具是否足够,故外层不判断 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $item_id, $item_num, $arr_logs_consume, 0, $log_param); $this->write_check($re, 3010311); } else { # 消耗资源 $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $item_key, $item_num); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $item_key, $item_num, 1, $item_id); $consume_currency = true; } } if ($consume_currency) { $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2304', array(), $arr_consume); $this->write_check($re, 3010332); } } # 奖励道具 $reward = array(); $reward_detail = array(); if (!empty($reward_info['reward_info'])) { $reward_item_info_arr = explode("|", $reward_info['reward_info']); foreach ($reward_item_info_arr as $item_info) { list($item_id, $item_num, $item_tag) = explode(":", $item_info); $reward_detail[$item_id] = $item_num; } } $this->get_game('Reward')->gen_reward_array($reward_detail, $reward); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2304', 'bind_flag' => 0)); $this->write_check_strict($re, 3010347); # 记录奖励领取日志 $re = $this->get_data('Event')->record_player_event_reward($player_id, $event_id, $reward_id, $this->current_time); $this->write_check($re, 3010351); $this->commit(); # 蛋疼的次数同步埋点 if ($event_template == 2) { # 充值回馈需要同步次数变更 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260); } # 粘806 + 通知道具变更信息 $ndata = array(); if (!empty($arr_logs_consume)) { foreach ($arr_logs_consume as $k => $v) { # 消耗的道具 $ndata[] = $v; } Protocol_Prop::prop_806($player_id, $ndata); } # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更 $ret = $this->get_game('Reward')->add_reward_log(true); #----------------------------------------------------------------- # 重新获取奖励项列表 #----------------------------------------------------------------- $event_reward_list = array(); $special_reward_list = array(); if (!empty($event_info['event_reward_info'])) { $reward_id_array = explode(':', $event_info['event_reward_info']); #echo "</br>===============".$event_info['event_id']."==================</br>"; #var_export($reward_id_array); $reward_info = $this->get_data('Event')->multi_get_reward_info($reward_id_array); #var_export($reward_info); # 对奖励列表升序排序 Com_Array::multisort($reward_info, array('reward_priority' => 'asc')); foreach ($reward_info as $reward) { #echo "</br>===============reward_id:".$reward['reward_id']."==================</br>"; # 获取奖励的具体道具列表 $reward_item_list = array(); if (!empty($reward['reward_info'])) { $reward_item_info_arr = explode("|", $reward['reward_info']); foreach ($reward_item_info_arr as $item_info) { list($item_id, $item_num, $item_tag) = explode(":", $item_info); $item_config = Cache_Prop::getInstance()->get_prop_info($item_id); $item_config['item_num'] = $item_num; $item_struct = Struct_Prop::get_prop_struct($item_config); $reward_item_list[$item_id] = $item_struct; if ($item_tag == $this->reward_item_tag_for_special) { $special_reward_list[$item_id] = $item_struct; } } } # 进度计算 $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward['reward_id'], 'reward_type' => $reward['reward_type'], 'reward_billing_cycle' => $reward['reward_billing_cycle']); $ret = $this->call_cond_func($player_id, $reward['cond_func'], $reward['cond_func_relation'], $sys_params); # 剩余领奖次数计算 list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward, $ret); # 领奖状态判定 if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) { $reward_status = 0; # 未到或已超过活动奖励领取时间 } elseif ((!empty($reward['valid_date_head']) || !empty($reward['valid_date_tail'])) && ($reward['valid_date_head'] > $this->current_time || $reward['valid_date_tail'] < $this->current_time)) { $reward_status = 0; # 未到或已超过活动奖励有效时间 } elseif (empty($real_remain_gain_num)) { # 用实际剩余领奖次数判断领奖状态 $reward_status = 0; } else { $reward_status = $ret['status']; } # 可领奖总数计算 if ($reward_status) { $can_receive_reward_num += 1; } $event_reward_list[] = array('reward_id' => $reward['reward_id'], 'reward_cond' => $reward['cond_desc'], 'reward_item_list' => $reward_item_list, 'reward_progress_head' => $ret['progress_head'], 'reward_progress_tail' => $ret['progress_tail'], 'reward_remain_gain_num' => $reward_remain_gain_num, 'reward_status' => $reward_status, 'reward_type' => $reward['reward_type'], 'consume_info' => $reward['consume_info'], 'reward_gain_stint' => $config_gain_stint); } } $out_2304 = array('event_tag' => $event_info['event_tag'], 'event_id' => $event_id, 'event_reward_list' => $event_reward_list, 'event_template' => $event_template); # 记录行为 Com_Log::write('xgame.event', "{$player_id}\t" . "get_event_reward\t" . "{$event_id}\t" . "{$reward_id}\t"); return $out_2304; }
/** * 赞好友动态 * 单条与一键 */ public function like_friend_news($player_id, $news_ids, $is_key = 0, $page = 1) { $is_key = intval($is_key); $page = intval($page) < 1 ? 1 : intval($page); if (empty($player_id) || empty($news_ids)) { $this->throw_error('10101'); //参数不全 } //加锁 if (!Com_Lock::lock('lock|like_friend_news|player_id=' . $player_id)) { //系统繁忙 $this->throw_error('170501'); } $player_id = intval($player_id); $arr_news_ids = array(intval($news_ids)); $objplayer = $this->get_data('Player'); $player_basic_info = $objplayer->get_player_info($player_id, array("privilege_level", 'ticket', 'level', 'gold', 'vip', 'level_exp', 'name')); $like_max_times = $this->like_default_times; if (intval($player_basic_info['vip']) > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_basic_info['vip'], 10069); $like_max_times = $this->like_default_times + $vip_set['max_times']; } //一键点赞扣2钻石 $ticket = 0; $arr_consume = array(); $price = $cost_gold = 10; if ($is_key) { if ($player_basic_info['ticket'] > 0) { if ($player_basic_info['ticket'] >= $cost_gold) { $this->get_data('Player')->check_player_resource($player_id, $player_basic_info, '-', 'ticket', $cost_gold); $ticket = $cost_gold; $cost_gold = 0; } else { $ticket = $player_basic_info['ticket']; $cost_gold = $cost_gold - $player_basic_info['ticket']; $this->get_data('Player')->check_player_resource($player_id, $player_basic_info, '-', 'ticket', $player_basic_info['ticket']); } } $this->get_data('Player')->check_player_resource($player_id, $player_basic_info, "-", "gold", $cost_gold); $arr_consume = array('price' => $price, 'gold' => $cost_gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $arr_news_ids = $this->get_no_like_newsid($player_id); if (!$arr_news_ids) { $this->throw_error('72201'); } //不存在未赞过 } $objfrined = $this->get_data('PlayerFriend'); $ret_news_ids = array(); //成功点赞动态ID $ret_error_msg = ''; $error_msg = ''; $sum_add_exp = 0; $sum_add_silver = 0; $add_exp = 0; $player_data = $objfrined->get_player_friend($player_id, array('follow', 'like_news', 'like_times')); if ($player_data['like_times']['today_like_friend_times'] + $player_data['like_times']['today_times'] >= $like_max_times) { $error_msg = '70120'; //今日点赞已达到上线 } else { //一次性获取动态信息 $news_data = $objfrined->get_news_info(implode(",", $arr_news_ids)); if (empty($news_data)) { $this->throw_error('10104'); } //不存在这条动态 foreach ($news_data as $key => $val) { $news_info[$val['news_id']] = $val; } foreach ($arr_news_ids as $news_id) { if ($error_msg) { $ret_error_msg = $error_msg; } //这条动态信息 $error_msg = ''; $friend_id = intval($news_info[$news_id]['player_id']); if ($player_data['like_times']['today_like_friend_times'] + $player_data['like_times']['today_times'] >= $like_max_times) { $error_msg = '70120'; //今日点赞已达到上线 break; } if (!isset($player_data['follow']['info'][$friend_id])) { $error_msg = '70107'; //未关注 continue; } #已赞过 if (isset($player_data['like_news'][$news_id])) { $error_msg = '71604'; continue; } if (count($player_data['like_news']) > 200) { //删除老数据避免存储太多 asort($player_data['like_news']); foreach ($player_data['like_news'] as $like_id => $news_time) { if ($news_time > time() - 86400 * 2) { break; } unset($player_data['like_news'][$like_id]); } } //异步更新好友数据 $sys_ret = $this->sys_update_like_friend_data($player_id, $friend_id, $news_id, $player_basic_info['name']); if ($sys_ret) { $player_data['like_news'][$news_id] = $news_info[$news_id]['create_time']; $player_data['like_times']['upts'] = time(); $player_data['like_times']['today_like_friend_times'] += 1; $player_add_exp = $this->add_default_exp; $ret_news_ids[] = $news_id; $sum_add_exp += $player_add_exp; $sum_add_silver += $this->add_default_silver; } else { $error_msg = '10104'; } } } $out_msg = ""; if (empty($ret_news_ids)) { if ($ret_error_msg) { $code = $ret_error_msg; } else { if ($error_msg) { $code = $error_msg; } else { $code = '10101'; } } $language_config = Cache_Language::getInstance()->get_language_info($code); $out_msg = $language_config['content']; } else { $this->start_trans(); //我赞的奖励 if ($is_key) { //一键点赞扣钻石 $this->get_data('Player')->update_player_resource($player_id, $player_basic_info, 716, array(), $arr_consume); } unset($player_data['follow']); //不参与更新,以上判断$news_id合法性 $player_ret = $objfrined->update_player_friend($player_id, $player_data); $reward = array(); $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key(1), 'item_id' => 1, 'item_num' => $sum_add_exp); #$reward[] = array('type'=>Cache_FbLoot::getInstance()->get_item_key(3),'item_id'=>3,'item_num'=>$sum_add_silver); $ret_reward = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '102')); unset($player_basic_info['gold']); unset($player_basic_info['ticket']); $ret_player_basic = $this->get_data('Player')->update_player_info($player_id, $player_basic_info); if ($player_ret && $ret_player_basic) { $this->commit(); $this->get_game('Reward')->add_reward_log(); // Protocol_Player::p2c_part_update($player_id,array('gold'=>'','ticket'=>'')); #数据中心推送 // if($cost_gold > 0){ // $params['act'] = 102; // $params['price'] = $cost_gold; // $params['gold'] = $cost_gold; // $params['black_gold'] = 0; // $params['count'] = 1; // $params['time'] = time(); // Com_DataCenter::getInstance()->publish_data($player_id,'prop',$params); // } } else { $this->rollback(); $out_msg = '10104'; } } $today_like_friend = intval($player_data['like_times']['today_like_friend_times']) + intval($player_data['like_times']['today_times']); $out = array(); $out['player_id'] = $player_id; $out['page'] = $page; $out['is_key'] = $is_key; $out['today_like_player'] = $like_max_times; //被赞过 $out['today_like_friend'] = $today_like_friend; //赞过+被赞过 $out['news_ids'] = $ret_news_ids; $out['add_silver'] = $sum_add_silver; $out['add_exp'] = $sum_add_exp; $out['like_max_times'] = $like_max_times; $out['error_msg'] = $out_msg; return $out; }
public function refine($player_id, $player_prop_id, $refine_type, $lock_attr_list, $auto_buy) { #$this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_refine); $this->param_check_numeric(array($player_id, $refine_type, $auto_buy), 0); # 加锁失败 if (!Com_Lock::lock("lock|refine|player_id={$player_id}")) { $this->throw_error('170501'); # 系统繁忙 } $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level'))); # 日志信息数组 $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 848); $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id); if (!$player_equip_info) { $this->throw_error('80013'); # 玩家没有该装备! } if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) { $this->throw_error('81104'); # 首充装备不允许洗练 } # -------------------------------------------------------------------- # 洗练类型检查 # -------------------------------------------------------------------- if (isset($player_equip_info['refine_info']) && $refine_type < $player_equip_info['refine_info']['last_refine_type']) { $this->throw_error('81003'); # 洗练级别低于最后洗练级别 } # -------------------------------------------------------------------- # 判断锁定项的合法性 # -------------------------------------------------------------------- $lock_attr_key_hash = array(); # 用来随机新洗练属性时去重 $lock_attr_seq_hash = array(); # 用来计算新洗练属性的序号时去重 $lock_attr_count = !empty($lock_attr_list) ? count($lock_attr_list) : 0; # 锁定个数 if (!empty($lock_attr_list)) { if (empty($player_equip_info['refine_info']['attr_info'])) { $this->throw_error('81004'); # 洗练属性锁定异常,锁定的洗练属性不存在 } foreach ($player_equip_info['refine_info']['attr_info'] as $attr_seq => $attr_info) { $seq_hash[$attr_seq] = $attr_info['attr_key']; } foreach ($lock_attr_list as $attr_seq) { if (!isset($seq_hash[$attr_seq])) { $this->throw_error('81004'); # 洗练属性锁定异常,锁定的洗练属性不存在 } $lock_attr_key_hash[$seq_hash[$attr_seq]] = $seq_hash[$attr_seq]; $lock_attr_seq_hash[$attr_seq] = $attr_seq; } } # 已用的序号需要保留,用来去重 $used_attr_seq_hash = $lock_attr_seq_hash; #var_export($lock_attr_key_hash); #var_export($lock_attr_seq_hash); # -------------------------------------------------------------------- # 获取配置信息[洗练+精炼+锁定] # -------------------------------------------------------------------- $refine_conf = Cache_Refine::getInstance()->get_equip_refine_base_info($refine_type); $en_refine_conf = Cache_Refine::getInstance()->get_equip_enhanced_refine_base_info($this->init_en_refine_lv); if (empty($refine_conf)) { $this->throw_error('81001'); # 获取洗炼基础配置信息失败 } if (empty($en_refine_conf)) { $this->throw_error('81005'); # 获取精炼基础配置信息失败 } if ($lock_attr_count > 0) { $lock_conf = Cache_Refine::getInstance()->get_equip_refine_lock_info($lock_attr_count); if (empty($lock_conf)) { $this->throw_error('81002'); # 获取洗炼锁定配置信息失败 } } # -------------------------------------------------------------------- # 计算资源消耗与材料消耗 # -------------------------------------------------------------------- list($cost_currency_type, $cost_currency_value) = explode(":", $refine_conf['cost_currency']); $material_cost_num = $refine_conf['cost_item_num']; # 材料实际消耗量 $material_cost_num_lock = !empty($lock_conf) ? $lock_conf['cost_item_num'] : 0; # 锁定材料实际消耗量 if (!empty($auto_buy)) { # 若勾选自动购买,则计算材料持有量,缺少量[即购买量],修正实际消耗量 $meterial_hold_num = 0; $material_list = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $refine_conf['cost_item_id'], 1); if (!empty($material_list)) { foreach ($material_list as $pp_id => $pp_info) { $meterial_hold_num += $pp_info['item_num']; } } if ($material_hold_num < $refine_conf['cost_item_num']) { $material_cost_num = $material_hold_num; # 获取正确的材料单价 $material_buy_info = $this->get_game('Shop')->shortcut_purchase_interface($refine_conf['cost_item_id'], 1); if (empty($material_buy_info['item_price'])) { $this->throw_error('81006'); # 消耗材料商城购买价格为空 } # 策划价格配置多项时,选其中一项 list($cur_type, $cur_val) = each($material_buy_info['item_price']); $cost_currency_type_m = $cur_type; $cost_currency_value_m = intval($cur_val * ($refine_conf['cost_item_num'] - $material_hold_num)); } # 若有锁定,则计算锁定材料持有量,缺少量[即购买量],修正实际消耗量 if ($lock_attr_count > 0) { $lock_conf = Cache_Refine::getInstance()->get_equip_refine_lock_info($lock_attr_count); if (empty($lock_conf)) { $this->throw_error('81002'); # 获取洗炼锁定配置信息失败 } $meterial_hold_num_lock = 0; $material_list_lock = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $lock_conf['cost_item_id'], 1); if (!empty($material_list_lock)) { foreach ($material_list_lock as $pp_id => $pp_info) { $meterial_hold_num_lock += $pp_info['item_num']; } } if ($material_hold_num_lock < $lock_conf['cost_item_num']) { $material_cost_num_lock = $material_hold_num_lock; # 获取正确的材料单价 $material_buy_info_lock = $this->get_game('Shop')->shortcut_purchase_interface($lock_conf['cost_item_id'], 1); if (empty($material_buy_info_lock['item_price'])) { $this->throw_error('81006'); # 消耗材料商城购买价格为空 } # 策划价格配置多项时,选其中一项 list($cur_type_lock, $cur_val_lock) = each($material_buy_info_lock['item_price']); $cost_currency_type_m_lock = $cur_type_lock; $cost_currency_value_m_lock = intval($cur_val_lock * ($lock_conf['cost_item_num'] - $material_hold_num_lock)); } } } $before_refine_attr = isset($player_equip_info['refine_attr']) ? $player_equip_info['refine_attr'] : array(); $before_refine_info = isset($player_equip_info['refine_info']) ? $player_equip_info['refine_info'] : array(); $this->start_trans(); # -------------------------------------------------------------------- # 洗练 # -------------------------------------------------------------------- $arr_logs = array(); # 消耗洗练材料 if ($material_cost_num > 0) { $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $refine_conf['cost_item_id'], $material_cost_num, $arr_logs, 0, $log_param); $this->write_check($re, 3010449); } # 消耗锁定材料 if ($lock_attr_count > 0 && $material_cost_num_lock > 0) { $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $lock_conf['cost_item_id'], $material_cost_num_lock, $arr_logs, 0, $log_param); $this->write_check($re, 3010203); } /** if ($lock_attr_count > 0) { $lock_conf = Cache_Refine::getInstance()->get_equip_refine_lock_info($lock_attr_count); if (empty($lock_conf)) { $this->throw_error('81002'); # 获取洗炼锁定配置信息失败 } $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $lock_conf['cost_item_id'], $lock_conf['cost_item_num'], $arr_logs, 0, $log_param); $this->write_check($re, 3010203); } **/ # 消耗货币[洗练消耗 + 材料购买消耗] $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1); if ($cost_currency_value_m > 0) { $cost_currency_key_m = Cache_Currency::getInstance()->get_key($cost_currency_type_m); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key_m, $cost_currency_value_m, 1, 1); } if ($cost_currency_value_m_lock > 0) { $cost_currency_key_m_lock = Cache_Currency::getInstance()->get_key($cost_currency_type_m_lock); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key_m_lock, $cost_currency_value_m_lock, 1, 1); } $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '848'); $this->write_check($re, 3010132); # 重新生成洗练属性,锁定的属性不能变 $need_rand_attr_num = $refine_conf['attr_num'] - $lock_attr_count; $rand_attr_key_list = Cache_Refine::getInstance()->get_rand_attr_key_list($player_equip_info['sub_type'], $need_rand_attr_num, $lock_attr_key_hash); if (empty($rand_attr_key_list) || count($rand_attr_key_list) < $need_rand_attr_num) { $this->throw_error('81007'); # 获取随机洗练属性类型失败 } # 获取洗练属性基础值 $refine_lv_stint = $this->get_refine_lv_stint($player_equip_info['level']); $attr_value_info_refine = Cache_Refine::getInstance()->get_attr_value_info_refine($refine_lv_stint); if (empty($attr_value_info_refine)) { $this->throw_error('81011'); # 获取洗练属性值配置失败 } # 获取精练属性基础值 $en_refine_lv_stint = $this->get_en_refine_lv_stint($player_equip_info['level']); $attr_value_info_en_refine = Cache_Refine::getInstance()->get_attr_value_info($this->init_en_refine_lv); $attr_value_info_en_refine_stint = Cache_Refine::getInstance()->get_attr_value_info($en_refine_lv_stint); if (empty($attr_value_info_en_refine) || empty($attr_value_info_en_refine_stint)) { $this->throw_error('81011'); # 获取洗练属性值配置失败 } $update_field = array('refine_attr' => array(), 'refine_info' => array()); # 锁定的洗练属性要保留 if (!empty($lock_attr_seq_hash)) { foreach ($lock_attr_seq_hash as $attr_seq) { $update_field['refine_attr'][$attr_seq] = $player_equip_info['refine_attr'][$attr_seq]; $update_field['refine_info']['attr_info'][$attr_seq] = $player_equip_info['refine_info']['attr_info'][$attr_seq]; } } # 随机的洗练属性的信息生成 foreach ($rand_attr_key_list as $attr_key) { $attr_seq = $this->get_refine_attr_seq($refine_type, $used_attr_seq_hash); $used_attr_seq_hash[$attr_seq] = $attr_seq; $attr_ratio = rand(intval($refine_conf['attr_limit_lower'] / 100), intval($refine_conf['attr_limit_upper'] / 100)) * 100; $attr_value = ceil($attr_value_info_refine[$attr_key] * ($attr_ratio / 10000)); $attr_limit = ceil($attr_value_info_en_refine[$attr_key] * ($attr_ratio / 10000)); $attr_stint = ceil($attr_value_info_en_refine_stint[$attr_key] * ($attr_ratio / 10000)); #echo "</br>==========$attr_ratio========</br>"; #echo "</br>==========$attr_key========</br>"; #echo "</br>==========$attr_value========</br>"; $update_field['refine_attr'][$attr_seq] = array($attr_key => $attr_value); $update_field['refine_info']['attr_info'][$attr_seq] = array('attr_seq' => $attr_seq, 'attr_key' => $attr_key, 'attr_value' => $attr_value, 'refine_attr_value' => $attr_value, 'attr_ratio' => $attr_ratio, 'en_refine_lv' => $this->init_en_refine_lv, 'en_refine_attr_value' => 0, 'attr_limit' => $attr_limit, 'attr_stint' => $attr_stint, 'attr_section' => $en_refine_conf['section'], 'en_refine_success_num' => 0, 'en_refine_failed_cont' => 0); } $update_field['refine_info']['last_refine_type'] = $refine_type; # 最后洗练类型 # 按attr_seq对attr_key排序 #Com_Array::multisort($update_field['refine_info']['attr_info'], array('attr_seq' => 'asc')); $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $update_field); $this->write_check($re, 3010414); $this->commit(); #var_export($update_field); $player_equip_info['refine_attr'] = $update_field['refine_attr']; $player_equip_info['refine_info'] = $update_field['refine_info']; # 若有购买缺少材料,记录虚假商城购买日志 if ($cost_currency_value_m > 0) { $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $refine_conf['cost_item_id'], intval($refine_conf['cost_item_num'] - $material_hold_num), $cost_currency_type_m, $cost_currency_value_m, 848); } if ($cost_currency_value_m_lock > 0) { $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $lock_conf['cost_item_id'], intval($lock_conf['cost_item_num'] - $material_hold_num_lock), $cost_currency_type_m_lock, $cost_currency_value_m_lock, 848); } # 提示消息洗练成功 $message = array('texts' => array(array('code' => 81016, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_id, 'item_id_master' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'item_position' => $player_equip_info['item_position'], 'action_type' => 1, 'before_refine_attr' => $before_refine_attr, 'after_refine_attr' => $player_equip_info['refine_attr'], 'before_refine_info' => $before_refine_info, 'after_refine_info' => $player_equip_info['refine_info']); Log_Forge::getInstance()->add_log($log_info, 'refine'); # 成就相关埋点 list($attr_perfection_avg, $en_refine_attr_full_flag) = $this->cal_attr_perfection_avg($player_equip_info['refine_info']); $achieve_val = "1:" . ceil($attr_perfection_avg / 100) . ":" . $player_equip_info['player_prop_id']; $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 36, $achieve_val, 4); # 要百分比分子 # 刷新玩家属性 if ($player_equip_info['item_position'] == 3) { $this->get_game('EquipAttr')->equip_attr($player_id); } # 粘806 + 通知道具变更信息 $ndata = array(); $ndata[] = $player_equip_info; if (!empty($arr_logs) && is_array($arr_logs)) { foreach ($arr_logs as $k => $v) { # 消耗的材料 $ndata[] = $v; } } Protocol_Prop::prop_806($player_id, $ndata); $out_847 = $this->get_refine_info($player_id, $player_prop_id, $refine_type, $lock_attr_seq_hash); Protocol::input($player_id, 3, 8, 847, $out_847); $out_848 = array('result' => 1); return $out_848; }
public function CMD2_775() { $lockKey = 'CMD2_775:' . $this->_param[0]; if (!Com_Lock::lock($lockKey)) { $this->check_error('1714001'); #加锁失败 } $data = $this->get_game('Auction')->buy_back($this->_authuser['player_id'], $this->_param[0]); Protocol::input($this->_authuser['player_id'], 3, 7, 775, $data); Com_Lock::unLock($lockKey); $this->CMD2_776(); }
public function crontab_clear_his_log() { //加锁 if (!Com_Lock::lock('lock|union_log|clear_his_log')) { //系统繁忙 return; } $log_time = strtotime(date("Y-m-d", time())) - 4 * 86400; $sql = sprintf("select * from `union_log` where `add_time` <{$log_time}"); $result = $this->select_all($sql); if ($result) { foreach ($result as $value) { if (!$value) { return false; } $this->del_union_log($value['union_id'], $value["log_type"], $value["log_id"]); } } }
/** * 加锁 * @param $key 键值 */ protected function lock($key) { $lockKey = 'lock|' . $this->_action . '|' . $this->_command . '|' . $key; if (!Com_Lock::lock($lockKey)) { $this->check_error('ERROR_GLOBAL_12'); } }
public function CMD2_557() { #加锁 $lockKey = 'CMD2_557' . $this->_authuser['player_id']; if (!Com_Lock::lock($lockKey)) { $this->check_error('1714001'); #加锁失败 } $this->get_game('PlayerFunc')->get_func_is_open($this->_authuser['player_id'], 29); $data = $this->get_game('Hero')->player_hero_grow_upgrade($this->_authuser['player_id'], $this->_param[0], $this->_param[1], $this->_param[2]); Com_Lock::unLock($lockKey); Protocol::input($this->_authuser['player_id'], 3, 5, 557, $data); Protocol_Player::p2c_part_update($this->_authuser['player_id'], array('hero_info' => array(), 'attr' => array())); $this->CMD2_501(); }
public function CMD2_1779() { #加锁 $lockKey = 'CMD2_1779' . $this->_authuser['player_id']; if (!Com_Lock::lock($lockKey)) { $this->check_error('1714001'); #加锁失败 } $data = $this->get_game('UnionBoss')->send_box_reward_role($this->_param[0]); Com_Lock::unLock($lockKey); Protocol::input($this->_authuser['player_id'], 3, 17, 1779, $data); }
public function CMD2_1159() { $lockKey = __FUNCTION__ . $this->_authuser['player_id']; if (!Com_Lock::lock($lockKey)) { //失败 $this->check_error('1714001'); } $data = $this->get_game('PlayerPVE')->get_invite_reward($this->_authuser['player_id']); Com_Lock::unLock($lockKey); Protocol::input($this->_authuser['player_id'], 3, 11, 1159, $data); }
/** * 主动向指定玩家抛出异常 * @param $player_id 玩家ID * @param $data 错误得id 或一个错误得数组 * @param $is_exit 抛出异常是否终止逻辑继续执行(true:终止false:继续) */ protected function initiative_throw_error($player_id, $data, $is_exit = true) { if ($this->is_trans()) { $this->rollback(); } Com_Lock::unLock(); if (is_array($data)) { $msg = Language_Message::make_message($data['code'], $data['params'], 1, $data['content']); } else { $msg = Language_Message::make_message($data); } Com_Log::log($player_id, 'z_fb_res', 1); Com_Log::log(array(0 => array($msg)), 'z_fb_res', 1); Protocol::input($player_id, 8, 7, 742, array(0 => array($msg))); Protocol::out(); if ($is_exit) { exit; } }
/** * 解散公会 * @param unknown $player_id * @param unknown $union_id */ public function dismiss_union($player_id, $union_id) { $objPlayerData = $this->get_data('Player'); $player_info = $objPlayerData->get_player_info($player_id, array('career_type', 'level', 'union_id')); $union_id = $player_info['union_id']; $union_id = intval($union_id); if ($union_id < 1) { $this->throw_error('170303'); } $objUnionInfoData = $this->get_data('UnionInfo'); $unionInfo = $objUnionInfoData->get_union_info($union_id); if (empty($unionInfo)) { $this->throw_error('170303'); } if ($unionInfo['player_num'] > 1) { $this->throw_error('174001'); } //加锁 if (!Com_Lock::lock('lock|union_player|player_num|union_id=' . $union_id)) { //系统繁忙 $this->throw_error('170501'); } $this->start_trans(); $objUnionPlayerData = $this->get_data('UnionPlayer'); $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id); //删除公会成员 $setUnionInfo['player_num'] = 0; $setUnionInfo['create_player_id'] = 0; $setUnionInfo['create_player_name'] = ''; $setUnionInfo['union_name'] = ''; Com_Log::debug_write('update_union_info', "dismiss_union|unoin_id={$union_id}" . json_encode($setUnionInfo)); $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $setUnionInfo); $retUnionPlayerInfo = $objUnionPlayerData->del_union_player($union_id, $player_id); $setPlayerInfo = array("union_id" => 0, "union_name" => "", "union_job" => 0); $retPlayerInfo = $this->get_data('Player')->update_player_info($player_id, $setPlayerInfo); $retUnionRank = $objUnionInfoData->delete_union_rank($union_id); //保留删除前数据 $objUnionPlayerHisData = $this->get_data('UnionPlayerHis'); $unionPlayerInfo['quit_time'] = time(); $retPlayerHisInfo = $objUnionPlayerHisData->update_union_player_info($player_id, $unionPlayerInfo); if ($retUnionInfo && $retUnionPlayerInfo && $retPlayerInfo && $retUnionRank && $retPlayerHisInfo) { $this->commit(); $this->get_game('Union')->Sync_Union_msg($union_id, -1, 2, 0, true); } else { $this->rollback(); $this->throw_error('10101'); } $update_player_detail_data['union_achieve_attr'] = array(); $this->get_data('PlayerDetail')->update_player_detail($player_id, $update_player_detail_data); Protocol_Player::p2c_part_update($player_id, array('union_id' => 0, 'union_name' => '', 'union_job' => 0, 'attr' => array(), 'player_data' => array('player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])))); $this->get_data("PlayerDailyTime")->set_used_time($player_id, "union_player_contribute", 0); Protocol::input($player_id, 7, 4, 511, array($player_id, 0, 0)); $this->get_data("Player")->add_no_union_player($player_id, $player_info['level']); #公会成员战力 $this->get_data("UnionInfo")->del_union_player_sum_fpower($union_id, $player_id); return array(1, $union_id); }
public function CMD2_1026() { $lockKey = 'CMD2_1026:' . $this->_authuser['player_id']; if (!Com_Lock::lock($lockKey)) { $this->check_error('1714001'); #加锁失败 } $data = $this->get_game('TaskChain')->finish_task_chain($this->_authuser['player_id'], $this->_param[0]); Com_Lock::unLock($lockKey); Protocol::input($this->_authuser['player_id'], 3, 10, 1025, $data); }