private function get_redis_key($week_offset = 0) { $time = $this->current_time - $week_offset * 7 * 86400; $week_date = Com_Util::get_next_week_day($time, false); # 每周周日 $redis_key = $this->week_fame_sorted_set . "|" . $week_date; Com_Log::write('xgame.magic_parliament', "get_redis_key: time={$time}|get_reids_key:{$redis_key}"); return $redis_key; }
public function _cal_login_refer($player_id, $event_date_head = 0, $event_date_tail = 0) { $login_series_max = $login_acc = 0; if (empty($player_id) || empty($event_date_head) || empty($event_date_tail)) { return array($login_series_max, $login_acc); } # 没有定义活动周期 # 出于效率考虑,日志查询仅执行1次 $event_logs = $this->get_data('Event')->get_player_event_log_login($player_id, $event_date_head, $event_date_tail); if (empty($event_logs)) { return array($login_series_max, $login_acc); } $login_status = array(); # 轮询活动所跨日期区间 $event_date_end = Com_Util::get_date_end($event_date_tail); $loop_time = $event_date_head; while ($loop_time < $event_date_end) { $day_stt = Com_Util::get_date_start($loop_time); # 当前起始时间戳 $day_end = Com_Util::get_date_end($loop_time); # 当前结束时间戳 #$day_stt_correct = max($day_stt, $event_date_head); # 修正,由于日志记录严格按照活动时间获取,故没必要修正 #$day_end_corrent = min($day_end, $event_date_tail); # 修正,由于日志记录严格按照活动时间获取,故没必要修正 foreach ($event_logs as $event_log) { if ($event_log['login_time'] >= $day_stt && $event_log['login_time'] <= $day_end) { # 当天有登录,结束循环 $login_status[$day_stt] = 1; break; } elseif ($event_log['logout_time'] >= $day_stt && $event_log['logout_time'] <= $day_end) { # 当天有登出,则也算有登录 $login_status[$day_stt] = 1; break; } } $loop_time += 86400; } $login_acc = count($login_status); $login_series = 0; # 当前计数连续登录天数 $pre_day_time = 0; # 前一天当前时间戳 if (!empty($login_status)) { foreach ($login_status as $day_time => $status) { if (empty($login_series)) { $login_series = 1; } else { if ($day_time - $pre_day_time == 86400) { $login_series += 1; } else { $login_series_max = max($login_series_max, $login_series); $login_series = 0; } } $pre_day_time = $day_time; } } return array($login_series_max, $login_acc); }
public function gain_free_reward($player_id, $plm_id) { $this->param_check_numeric(array($player_id, $plm_id)); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); # 获取议会配置信息 $plm_conf = Cache_MagicParliament::getInstance()->get_parliament_conf($plm_id); if (empty($plm_conf)) { $this->throw_error('100002'); # 获取魔法议会配置失败 } # 议会免费奖励领取上限 $free_reward_gain_stint = $this->get_free_reward_gain_stint($plm_id, $plm_conf); # 获取玩家当日免费奖励领取次数 $free_reward_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id'])); # 判断上限 if ($free_reward_num >= $free_reward_gain_stint) { $this->throw_error('100008'); # 魔法议会免费领奖次数超过上限 } $this->start_trans(); # 更新免费奖励领取次数 $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id'])); $this->write_check($re, 3010223); # 发放免费奖励 $reward = array(); $reward_detail = $this->get_game('Reward')->get_reward_detail($plm_conf['free_reward']); $this->get_game('Reward')->gen_reward_array($reward_detail, $reward); if (!empty($reward)) { $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2506'), 1); $this->write_check_strict($re, 3010411); } # 记录行为日志 $action_log = array('player_id' => $player_id, 'reg_time' => $this->current_time, 'plm_id' => $plm_id, 'action_type' => 3, 'reward_info' => json_encode($reward_detail)); $re = $this->get_data('MagicParliament')->record_action_log($action_log); $this->write_check_strict($re, 3010445); $this->commit(); # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更 $ret = $this->get_game('Reward')->add_reward_log(true); # 刷新议会信息 $out_2503 = $this->init_magic_parliament_deatil($player_id, $plm_id); Protocol::input($player_id, 3, 25, 2503, $out_2503); # 记录行为 Com_Log::debug_write('xgame.magic_parliament', "{$player_id}\t" . "gain_free_reward\t" . "{$plm_id}\t"); $out_2506 = array(); return $out_2506; }
public function compose($player_id, $target_id, $comp_type, $comp_sub_type, $auto_buy, $onekey) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); # 参数校验,comp_sub_type允许为0 $this->param_check_numeric(array($player_id, $target_id, $comp_type, $comp_sub_type), 0); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level'))); # 一键合成不允许自动购买 if ($onekey) { $auto_buy = 0; } # 获取具体合成信息 $comp_info = Cache_ItemCompose::getInstance()->get_item_compose_info_by_target_id($target_id); if (empty($comp_info)) { $this->throw_error('90002'); # 没有配置该道具的合成信息 } $comp_type = $comp_info['comp_type']; $comp_sub_type = $comp_info['comp_sub_type']; /** 由于前端问题,传参此处可能报异常,反正这两个参数不实用,故忽略 if ($comp_info['comp_type'] != $comp_type || $comp_info['comp_sub_type'] != $comp_sub_type) { $this->throw_error('90003'); # 合成参数异常 } **/ # 检查消耗情况 $cost_material_info_hash = array(); # 消耗材料信息哈希,为了方便一次性查找所有消耗材料的持有数 for ($i = 1; $i <= 5; $i++) { if (!empty($comp_info['m' . $i . '_id']) && !empty($comp_info['m' . $i . '_amount'])) { $cost_material_info_hash[$comp_info['m' . $i . '_id']] = $comp_info['m' . $i . '_amount']; } } # -------------------------------------------------------------------- # 计算可一键合成的产物数量 # -------------------------------------------------------------------- $onekey_num_list = array(); # 每项材料可以满足合成条件几次 if (!empty($cost_material_info_hash)) { $material_hold_nums = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, array_keys($cost_material_info_hash)); foreach ($cost_material_info_hash as $m_id => $m_amount) { $onekey_num_list[$m_id] = intval($material_hold_nums[$m_id] / $m_amount); } } $onekey_num = min($onekey_num_list); # 木桶原理,能一键合成的产物数由最少材料项决定 if ($onekey) { if (empty($onekey_num)) { $this->throw_error('90004'); # 合成所需材料不足 } $onekey_num = min($onekey_num, intval($player_info['silver'] / $comp_info['cost'])); # 木桶原理,能一键合成的产物数还由玩家持有货币决定 if (empty($onekey_num)) { $this->throw_error('10113'); # 金币不足 } } else { if (empty($onekey_num) && empty($auto_buy)) { $this->throw_error('90004'); # 合成所需材料不足 } $onekey_num = 1; # 非一键合成一次只允许合成一件 } $this->start_trans(); # 消耗虚拟货币 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $comp_info['cost'] * $onekey_num, 1, 1); # 消耗材料 $arr_logs = array(); $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2202); foreach ($cost_material_info_hash as $m_id => $m_amount) { $hold_num = !empty($material_hold_nums[$m_id]) ? $material_hold_nums[$m_id] : 0; if (!empty($auto_buy) && $hold_num < $m_amount) { # 一定是单次合成 # 获取正确的单价 $price_info = $this->get_game('Shop')->shortcut_purchase_interface($m_id, 1); if (empty($price_info['item_price'])) { $this->throw_error('130001'); # 商城没有出售该道具 } # 策划价格配置多项时,选其中一项 list($cur_idx, $cur_val) = each($price_info['item_price']); $price = $cur_val; $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx); $cost_currency_value = intval($cur_val * ($m_amount - $hold_num)); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cur_idx); if ($hold_num > 0) { # 该方法在道具不足时会报错,无需外层再判断是否道具足够 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $material_hold_nums[$m_id], $arr_logs, 0, $log_param); $this->write_check($re, 3010156); } # 若有购买缺少材料,记录虚假商城购买日志 if ($cost_currency_value > 0) { $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $m_id, intval($m_amount - $hold_num), $cur_idx, $cost_currency_value, 2202); } } else { # 可能单次,可能一键 # 该方法在道具不足时会报错,无需外层再判断是否道具足够 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $m_amount * $onekey_num, $arr_logs, 0, $log_param); $this->write_check($re, 3010161); } } # TODO: 数据中心推送 $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2202'); $this->write_check($re, 3010167); #--------------------------------------------------------------------- # 按概率计算成功次数 #--------------------------------------------------------------------- $success_num = 0; for ($i = 1; $i <= $onekey_num; $i++) { if (Com_Random::probability($comp_info['succ_rate'], 10000)) { # 成功 $success_num += 1; } } if ($success_num) { # 成功 # 发送道具 $reward[] = array('type' => 'prop', 'item_id' => $target_id, 'item_num' => $success_num); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2202)); #send_reward失败时,会返回各种失败情况的错误码 $this->write_check_strict($re, 3010173); } # 记录合成日志 $this->commit(); # -------------------------------------------------------------------- # 通知道具变更,粘包806 # -------------------------------------------------------------------- $this->get_game('Reward')->add_reward_log(); # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志 if (!empty($arr_logs) && is_array($arr_logs)) { $ndata = array(); foreach ($arr_logs as $key => $val) { $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); } # -------------------------------------------------------------------- # 刷新2201协议 # -------------------------------------------------------------------- $data_2201 = $this->get_compose_info($player_id, $comp_type, $comp_sub_type); Protocol::input($player_id, 3, 22, 2201, $data_2201); # 记录行为 Com_Log::write('xgame.compose', "{$player_id}\t" . "{$target_id}\t" . "{$auto_buy}\t" . "{$onekey}\t" . "{$onekey_num}\t" . "{$success_num}\t"); # 日常任务埋点,宝石合成才触发,考虑宝石种类可能包含多种,不方便使用$arr_logs[0]['type'] == 3 && $arr_logs[0]['sub_type'] == 6类似条件 #if ($comp_type == $this->comp_type_for_gem) { # 改为任意合成都算 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 109, 109, $onekey_num); #} #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 12, $onekey_num); # -------------------------------------------------------------------- # 公告 # -------------------------------------------------------------------- $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 70), array('rep_type' => 2, 'rep_val' => $target_id)); $prop_info = Cache_Prop::getInstance()->get_prop_info($target_id); $this->get_game('SystemNotice')->push_sys_notice($player_id, 70, 0, $replace_info, 0, $prop_info['need_broad_cast']); $out_2202 = array('result' => 1); return $out_2202; }
/** * @Purpose: * 购买金蛋活动挑战次数 * @param $player_id 玩家ID */ public function buy_egg_active_times($player_id) { $player_id = intval($player_id); $buy_times_table = Cache_BuyTimes::getInstance()->get_buy_times_info(9); if (!$buy_times_table) { $this->throw_error('113602'); #buy_times配置表读取错误 } else { if (!isset($buy_times_table['max_times']) || $buy_times_table['max_times'] < 1) { $this->throw_error('113701'); #buy_times配置表的max_times字段配置错误 } else { if (!isset($buy_times_table['cost_num']) || empty($buy_times_table['cost_num'])) { $this->throw_error('113702'); #buy_times配置表的cost_num字段配置错误 } else { if (!isset($buy_times_table['cost_type']) || $buy_times_table['cost_type'] < 1) { $this->throw_error('113704'); #buy_times配置表的cost_type配置错误 } else { if (!isset($buy_times_table['per_num']) || $buy_times_table['per_num'] < 1) { $this->throw_error('113705'); #buy_times配置表的per_num配置错误 } } } } } #获取玩家已购买的次数 $player_times = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'buy_egg_active_times'); #$player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'ticket', 'gold', 'privilege_level')); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'ticket', 'gold', 'silver', 'privilege_level'))); if ($player_times >= $buy_times_table['max_times']) { $this->throw_error('10225'); #购买次数已满 } $cost_num = explode("|", $buy_times_table['cost_num']); $expend_coin = $cost_num[$player_times]; if ($expend_coin < 1) { $this->throw_error('113703'); #buy_times配置表的cost_num字段配置消耗不足 } $cost_currency_key = Cache_Currency::getInstance()->get_key($buy_times_table['cost_type']); if (empty($cost_currency_key)) { $this->throw_error('113704'); #buy_times配置表的cost_type配置错误 } # 消耗货币 /***************/ $ticket = 0; $gold = $expend_coin; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] >= $expend_coin) { $ticket = $expend_coin; $gold = 0; } else { $ticket = $player_info['ticket']; $gold = $expend_coin - $player_info['ticket']; } } $arr_consume = array('price' => $expend_coin, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 /***************/ $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $expend_coin, 1, $buy_times_table['cost_type']); $this->start_trans(); #增加挑战次数 $add_res = $this->get_data('PlayerDailyTime')->pre_add_used_time($player_id, 'add_egg_active_times', $buy_times_table['per_num']); if (!$add_res) { $this->throw_error('10104'); } #增加购买次数 $add_buy_res = $this->get_data('PlayerDailyTime')->pre_add_used_time($player_id, 'buy_egg_active_times'); if (!$add_buy_res) { $this->throw_error('10104'); } #扣货币 $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 758, array(), $arr_consume); if (!$update_res) { $this->throw_error('10104'); } $this->commit(); $cost_type = 0; $cost_num = 0; $add_times = 0; if ($player_times + 1 < $buy_times_table['max_times']) { $num = explode("|", $buy_times_table['cost_num']); $cost_num = $num[$player_times + 1]; $cost_type = $buy_times_table['cost_type']; $add_times = $buy_times_table['per_num']; } return array('id' => intval($cost_type), 'num' => intval($cost_num), 'add_times' => intval($add_times)); }
/** * @Purpose: * 提升英雄成长值 * @Param $player_id * @Param $hero_id * @Param $state 0普通提升 1批量提升 * @Param $auto 为1时表示道具不足时从上次自动购买道具 */ public function player_hero_grow_upgrade($player_id, $hero_id, $state, $auto = 0) { $player_id = intval($player_id); $hero_id = strval($hero_id); $obj_player_hero_data = $this->get_data('PlayerHero'); $hero_data = $obj_player_hero_data->get_player_hero_info($player_id, $hero_id); if (empty($hero_data)) { $this->throw_error('10102'); #英雄不存在 } $hero_conf = Cache_HeroAttr::getInstance()->get_hero_attr_info($hero_data['hero_code']); if (empty($hero_conf)) { $this->throw_error('50120'); #英雄配置错误 } if ($hero_data['grow_rate'] >= $hero_conf['grow_limit']) { $this->throw_error('50121'); #成长值已达上限 } $obj_hero_grow = $this->get_data('PlayerHeroGrow'); $hero_grow_id = $obj_hero_grow->get_player_hero_grow_data($hero_id); $hero_grow_conf = array(); $findFlag = false; if (!$hero_grow_id) { $findFlag = true; } else { $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id); if (empty($hero_grow_conf)) { $findFlag = true; } else { if ($hero_data['grow_rate'] < $hero_grow_conf['grow_left'] || $hero_data['grow_rate'] >= $hero_grow_conf['grow_right']) { #区间错误 $findFlag = true; } } } if ($findFlag) { #启动自动纠错 $hero_grow_id = $this->find_hero_grow_id($hero_data['grow_rate'], $hero_grow_conf); if (!$hero_grow_id) { $this->throw_error('10111'); #配置错误 } } if (empty($hero_grow_conf)) { $this->throw_error('10111'); } $obj_prop_game = $this->get_game('Prop'); $obj_shop_game = $this->get_game('Shop'); $consume_props = $last_props = $arr_consume = $arr_shop_log = array(); $last_props[$hero_grow_conf['item_id']] = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $hero_grow_conf['item_id'])); if (empty($auto) && $last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) { $this->throw_error('50107'); } $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); $crit_counter = 0; #暴击计数 $counter = 10; #while执行计数 $sum_rand_grow_val = 0; #总提升数量 $new_hero_grow_val = 0; #新的成长值 $upgrade_times = $counter; $error_code = 0; $update_gold = false; #是否更新彩钻或钻石资源 do { $need_buy_prop_nums = 0; #每次执行所需要的材料需在商城购买的数量 if ($last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) { $last_props[$hero_grow_conf['item_id']] = 0; $need_buy_prop_nums = $hero_grow_conf['item_nums'] - $last_props[$hero_grow_conf['item_id']]; if ($last_props[$hero_grow_conf['item_id']] > 0) { $consume_props[$hero_grow_conf['item_id']] += $last_props[$hero_grow_conf['item_id']]; } } else { $last_props[$hero_grow_conf['item_id']] -= $hero_grow_conf['item_nums']; #剩余数量 $consume_props[$hero_grow_conf['item_id']] += $hero_grow_conf['item_nums']; #消耗数量 } if ($need_buy_prop_nums > 0) { #材料不足需要在商城购买 $update_gold = true; $buy_prop_info = $obj_shop_game->shortcut_purchase_interface($hero_grow_conf['item_id'], 1); if (empty($buy_prop_info['item_price'])) { $this->throw_error('130001'); #商城没有出售该道具 } list($cost_currency_type, $cost_currency_value) = each($buy_prop_info['item_price']); $cost_currency_value *= $need_buy_prop_nums; $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_tmp_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $need_buy_prop_nums); if (!empty($arr_tmp_consume)) { $arr_consume['price'] += $arr_tmp_consume['price']; $arr_consume['gold'] += $arr_tmp_consume['gold']; $arr_consume['ticket'] += $arr_tmp_consume['ticket']; $arr_consume['count'] += $arr_tmp_consume['count']; } #虚拟商城记录日志 if (!isset($arr_shop_log[$hero_grow_conf['item_id']])) { $arr_shop_log[$hero_grow_conf['item_id']]['cost_resource_id'] = $cost_currency_type; } $arr_shop_log[$hero_grow_conf['item_id']]['item_num'] += $need_buy_prop_nums; $arr_shop_log[$hero_grow_conf['item_id']]['cost_resource_num'] += $cost_currency_value; $error_code = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 0, $cost_currency_type); if ($error_code !== true) { if ($counter == 10) { #首次执行如果资源不足则退出 $this->throw_error($error_code); } break; } } $counter--; $rand_val = 0; $is_crit = Com_Random::probability($hero_grow_conf['crit_rate']); if ($is_crit) { $crit_counter++; $rand_val = $this->parse_data($hero_grow_conf['val_crit']); } else { $rand_val = $this->parse_data($hero_grow_conf['val_nor']); } if (!$rand_val) { $this->throw_error('50122'); #英雄成长配置表解析错误 } #单次随机值 $real_rand_val = Com_Random::get_probability_key($rand_val); #批量随机值之和 $sum_rand_grow_val += $real_rand_val; #英雄的新成长值 $new_hero_grow_val = $hero_data['grow_rate'] + $sum_rand_grow_val; if ($new_hero_grow_val >= $hero_conf['grow_limit']) { #超过英雄成长值上限 $new_hero_grow_val = $hero_conf['grow_limit']; $sum_rand_grow_val = $hero_conf['grow_limit'] - $hero_data['grow_rate']; break; } #移动至下一个成长值区间 if ($new_hero_grow_val > $hero_grow_conf['grow_right']) { $hero_grow_id++; $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id); if (empty($hero_grow_conf)) { break; } if (!isset($last_props[$hero_grow_conf['item_id']])) { $last_props[$hero_grow_conf['item_id']] = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $hero_grow_conf['item_id'])); } } if (empty($auto) && $last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) { #道具不足 break; } } while ($counter > 0 && $state > 0); #控制循环数量防止进入死循环 $this->start_trans(); $result = true; if ($update_gold) { $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 557, array(), $arr_consume); $this->write_check($result, 3010476); } if (!empty($consume_props)) { $log_param = array('cmd_id' => 557, 'level' => $player_info['level'], 'vip' => $player_info['vip']); $logs = array(); foreach ($consume_props as $prop_id => $prop_nums) { #批量扣除多个道具如果可能 $result = $obj_prop_game->deduct_prop_by_prop_id($player_id, $prop_id, $prop_nums, $logs, 1, $log_param); if (!$result) { $this->throw_error('10101'); } } } if ($result) { $hero_data['grow_rate'] = $new_hero_grow_val; $hero_data['fight'] = $this->calc_fight($player_id, $hero_data, $hero_data['fit'], $hero_data['rune_hole_list'], $hero_data['star_add_attr_per'], $hero_data['skill_list']); $update_field['grow_rate'] = $hero_data['grow_rate']; $update_field['fight'] = $hero_data['fight']; $result = $this->update_db($player_id, $update_field, $hero_data, 557); $this->get_data('RankList')->update_hero_rank($hero_id, $hero_data['fight']); } if ($result) { $this->commit(); $obj_hero_grow->set_player_hero_grow_data($hero_id, $hero_grow_id); $n_hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id); #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 26, $upgrade_times - $counter); $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 37, $hero_data['grow_rate'] + $hero_data['fit_grow'], 8); if (!empty($arr_shop_log)) { foreach ($arr_shop_log as $item_id => $item_info) { $obj_shop_game->add_dummy_shop_log($player_id, $player_info, $item_id, $item_info['item_num'], $item_info['cost_resource_id'], $item_info['cost_resource_num'], 557); } } return array('res' => $crit_counter, 'rand_val' => $sum_rand_grow_val, 'cur_grow_val' => $new_hero_grow_val, 'effect' => 10000 * round($this->calc_grow_attar($new_hero_grow_val, $hero_conf['grow']), 4), 'prop_id' => $n_hero_grow_conf['item_id'], 'prop_nums' => $n_hero_grow_conf['item_nums'], 'nor_desc' => $n_hero_grow_conf['nor_desc'], 'crit_desc' => $n_hero_grow_conf['crit_desc']); } else { $this->throw_error('10101'); } }
/** * 道具属性结构体 * @param $data * @return array */ public static function get_item_additions(&$data) { $attr_index = Cache_ItemKey::getInstance()->get_item_key(); $role_index = Cache_RoleKey::getInstance()->get_item_key(); // echo "sub_type:".$data['sub_type']."<br>"; $out = array(); $arr_other = array(); $fpower_calc = array(); $fpower_base_calc = array(); if ($data['type'] == 1 || $data['type'] == 6) { if (empty($data['player_prop_id'])) { // $attrData = Cache_EquipBaseAttr::getInstance()->get_equip_base_attr($data['sub_type'],$data['quality'],$data['level'],$data['star_level']); $obj = new Game_Prop(); $attrData = $obj->get_equip_attr($data); unset($obj); // Com_Log::log($attrData,'cache_prop',1); $data['base_attr'] = $attrData['base_attr']; $data['addition_attr'] = $attrData['addition_attr']; $data['base_attr'] = $attrData['base_attr']; $data['level'] = $attrData['level']; $data['intensive_level'] = $attrData['intensive_level']; $data['intensive_desc'] = $attrData['intensive_desc']; } # ---------------------------------------------------------------- # 星图加成信息 # ---------------------------------------------------------------- $star_map = array(); $we_swallow_revise_info = array(); if (!empty($data['star_map_desc'])) { if (is_string($data['star_map_desc'])) { $data['star_map_desc'] = json_decode($data['star_map_desc'], true); } $star_map = self::parse_star_map($data['star_map_desc']); } # ---------------------------------------------------------------- # 基础属性 # ---------------------------------------------------------------- if (!empty($data['base_attr'])) { if (is_string($data['base_attr'])) { $data['base_attr'] = json_decode($data['base_attr'], true); } list($key, $val) = each($data['base_attr']); //基础属性 就一个 # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_base_calc[$key] += $val; # ---------------------------------------------------------------- # 强化属性加成 # ---------------------------------------------------------------- if (!empty($data['intensive_desc'])) { if (is_string($data['intensive_desc'])) { $data['intensive_desc'] = json_decode($data['intensive_desc'], true); } list($i_key, $i_val) = each($data['intensive_desc']); //强化属性 if ($i_key == 'atk' || $i_key == 'atk_max') { $i_key = 'atk_min'; } if (isset($star_map['intensify'])) { $i_val += ceil($i_val * ($star_map['intensify'] / 10000)); //星图加成 } $fpower_calc[$i_key] += $i_val; } $fpower_calc[$key] += $val; $out[] = array(0 => intval($attr_index['equip_base_val']), 1 => array(0 => $role_index[$key], 1 => ceil($val), 2 => 0, 3 => $i_val)); } # ---------------------------------------------------------------- # 附加属性 # ---------------------------------------------------------------- if (!empty($data['addition_attr']) && is_array($data['addition_attr'])) { $out_additional = array(); foreach ($data['addition_attr'] as $key => $val) { # -------------------------------------------------------- # 翅膀装备吞噬属性加成 # -------------------------------------------------------- if (!empty($data['we_swallow_info']) && is_array($data['we_swallow_info']['swallow_attr'])) { if (isset($data['we_swallow_info']['swallow_attr'][$key])) { $add_val = $data['we_swallow_info']['swallow_attr'][$key]; if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_calc[$key] += $add_val; } } # -------------------------------------------------------- # 星图加成 # -------------------------------------------------------- if (isset($star_map['additional'])) { $val += $val * ($star_map['additional'] / 10000); } # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_base_calc[$key] += $val; if (in_array($key, Cache_AttrConfig::getInstance()->get_percent_key())) { $show_type = 1; //前端显示百分比 } else { $show_type = 0; } $out_additional[] = array(0 => $role_index[$key], 1 => ceil($val), 2 => $show_type, 3 => ceil($add_val), 'sort_priority' => self::$_sort_priority[$key]); $fpower_calc[$key] += $val; } # 排序 Com_Array::multisort($out_additional, array('sort_priority' => 'asc')); unset($out_additional['sort_priority']); $out[] = array(0 => $attr_index['equip_additional'], 1 => $out_additional); } # ---------------------------------------------------------------- # 洗练属性 # ---------------------------------------------------------------- if ($data['type'] == 1) { # 只有装备类才获取 if (empty($data['refine_attr']) || empty($data['refine_info'])) { # 为空显示默认洗练属性 if (!Com_Util::is_first_charge_item($data['prop_id'])) { list($data['refine_attr'], $data['refine_info']) = TenYear::getInstance('Game_EquipRefine')->extend_refine($data['sub_type'], $data['level']); } } if (!empty($data['refine_attr']) && is_array($data['refine_attr'])) { $out_refine = array(); $attr_perfection_sum = 0; $attr_progress_sum = 0; foreach ($data['refine_attr'] as $attr_seq => $attr_info) { # -------------------------------------------------------- # 注意,这两项的取值必须在key做转换之前,否则在key转换后可能导致取不到值 # -------------------------------------------------------- $attr_limit = $data['refine_info']['attr_info'][$attr_seq]['refine_attr_value'] + $data['refine_info']['attr_info'][$attr_seq]['attr_stint']; $attr_ratio = $data['refine_info']['attr_info'][$attr_seq]['attr_ratio']; $attr_progress = ceil($data['refine_info']['attr_info'][$attr_seq]['en_refine_attr_value'] / $data['refine_info']['attr_info'][$attr_seq]['attr_stint'] * 10000); # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if (!is_array($attr_info)) { continue; } # TODO: 为了兼容旧的洗练数据,以后要清档上功能,可以除去这行 list($key, $val) = each($attr_info); if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } $fpower_base_calc[$key] += $val; $fpower_calc[$key] += $val; $out_refine[] = array(0 => $role_index[$key], 1 => ceil($val), 2 => 0, 3 => $attr_limit, 'sort_priority' => self::$_sort_priority[$key]); $attr_perfection_sum += $attr_ratio; $attr_progress_sum += $attr_progress; } # 排序 Com_Array::multisort($out_refine, array('sort_priority' => 'asc')); unset($out_refine['sort_priority']); $out[] = array(0 => $attr_index['equip_refine'], 1 => $out_refine); $out[] = array(0 => $attr_index['equip_refine_perfection'], 1 => ceil($attr_perfection_sum / 5)); $out[] = array(0 => $attr_index['equip_en_refine_progress'], 1 => ceil($attr_progress_sum / $data['refine_info']['last_refine_type'])); } } #策划要一个道具的基础属性战力 $fpower_base = Formula_Fpower::calc_fpower($fpower_base_calc); $out[] = array(0 => intval($attr_index['raw_fpower']), 1 => $fpower_base); # ---------------------------------------------------------------- # 强化等级 # ---------------------------------------------------------------- if (!empty($data['intensive_level'])) { $out[] = array(0 => $attr_index['intensive_level'], 1 => $data['intensive_level']); } # ---------------------------------------------------------------- # 最大强化等级 # ---------------------------------------------------------------- if ($data['type'] == 1) { # 只有装备类才获取 $intensify_lv_limit = TenYear::getInstance('Game_EquipIntensifier')->get_intensify_lv_limit_by_item_level($data['level']); $out[] = array(0 => $attr_index['intensify_max'], 1 => $intensify_lv_limit); } # ---------------------------------------------------------------- # 强化属性 # ---------------------------------------------------------------- if (!empty($data['intensive_desc'])) { if (is_string($data['intensive_desc'])) { $data['intensive_desc'] = json_decode($data['intensive_desc'], true); } $val = 0; list($key, $val) = each($data['intensive_desc']); //强化属性 # atk相关特殊处理,将atk与atk_max替换成atk_min,因为role_key只有atk_min if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } if (isset($star_map['intensify'])) { $val += ceil($val * ($star_map['intensify'] / 10000)); //星图加成 } $fpower_calc[$key] += $val; $out[] = array(0 => $attr_index['equip_strengthen_val'], 1 => $val); } # ---------------------------------------------------------------- # 翅膀装备吞噬等级与经验 # ---------------------------------------------------------------- if ($data['type'] == 6) { # 只有翅膀装备类才获取 if (!empty($data['we_swallow_info'])) { $out[] = array(0 => $attr_index['wing_equip_swallow_lv'], 1 => $data['we_swallow_info']['swallow_lv']); $out[] = array(0 => $attr_index['wing_equip_swallow_exp'], 1 => $data['we_swallow_info']['swallow_exp']); } else { $out[] = array(0 => $attr_index['wing_equip_swallow_lv'], 1 => 0); $out[] = array(0 => $attr_index['wing_equip_swallow_exp'], 1 => 0); } } # ---------------------------------------------------------------- # 镶嵌宝石属性 # ---------------------------------------------------------------- $gem_item = array(); $gem_configs = array(); $hole_stint = TenYear::getInstance('Game_EquipInlayGems')->get_prop_inlay_gem_hole_stint($data); # 孔位上限 for ($i = 1; $i <= $hole_stint; $i++) { //镶嵌部分 if (!empty($data['inlay_gems'][$i])) { $gem_id = $data['inlay_gems'][$i]; if (!isset($gem_configs[$gem_id])) { $gem_configs[$gem_id] = Cache_Forge::getInstance()->get_inlay_gems_by_id($gem_id); } $attr = self::parse_gem_config_attr($gem_configs[$gem_id]); $out_additional = array(); $gem_fpower = 0; if (!empty($attr)) { foreach ($attr as $key => $val) { if ($key == 'atk' || $key == 'atk_max') { $key = 'atk_min'; } if (isset($star_map['gem'])) { $val += ceil($val * ($star_map['gem'] / 10000)); //星图加成 } /** if(in_array($key,Cache_AttrConfig::getInstance()->get_percent_key())){ $show_type = 1; //前端显示百分比 } else{ $show_type = 0; } **/ if (isset($role_index[$key])) { $fpower_calc[$key] += $val; $out_additional[] = array(0 => $role_index[$key], 1 => intval($val)); } } $gem_fpower += Formula_Fpower::calc_fpower($attr); } $gem_item[] = array(0 => $i, 1 => self::get_prop_struct($gem_configs[$gem_id]), 2 => $gem_fpower, 3 => $out_additional); //0 sid 1 战力 2 属性 } else { $gem_item[] = array(0 => $i, 1 => array(), 2 => 0, 3 => array()); //0 sid 1 战力 2 属性 } } $out[] = array(0 => $attr_index['gem'], 1 => $gem_item); //星图属性 if (isset($data['star_map_id']) && $data['star_map_id'] > 0) { $star_attr = array(); $star_map_config = Cache_Prop::getInstance()->get_prop_info($data['star_map_id']); $star_attr['star'] = self::get_prop_struct($star_map_config); $star_attr['power'] = 0; //战力计算 $star_attr['property'] = array(); $star_map_info = Cache_Forge::getInstance()->get_star_map_config_byid($data['star_map_id']); if ($star_map_info) { foreach ($star_map_info as $k => $v) { $a = array(); $a['addition_type'] = self::$_star_map_attr_enum[$v['data']]; #$a['addition_key'] = $v['data']; $a['addition_val'] = $v['data_value']; if (isset($attr_index[$k])) { // if(!isset($attr_index[$k])){ // Com_Log::log($k,'addition',1); // } $a['condition_type'] = 0; $a['condition_key'] = array('k' => $attr_index[$k], 'v' => $v['limit_value'], 'per' => 0); } else { if ($k == 'inlay_gems_lv') { $a['condition_type'] = 1; } elseif ($k == 'inlay_gems') { $a['condition_type'] = 2; } elseif ($k == 'activate') { $a['condition_type'] = 3; } $a['condition_key'] = array('k' => 0, 'v' => $v['limit_value'], 'per' => 0); } $star_attr['property'][] = $a; } } $out[] = array(0 => $attr_index['star'], 1 => $star_attr); } # ---------------------------------------------------------------- # 吞噬属性:需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 # ---------------------------------------------------------------- list($allow_swallow_sub_type, $allow_swallow_id) = TenYear::getInstance('Game_EquipSwallow')->get_swallow_restriction_info($data['sub_type']); $distinct_swallow_list = Cache_Forge::getInstance()->get_distinct_swallow_list(); foreach ($distinct_swallow_list as $swallow_info) { if (!empty($allow_swallow_id) && !in_array($swallow_info['swallow_id'], $allow_swallow_id)) { continue; } $swallow[$swallow_info['swallow_id']] = array('swallow_id' => $swallow_info['swallow_id'], 'swallow_lv' => 0, 'swallow_exp' => 0); } if (!empty($data['swallow_info'])) { foreach ($data['swallow_info'] as $swallow_id => $swallow_info) { $swallow[$swallow_id] = array('id' => $swallow_info['swallow_id'], 'lv' => $swallow_info['swallow_lv'], 'value' => $swallow_info['swallow_exp']); } } $out[] = array(0 => $attr_index['swallow'], 1 => $swallow); if (!empty($data['equip_view'])) { if (is_string($data['equip_view'])) { $equip_view = $data['equip_view']; } else { $equip_view = implode(':', $data['equip_view']); } if ($equip_view == '0:0:0:0' || $equip_view == '0:0:0') { $equip_view = ''; } } $out[] = array(0 => $attr_index['equip_view'], 1 => $equip_view); if (!empty($fpower_calc)) { // Com_Log::log('============[start]===========','equip_fpower',1); // Com_Log::log("prop_id:{$data['prop_id']}",'equip_fpower',1); // Com_Log::log($fpower_calc,'equip_fpower',1); $data['fpower'] = Formula_Fpower::calc_fpower($fpower_calc); // Com_Log::log("fpower:{$data['fpower']}",'equip_fpower',1); // Com_Log::log('============[end]===========','equip_fpower',1); } else { $data['fpower'] = 0; } } foreach (self::$_out_base_keys as $key) { if ($key == 'bind_type') { #特殊处理下 if (isset($attr_index[$key]) && isset($data['bind_flag'])) { $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data['bind_flag'])); } } elseif ($key == 'star_level') { if ($data['star_level'] > 10) { $data['star_level'] = $data['show_star']; } $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data['star_level'])); } else { if (isset($attr_index[$key]) && isset($data[$key]) && !empty($data[$key])) { $out[] = array(0 => intval($attr_index[$key]), 1 => intval($data[$key])); } } } return $out; }
public function CMD2_557() { # 消耗虚拟货币 $player_id = $this->_authuser['player_id']; $out = array('player_id' => $player_id, "code" => 0); $cost_currency_key = Cache_Currency::getInstance()->get_key(20); $cost_currency_value = 1; $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'gold', 'silver', 'ticket', 'privilege_level', 'vip')); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value); $re = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 0, 20); if ($re !== true) { $out['code'] = 1; } else { $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '557', array(), $arr_consume); if (!$re) { $out['code'] = 1; } } Protocol::input($this->_authuser['player_id'], 5, 4, 557, $out); }
public function clear_challenge_battle_cd($player_id) { $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); # 获取挑战剩余cd时间 $remain_cd = $this->get_data('Challenge')->get_challenge_remain_cd($player_id); $this->start_trans(); # 消耗虚拟货币 $cost_currency_key = Cache_Currency::getInstance()->get_key($this->clear_cd_cost_currency_type); $cost_currency_value = Formula_Ladder::challenge_cd_prize($remain_cd); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1207', array(), $arr_consume); $this->write_check($re, 3011487); # 清除天梯挑战cd时间 $re = $this->get_data('Challenge')->clear_remain_cd($player_id); $this->write_check($re, 3011491); $this->commit(); $out = array('result' => 1); # 记录行为 Com_Log::write('xgame.challenge', "{$player_id}\t" . "clear_challenge_battle_cd\t"); return $out; }
public function equip_starmap_do($player_id, $player_prop_id, $star_spid) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); $this->param_check_numeric(array($player_id)); # 没有玩家信息 $player_info = $this->get_data('Player')->get_player_info($player_id); if (empty($player_info)) { $this->throw_error('10104'); } # 玩家没有该装备 $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id); if (empty($player_prop_info)) { $this->throw_error('80013'); } if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) { $this->throw_error('81103'); # 首充装备不允许觉醒 } # 824展示协议返回数据 $out_824 = array('player_prop_id' => $player_prop_id, 'star_pid' => $star_spid, 'box_up' => array(), 'box_down' => array()); $before_starmap_desc = $player_prop_info['star_map_desc']; # 判断行为类型:flag=0星图卸载;flag=1星图安装;flag=2星图替换 if (empty($star_spid)) { if (empty($player_prop_info['star_map_id'])) { $this->throw_error('80031'); //该装备未曾安装星图! } $flag = 0; } else { $flag = empty($player_prop_info['star_map_id']) ? 1 : 2; } # 检查旧星图配置信息【卸载||替换】 if ($flag == 0 || $flag == 2) { $starmap_config_forSend = Cache_Prop::getInstance()->get_prop_info($player_prop_info['star_map_id']); if (!$starmap_config_forSend) { $this->throw_error('80033'); //没有该星图的配置信息! } } # 检查新星图配置信息【安装||替换】 if ($flag == 1 || $flag == 2) { $starmap_info_forInstall = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $star_spid); if (!$starmap_info_forInstall) { $this->throw_error('80032'); //玩家没有该星图! } $out_824['box_up'] = array('pos' => $starmap_info_forInstall['item_position'], 'index' => $starmap_info_forInstall['grid']); $starmap_config_forInstall = Cache_Prop::getInstance()->get_prop_info($starmap_info_forInstall['prop_id']); if (!$starmap_config_forInstall) { $this->throw_error('80033'); //没有该星图的配置信息! } $starmap_config = Cache_Forge::getInstance()->get_starmap_info($starmap_info_forInstall['prop_id']); # 允许的装备种类检查 if (!empty($starmap_config[0]['require_sub_type'])) { $require_sub_type = explode(":", $starmap_config[0]['require_sub_type']); if (!in_array($player_prop_info['sub_type'], $require_sub_type)) { $this->throw_error('80035'); //该觉醒石不允许镶嵌在该种类的装备上 } } # 要求的等级检查 if (!empty($starmap_config[0]['require_equip_level']) && $player_prop_info['level'] < $starmap_config[0]['require_equip_level']) { $this->throw_error('80040'); # 装备等级低于觉醒石要求等级,不允许镶嵌 } } $this->start_trans(); if ($flag == 0 || $flag == 2) { //发放旧星图【卸载||替换】 $reward = array(); $sendarrLogs = array(); $reward[] = array('type' => 'prop', 'item_id' => $player_prop_info['star_map_id'], 'item_num' => 1); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 824)); #send_reward失败时,会返回各种失败情况的错误码 $this->write_check_strict($re, 3010130); $sendarrLogs = $this->get_game('Reward')->get_prop_log(); $out_824['box_down'] = array('pos' => $sendarrLogs[0]['item_position'], 'index' => $sendarrLogs[0]['grid']); if ($flag == 2) { //扣除新星图【替换】 $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $starmap_info_forInstall, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 824)); $this->write_check($re, 3010136); } } else { //扣除新星图【安装】 $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $starmap_info_forInstall, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 824)); $this->write_check($re, 3010140); } # 更新装备状态 if ($flag) { # 【安装||替换】 $player_prop_info['star_map_id'] = $starmap_info_forInstall['prop_id']; $player_prop_info['star_map_desc'] = $this->get_latest_starmap_desc($player_prop_info); } else { # 【卸载】 $player_prop_info['star_map_id'] = ''; $player_prop_info['star_map_desc'] = array(); } $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('star_map_id' => $player_prop_info['star_map_id'], 'star_map_desc' => $player_prop_info['star_map_desc'])); $this->write_check($re, 3010152); $this->commit(); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_info['player_prop_id'], 'item_id_master' => $player_prop_info['prop_id'], 'item_type' => $player_prop_info['type'], 'item_sub_type' => $player_prop_info['sub_type'], 'item_quality' => $player_prop_info['quality'], 'item_level' => $player_prop_info['level'], 'item_star_level' => $player_prop_info['star_level'], 'player_prop_id_install' => $starmap_info_forInstall ? $starmap_info_forInstall['player_prop_id'] : 0, 'item_id_install' => $starmap_info_forInstall ? $starmap_info_forInstall['prop_id'] : 0, 'player_prop_id_uninstall' => $sendarrLogs ? $sendarrLogs[0]['player_prop_id'] : 0, 'item_id_uninstall' => $sendarrLogs ? $sendarrLogs[0]['prop_id'] : 0, 'before_starmap_desc' => $before_starmap_desc, 'after_starmap_desc' => $player_prop_info['star_map_desc']); Log_Forge::getInstance()->add_log($log_info, 'starmap'); if ($flag == 1 || $flag == 2) { # 安装和替换才算 # 引导任务埋点 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 25, 1); } $this->handle_starmap_refer_achieve($player_id); # 刷新玩家属性 if ($player_prop_info['item_position'] == 3) { $this->get_game('EquipAttr')->equip_attr($player_id); } # 通知道具变更 粘包806 $this->get_game('Reward')->add_reward_log(); # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志 $ndata = array(); $ndata[] = $player_prop_info; /** //发放的星图 if($flag == 0 || $flag == 2) { foreach($sendarrLogs as $key => $val) { $ndata[] = $val; } } **/ //扣除的星图 if ($flag == 1 || $flag == 2) { $starmap_info_forInstall['item_num'] -= 1; $ndata[] = $starmap_info_forInstall; } Protocol_Prop::prop_806($player_id, $ndata); //获取 星图 $player_star_map = $this->get_game('Prop')->get_prop_list_by_type($player_id, $this->starmap_type, $this->starmap_sub_type); # 过滤不允许镶嵌该装备的星图 $player_star_map = $this->filter_unvalid_starmap($player_prop_info, $player_star_map); $data = array(); if ($player_star_map) { foreach ($player_star_map as $k => $v) { $data[] = Struct_Prop::get_item_box_struct($v); } } $emp = array(0 => $player_prop_id, 1 => $data); Protocol::input($player_id, 3, 8, 824, $out_824); Protocol::input($player_id, 3, 8, 823, $emp); }
private function _cal_invest_remain_time() { $fund_issue_time = Cache_Const::getInstance()->get_const('fund_issue_time'); $server_start_time = strtotime(SERVER_FIRST_START_TIME); if (empty($fund_issue_time)) { # 无法获取功能发布时间,无法区分新服老服,只能使用开服时间 $deadline = Com_Util::get_date_end($server_start_time) + ($this->fund_valid_deposit_day - 1) * 86400; } else { if ($server_start_time > $fund_issue_time) { # 新服 $deadline = Com_Util::get_date_end($server_start_time) + ($this->fund_valid_deposit_day - 1) * 86400; } else { # 老服,使用功能发布时间 $deadline = Com_Util::get_date_end($fund_issue_time) + ($this->fund_valid_deposit_day - 1) * 86400; } } $remain_time = max(0, $deadline - $this->current_time); return $remain_time; }
/** * 购买次数 * @param $player_id * @return array */ public function add_fight_times($player_id) { $p_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_grab_domain_add_times'); $p_num = $p_num ? $p_num : 0; $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); $vip_level = $player_info['vip'] ? $player_info['vip'] : 0; //获取购买消耗信息 $buy_times_info = Cache_UnionGrabDomain::getInstance()->get_buy_times_info($vip_level); //获取购买次数上限 $times_limit = $this->get_buy_max_times($player_id, $buy_times_info); if ($p_num >= $times_limit) { // 你不能再增加进攻次数了 if (10 > $vip_level) { $this->throw_error(6010121); } else { $this->throw_error(6010146); } } $purchase_times_cost = explode("|", $buy_times_info['cost_num']); $cost_currency_value = intval($purchase_times_cost[$p_num]); $cost_currency_type = $buy_times_info['cost_type']; $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, 1, $cost_currency_type); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type); $this->start_trans(); $result = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'union_grab_domain_add_times'); if ($result) { $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2602, array(), $arr_consume); } if ($result) { $this->commit(); $max_time = $p_num + 1; $grab_domain_conf = Cache_UnionGrabDomain::getInstance()->get_base_conf(); $max_fight_times = $grab_domain_conf['times']; $cur_num = intval($this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_grab_domain_use_times')); if ($max_time >= $times_limit) { //到了最大次数 前端不弹提示框 这里约定传 null $next_cost = ''; } else { $p_num = $p_num + 1; $next_cost = intval($purchase_times_cost[$p_num]); $next_cost = $cost_currency_type . ':' . $next_cost; } Protocol_Msg::msg($player_id, 12017); //给前端提示 购买成功 return array('cur_num' => $cur_num, 'max_time' => $max_time + $max_fight_times, 'next_cost' => $next_cost); } else { $this->rollback(); $this->throw_error('10110', 6010122); } }
/** * 复活 * @param int $player_id 玩家id * @return array */ public function relive($player_id) { $res = array(); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); //配置 $kf_duel_conf = Cache_CrossDuel::getInstance()->get_battle_conf(41001); if (!$kf_duel_conf) { $this->throw_error(10222, 6010106); } $purchase_relive_cost = explode(":", $kf_duel_conf['relive_price']); $cost_currency_value = $purchase_relive_cost[1]; $cost_currency_type = $purchase_relive_cost[0]; $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, 1, $cost_currency_type); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type); $this->start_trans(); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1237, array(), $arr_consume); if (true === $result) { $this->commit(); Protocol::input($player_id, 7, 4, 559, 0); //成功通知C++ } else { $this->rollback(); $this->throw_error(10110, 6010107); } $res['res'] = 1; return $res; }
public function get_daily_task_reward($player_id, $player_info = null, $task_star_acc = 9, $is_throw_error = 0) { if (empty($player_info)) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level')); } # 获取奖励信息 $reward = array(); $award_info = Cache_TaskDaily::getInstance()->get_task_daily_award($player_info['level']); $award_add_info = Cache_TaskDaily::getInstance()->get_task_daily_award_add($task_star_acc); if (empty($award_info) || empty($award_info['reward_base']) || empty($award_add_info)) { if ($is_throw_error) { $this->throw_error('10014'); } else { return array(); } } # 获取vip对奖励的加成信息,只加成非道具奖励 $vip_add_coeff = Com_Util::get_vip_special_reward_add_coeff(10062, $player_info['vip'], $player_info['privilege_level'], $player_id); # 基础奖励,正常情况下$award_info['reward_base']不包含道具奖励 #$coeff = (1 + $award_add_info['add_ratio'] / 10000) * (1 + $vip_add_coeff); $coeff = $award_add_info['add_ratio'] / 10000 * (1 + $vip_add_coeff); $reward_detail_base = $this->get_game('Reward')->get_reward_detail($award_info['reward_base'], $coeff); $this->get_game('Reward')->gen_reward_array($reward_detail_base, $reward); # 额外道具奖励,正常情况下$award_add_info['reward_item']不包含虚拟资源奖励 if (!empty($award_add_info['reward_item'])) { $reward_detail_add = $this->get_game('Reward')->get_reward_detail($award_add_info['reward_item'], 1); $this->get_game('Reward')->gen_reward_array($reward_detail_add, $reward); } # 记录行为 Com_Log::write('xgame.taskhandler', "{$player_id}\t" . "get_daily_task_reward\t" . "{$player_info['level']}\t" . "{$vip_add_coeff}\t" . "{$coeff}\t" . json_encode($award_info['reward_base']) . "\t" . json_encode($reward_detail_base) . "\t" . json_encode($reward_detail_add) . "\t" . json_encode($reward) . "\t"); return array($reward, $award_add_info); }
protected function equip_intensify_handle($flag, $player_id, $player_gems, $player_info, $player_equip_info, $intensify_config, $auto_buy, $bless_item_id) { if ($flag) { # 成功 $player_equip_info['intensive_lose_times'] = 0; $player_equip_info['intensive_level'] += 1; $player_equip_info['intensive_desc'] = Game_EquipIntensifier::get_latest_intensive_desc($player_equip_info, $intensify_config); if ($player_equip_info['star_map_id']) { # 获取最新星图状态desc $player_equip_info['star_map_desc'] = $this->get_game('EquipStarMap')->get_latest_starmap_desc($player_equip_info); } } else { # 失败 $player_equip_info['intensive_lose_times'] += 1; } $this->start_trans(); # 玩家银两更新 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $intensify_config['silver_num'], 1, 1); # 强化特效信息更新 $equip_view = $player_equip_info['equip_view']; if ($equip_view[0]) { $weapon_effect = Cache_WeaponEffect::getInstance()->get_weapon_effect($equip_view[0], $player_equip_info['intensive_level']); if ($weapon_effect && $weapon_effect['effect_id']) { $equip_view[2] = $weapon_effect['effect_id']; } } $equip_update_field = array('intensive_lose_times' => $player_equip_info['intensive_lose_times'], 'intensive_level' => $player_equip_info['intensive_level'], 'intensive_desc' => $player_equip_info['intensive_desc'], 'star_map_desc' => $player_equip_info['star_map_desc'], 'equip_view' => $equip_view); $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $equip_update_field); $this->write_check($re, 3010414); $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 816); # 消耗祝福石 if (!empty($bless_item_id)) { $arr_logs_bless_item = array(); $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $bless_item_id, 1, $arr_logs_bless_item, 0, $log_param); $this->write_check($re, 3010422); } # 消耗强化宝石和钻石【勾选自动购买时当所需强化宝石不足时需要消耗钻石】 $gem_cost_num = $intensify_config['item_num']; $cost_currency_type = 0; $cost_currency_value = 0; $price = 0; if ($auto_buy) { if ($player_gems < $intensify_config['item_num']) { $gem_cost_num = $player_gems; # 获取正确的强化宝石的单价 $intensify_gem_info = $this->get_game('Shop')->shortcut_purchase_interface($intensify_config['item_id'], 1); if (empty($intensify_gem_info['item_price'])) { $this->throw_error('80318'); # 商城强化宝石没有配置价格 } # 策划价格配置多项时,选其中一项 list($cur_type, $cur_val) = each($intensify_gem_info['item_price']); $price = $cur_val; $cost_currency_type = $cur_type; $cost_currency_value = intval($cur_val * ($intensify_config['item_num'] - $player_gems)); } } if ($gem_cost_num > 0) { $arr_logs_gem = array(); $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $intensify_config['item_id'], $gem_cost_num, $arr_logs_gem, 0, $log_param); $this->write_check($re, 3010449); } # 消耗虚拟货币 if ($cost_currency_value > 0) { $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, intval($intensify_config['item_num'] - $player_gems)); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type); } $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '816', array(), $arr_consume); $this->write_check($re, 3010476); $this->commit(); # 若有购买缺少材料,记录虚假商城购买日志 if ($cost_currency_value > 0) { $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $intensify_config['item_id'], intval($intensify_config['item_num'] - $player_gems), $cost_currency_type, $cost_currency_value, 816); } # 刷新玩家属性 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_gem) && is_array($arr_logs_gem)) { foreach ($arr_logs_gem as $k => $v) { # 消耗的宝石 $ndata[] = $v; } } if (!empty($arr_logs_bless_item)) { # 消耗的祝福石,祝福石只消耗1个 $ndata[] = $arr_logs_bless_item[0]; } Protocol_Prop::prop_806($player_id, $ndata); # 通知玩家信息变更[必须放在commit之后] return $player_equip_info['intensive_desc']; }
public function upgrade_rune($player_id, $rune_id) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_skill); $this->param_check_numeric(array($player_id, $rune_id)); $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); # 获取当前符文等级 $now_level = 0; if (!empty($arr_player_detail['skill_rune_info'])) { foreach ($arr_player_detail['skill_rune_info'] as $sid => $rune_info) { foreach ($rune_info as $rid => $rinfo) { if ($rid == $rune_id) { $now_level = $rinfo['level']; break; } } } } $rune_config = Cache_SkillRune::getInstance()->get_skill_rune_info_by_rl($rune_id, $now_level + 1, 1); $skill_id = $rune_config['skill_id']; Com_Log::write('xgame.skill.debug', "rune==============" . $player_id . ":" . $rune_config['sid'] . ":" . $rune_config['rune_level']); if (!isset($arr_player_detail['skill_info'][$skill_id])) { $this->throw_error('60014'); //技能与符文配置不一致 } if ($arr_player_detail['skill_info'][$skill_id]['level'] < $rune_config['require_skill_level']) { $this->throw_error('60020'); //未达到激活符文所需技能等级 } # 首次激活需要判断前置符文是否已经激活【技能对应的多个符文序列必须按顺序激活,由配置表skill_rune中的rune_seq决定顺序】 if ($now_level == 0 && $rune_config['rune_seq'] != 1) { $rune_seq = Cache_SkillRune::getInstance()->get_skill_rune_info_by_seq($skill_id, $rune_config['rune_seq'] - 1, 1); if (!isset($arr_player_detail['skill_rune_info'][$skill_id][$rune_seq['sid']])) { $this->throw_error('60016'); //该符文不能被激活,请先激活上一符文再继续 } } $this->start_trans(); # 消耗激活所需资源 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $rune_config['cost_silver'], 1, 1); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'crystal', $rune_config['cost_skill_point'], 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '604'); $this->write_check($re, 3010598); # 更新技能符文信息 if ($now_level == 0) { $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] = 1; $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['rune_index'] = $rune_config['rune_seq']; } else { $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] += 1; } $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, $arr_player_detail); $this->write_check($re, 3010608); $this->commit(); //同步人物属性 $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); if ($now_level == 0) { # 首次激活 $out[0] = intval(1); $out[1] = intval($skill_id); $out[2] = intval($rune_id); $ac_info = array(); //符文状态 0未激活 1 可激活 2 已经激活 $rune_info = Cache_SkillRune::getInstance()->get_skill_rune_list_group($skill_id, 1); foreach ($rune_info as $k => $v) { if (isset($arr_player_detail['skill_rune_info'][$skill_id][$v['sid']])) { $ac_info[] = array(0 => intval($v['sid']), 1 => 2); } elseif ($rune_config['rune_seq'] + 1 == $v['rune_seq'] && $arr_player_detail['skill_info'][$skill_id]['level'] >= $v['require_skill_level']) { $ac_info[] = array(0 => intval($v['sid']), 1 => 1); } else { $ac_info[] = array(0 => intval($v['sid']), 1 => 0); } } $out[3] = $ac_info; $this->handle_rune_refer_achieve($player_id); $skill_config = Cache_Skill::getInstance()->get_skill_infobysl($skill_id, 1); // Com_Log::write('trigger_guid_task.'.$player_id,"skill:".var_export($skill_config,true)); $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 1, 1, $skill_config['keyboard']); #引导任务 } else { # 升级 $out[0] = 1; $out[1] = intval($rune_id); $out[2] = intval($arr_player_detail['skill_rune_info'][$rune_config['skill_id']][$rune_id]['level']); $out[3] = intval($player_info['crystal']); } # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $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, 'rune_id' => $rune_id, 'rune_seq' => $rune_config['rune_seq'], 'before_level' => $now_level, 'after_level' => $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level']); Log_Skill::getInstance()->add_log($log_info, 'rune'); return $out; }
/** * 毁灭奥克兰副本复活 * @param unknown $player_id * $type 1消耗 2不消耗 */ public function destroy_akland_relive($player_id, $type) { $type = intval($type); if ($type == 1) { $player_info = $this->get_data('Player')->get_player_info($player_id, array("privilege_level", "ticket", "level", "vip", "map_id", "gold", 'player_id')); # 消耗虚拟货币 $cost_currency_type = 2; $cost_currency_value = 5; $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '748', array(), $arr_consume); $this->write_check($re, 5010174); $this->start_trans(); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 748, array(), $arr_consume); $this->write_check($re, 5010177); } $this->commit(); Protocol::input($player_id, 7, 4, 560, array($type)); }
/** * @Purpose: * 翅膀装备传承 * @Param $player_id 玩家ID * @Param $inherit_equip_pid 传承装备ID * @Param $be_inherit_equip_pid 继承装备ID */ public function wing_equip_inherit($player_id, $inherit_equip_pid, $be_inherit_equip_pid) { $player_id = intval($player_id); $inherit_equip_pid = strval($inherit_equip_pid); $be_inherit_equip_pid = strval($be_inherit_equip_pid); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'career_type', 'level', 'vip', 'privilege_level'))); if (empty($player_info)) { $this->throw_error('20002'); //没有玩家信息! } $player_prop_list = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, array($inherit_equip_pid, $be_inherit_equip_pid)); $inherit_equip_info = $player_prop_list[$inherit_equip_pid]; $be_inherit_equip_info = $player_prop_list[$be_inherit_equip_pid]; if (empty($inherit_equip_info) || empty($be_inherit_equip_info)) { $this->throw_error('80013'); } else { if ($inherit_equip_info['sub_type'] == 7 || $be_inherit_equip_info['sub_type'] == 7) { $this->throw_error('10110'); #数据错误 } } $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key()); if (empty($player_detail['wing_info'][$inherit_equip_info['vocation_limit']]) || empty($player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']])) { $this->throw_error('10110'); #数据错误 } $inherit_table = Cache_WingEquipment::getInstance()->get_wing_equip_inherit_info(array('item_level' => $be_inherit_equip_info['level'])); if (empty($inherit_table)) { $this->throw_error('10109'); #配置表读取错误 } else { if (empty($inherit_table['expend_prop'])) { $this->throw_error('150022'); #wing_equip_inherit配置表的expend_prop字段配置错误 } } $prop_list = $this->format_table_field($inherit_table['expend_prop']); if (!Com_Array::is_good_arr($prop_list)) { $this->throw_error('150022'); #wing_equip_inherit配置表的expend_prop字段配置错误 } #道具检测 $arr_consume = array(); foreach ($prop_list as $id => $num) { if (empty($id) || empty($num)) { $this->throw_error('150022'); #wing_equip_inherit配置表的expend_prop字段配置错误 } $cost_currency_key = Cache_Currency::getInstance()->get_key($id); if ($cost_currency_key == 'prop') { #传承装备和继承装备等级不同时,才需要消耗道具 if ($inherit_equip_info['level'] != $be_inherit_equip_info['level']) { $this->get_game('Prop')->check_player_prop($player_id, $player_info, $id, $num, $arr_consume); } } else { if (empty($cost_currency_key)) { $this->throw_error('150022'); #wing_equip_inherit配置表的expend_prop字段配置错误 } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $num, 1, $id); } } #如果是已装备的,传承前先清楚原来的装备属性 if ($inherit_equip_info['item_position'] == $this->wing_pos) { $wing_attr = $player_detail['wing_info'][$inherit_equip_info['vocation_limit']]; $wing_attr['equipment'][$inherit_equip_info['sub_type']] = array(); $arr_remove_prop_detail = $inherit_equip_info; Struct_Prop::get_item_additions($arr_remove_prop_detail); $wing_attr['fight'] -= $arr_remove_prop_detail['fpower']; $wing_attr['fight'] = $wing_attr['fight'] > 0 ? $wing_attr['fight'] : 0; $wing_attr['equipment_fight'] -= $arr_remove_prop_detail['fpower']; $wing_attr['equipment_fight'] = $wing_attr['equipment_fight'] > 0 ? $wing_attr['equipment_fight'] : 0; $player_detail['wing_info'][$inherit_equip_info['vocation_limit']] = $wing_attr; } if ($be_inherit_equip_info['item_position'] == $this->wing_pos) { $be_wing_attr = $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']]; $be_wing_attr['equipment'][$be_inherit_equip_info['sub_type']] = array(); $arr_remove_prop_detail = $be_inherit_equip_info; Struct_Prop::get_item_additions($arr_remove_prop_detail); $be_wing_attr['fight'] -= $arr_remove_prop_detail['fpower']; $be_wing_attr['fight'] = $be_wing_attr['fight'] > 0 ? $be_wing_attr['fight'] : 0; $be_wing_attr['equipment_fight'] -= $arr_remove_prop_detail['fpower']; $be_wing_attr['equipment_fight'] = $be_wing_attr['equipment_fight'] > 0 ? $be_wing_attr['equipment_fight'] : 0; $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']] = $be_wing_attr; } #传承 $update_equip_list = $this->get_inherit_wing_equip($inherit_equip_info, $be_inherit_equip_info); $is_update_wing = false; $is_update_be_wing = false; #如果是已装备的,重新计算翅膀战斗力 if ($inherit_equip_info['item_position'] == $this->wing_pos) { $wing_attr = $player_detail['wing_info'][$inherit_equip_info['vocation_limit']]; $wing_attr['equipment'][$inherit_equip_info['sub_type']] = $inherit_equip_info; $wing_attr['equip_attr'] = $this->get_wing_equip_attr($wing_attr['equipment']); $arr_prop_detail = $inherit_equip_info; Struct_Prop::get_item_additions($arr_prop_detail); $wing_attr['fight'] += $arr_prop_detail['fpower']; $wing_attr['equipment_fight'] += $arr_prop_detail['fpower']; $player_detail['wing_info'][$inherit_equip_info['vocation_limit']] = $wing_attr; $is_update_wing = true; } if ($be_inherit_equip_info['item_position'] == $this->wing_pos) { $be_wing_attr = $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']]; $be_wing_attr['equipment'][$be_inherit_equip_info['sub_type']] = $be_inherit_equip_info; $be_wing_attr['equip_attr'] = $this->get_wing_equip_attr($be_wing_attr['equipment']); $arr_prop_detail = $be_inherit_equip_info; Struct_Prop::get_item_additions($arr_prop_detail); $be_wing_attr['fight'] += $arr_prop_detail['fpower']; $be_wing_attr['equipment_fight'] += $arr_prop_detail['fpower']; $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']] = $be_wing_attr; $is_update_be_wing = true; } $this->start_trans(); #更新道具属性 if (!empty($update_equip_list[$inherit_equip_pid])) { $update_res = $this->get_data('PlayerProp')->update_player_prop($inherit_equip_info, $update_equip_list[$inherit_equip_pid]); if (!$update_res) { $this->throw_error('10104'); } } if (!empty($update_equip_list[$be_inherit_equip_pid])) { $update_res = $this->get_data('PlayerProp')->update_player_prop($be_inherit_equip_info, $update_equip_list[$be_inherit_equip_pid]); if (!$update_res) { $this->throw_error('10104'); } } #更新翅膀战斗力 if ($is_update_wing || $is_update_be_wing) { $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info'])); if (!$update_res) { $this->throw_error('10104'); } } foreach ($prop_list as $id => $num) { if (empty($id) || empty($num)) { $this->throw_error('150022'); #wing_equip_inherit配置表的expend_prop字段配置错误 } $cost_currency_key = Cache_Currency::getInstance()->get_key($id); if ($cost_currency_key == 'prop') { #传承装备和继承装备等级不同时,才需要消耗道具 if ($inherit_equip_info['level'] != $be_inherit_equip_info['level']) { $this->get_game('Prop')->dedcut_player_prop($player_id, $player_info, 1512); } } else { if (empty($cost_currency_key)) { $this->throw_error('150022'); #wing_equip_inherit配置表的expend_prop字段配置错误 } #扣货币 $deduct_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1512, array(), $arr_consume); if (!$deduct_res) { $this->throw_error('10104'); } } } if ($is_update_wing && $player_detail['wing_info'][$inherit_equip_info['vocation_limit']]['fight'] > 0) { $wing_fight = $player_detail['wing_info'][$inherit_equip_info['vocation_limit']]['fight']; $this->get_data('RankList')->update_wing_rank($player_id, $inherit_equip_info['vocation_limit'], $wing_fight); } if ($is_update_be_wing && $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']]['fight'] > 0) { $wing_fight = $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']]['fight']; $this->get_data('RankList')->update_wing_rank($player_id, $be_inherit_equip_info['vocation_limit'], $wing_fight); } $this->commit(); $ndata = array(); if (!$is_update_wing) { $ndata[] = $inherit_equip_info; } if (!$is_update_be_wing) { $ndata[] = $be_inherit_equip_info; } if (!empty($ndata)) { #806通知前端道具属性变更 Protocol_Prop::prop_806($player_id, $ndata); } if ($is_update_wing || $is_update_be_wing) { #同步翅膀属性 $str = $this->get_activation_wing_interface($player_id, $player_detail['wing_info']); Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])))); } $rtn_data = array('inherit_equip_info' => empty($inherit_equip_info) ? array() : Struct_Prop::get_prop_struct($inherit_equip_info), 'be_inherit_equip_info' => empty($be_inherit_equip_info) ? array() : Struct_Prop::get_prop_struct($be_inherit_equip_info)); return $rtn_data; }
public function wing_equip_swallow($type, $player_id, $player_prop_id, $swallow_equips, $onekey = 0) { $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id); $this->param_check_numeric(array($type, $player_id), 0); if (empty($swallow_equips)) { $this->throw_error('10107'); } # 参数错误 $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'career_type')); $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key()); # 1515展示协议返回数据,1515协议需要写死传回已配置的所有吞噬属性,即便当前道具尚未有激活任意项吞噬属性,也需要用初始值填充 $out_1515 = array('player_ppid' => $player_prop_id, 'swallow_ppids' => $swallow_equips, 'item_struct' => array()); $swallow_equips = explode(':', $swallow_equips); $swallow_equips = array_filter($swallow_equips); $player_prop_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id); $before_player_prop_info = $player_prop_info; if (empty($player_prop_info)) { $this->throw_error('80013'); //玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_info['prop_id'])) { if (!empty($type)) { # 实际吞噬 $this->throw_error('81106'); # 首充装备不允许吞噬 } else { $message = array('texts' => array(array('code' => 81106, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许吞噬 $out_1515['swallow_ppids'] = ""; return $out_1515; } } # 计算吞噬属性最大等级 $swallow_lv_max = $this->get_we_swallow_lv_max($player_prop_info['vocation_limit'], $player_detail); $swallow_config_max = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($swallow_lv_max); if (empty($swallow_config_max)) { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } $player_prop_details = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, $swallow_equips); if (empty($player_prop_details)) { $this->throw_error('80024'); //未选择有效的被吞噬装备 } # 被吞噬装备信息 $before_swallow_info = empty($player_prop_info['we_swallow_info']) ? array() : $player_prop_info['we_swallow_info']; $player_prop_id_slave = ""; $item_id_slave = ""; $onekey_prop_list = array(); # 保存允许一键吞噬的装备ID列表 foreach ($swallow_equips as $pprop_id) { if (!empty($type)) { # 实际吞噬 if (empty($player_prop_details[$pprop_id])) { $this->throw_error('80013'); # 玩家没有该装备! } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $this->throw_error('81107'); # 首充装备不允许被吞噬 } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { $this->throw_error('80044'); # 装备品质未达到被吞噬要求 } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $this->throw_error('80045'); # 装备已达到最大吞噬等级 } } else { # 非实际吞噬 if (!empty($onekey)) { # 一键勾选 if (empty($player_prop_details[$pprop_id])) { continue; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { continue; } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { continue; } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { continue; } } else { # 单项勾选,单次勾选获取吞噬信息需要弹提示属性满的消息,但不能阻断程序执行,只能跳出循环 if (empty($player_prop_details[$pprop_id])) { $message = array('texts' => array(array('code' => 80013, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 玩家没有该装备! break; } if (Com_Util::is_first_charge_item($player_prop_details[$pprop_id]['prop_id'])) { $message = array('texts' => array(array('code' => 81107, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 首充装备不允许被吞噬 break; } if ($player_prop_details[$pprop_id]['quality'] < $this->min_swallow_quality) { $message = array('texts' => array(array('code' => 80044, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 装备品质未达到被吞噬要求 break; } if (isset($player_prop_info['we_swallow_info']['swallow_exp']) && $player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $message = array('texts' => array(array('code' => 80045, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 装备已达到最大吞噬等级 break; } } } $player_prop_id_slave .= "{$pprop_id}:"; $item_id_slave .= $player_prop_details[$pprop_id]['prop_id'] . ":"; $onekey_prop_list[] = $pprop_id; # 计算增加属性值 && 修正经验值 $add_swallow_exp = self::$swallow_quality_to_exp_map[$player_prop_details[$pprop_id]['quality']] * (1 + intval($player_prop_details[$pprop_id]['level'] / 5) / 4); if (isset($player_prop_info['we_swallow_info'])) { $player_prop_info['we_swallow_info']['swallow_exp'] += $add_swallow_exp; } else { $player_prop_info['we_swallow_info'] = array('swallow_lv' => 0, 'swallow_exp' => $add_swallow_exp, 'swallow_attr' => array()); } } # 根据吞噬属性的exp,刷新吞噬属性的lv if (!empty($player_prop_info['we_swallow_info'])) { $swallow_config = Cache_Forge::getInstance()->get_we_swallow_config_by_exp($player_prop_info['we_swallow_info']['swallow_exp']); if (!empty($swallow_config)) { $player_prop_info['we_swallow_info']['swallow_lv'] = min($swallow_config['swallow_lv'], $swallow_lv_max); # 根据最大lv,修正经验值 if ($player_prop_info['we_swallow_info']['swallow_exp'] >= $swallow_config_max['swallow_exp'] - 1) { $player_prop_info['we_swallow_info']['swallow_exp'] = $swallow_config_max['swallow_exp'] - 1; } } else { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } } # 根据吞噬等级,计算吞噬加成附加属性 $we_swallow_revise_info = Cache_Forge::getInstance()->get_we_swallow_config_by_lv($player_prop_info['we_swallow_info']['swallow_lv']); if (empty($we_swallow_revise_info)) { $this->throw_error('80047'); # 未找到翅膀装备吞噬配置信息 } foreach ($player_prop_info['addition_attr'] as $attr_key => $attr_val) { $attr_val = ceil($attr_val * $we_swallow_revise_info['attr_revise_ratio'] / 10000) + $we_swallow_revise_info[$attr_key]; $player_prop_info['we_swallow_info']['swallow_attr'][$attr_key] = $attr_val; } if (empty($type)) { # 修正被吞噬的装备列表,去除吞噬属性达到上限及之后的其它装备 $out_1515['swallow_ppids'] = empty($onekey_prop_list) ? "" : implode(":", $onekey_prop_list); $out_1515['item_struct'] = Struct_Prop::get_prop_struct($player_prop_info); if (empty($out_1515['swallow_ppids']) && !empty($onekey)) { # 没有能被吞噬的装备 $message = array('texts' => array(array('code' => 80046, 'content' => array(), 'params' => array())), 'delay' => 0); Protocol::input($player_id, 3, 7, 742, $message); # 没有可以被吞噬的装备 } return $out_1515; } $out_1516 = array(0 => $player_prop_id, 1 => array('item_position' => 1, 'grid_list' => array())); $this->start_trans(); # 更新吞噬信息 $re = $this->get_data('PlayerProp')->update_player_prop($player_prop_info, array('we_swallow_info' => $player_prop_info['we_swallow_info'], 'we_swallow_version' => $this->we_swallow_version)); $this->write_check($re, 3010177); # 扣除被吞噬装备 foreach ($player_prop_details as $k => $v) { $re = $this->get_data('PlayerProp')->update_prop_num($player_id, $v, 1, '-', array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'cmd_id' => 1516)); $this->write_check($re, 3010182); } # 刷新玩家翅膀战力与镶嵌装备的附加属性及战力 if ($player_prop_info['item_position'] == $this->wing_pos) { $wing_attr = $player_detail['wing_info'][$player_prop_info['vocation_limit']]; # 修正缓存的翅膀装备吞噬信息 $wing_attr['equipment'][$player_prop_info['sub_type']]['we_swallow_info'] = $player_prop_info['we_swallow_info']; $wing_attr['equip_attr'] = $this->get_game('PlayerWing')->get_wing_equip_attr($wing_attr['equipment']); # 减去吞噬之前的战力 Struct_Prop::get_item_additions($before_player_prop_info); $wing_attr['fight'] -= $before_player_prop_info['fpower']; $wing_attr['equipment_fight'] -= $before_player_prop_info['fpower']; if ($wing_attr['fight'] < 0) { $wing_attr['fight'] = 0; } if ($wing_attr['equipment_fight'] < 0) { $wing_attr['equipment_fight'] = 0; } # 加上吞噬之后的战力 $player_prop_info_cp = $player_prop_info; Struct_Prop::get_item_additions($player_prop_info_cp); $wing_attr['fight'] += $player_prop_info_cp['fpower']; $wing_attr['equipment_fight'] += $player_prop_info_cp['fpower']; # 更新wing_info $player_detail['wing_info'][$player_prop_info['vocation_limit']] = $wing_attr; $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info'])); $this->write_check($re, 3010242); #更新翅膀排行 if ($player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight'] > 0) { $wing_fight = $player_detail['wing_info'][$player_prop_info['vocation_limit']]['fight']; $this->get_data('RankList')->update_wing_rank($player_id, $player_prop_info['vocation_limit'], $wing_fight); } } $this->commit(); # 成就相关埋 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 39, $player_prop_info['we_swallow_info']['swallow_lv'], 8); # -------------------------------------------------------------------- # 游戏日志记录 # -------------------------------------------------------------------- $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_info['player_prop_id'], 'item_id_master' => $player_prop_info['prop_id'], 'item_type' => $player_prop_info['type'], 'item_sub_type' => $player_prop_info['sub_type'], 'item_quality' => $player_prop_info['quality'], 'item_level' => $player_prop_info['level'], 'item_star_level' => $player_prop_info['star_level'], 'player_prop_id_slave' => rtrim($player_prop_id_slave, ":"), 'item_id_slave' => rtrim($item_id_slave, ":"), 'before_swallow_info' => $before_swallow_info, 'after_swallow_info' => $player_prop_info['we_swallow_info'], 'before_swallow_lv' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_lv'], 'after_swallow_lv' => $player_prop_info['we_swallow_info']['swallow_lv'], 'before_swallow_exp' => empty($before_swallow_info) ? 0 : $before_swallow_info['swallow_exp'], 'after_swallow_exp' => $player_prop_info['we_swallow_info']['swallow_exp']); Log_Forge::getInstance()->add_log($log_info, 'we_swallow'); # 通知翅膀属性变更 if ($player_prop_info['item_position'] == $this->wing_pos) { #同步翅膀属性 $str = $this->get_game('PlayerWing')->get_activation_wing_interface($player_id, $player_detail['wing_info']); Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level'])))); } # 通知道具变更806 $ndata = array(); $ndata[] = $player_prop_info; foreach ($player_prop_details as $key => &$val) { $val['item_num'] -= 1; $out_1516[1]['grid_list'][] = $val['grid']; $ndata[] = $val; } Protocol_Prop::prop_806($player_id, $ndata); # 刷装备1506[翅膀装备强化面板]与1514[可吞噬道具列表] $out_1506 = $this->get_game('PlayerWing')->equipment_intensify_panel($player_id, 4); $out_1514 = $this->get_wing_equips_for_swallow($player_id, $player_prop_id); Protocol::input($player_id, 3, 15, 1506, $out_1506); Protocol::input($player_id, 3, 15, 1514, $out_1514); # 记录行为 Com_Log::write('xgame.forge_we_swallow', "{$player_id}\t" . "we_swallow\t" . "{$type}\t" . "{$player_prop_id}\t" . implode(",", $swallow_equips)); return $out_1516; }
private function filter_unvalid_props($player_prop_info, $player_props) { if (empty($player_props)) { return $player_props; } # 过滤非装备道具 foreach ($player_props as $key => $val) { if ($val['type'] != $this->equip_type) { unset($player_props[$key]); } # 过滤自身 if ($val['player_prop_id'] == $player_prop_info['player_prop_id']) { unset($player_props[$key]); } # 过滤掉品质大于>=4的装备,秋水确定于20150811 if ($val['quality'] >= 4) { unset($player_props[$key]); } } $swallow_restriction = Cache_Forge::getInstance()->get_swallow_restriction($player_prop_info['sub_type']); if (!empty($swallow_restriction['allow_swallow_sub_type'])) { $allow_swallow_sub_type = explode(":", $swallow_restriction['allow_swallow_sub_type']); foreach ($player_props as $key => $val) { if (!in_array($val['sub_type'], $allow_swallow_sub_type)) { unset($player_props[$key]); } if (Com_Util::is_first_charge_item($val['prop_id'])) { # 首充装备不允许被吞噬 unset($player_props[$key]); } } } return $player_props; }
public function enhanced_refine($player_id, $player_prop_id, $refine_attr_seq, $add_success_rate) { #$this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_enhanced_refine); $this->param_check_numeric(array($player_id, $refine_attr_seq)); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); $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('81105'); # 首充装备不允许精练 } $out_850 = array('player_prop_id' => $player_prop_id, 'result' => 0); # 洗练属性检查 if (empty($player_equip_info['refine_info'])) { $this->throw_error('81008'); # 洗练属性为空,不能精炼 } # 获取洗练属性key /** foreach ($player_equip_info['refine_info']['attr_info'] as $attr_seq => $attr_info) { if ($attr_info['attr_seq'] == $refine_attr_seq) { $en_refine_attr_key = $attr_info['attr_key']; break; } } **/ if (!isset($player_equip_info['refine_info']['attr_info'][$refine_attr_seq])) { $this->throw_error('81009'); # 精炼属性异常,选择的精炼属性不存在 } $refine_info = $player_equip_info['refine_info']; $refine_attr = $player_equip_info['refine_attr']; $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']); if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] >= $player_equip_info['level'] && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) { $this->throw_error('81010'); # 精炼属性已满 } # 计算成功率 + 货币消耗 $refine_info_mod = $this->get_en_refine_success_rate_and_cost_currency($refine_info); list($cost_currency_type, $cost_currency_value) = explode(":", $refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_cost_currency']); if ($add_success_rate) { $refine_info_mod['en_refine_success_rate'] += $this->add_success_rate; } $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(); $success_flag = false; if (Com_Random::probability($refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_success_rate'], 10000)) { if ($refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']) { $delta = ceil($refine_info_mod['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']); } else { $delta = 0; } $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] += $delta; if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] > $refine_info['attr_info'][$refine_attr_seq]['attr_stint']) { $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['attr_stint']; } $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] += 1; $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] = 0; $refine_info['attr_info'][$refine_attr_seq]['attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['refine_attr_value'] + $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value']; # 升级 $en_refine_lv_stint = $this->get_en_refine_lv_stint($player_equip_info['level']); $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']); if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] < $en_refine_lv_stint && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) { # 获取精练属性基础值 $attr_value_info_en_refine_old = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']); $refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] += $this->en_refine_lv_delta; $attr_value_info_en_refine = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']); if (empty($attr_value_info_en_refine)) { $this->throw_error('81011'); # 获取洗练属性值配置失败 } $attr_key = $refine_info['attr_info'][$refine_attr_seq]['attr_key']; $attr_ratio = $refine_info['attr_info'][$refine_attr_seq]['attr_ratio']; $refine_info['attr_info'][$refine_attr_seq]['attr_limit'] = ceil(($attr_value_info_en_refine[$attr_key] - $attr_value_info_en_refine_old[$attr_key]) * ($attr_ratio / 10000)); $en_refine_conf = Cache_Refine::getInstance()->get_equip_enhanced_refine_base_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']); $refine_info['attr_info'][$refine_attr_seq]['attr_section'] = $en_refine_conf['section']; $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] = 0; } $refine_attr[$refine_attr_seq] = array($refine_info['attr_info'][$refine_attr_seq]['attr_key'] => $refine_info['attr_info'][$refine_attr_seq]['attr_value']); $out_850['result'] = 1; $success_flag = true; } else { $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] += 1; # 连续失败精炼次数 } $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 ($add_success_rate) { $cost_currency_key_other = Cache_Currency::getInstance()->get_key($this->add_success_rate_cost_cur_type); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key_other, $this->add_success_rate_cost_cur_value, 1, 0); } $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '850'); $this->write_check($re, 3010132); $update_field = array('refine_attr' => $refine_attr, 'refine_info' => $refine_info); $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $update_field); $this->write_check($re, 3010414); $this->commit(); # 提示购买成功消息 if ($success_flag) { $message = array('texts' => array(array('code' => 81014, 'content' => array(), 'params' => array(array(array('txt' => '', 'type' => 6, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_key'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_value'] - $before_refine_info['attr_info'][$refine_attr_seq]['attr_value'], 'param' => ''))))), 'delay' => 0); } else { $message = array('texts' => array(array('code' => 81015, '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' => 2, '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'); # 刷新玩家属性 if ($player_equip_info['item_position'] == 3) { $this->get_game('EquipAttr')->equip_attr($player_id); } # 粘806 + 通知道具变更信息 $player_equip_info['refine_attr'] = $update_field['refine_attr']; $player_equip_info['refine_info'] = $update_field['refine_info']; $ndata = array($player_equip_info); Protocol_Prop::prop_806($player_id, $ndata); $out_849 = $this->get_enhanced_refine_info($player_id, $player_prop_id, $refine_attr_seq); Protocol::input($player_id, 3, 8, 849, $out_849); return $out_850; }
public function do_async_deal_event_log($event_log_info) { if (empty($event_log_info)) { return false; } $event_log_info = json_decode($event_log_info, true); $date = date('Y-m-d H:i:s'); try { echo "=========[AsyncDealEventLog:date={$date}|" . json_encode($event_log_info) . "=========\n"; switch ($event_log_info['log_type']) { case 'login': $re = $this->get_data('Event')->record_player_event_log_login($event_log_info); break; case 'pub': $re = $this->get_data('Event')->record_player_event_log_pub($event_log_info); break; case 'shop': $re = $this->get_data('Event')->record_player_event_log_shop($event_log_info); break; case 'sign': $re = $this->get_data('Event')->record_player_event_log_sign($event_log_info); break; case 'item_consume': #$re = $this->get_data('Event')->record_player_event_log_item_consume($event_log_info); $re = $this->get_data('Event')->record_player_event_log_item_consume_other($event_log_info); break; case 'coin_exchange': $re = $this->get_data('Event')->record_player_event_log_coin_exchange($event_log_info); break; case 'daily_active': $event_log_info['reg_time'] = Com_Util::get_date_end($event_log_info['reg_time']); # 替换记录时间为当前结束时间戳 $re = $this->get_data('Event')->record_player_event_log_daily_active($event_log_info); break; case 'grabmine': $re = $this->get_data('Event')->record_player_event_log_grabmine($event_log_info); break; case 'world_boss': $re = $this->get_data('Event')->record_player_event_log_world_boss($event_log_info); break; case 'world_boss_treasure': $re = $this->get_data('Event')->record_player_event_log_world_boss_treasure($event_log_info); break; case 'athena': $re = $this->get_data('Event')->record_player_event_log_athena($event_log_info); break; } } catch (Exception $e) { echo $e->getMessage(); } }
/** * 购买挑战次数 * @param unknown $player_id */ public function buy_grab_treasure_times($player_id) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'gold', 'silver', 'ticket', 'privilege_level', 'vip')); # 获取当日已挑战次数及其购买次数 $battle_buy_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grab_treasure_battle_buy_times'); if (empty($battle_buy_num)) { $battle_buy_num = 0; } # 获取购买消耗信息 $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info($this->grab_treasure_battle_buy_type, 1); # 获取购买次数上限 $buy_stint = $this->get_grab_treasure_num_buy_stint($player_id, $this->grab_treasure_battle_buy_type, $buy_times_info); # 购买次数上限检查 if ($battle_buy_num >= $buy_stint) { $this->throw_error('10225'); # 已达到最大购买次数 } # 获取消耗资源类型与值 $cost_currency_type = $buy_times_info['cost_type']; $cost_currency_value = Cache_BuyTimes::getInstance()->cal_buy_price($battle_buy_num, $buy_times_info['cost_num'], "|", 1); $this->start_trans(); # 消耗虚拟货币 $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1223', array(), $arr_consume); $this->write_check($re, 5010391); # 更新当日挑战次数及挑战次数购买次数 $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'grab_treasure_battle_buy_times', 1); $this->write_check($re, 5010395); $this->commit(); # 当前挑战次数上限 $current_battle_num_max = ($battle_buy_num + 1) * $buy_times_info['per_num'] + $this->grab_treasure_max_times; # 剩余挑战次数可购买次数 $battle_num_buy_remain = $buy_stint - $battle_buy_num - 1 > 0 ? $buy_stint - $battle_buy_num - 1 : 0; list($cost_currency_type, $cost_currency_value) = $this->get_grab_treasure_battle_next_buy_price($player_id, $buy_times_info); $battle_num_next_buy_price = "{$cost_currency_type}:{$cost_currency_value}"; $out = array('current_battle_num_max' => $current_battle_num_max, 'battle_num_buy_remain' => $battle_num_buy_remain, 'battle_num_next_buy_price' => $battle_num_next_buy_price); # 提示购买成功消息 $message = array('texts' => array(), 'delay' => 0); $message['texts'][] = array('code' => 10237, 'content' => array(), 'params' => array()); Protocol::input($player_id, 3, 7, 742, $message); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040); return $out; }
/** * 购买特惠礼包 * @param int player_id 玩家id * @param int gid 礼包id * @return array */ public function gift_package_buy($player_id, $gid) { $player_id = intval($player_id); $gid = intval($gid); if (!$gid) { $this->throw_error(10107, 6010077); } //获取奖励配置 if (!($set_gift_package = Cache_NewServerActivity::getInstance()->get_gift_package($gid))) { $this->throw_error(6010045, 6010052); } //是否已买过 $activity_player = $this->get_data('NewServerActivity')->get_player_info($player_id, array('gift_info')); if (isset($activity_player['gift_info']) && is_array($activity_player['gift_info']) && in_array($gid, $activity_player['gift_info'])) { $this->throw_error(6010053); } if (!is_array($activity_player['gift_info'])) { $activity_player['gift_info'] = array(); } $activity_player['gift_info'][] = $gid; $pinfo = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'career_type'))); $costs = explode(':', $set_gift_package['price']); $item_id = $costs[0]; $cost_num = $costs[1]; $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id); $career_type = $pinfo['career_type']; $reward = array(); $rewards = explode('|', $set_gift_package['item_info']); foreach ($rewards as $value) { $tmp = explode(':', $value); if (count($tmp) > 1) { if ($career_type && isset($tmp[2]) && $tmp[2] && $career_type != $tmp[2]) { continue; } $reward[] = array('type' => Cache_Currency::getInstance()->get_key($tmp[0]), 'item_id' => $tmp[0], 'item_num' => $tmp[1]); } else { $this->throw_error(10222, 6010054); } } $up_arr = array('player_id' => $player_id, 'gift_info' => $activity_player['gift_info']); $arr_consume = Com_Util::get_consume_info_for_data_center($pinfo, $item_key, $cost_num, 1, $item_id); $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', $item_key, $cost_num, 1, $item_id); $this->start_trans(); $re = $this->get_data('Player')->update_player_resource($player_id, $pinfo, 2313, array(), $arr_consume); $this->write_check($re, 6010055); $re = $this->get_data('NewServerActivity')->update_player_info($player_id, $up_arr); $this->write_check($re, 6010056); $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2313, 'bind_flag' => 0)); $this->write_check_strict($re, 6010057); $this->commit(); $this->get_game('Reward')->add_reward_log(true); $data = $this->get_gift_package_panel($player_id); Protocol::input($player_id, 8, 23, 2312, $data); return array('res' => 1); }
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; }
private function filter_unvalid_props($player_prop_info, $player_props) { if (empty($player_props)) { return $player_props; } foreach ($player_props as $key => $val) { # 过滤非装备道具 if ($val['type'] != $this->equip_type) { unset($player_props[$key]); } # 过滤自身 if ($val['player_prop_id'] == $player_prop_info['player_prop_id']) { unset($player_props[$key]); } # 过滤首充装备 if (Com_Util::is_first_charge_item($val['prop_id'])) { unset($player_props[$key]); } # 过滤非相同类型与子类型 if ($val['type'] != $player_prop_info['type'] || $val['sub_type'] != $player_prop_info['sub_type']) { unset($player_props[$key]); } # 过滤等级不符合要求装备 if ($val['level'] < $player_prop_info['level']) { unset($player_props[$key]); } elseif ($val['level'] == $player_prop_info['level']) { # 过滤品质不符合要求装备 if ($val['quality'] < $player_prop_info['quality']) { unset($player_props[$key]); } elseif ($val['quality'] == $player_prop_info['quality']) { # 过滤星级不符合要求装备 if ($val['star_level'] <= $player_prop_info['star_level']) { unset($player_props[$key]); } } } } return $player_props; }
/** * 领取所有资源 * @param int player_id 玩家id * @param int type 领取类型 1,免费;2,消耗钻石 */ public function get_back_all($player_id, $type) { $player_id = intval($player_id); if (!in_array($type, array(1, 2))) { //参数错误 $this->throw_error(10107, 6010018); } $df = 0; $data = $this->get_data('GetBackCurrency')->get_yesterday_info($player_id, $df); if ($data['reward_num'] < 1) { //无资源可以找回 $this->throw_error(6010109, 6010114); } if ($data['is_vip']) { $type = 2; } $cost_currency_value = 0; $reward_detail = array(); foreach ($data['func_info'] as &$func) { if (1 == $func['reward_status']) { if (!$data['is_vip'] && 2 == $type) { $value = explode(':', $func['cost_num']); $cost_currency_type = $value[0]; $cost_currency_value += $value[1]; } if (!empty($func['reward'])) { $reward_array = explode("|", $func['reward']); foreach ($reward_array as $reward) { list($item_idx, $item_num) = explode(":", $reward); if (empty($item_num)) { continue; } if (1 == $type) { $item_num = ceil($item_num / 2); } $reward_detail[$item_idx] += intval($item_num); } } $func['reward_status'] = 2; } } if (!$reward_detail) { $this->throw_error(6010109, 6010115); } $send_reward = array(); $this->get_game('Reward')->gen_reward_array($reward_detail, $send_reward); if ($cost_currency_value) { $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($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $data['reward_num'], $cost_currency_type); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type); } $arr_up['func_info'] = $data['func_info']; $arr_up['reward_num'] = 0; $this->start_trans(); $result = $this->get_data('GetBackCurrency')->update_player_info($player_id, $data['day'], $arr_up); if ($result) { $result = $this->get_game('Reward')->send_reward($player_id, $send_reward, array('cmd_id' => 2021)); if ($result !== true) { $this->throw_error($result); } } if ($cost_currency_value) { if ($result) { $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2021, array(), $arr_consume); } } if ($result) { $this->commit(); $this->get_game('Reward')->add_reward_log(true); } else { $this->rollback(); $this->throw_error('10101', 6010116); } $data = $this->get_panel($player_id); Protocol::input($player_id, 8, 20, 2019, $data); //该死的同步次数 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130); return array('res' => 1); }
/** * 全服邀请 */ public function all_service_invite_union($player_id) { $player_id = intval($player_id); $playerInfo = $this->get_data('Player')->get_player_info($player_id, array("union_id", "silver", "union_name", "gold", "ticket", "level", "vip", "name", "union_job", "privilege_level")); if (!$playerInfo['union_id']) { $this->throw_error('171101'); //没有加入公会 } $union_conf = Cache_UnionBase::getInstance()->get_union_conf(); if (empty($union_conf)) { $this->throw_error(10222, 5011990); } if (!isset($union_conf['world_invite'])) { $this->throw_error(10222, 5011993); } list($cost_currency_type, $cost_currency_value) = explode(":", $union_conf['world_invite']); # 消耗虚拟货币 $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type); $arr_consume = Com_Util::get_consume_info_for_data_center($playerInfo, $cost_currency_key, $cost_currency_value); $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', $cost_currency_key, $cost_currency_value, 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, '1789', array(), $arr_consume); $this->write_check($re, 5012009); $arr_replace = array(); $arr_replace[] = array('rep_type' => 7, 'txt' => $playerInfo['union_name']); $arr_replace[] = array('rep_type' => 10, 'txt' => "#1", 'rep_val' => 1703, 'rep_param' => array($playerInfo['union_id'])); $msg = Language_Message::make_message(178901, $arr_replace, 0, '', true); $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 1, 1); }
public function get_reward_info($reward_id) { if (empty($reward_id)) { return false; } $sql = "select * from event_reward_master where reward_id = {$reward_id}"; $record = $this->select_one($sql, $this->get_cache_key(array('reward_id' => $reward_id), $this->prefix_event_reward_master)); if (!empty($record['valid_date_flag'])) { # 每日活动奖励 $date_start = Com_Util::get_date_start(); # 修正每日活动的相关时间 $record['valid_date_head'] += $date_start; $record['valid_date_tail'] += $date_start; } return $record; }
/** * [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); }