/** * 获取包裹或者仓库的上限 * @param $player_id * @param $type * @param null $vip * @return int */ public function get_max_bag_storage_num($player_id, $type, $player_info = null) { if ($type > 2) { return 0; } if (is_null($player_info) || !isset($player_info['vip']) || !isset($player_info['bag_num']) || !isset($player_info['storage_num'])) { $player_info = $this->get_data('Player')->get_player_info($player_id, array('vip', 'bag_num', 'storage_num')); } $vip = $player_info['vip']; if ($type == 1) { $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($vip, 10024); $add = 0; if ($vip_level_config) { $add = $vip_level_config['max_times']; } $num = $this->_max_bag_num + $add; if ($player_info['bag_num'] > $num) { return $player_info['bag_num']; } return $num; } elseif ($type == 2) { $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($vip, 10058); $add = 0; if ($vip_level_config) { $add = $vip_level_config['max_times']; } $num = $this->_max_storage_num + $add; if ($player_info['storage_num'] > $num) { return $player_info['storage_num']; } return $num; } }
public function buy_buff($player_id, $buff_id, $map_id) { $this->param_check_numeric(array($player_id, $buff_id, $map_id)); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level'))); # 获取BUFF信息 $buff_info = Cache_GrabMine::getInstance()->get_buff_info($buff_id); if (empty($buff_info) || empty($buff_info['buff_cost'])) { $this->throw_error('180002'); # 抢矿副本Buff信息配置错误 } # 获取限制类型和限制信息 $vip_limit_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10055); $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10055); if (!empty($vip_limit_type) && !empty($vip_limit_info) && $vip_limit_info['param_1'] == $buff_info['sid']) { $check_level = $vip_limit_type['fun_type'] == 1 ? $player_info['vip'] : $player_info['privilege_level']; if ($check_level < $vip_limit_info['vip_level']) { $error_code = $vip_limit_type['fun_type'] == 1 ? '180007' : '180008'; # vip|特权等级不够,不能购买 $this->throw_error($error_code); } } # 获取BUFF购买剩余CD $buff_buy_remain_cd = $this->get_data('GrabMine')->get_buff_buy_remain_cd($player_id, $buff_id); if ($buff_buy_remain_cd > 0) { $this->throw_error('180004'); # 抢矿副本Buff购买CD中 } # 确定唯一活动关键字 $act_keyword = $this->get_grabmine_activity_keyword($map_id); $bbn_keyword = $this->get_buff_buy_num_keyword($act_keyword, $buff_id); # 获取BUFF当日购买次数 $buff_buy_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $bbn_keyword); $buff_buy_cost = $this->cal_buff_price($buff_buy_num, $buff_info['buff_cost']); $this->start_trans(); # 钻石消耗 $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, 'gold', $buff_buy_cost); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $buff_buy_cost, 1, 1); $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1125', array(), $arr_consume); $this->write_check($re, 3010225); # 更新buff购买CD $re = $this->get_data('GrabMine')->add_buff_buy_cd($player_id, $buff_id, $buff_info['buff_use_cd']); $this->write_check($re, 3010229); # 更新buff购买次数 $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $bbn_keyword); $this->write_check($re, 3010233); $this->commit(); # 通知C++购买BUFF Protocol::input($player_id, 7, 4, 486, array('buff_id' => $buff_id, 'buff_duration' => $buff_info['buff_duration'])); # 通知玩家信息变更[必须放在commit之后] # 下次购买价格 $next_buy_cost = $this->cal_buff_price($buff_buy_num + 1, $buff_info['buff_cost']); $out_1125 = array('buff_id' => $buff_id, 'next_buy_cost' => $next_buy_cost); # 记录行为 Com_Log::debug_write('xgame.grabmine', "{$player_id}\t" . "buy_buff\t" . "{$buff_id}\t" . "{$buff_info['buff_cost']}\t"); return $out_1125; }
public function privilege_clear_battle_cd($player_id, $privilege_level) { #特权免CD if ($privilege_level > 0) { $left_cd = $this->get_game('VipSpecial')->get_left_time($player_id); if ($left_cd > 0) { $vip_info = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10080); if (!empty($vip_info)) { if ($privilege_level >= $vip_info['vip_level']) { $this->get_data('GrabTreasure')->clear_remain_cd($player_id); } } } } }
public function prop_use_by_prop_id($player_id, $prop_id, $use_num = 1) { if ($use_num <= 0) { $use_num = 1; } $prop_config = Cache_Prop::getInstance()->get_prop_info($prop_id); $player_info = $this->get_data('Player')->get_player_info($player_id, array("vip", 'level')); //可使用大喇叭功能vip限制 if ($prop_config['type'] == 3 && $prop_config['sub_type'] == 0) { $error_code = 0; $vip = $player_info['vip']; $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10043); $num = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, $prop_id); if ($num < 1 && intval($vip) < $vip_set['vip_level']) { $error_code = 8; } else { if (intval($vip) < $vip_set['vip_level']) { $error_code = 7; } else { if ($num < 1) { $error_code = 2; } } } if ($error_code) { return array('error_code' => intval($error_code), 'cooldown_msec' => 0); } } if (empty($prop_config)) { return array('error_code' => 2, 'cooldown_msec' => 0); } if ($prop_config['cooldown_time'] > 0) { $ttl = $this->exist_lock($player_id, $prop_id); if ($ttl) { return array('error_code' => 4, 'cooldown_msec' => intval($ttl)); //还在冷却中 } } //先只做扣除操作 $arr_logs = array('cmd_id' => 409); $result = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $prop_id, $use_num, $arr_logs, 0, array('cmd_id' => 409, 'level' => $player_info['level'], 'vip' => $player_info['vip'])); $this->_prop_log = $arr_logs; if ($result !== true) { return array('error_code' => 2, 'cooldown_msec' => 0); } // Protocol_Msg::msg($player_id,80917);#提示使用成功 return array('error_code' => 0, 'cooldown_msec' => intval($prop_config['cooldown_time'])); }
private function add_player_attr($vip_special_level, $player_id) { $data = array(); if ($this->get_left_time($player_id) > 0) { $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($vip_special_level, 10066); if ($vip_level_config) { $data['hp'] = $vip_level_config['max_times']; } $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($vip_special_level, 10067); if ($vip_level_config) { $data['atk_min'] = $vip_level_config['max_times']; } $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($vip_special_level, 10068); if ($vip_level_config) { $data['arm'] = $vip_level_config['max_times']; } } else { $data['hp'] = 0; $data['atk_min'] = 0; $data['arm'] = 0; } $this->get_data('PlayerDetail')->update_player_detail($player_id, array('vip_special_attr' => json_encode($data))); }
public static function get_vip_special_reward_add_coeff($func_id, $player_vip, $player_privilege_level, $player_id) { $vip_limit_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id($func_id); if ($vip_limit_type['fun_type'] == 1 && !empty($player_vip)) { $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, $func_id); } elseif ($vip_limit_type['fun_type'] == 2 && !empty($player_privilege_level)) { $left_time = TenYear::getInstance('Game_VipSpecial')->get_left_time($player_id); if ($left_time > 0) { $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_privilege_level, $func_id); } } $vip_add_coeff = !empty($vip_limit_info) ? $vip_limit_info['max_times'] / 10000 : 0; return $vip_add_coeff; }
public function get_reward($player_id, $sid) { $player_id = intval($player_id); $sid = intval($sid); #Protocol_Player::p2c_part_update($player_id,array('worldboss_remaining_count'=>3)); $cd = $this->get_boss_open_state($player_id); if ($cd == 0) { $this->throw_error(176007); #已超时 } #判断次数是否用完 $baseinfo = $this->get_base_info_id($sid); if (empty($baseinfo)) { $this->throw_error(10222, 2010122); } #配置表错误 $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'world_boss_corpse_count'); $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'gold', 'vip', 'level', 'player_id', 'ticket', 'privilege_level')); $left_time = $baseinfo['corpse_times'] - $used_time; #vip 增加次数 if ($player_info['vip'] > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['vip'], 10033); #增加上限 $left_time += $vip_set['max_times']; } if ($left_time <= 0) { $this->throw_error(11008); #次数已用完 return array('reward_list' => array(), 'is_full' => 2, 'left_time' => $used_time, 'cost_num' => 0); #次数已用完 } #判断消耗是否足够 $cost = $this->get_cost_for_time($used_time, $baseinfo['corpse_cost_num'], $player_info['vip']); $left_cost = 0; $arr_consume = array(); if ($baseinfo['corpse_cost_type'] == 1) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $cost); } elseif ($baseinfo['corpse_cost_type'] == 2 || $baseinfo['corpse_cost_type'] == 20) { if ($player_info['ticket'] >= $cost) { $gold = 0; } else { $gold = $cost - intval($player_info['ticket']); } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost, 1, 1); $arr_consume = array('price' => $cost, 'gold' => $gold, 'ticket' => $cost - $gold, 'count' => 1); #数据中心推送 } else { $this->throw_error(10222, 2010123); } #判断包裹是否已满 $isfull = $this->get_game('Prop')->get_empty_pos($player_id); if (false === $isfull) { return array('reward_list' => array(), 'is_full' => 1, 'used_time' => $used_time, 'cost_num' => $cost); } $reward_list = $this->get_data('WorldBoss')->get_boss_reward_list($player_id); $rewards = $this->get_reward_rand_player_id($player_id, $sid, $cost, $reward_list); if (!empty($rewards)) { $send_reward = array(array('type' => Cache_FbLoot::getInstance()->get_item_key($rewards['type']), 'item_id' => $rewards['item_id'], 'item_num' => $rewards['item_num'])); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1120, array(), $arr_consume); if ($result === true) { $result_s = $this->get_game('Reward')->send_reward($player_id, $send_reward, array('cmd_id' => '1120', 'bind_flag' => 0), 1); if (true === $result_s) { $this->get_game('Reward')->add_reward_log(false, 0, 0); //记录日志 #添加抽取记录 if (empty($reward_list['list_log']) || $reward_list['list_log'] == '' || is_null($reward_list['list_log'] || $reward_list['list_log'] == 'null')) { $log_list = array(); } else { $log_list = json_decode($reward_list['list_log'], true); } $log_list[] = $rewards['item_id']; $this->get_data('WorldBoss')->set_boss_reward_list($player_id, array('list_log' => json_encode($log_list))); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'world_boss_corpse_count'); /* $gainMsg = array(); $gainMsg['gain_type']=1; $gainMsg['type'] =$rewards['type']; $gainMsg['sid'] =$rewards['item_id']; $gainMsg['num'] =$rewards['item_num']; $gainMsg['time'] =time(); Protocol::input($player_id, 8, 7, 740, array($gainMsg)); */ $cost = $this->get_cost_for_time($used_time + 1, $baseinfo['corpse_cost_num'], $player_info['vip']); $res = array('reward_list' => array($rewards), 'is_full' => 0, 'used_time' => $used_time + 1, 'cost_num' => $cost); #活动日志 $_event_log = array('log_type' => 'world_boss_treasure', 'player_id' => $player_id, 'reg_time' => time(), 'map_id' => $sid); $this->get_game('Event')->async_deal_event_log($_event_log); #同步功能次数 $num = $this->get_left_sum_time($player_id); $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1110, $num); #公会任务 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, "1110"); return $res; } else { $this->throw_error(10110, 2010124); } } else { //echo "1"; if ($result === false) { $this->throw_error(10110, 2010125); } $this->throw_error($result); } } else { // echo "2"; $this->throw_error(10222, 2010126); } }
/** * @Purpose: * 每日签到 * @Param $player_id 玩家ID * @Param $mday 签到日 */ public function daily_sign($player_id, $mday) { $player_id = intval($player_id); $mday = intval($mday); #获取每日签到数据 $data = $this->get_data('DailySign')->get_daily_sign_info($player_id); if ($data) { $sign_info = array(); if ($data['sign_info'] && !is_array($data['sign_info'])) { $sign_info = json_decode($data['sign_info'], true); } #月签到次数验证 if ($data['sign_num'] >= $data['sign_num_max'] && $sign_info[$mday + 1]['state'] != 5) { $this->throw_error('200101'); //不可签到 } $player_info = $this->get_data('Player')->get_player_info($player_id, array('privilege_level', 'vip', 'ticket', 'gold')); $arr_consume = array(); $cun_day = intval(date('d')); #5点刷新 $expireAt = mktime(5, 0, 0, date('m'), date('d'), date('Y')); $time = time(); if ($time < $expireAt) { $cun_day = intval(date('d', strtotime('-1 day'))); } #获取开服时间,如果和每日签到信息再同一个月内,则需要记录 $date = getdate(strtotime(SERVER_FIRST_START_TIME)); $expiredateAt = mktime(5, 0, 0, $date['mon'] + 1, 1, $date['year']); if ($date['year'] == date('Y') && ($date['mon'] == intval(date('m')) || $time < $expiredateAt)) { $cun_day = $cun_day - $date['mday'] + 1; } $is_expend = false; $sign_state = 0; if (!$sign_info[$mday] || $sign_info[$mday + 1]['state'] == 0) { $sign_state = $sign_info[$mday + 1]['state']; } else { if ($mday + 1 <= $cun_day && $sign_info[$mday + 1]['state'] == 1 && $data['day'] != $cun_day) { $sign_state = $sign_info[$mday + 1]['state']; } else { if ($mday + 1 <= $cun_day && $sign_info[$mday + 1]['state'] == 3) { if ($data['day'] == $cun_day) { #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10045); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } #获取VIP配置表副本限制 $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10045); if ($vip_table['vip_level'] < 1 || $player_vip < $vip_table['vip_level']) { $this->throw_error('200103'); //vip等级不足 } #获取补签配置表 $after_sign_table = $this->get_cache_table_data('sign_limit_table', array('sign_num' => $data['after_sign_num'])); if ($after_sign_table) { $data['after_sign_expend'] = $after_sign_table['expend_diamond']; } $deduct_coin = 0; $gold = 0; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] < $data['after_sign_expend']) { $deduct_coin = $player_info['ticket']; } else { $deduct_coin = $data['after_sign_expend']; } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $deduct_coin); $is_expend = true; } if ($deduct_coin < $data['after_sign_expend']) { $gold = $data['after_sign_expend'] - $deduct_coin; $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $gold); $is_expend = true; } $arr_consume = array('price' => $data['after_sign_expend'], 'gold' => $gold, 'ticket' => $deduct_coin, 'count' => 1); #数据中心推送 } /* #钻石不足 $player_gold = $this->get_data('Player')->get_player_info($player_id, 'gold'); if ($data['after_sign_expend'] > $player_gold) { $this->throw_error('1717001'); //钻石不足 } */ $sign_state = $sign_info[$mday + 1]['state']; } else { if ($sign_info[$mday + 1]['state'] == 4 || $sign_info[$mday + 1]['state'] == 5 || $sign_info[$mday + 1]['state'] == 6) { $sign_state = $sign_info[$mday + 1]['state']; } else { $this->throw_error('200101'); //不可签到 } } } } #获取每日签到配置表 $sign_table = $this->get_cache_table_data('sign_table', null); if (empty($sign_table) || !Com_Array::is_good_arr($sign_table)) { $this->throw_error('10109'); //配置表读取错误 } $is_update = false; $is_free_sign = false; $deduct_diamond = 0; if ($sign_state == 1 || $sign_state == 3) { $is_update = true; #记录签到日期,一天只能免费签到一次 if ($data['day'] != $cun_day) { $update_data['day'] = $data['day'] = $cun_day; $is_free_sign = true; } #生成下一条补签日期 if ($mday + 2 <= $cun_day && !empty($sign_info[$mday + 2])) { $sign_info[$mday + 2]['state'] = 3; if (!$is_free_sign && $sign_state == 3) { $deduct_diamond = $data['after_sign_expend']; $update_data['after_sign_num'] = ++$data['after_sign_num']; #获取补签配置表 $after_sign_table = $this->get_cache_table_data('sign_limit_table', array('sign_num' => $data['after_sign_num'])); if ($after_sign_table) { $data['after_sign_expend'] = $after_sign_table['expend_diamond']; $update_data['after_sign_expend'] = $after_sign_table['expend_diamond']; } } } #获取玩家VIP等级 $player_vip = $player_info['vip']; #签到奖励领取判定 if ($sign_table[$mday]['vip_level'] > 0 && $player_vip >= $sign_table[$mday]['vip_level']) { $sign_info[$mday + 1]['state'] = 6; } else { $sign_info[$mday + 1]['state'] = 4; } } else { if ($sign_state == 5) { $sign_info[$mday + 1]['state'] = 6; } else { $this->throw_error('200101'); //不可签到 } } #获取奖励道具 $prop_id = $sign_table[$mday]['prop_id']; if ($sign_info[$mday + 1]['state'] == 4 || $sign_info[$mday + 1]['state'] == 6 && $sign_state == 5) { $prop_num = $sign_table[$mday]['prop_num']; } else { $prop_num = $sign_table[$mday]['prop_num'] + $sign_table[$mday]['vip_prop_num']; } $prop_list[] = array('id' => $prop_id, 'num' => $prop_num); #格式化道具格式 $prop_info = $this->format_prop($prop_list); if ($is_update) { $update_data['sign_num'] = ++$data['sign_num']; } $data['sign_info'] = $sign_info; $update_data['sign_info'] = json_encode($sign_info); $this->start_trans(); #更新每日签到 $update_res = $this->get_data('DailySign')->update_daily_sign($player_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } #扣钻石 if ($is_expend) { $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2002, array(), $arr_consume); #$update_res = $this->get_data('Player')->update_player_gold($player_id, "-".$deduct_diamond); if (!$update_res) { $this->throw_error('10104'); } } if ($is_update) { #同步更新玩家使用次数总表 $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'daily_sign_free_times', 1); #更新翅膀激活条件 #Com_Log::write("sign_num.".$player_id,var_export($update_data['sign_num'],true)); $this->get_game('PlayerWing')->update_wing_activation_condition($player_id, 2, $update_data['sign_num']); } $this->commit(); $this->start_trans(); #道具发送 if (Com_Array::is_good_arr($prop_info)) { $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '2002', 'bind_flag' => 0)); if ($result === false) { $this->throw_error('10104'); } else { if ($result !== true) { $this->throw_error($result); } } } $this->commit(); if ($is_update) { $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130); $this->get_game('VipSpecial')->add_vip_special_exp($player_id, 1131); } $this->get_game('Reward')->add_reward_log(true); #Protocol_Player::p2c_part_update($player_id,array('gold'=>0,'ticket'=>0)); #更新临时数据区数据 $this->update_temporary_data($data); #每日活跃度更新 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 1000); #公会任务触发 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 1131); } return array(intval($mday)); }
public function check_go_into($player_id, $map_id) { $pinfo = $this->get_data('Player')->get_player_info($player_id, array('vip', 'privilege_level')); $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10009); if ($vip_type['fun_type'] == 1) { $vip = $pinfo['vip']; } elseif ($vip_type['fun_type'] == 2) { $vip = $pinfo['privilege_level']; } $c_set = Cache_PlayerPve::getInstance()->get_seting(); $left_fight_num = $this->get_vip_times($vip) + $c_set[0]['sums'] - $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'used_fight_num') + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'used_sell_num'); #判断挑战次数是否用完 if ($left_fight_num <= 0) { return false; } $f_info = $this->get_data('PlayerPve')->get_player_fb_info($player_id); //玩家最后通关信息 $c_info = Cache_PlayerPve::getInstance()->get_pev_sid($map_id); //获取副本消息 if (!empty($f_info)) { if ($f_info['chapter_id'] < $c_info[0]['chapter_id']) { return false; } else { if ($f_info['chapter_id'] == $c_info[0]['chapter_id']) { $c_list = Cache_PlayerPve::getInstance()->get_pve_list($f_info['chapter_id']); //挑战副本信息 $fb_info = $this->get_data('PlayerFB')->get_player_fb_info($player_id); $type = $this->check_is_open($map_id, $f_info['chapter_info'], $c_list, $c_info[0]['map_sid'], $fb_info); if ($type == 0) { return false; } } } } return true; }
private function five_rand_reward($player_id, $type, $free = false, $last_comtime = 10, $p_info = null, $used_item = false) { $this->start_trans(); $result = array(); $max_rand = 1; $is_first = true; if ($last_comtime > 0) { $is_first = false; } $cost_gold_count = '+1'; $log_data = $this->get_data('PlayerPub')->get_player_pub_info($player_id); $cost_count = isset($log_data['cost_gold_count']) ? 0 + $log_data['cost_gold_count'] : 0; $set = Cache_PubHero::getInstance()->pub_cost_value_by_type(2); if ($is_first) { $result[] = array('type' => 1, 'data' => array('typeid' => 1, 'hero_id' => 5002)); $cost_count = 1; } else { #获取特殊英雄的次数--使用道具不出特色英雄 $specil_num = $this->get_specil_num(2); if ($cost_count >= $set['special_num'] - 1) { $specil_num = 1; $cost_gold_count = 0; $cost_count = 0; } else { $cost_count += 1; } if ($specil_num > $max_rand) { $specil_num = $max_rand; } $com_num = $max_rand - $specil_num; #五连抽普通抽取 $data = $this->get_chance_list_com($player_id, $type); for ($i = 0; $i < $com_num; $i++) { $result[] = $this->randval_com($data, $player_id); } if ($specil_num == 1) { $cost_gold_count = 0; $cost_count = 0; } #特殊英雄的抽取 $init_data = Cache_PubHero::getInstance()->get_specil_heros(); for ($i = 0; $i < $specil_num; $i++) { if ($used_item) { $temp = $this->randval_specil($player_id, $free, 1, $i, $init_data); } else { $temp = $this->randval_specil($player_id, $free, 2, $i, $init_data); } $result[] = array('type' => 1, 'data' => array('typeid' => 1, 'hero_id' => $temp['hero_id'])); } } if ($this->update_info($result, $player_id, $free)) { if (is_null($p_info)) { $p_info = $this->get_data('Player')->get_player_info($player_id, array('chips', 'vip', 'union_id', 'pubnum')); $p_info['chips'] == '' ? $p_info['chips'] = 0 : $p_info['chips']; } if ($free) { #更改免费次数 $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'pub_left_five_num'); $this->get_data('PlayerPub')->update_player_pub_info($player_id, array('cost_gold_count' => $cost_gold_count, 'last_fivetime' => time())); } else { $this->get_data('PlayerPub')->update_player_pub_info($player_id, array('cost_gold_count' => $cost_gold_count)); } $this->commit(); $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10081); $left_num = 0; $left_left_time = 0; if (!empty($vip_set) && $vip_set['vip_level'] <= $p_info['vip']) { $left_num = $vip_set['max_times'] - $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'pub_left_five_num'); $left_left_time = $vip_set['param_2']; } if (!$free) { $left_left_time = $left_left_time - (time() - $last_comtime); $left_left_time = $left_left_time < 0 ? 0 : $left_left_time; } $r = array(); $r['status'] = 1; $r['result'] = $result; $r['chips'] = intval($p_info['chips']); $r['type'] = $type; $r['left_free_num'] = $left_num; $r['left_time'] = $left_left_time; $r['com_rand_time'] = 0; #次数内必出 $r['gold_rand_time'] = $set['special_num'] - $cost_count; #次数内必出 #埋点 $this->add_other_func_count($player_id, $p_info['union_id'], '1070_1', 2); return $r; } else { $this->rollback(); $this->throw_error('10110', 2010046); //数据错误 } }
/** * @Purpose: * 刷新玩家公会通缉榜副本 * @Param $player_id 玩家ID */ public function refresh_wanted_fb($player_id) { $player_id = intval($player_id); #获取玩家公会ID,验证公会信息 #$player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'privilege_level', 'level', 'vip', 'ticket', 'gold', 'silver')); $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'union_id', 'privilege_level', 'level', 'vip', 'ticket', 'gold', 'silver'))); $union_id = $player_info['union_id']; if ($union_id < 1) { $this->throw_error('171101'); #未加入公会 } #获取玩家通缉榜天数据 $uwd_data = $this->get_data("UnionWanted")->get_union_wanted_daily_info($player_id, 'uwd', 'day'); if (!$uwd_data) { $this->throw_error('10110'); #数据错误 } #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10060); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } $free_times_vip_table = array(); if ($player_vip > 0) { #获取VIP配置表免费次数配置 $free_times_vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, 10060); } $deduct_coin = false; $arr_consume = array(); if ($uwd_data['used_free'] >= $free_times_vip_table['max_times'] + $uwd_data['use_free']) { if ($uwd_data['use_expend'] && !is_array($uwd_data['use_expend'])) { $uwd_data['use_expend'] = json_decode($uwd_data['use_expend'], true); } #免费刷新副本次数不足时,检测货币是否足够 if ($uwd_data['use_expend']['id'] > 0 && $uwd_data['use_expend']['num'] > 0) { $cur_idx = $uwd_data['use_expend']['id']; $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx); if ('gold' == $cost_currency_key) { if (20 == $cur_idx) { if ($player_info['ticket'] < $uwd_data['use_expend']['num']) { $ticket = $player_info['ticket']; $gold = $uwd_data['use_expend']['num'] - $ticket; } else { $ticket = $uwd_data['use_expend']['num']; $gold = 0; } } else { $gold = $uwd_data['use_expend']['num']; $ticket = 0; } $arr_consume = array('price' => $ticket + $gold, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $uwd_data['use_expend']['num'], 1, $cur_idx); $deduct_coin = true; } else { $this->throw_error('10110'); #数据错误 } } #获取玩家通缉榜数据 $uw_data = $this->get_data("UnionWanted")->get_union_wanted_info($player_id); if (!$uw_data) { $this->throw_error('10110'); #数据错误 } if (!is_array($uw_data['wanted_info'])) { $uw_data['wanted_info'] = json_decode($uw_data['wanted_info'], true); } #获取公会通缉榜等级 $wanted_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'wanted_level'); $base_table = $this->get_cache_table_data('base_table', array('level' => $wanted_level)); if (!$base_table) { $this->throw_error('10109'); //配置表读取错误 } if ($deduct_coin) { $update_uwd['used_times'] = ++$uwd_data['used_times']; } else { $update_uwd['used_free'] = ++$uwd_data['used_free']; } if ($uwd_data['used_free'] >= $free_times_vip_table['max_times'] + $uwd_data['use_free']) { $times_table = $this->get_cache_table_data('times_table', array('type' => 1, 'times' => $uwd_data['used_times'])); if ($times_table) { #通过刷新消耗配置表获得下次刷新需要消耗的货币数量 list($id, $value) = explode("|", $times_table['cost']); $update_uwd['use_expend'] = json_encode(array('id' => $id, 'num' => $value)); } } #创建通缉数据结构 $wanted_data = $this->create_wanted_struct($wanted_level); $uw_data['wanted_info']['union_wanted_info'] = $wanted_data; $update_data['wanted_info'] = json_encode($uw_data['wanted_info']); $this->start_trans(); #更新玩家公会通缉榜数据 $update_res = $this->get_data("UnionWanted")->update_union_wanted($player_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } if ($deduct_coin) { $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1717, array(), $arr_consume); if (!$update_res) { $this->throw_error('10104'); } } if ($update_uwd) { #更新玩家公会通缉榜天数据 $this->get_data("UnionWanted")->update_union_wanted_daily_data($player_id, 'uwd', $update_uwd); } $this->commit(); $this->update_temporary_data($uw_data); return array('0' => 1); }
public function do_inspire($player_id, $union_id, $type) { $player_id = intval($player_id); $union_id = intval($union_id); $res = array(); $res['res'] = 0; #判断是否为会长或副会长 $union_info = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id); #错误码 $error_code = 0; if (!empty($union_info)) { if (isset($union_info['job_id'])) { $union_info_exp = $this->get_data('UnionInfo')->get_union_info($union_id); $setting = $this->get_base_level($union_info_exp['union_level']); if (1 == $type) { #1金币鼓舞) $used_time = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, 'union_boss_inspire_count'); $max_time = intval($setting['inspire_silver_max_times']); $error_code = 176003; } elseif (2 == $type) { #钻石鼓舞 $used_time = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, 'union_boss_gold_inspire_count'); $max_time = intval($setting['inspire_gold_max_times']); $error_code = 176004; } elseif ($type == 3) { #群体鼓舞 if (false === $this->check_union_job($union_info['job_id'], $setting['inspire_group_job'])) { $this->throw_error(176001); #职位不足 } $used_time = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, 'union_boss_group_inspire_count'); $max_time = $setting['inspire_group_max_time']; $error_code = 176005; } elseif (4 == $type) { #群体复活 if (false === $this->check_union_job($union_info['job_id'], $setting['relive_group_job'])) { $this->throw_error('176002'); #职位不足 } $used_time = 0 + $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, 'union_boss_group_relive_count'); $max_time = $setting['relive_group_max_time']; $error_code = 176006; } if (!empty($setting)) { #次数判断 #$setting['inspire_max_times']=100; $player_info = $this->get_data('Player')->get_player_info($player_id, array('silver', 'gold', 'player_id', 'level', 'vip', 'ticket', 'privilege_level')); if ($used_time < $max_time) { #判断费用是否足够 if (1 == $type) { #金币鼓舞 $cost_num = $this->get_cost_num($used_time, $setting['inspire_silver_cost_num']); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $cost_num); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1771); if (true == $result) { if ($this->rand_inspire($setting['inspire_silver_rand'])) { $res['res'] = 1; Protocol::input($player_id, 7, 4, 495, array('player_id' => $player_id, 'union_id' => $union_id, 'group' => 0)); $this->get_data("PlayerDailyTime")->add_used_time($player_id, 'union_boss_inspire_count'); } else { $res['res'] = 0; } // Protocol_Player::p2c_part_update($player_id,array('silver'=>0,'gold'=>0));#同步消耗 } else { $this->throw_error(10110, 2010160); } } elseif (2 == $type) { #判断功能开启 $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10052); if ($vip_set['vip_level'] > $player_info['vip']) { $this->throw_error('11089'); } #钻石鼓舞 #先扣除彩钻 $cost = $this->get_cost_num($used_time, $setting['inspire_gold_cost_num']); $ticket = 0; $price = $cost; if ($player_info['ticket'] >= $cost) { $ticket = $cost; $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $cost); $cost = 0; } else { $ticket = $player_info['ticket']; $cost = $cost - $player_info['ticket']; $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $player_info['ticket']); $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost); } $arr_consume = array('price' => $price, 'gold' => $cost, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1771, array(), $arr_consume); if (true == $result) { // Protocol_Player::p2c_part_update($player_id,array('silver'=>0,'gold'=>0));#同步消耗 if ($this->rand_inspire($setting['inspire_gold_rand'])) { $res['res'] = 1; Protocol::input($player_id, 7, 4, 495, array('player_id' => $player_id, 'union_id' => $union_id, 'group' => 1)); $this->get_data("PlayerDailyTime")->add_used_time($player_id, 'union_boss_gold_inspire_count'); // Protocol_Player::p2c_part_update($player_id,array('silver'=>0,'gold'=>0,'ticket')); } else { $res['res'] = 0; } } else { $this->throw_error(10110, 2010143); #数据错误 } } elseif (3 == $type) { #全体鼓舞 $ticket = 0; $price = $setting['inspire_group_gold_cost_num']; if ($player_info['ticket'] >= $setting['inspire_group_gold_cost_num']) { $ticket = $setting['inspire_group_gold_cost_num']; $gold = 0; } else { $ticket = $player_info['ticket']; $gold = $setting['inspire_group_gold_cost_num'] - $player_info['ticket']; } $arr_consume = array('price' => $setting['inspire_group_gold_cost_num'], 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $setting['inspire_group_gold_cost_num'], 1, 1); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1771, array(), $arr_consume); if (true === $result) { if ($this->rand_inspire($setting['inspire_group_rand'])) { $res['res'] = 1; Protocol::input($player_id, 7, 4, 495, array('player_id' => $player_id, 'union_id' => $union_id, 'group' => 2)); $this->get_data("PlayerDailyTime")->add_used_time($player_id, 'union_boss_group_inspire_count'); // Protocol_Player::p2c_part_update($player_id,array('silver'=>0,'gold'=>0));#同步消耗 } else { $res['res'] = 0; } } else { $this->throw_error(10110, 2010145); #数据错误 } } elseif (4 == $type) { #群体复活 $arr_consume = array(); if ($setting['relive_group_cost_type'] == 1) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $setting['relive_group_cost_num']); } else { /***************/ $ticket = 0; $gold = $setting['relive_group_cost_num']; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] >= $setting['relive_group_cost_num']) { $ticket = $setting['relive_group_cost_num']; $gold = 0; } else { $ticket = $player_info['ticket']; $gold = $setting['relive_group_cost_num'] - $player_info['ticket']; } } $arr_consume = array('price' => $setting['relive_group_cost_num'], 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $setting['relive_group_cost_num'], 1, 1); } $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1771, array(), $arr_consume); if (true === $result) { $res['res'] = 1; Protocol::input($player_id, 7, 4, 495, array('player_id' => $player_id, 'union_id' => $union_id, 'group' => 3)); $this->get_data("PlayerDailyTime")->add_used_time($player_id, 'union_boss_group_relive_count'); // Protocol_Player::p2c_part_update($player_id,array('silver'=>0,'gold'=>0));#同步消耗 } else { $this->throw_error('10110', 2010146); #数据错误 } } else { $this->throw_error('10107', 2010147); #参数错误 } } else { $this->throw_error($error_code); #次数已用完 } } else { $this->throw_error('10222', 2010148); #配置表错误 } } } $res['type'] = $type; return $res; }
/** * 复活 * @param int $player_id 玩家id * @param int $sid 活动id * @return array */ public function relive($player_id, $sid) { $res = array(); $set = Cache_Trial::getInstance()->get_trial_set($sid); $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'trial_relive_count'); $pinfo = $this->get_data('Player')->get_player_info($player_id, array('gold', 'level', 'vip', 'player_id', 'ticket', 'privilege_level')); $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($pinfo['vip'], 10074); $vip_time = 0; if (!empty($vip_set)) { $vip_time = $vip_set['max_times']; } if ($used_time < $set['relive_times'] + $vip_time) { $cost_list = explode('|', $set['relive_cost']); $list_num = count($cost_list); $cost_num = 0; if (!empty($cost_list)) { $cost_num = abs($cost_list[$list_num - 1]); if ($used_time < $list_num && $list_num) { $cost_num = $cost_list[$used_time]; } } else { $this->throw_error(10222, 6010007); } /***************/ $ticket = 0; $gold = $cost_num; if ($pinfo['ticket'] > 0) { if ($pinfo['ticket'] >= $cost_num) { $ticket = $cost_num; $gold = 0; } else { $ticket = $pinfo['ticket']; $gold = $cost_num - $pinfo['ticket']; } } $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); //数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', 'gold', $cost_num, 1, 1); $result = $this->get_data('Player')->update_player_resource($player_id, $pinfo, 1140, array(), $arr_consume); if (true === $result) { $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'trial_relive_count'); Protocol::input($player_id, 7, 4, 530, 0); //成功通知C++ } else { $this->throw_error(10110, 6010008); } $res['res'] = 1; } else { $res['res'] = 2; //次数已用完 } return $res; }
/** * 获取赞过我的消息 */ public function get_like_player_info($player_id) { $objlike = $this->get_data('PlayerLike'); $objfrined = $this->get_data('PlayerFriend'); $data = $objlike->get_like_data($player_id); Com_Array::multisort($data, array('create_time' => 'desc', 'news_id' => 'desc')); $player_data = $objfrined->get_player_friend($player_id, array('follow', 'blacklist', 'like_times')); $player_freinds = array_keys($player_data['follow']['info']); $result = array(); $show_data = array(); $add_exp = 0; $like_tips_info = $this->get_data('NewsTips')->get_player_newstips($player_id, self::$_like_tips_type); if ($data) { $show_data = array_slice($data, 0, 20); //每次显示最新20条 foreach ($show_data as $key => $val) { $show_data[$key]['is_friend'] = 0; if (in_array($val['player_id'], $player_freinds)) { $show_data[$key]['is_friend'] = 1; } $add_exp += intval($val['exp']); $sid = $val['news_id'] . $val['player_id']; $ret = $objlike->del_like_data_by_likeid($player_id, $sid); if (!$ret) { $ret = $objlike->del_like_data_by_likeid($player_id, $val['news_id']); //打开后清除好友点赞提示 } $this->write_check($ret, 5011398); } //好友点赞提示数 $set_data['num'] -= count($show_data); $set_data['num'] = $set_data['num'] < 0 ? 0 : $set_data['num']; $ret = $objtips = $this->get_data('NewsTips')->update_player_tips($player_id, self::$_like_tips_type, $set_data); $this->write_check($ret, 5011404); } else { $ret = $this->get_data('NewsTips')->update_player_tips($player_id, self::$_like_tips_type, array('num' => 0)); $this->write_check($ret, 5011407); } if ($add_exp > 0) { #被点赞获得奖励 $reward = array(); $reward[] = array('type' => 'exp', 'item_id' => 1, 'item_num' => $add_exp); $ret = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '102')); if ($ret === true) { $this->get_game('Reward')->add_reward_log(true); } } $player_basic_info = $this->get_data('Player')->get_player_info($player_id, array('ticket', 'level', 'gold', 'vip', 'level_exp', 'name')); $like_max_times = $this->like_default_times; if (intval($player_basic_info['vip']) > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_basic_info['vip'], 10069); $like_max_times = $this->like_default_times + $vip_set['max_times']; } $today_like_friend = intval($player_data['like_times']['today_like_friend_times']) + intval($player_data['like_times']['today_times']); $result['player_id'] = $player_id; $result['today_like_player'] = $like_max_times; $result['today_like_friend'] = $today_like_friend; //赞过+被赞过 $result['like_info'] = $show_data; return Struct_Friend::get_player_likes($result); }
/** * 找会资源接口 * @param $player_id * @param $privilege_level * @param $times * @return array */ public function get_back_reward($player_id, $privilege_level, $times) { $my_arena_info = $this->get_data('KFArena')->get_kf_arena_info($player_id); $dw_config = Cache_CrossArenaLevel::getInstance()->get_config_info($my_arena_info['dw']); $rewards = $this->format_level_reward($dw_config['win_reward']); if (!empty($rewards)) { $reward = $rewards[$my_arena_info['dw_lv']]; } $send_reward = array(); if (!empty($reward)) { #vip特权奖励加层 $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); if ($left_time) { $vip_level_config = Cache_VipLevelLimit::getInstance()->get_limit_info($privilege_level, 10065); } else { $vip_level_config = array(); } if ($vip_level_config) { $vip_addtion = $vip_level_config['max_times'] / 10000; } else { $vip_addtion = 0; } $full_reward_flag = $this->get_reward_rate(); $send_reward = $this->format_reward($reward['info'], $full_reward_flag, $vip_addtion, $times); } return $send_reward; }
public function get_refine_info($player_id, $player_prop_id, $refine_type = 0, $lock_attr_seq_hash = array()) { #$this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_refine); $this->param_check_numeric(array($player_id)); $player_info = $this->get_data('Player')->get_player_info($player_id, array('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('81104'); # 首充装备不允许洗练 } $out_847 = array('player_prop_id' => $player_prop_id, 'refine_type' => $refine_type, 'attr_perfection_avg' => 0, 'refine_conf_list' => array(), 'refine_lock_conf_list' => array(), 'refine_info_list' => array()); # -------------------------------------------------------------------- # 获取洗练配置信息 # -------------------------------------------------------------------- $base_info_all = Cache_Refine::getInstance()->get_equip_refine_base_info_all(); if (empty($base_info_all)) { $this->throw_error('81001'); # 获取洗炼基础配置信息失败 } $default_refine_type = 5; # 默认洗练类型[当前能洗练的最小洗练级别] # vip洗练级别限制 $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['vip'], 10079); if (!empty($vip_limit_info)) { $refine_type_vip_limit = $vip_limit_info['max_times']; } else { $refine_type_vip_limit = 5; } foreach ($base_info_all as $base_info) { $refine_conf = array('refine_type' => $base_info['refine_type'], 'attr_limit_lower' => $base_info['attr_limit_lower'], 'attr_limit_upper' => $base_info['attr_limit_upper'], 'attr_num' => $base_info['attr_num'], 'cost_item' => "{$base_info['cost_item_id']}:{$base_info['cost_item_num']}", 'cost_currency' => $base_info['cost_currency'], 'refine_status' => $base_info['refine_type'] > $refine_type_vip_limit ? 2 : 1); if (isset($player_equip_info['refine_info']['last_refine_type']) && $player_equip_info['refine_info']['last_refine_type'] > $base_info['refine_type']) { $refine_conf['refine_status'] = 0; } if ($refine_conf['refine_status'] && $default_refine_type > $refine_conf['refine_type']) { $default_refine_type = $refine_conf['refine_type']; } $out_847['refine_conf_list'][] = $refine_conf; } if (!empty($player_equip_info['refine_info']['last_refine_type'])) { $default_refine_type = $player_equip_info['refine_info']['last_refine_type']; } if (empty($out_847['refine_type'])) { $out_847['refine_type'] = $default_refine_type; } # -------------------------------------------------------------------- # 获取锁定配置信息 # -------------------------------------------------------------------- $lock_info_all = Cache_Refine::getInstance()->get_equip_refine_lock_info_all(); if (empty($lock_info_all)) { $this->throw_error('81002'); # 获取洗炼锁定配置信息失败 } foreach ($lock_info_all as $lock_info) { $lock_conf = array('lock_num' => $lock_info['lock_num'], 'cost_item' => "{$lock_info['cost_item_id']}:{$lock_info['cost_item_num']}"); $out_847['refine_lock_conf_list'][] = $lock_conf; } # -------------------------------------------------------------------- # 获取装备洗练属性信息 # -------------------------------------------------------------------- $attr_perfection_sum = 0; if (!empty($player_equip_info['refine_info'])) { foreach ($player_equip_info['refine_info']['attr_info'] as $attr_seq => $attr_info) { $out_847['refine_info_list'][] = array('attr_seq' => $attr_info['attr_seq'], 'attr_key' => Cache_RoleKey::getInstance()->get_item_key($attr_info['attr_key']), 'attr_value' => $attr_info['attr_value'], 'attr_limit' => $attr_info['refine_attr_value'] + $attr_info['attr_stint'], 'attr_perfection' => $attr_info['attr_ratio'], 'en_refine_attr_delta' => 0, 'en_refine_success_rate' => 0, 'en_refine_cost_currency' => 0, 'lock_status' => isset($lock_attr_seq_hash[$attr_seq]) ? 1 : 0); $attr_perfection_sum += $attr_info['attr_ratio']; } $out_847['refine_info_list'] = Struct_Prop::attr_sort_2($out_847['refine_info_list']); } $out_847['attr_perfection_avg'] = ceil($attr_perfection_sum / 5); #var_export($out_847); return $out_847; }
private function get_task_flush_cost_cur_value($flush_count, $player_info) { # 获取限制类型和限制信息 $vip_limit_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10011); if ($vip_limit_type['fun_type'] == 1 && !empty($player_info['vip'])) { $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['vip'], 10011); } elseif ($vip_limit_type['fun_type'] == 2 && !empty($player_info['privilege_level'])) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_info['player_id']); if ($left_time > 0) { $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info($player_info['privilege_level'], 10011); } } if (!empty($vip_limit_info)) { if ($vip_limit_info['max_times'] > $flush_count) { $task_flush_cost_cur_value = 0; return array($this->task_flush_cost_cur_type_1, $task_flush_cost_cur_value); } else { $flush_count -= $vip_limit_info['max_times']; # 扣除vip特权免费的次数之后再计算价格 } } $flush_cost_info = Cache_TimesExpendControl::getInstance()->get_cost_info($this->daily_task_flush_type, $flush_count + 1); list($task_flush_cost_cur_type, $task_flush_cost_cur_value) = explode("|", $flush_cost_info['cost']); /** # 刷新次数修正 if ($flush_count > $this->task_flush_boundary_num) $flush_count = $this->task_flush_boundary_num; if ($flush_count <= $this->task_flush_revise_num) { # 使用第一种货币刷新 $task_flush_cost_cur_type = $this->task_flush_cost_cur_type_1; $task_flush_cost_cur_value = intval($flush_count) * 2500 + 5000; } else { # 使用第二种货币刷新 $task_flush_cost_cur_type = $this->task_flush_cost_cur_type_2; $task_flush_cost_cur_value = 5 + (intval($flush_count) - 11) * 2; } **/ return array($task_flush_cost_cur_type, $task_flush_cost_cur_value); }
/** * 捐献 * @param unknown $union_id * @param unknown $funds */ public function donate_silver($player_id, $union_id, $gold) { $union_id = intval($union_id); $gold = abs(intval($gold)); $objUnionPlayerData = $this->get_data('UnionPlayer'); $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id); if (empty($unionPlayerInfo)) { $this->throw_error('171001'); //该玩家未加入该公会 } $playerInfo = $this->get_data('Player')->get_player_info($player_id, array("ticket", "vip", "level", "gold", "privilege_level")); $this->start_trans(); $cost_gold = $gold; $ticket = 0; /* if($playerInfo['ticket']>0){ if($playerInfo['ticket']>=$gold){ $ticket = $gold; $this->get_data('Player')->check_player_resource($player_id,$playerInfo,'-','ticket',$gold); $cost_gold = 0; }else{ $ticket = $playerInfo['ticket']; $cost_gold = $gold-$playerInfo['ticket']; $this->get_data('Player')->check_player_resource($player_id,$playerInfo,'-','ticket',$playerInfo['ticket']); } } */ $arr_consume = array('price' => $gold, 'gold' => $cost_gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, "-", "gold", $cost_gold); $objUnionInfoData = $this->get_data('UnionInfo'); $unionInfo = $objUnionInfoData->get_union_info($union_id, array("union_level", "fund", "union_exp")); $unionBaseConfig = Cache_UnionBase::getInstance()->get_union_base_info($unionInfo['union_level']); //金币与公会资金比例 $add_fund = intval($gold * $unionBaseConfig["donate_union_gold"]); if (intval($unionInfo["fund"]) + $add_fund > $unionBaseConfig['max_union_gold']) { $this->throw_error('173202'); //大于公会可容纳最大资金 } $union_player_contribute = $this->get_data("PlayerDailyTime")->get_player_used_time($player_id, "union_player_contribute"); if (intval($union_player_contribute) + $gold > $unionBaseConfig['max_union_contribute']) { $this->throw_error('173203'); //大于单日可以捐赠最大金币 } //加锁 if (!Com_Lock::lock('lock|union_info|donate_silver|union_id=' . $union_id)) { //系统繁忙 $this->throw_error('170501'); } $add_union_exp = 0; $update_data = array(); $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10073); if ($playerInfo['vip'] >= $vip_table['vip_level']) { $unionBaseConfig = Cache_UnionBase::getInstance()->get_union_base_info($playerInfo['vip']); $add_union_exp = $gold * $unionBaseConfig['donate_union_exp']; $arr_union_reward = array(); $arr_union_reward[] = array("type" => "union_exp", "item_id" => 9, "item_num" => $add_union_exp); $success_add_exp = $this->get_game('UnionReward')->send_reward($player_id, $arr_union_reward, array("cmd_id" => 10073)); } $retPlayer = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, 1732, array(), $arr_consume); $total_fund = $unionInfo["fund"] + $add_fund; $update_data["fund"] = "+" . $add_fund; Com_Log::debug_write('update_union_info', "donate_silver|unoin_id={$union_id}" . json_encode($update_data)); $front_amount_dedicate = $unionPlayerInfo['total_dedicate']; $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $update_data); $add_player_dedicate = intval($gold * $unionBaseConfig["donate_union_contribution"]); $ret_add_player_dedicate = $this->add_player_dedicate($player_id, $add_player_dedicate); //钻石与公会贡献比例 if ($ret_add_player_dedicate && $retPlayer && $retUnionInfo) { $this->commit(); $this->get_game('Union')->Sync_Union_msg($union_id); if ($success_add_exp) { $this->get_game('UnionReward')->add_union_reward_log(); } } else { $this->rollback(); $this->throw_error('10101'); } //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $add_player_dedicate, 'amount' => $front_amount_dedicate, 'after_amount' => $unionPlayerInfo['total_dedicate'], 'cmd_id' => 1732); Log_Common::getInstance()->add_log($log_data); $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9001, $gold); //添加日志 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $gold); $arr_replace[] = array('rep_type' => 7, 'txt' => $add_player_dedicate); $arr_replace[] = array('rep_type' => 7, 'txt' => $add_fund); $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $union_id, 173404, $arr_replace); //公会成就捐献 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 18, $gold); return array($union_id, $gold, $add_fund, $add_player_dedicate, intval($success_add_exp)); }
/** * 钻石鼓舞 * @param int $player_id 玩家id * @param int $sid 地图id * @return array */ public function inspire($player_id, $sid) { $player_id = intval($player_id); $sid = intval($sid); //$type = intval($type); if (!$sid || !$player_id) { //参数错误 $this->throw_error(10107, 6010117); } $arr_consume = $res = array(); $set = Cache_Athena::getInstance()->get_athena_inspire($sid); $pinfo = $this->get_data('Player')->get_player_info($player_id, array('gold', 'vip', 'player_id', 'level', 'ticket', 'privilege_level')); $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10083); if ($pinfo['vip'] < $vip_set['vip_level']) { $this->throw_error(6010091, 6010118); #vip等级未达到 } $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_duel_inspire_gold_count'); $max_time = $set['inspire_gold_max_times']; $cost_num = $this->get_cost_num($used_time, $set['inspire_gold_cost_num']); if ($cost_num <= 0) { //配置错误 $this->throw_error(10222, 6010119); } //先扣除彩钻 $rand_num = $set['inspire_gold_rand']; /***************/ $ticket = 0; $gold = $cost_num; if ($pinfo['ticket'] >= $cost_num) { $ticket = $cost_num; $gold = 0; } else { $ticket = $pinfo['ticket']; $gold = $cost_num - $pinfo['ticket']; } $arr_consume = array('price' => $cost_num, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); //数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', 'gold', $cost_num, 1, 1); if ($used_time < $max_time) { //还有次数 $res['res'] = 1; $result = $this->get_data('Player')->update_player_resource($player_id, $pinfo, 1239, array(), $arr_consume); if (true === $result) { $rand_id = rand(1, 100); if ($rand_id <= $rand_num) { $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'kf_duel_inspire_gold_count'); Protocol::input($player_id, 7, 4, 562, 0); //成功通知C++ $res['res'] = 1; $res['time'] = $max_time - $used_time - 1; } else { $res['res'] = 0; $res['time'] = $max_time - $used_time; } } else { $res['res'] = 0; $res['time'] = $max_time - $used_time; } } else { //次数已用完 $res['res'] = 2; $res['time'] = 0; $this->throw_error(11016, 6010005); } return $res; }
public function get_reward_by_sid($player_id, $sid, $times, $currency_types, $pinfo, $union_level, $wanted_level, $player_times = array()) { $currency_types = explode(',', $currency_types); $reward = ''; switch ($sid) { case 1: //主线副本 $exp_num = $this->get_game('PlayerFB')->main_fb_resource_retrieve($player_id, $times, 3, $pinfo, $union_level); if ($exp_num) { $reward = "1:" . ceil($exp_num); } break; case 2: //挑战副本 $send_reward = $this->get_game('PlayerPVE')->get_compensation_reward($player_id, 2, null, null, null, $pinfo); $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num'] * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 3: //vip副本 $exp_num = $this->get_game('PlayerFB')->vip_fb_resource_retrieve($player_id, $pinfo['level'], $pinfo['vip'], $times); if ($exp_num) { $reward = "1:" . ceil($exp_num); } break; case 4: //日常任务 $arr_reward = $this->get_game('TaskHandler')->get_daily_task_reward($player_id, $pinfo); if ($arr_reward) { $send_reward = $arr_reward[0]; $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num'] * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 5: //天梯 $reward_detail = $this->get_game('Challenge')->get_challenge_battle_reward($player_id, $pinfo); if ($reward_detail) { $arr_award = array(); foreach ($reward_detail as $key => $value) { if (in_array($key, $currency_types)) { $arr_award[] = $key . ':' . ceil($value * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 6: //竞技场 $send_reward = $this->get_game('KFArena')->get_back_reward($player_id, $pinfo['privilege_level'], $times); $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num']); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 7: //世界boss if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $baseinfo = $this->get_game('WorldBoss')->get_base_info_id($f_sid); #vip加成奖励 $vip_exp = 0; if ($pinfo['privilege_level'] > 0) { $left_cd = $this->get_game('VipSpecial')->get_left_time($player_id); if ($left_cd > 0) { $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($pinfo['privilege_level'], 10034); if (!empty($vip_set)) { $vip_exp = $vip_set['max_times']; } } } $rank_list = Cache_WorldBoss::getInstance()->get_rank_reward(); $rankreward = $rank_list[25]['reward_per']; $item_num = ($vip_exp / 10000 + 1) * ceil($baseinfo['dps_reward'] * $rankreward / 100); $reward = '1:' . ceil($item_num * $times); if (isset($player_times['world_boss_battle_rank']) && $player_times['world_boss_battle_rank']) { $count = count($rank_list); if ($player_times['world_boss_battle_rank'] > $count) { $rank_num = $count; } else { $rank_num = $player_times['world_boss_battle_rank']; } if ($rank_list[$rank_num - 1]['item_id'] && in_array($rank_list[$rank_num - 1]['item_id'], $currency_types) && $rank_list[$rank_num - 1]['item_reward_cnt']) { $item_num = ceil($rank_list[$rank_num - 1]['item_reward_cnt'] * 0.7) * $times; $reward = $reward . '|' . $rank_list[$rank_num - 1]['item_id'] . ':' . $item_num; } } break; case 8: //水晶争夺 if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $send_reward = $this->get_game('GrabMine')->get_grabmine_reward($player_id, $pinfo, $f_sid); $arr_award = array(); foreach ($send_reward as $value) { if (in_array($value['item_id'], $currency_types)) { $arr_award[] = $value['item_id'] . ':' . ceil($value['item_num'] * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 9: //智力问答 $reward_detail = $this->get_game('AthenaQuestion')->get_athena_question_socre_reward($player_id, $pinfo); if ($reward_detail) { $arr_award = array(); foreach ($reward_detail as $key => $value) { if (in_array($key, $currency_types)) { $arr_award[] = $key . ':' . ceil($value * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 10: //欢乐魔蛋 $rewards = $this->get_game('PlayerFB')->egg_active_resource_retrieve($player_id, $pinfo['level'], $times); if ($rewards) { $arr_award = array(); foreach ($rewards as $value) { if (in_array($value['id'], $currency_types)) { $arr_award[] = $value['id'] . ':' . ceil($value['num']); } } if ($arr_award) { $reward = implode('|', $arr_award); } } break; case 11: //守卫女神 if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $athena_set = Cache_Athena::getInstance()->get_athena_set($f_sid); $max_waves = $athena_set['max_waves']; $wave = ceil($max_waves * 0.7); $rewards = Cache_Athena::getInstance()->get_athena_reward($f_sid); if ($rewards && $wave > 0) { $reward_ids = array(); foreach ($rewards as $val) { if ($val['sid'] == $f_sid && $wave == $val['waves']) { $reward_ids = explode('|', $val['rewards']); } } if (!empty($reward_ids)) { $arr_award = array(); $vip_exp = $this->get_game('Athena')->get_vip_add_exp($player_id); foreach ($reward_ids as $v) { $temp = explode(':', $v); if (count($temp) > 1) { if (in_array($temp[0], $currency_types)) { $item_num = $temp[1] * (1 + $vip_exp); $arr_award[] = $temp[0] . ':' . ceil($item_num * $times); } } } if ($arr_award) { $reward = implode('|', $arr_award); } } } break; case 12: //神之试炼 if (!$this->_player_func) { $this->get_now_sids($player_id, $pinfo['level']); } $f_sid = $this->_player_func[$sid]; if (!$f_sid) { return $reward; } $buff = Cache_Trial::getInstance()->get_buff($f_sid, 3); $rewards = Cache_Trial::getInstance()->get_trial_reward(); $reward_string = Cache_Trial::getInstance()->get_reward($pinfo['level'], $rewards); $reward_array = explode("|", $reward_string); $arr_award = array(); foreach ($reward_array as $arr) { list($item_idx, $item_num) = explode(":", $arr); if (empty($item_num)) { continue; } if (in_array($item_idx, $currency_types)) { $arr_award[] = $item_idx . ':' . ceil($item_num * $buff * $times); } } if ($arr_award) { $reward = implode('|', $arr_award); } break; case 13: //公会通缉 $exp_num = $this->get_game('UnionWanted')->wanted_fb_resource_retrieve($pinfo['level'], $wanted_level, 3, 2, $times); if ($exp_num) { $reward = "1:" . ceil($exp_num); } break; case 14: //3v3 $id = $this->get_data('KFDuel')->get_open_sid($pinfo['level']); $reward = ''; if ($id) { $reward_conf = Cache_CrossDuel::getInstance()->get_battle_reward_conf($id, $pinfo['level']); $point = intval($reward_conf['point'] * $times / 2); $rewards = array(); $arr_reward = explode('|', $reward_conf['reward']); foreach ($arr_reward as $value) { $ar_re = explode(':', $value); if (in_array($ar_re[0], $currency_types)) { $rewards[] = $ar_re[0] . ':' . intval($ar_re[1] * $times / 2); } } $reward = implode('|', $rewards); if (in_array(16, $currency_types)) { $reward = $reward . '|16:' . $point; } } break; case 15: //8v8 $rank_conf = Cache_FlameBattle::getInstance()->get_rank_conf(11); $gold = $rank_conf['gold']; $score = $rank_conf['reward']; $rewards = array(); $reward = ''; if (in_array(3, $currency_types)) { $rewards[] = '3:' . $gold * $times; } if (in_array(17, $currency_types)) { $rewards[] = '17:' . $score * $times; } $reward = implode('|', $rewards); break; default: //pass break; } return $reward; }
public function use_temp_vip($player_id, $item_id) { $player_id = intval($player_id); $item_id = intval($item_id); $item_set = Cache_VipReward::getInstance()->get_vip_item($item_id); if (empty($item_id)) { return false; } $player_info = $this->get_data('Player')->get_player_info($player_id, array('vip', 'vip_exp', 'after_hero_hole', 'name')); if ($item_set['vip_level'] >= $player_info['vip']) { $data = array('add_time' => time() + $item_set['add_time'], 'vip_level' => $item_set['vip_level'], 'state' => 1); if ($this->get_data('VipReward')->update_temp_vip($player_id, $data)) { $update_data['vip'] = $item_set['vip_level']; $update_data['vip_temp_time'] = $data['add_time']; if ($item_set['vip_level'] > 0) { $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10057); if ($vip_table['vip_level'] > 0 && $item_set['vip_level'] >= $vip_table['vip_level']) { if ($player_info['after_hero_hole'] < 2) { #直接开启全部英雄位 $update_data['after_hero_hole'] = 2; } } } if ($this->get_data('Player')->update_player_info($player_id, $update_data)) { $param = array(array('rep_type' => 7, 'rep_val' => $item_set['vip_level']), array('rep_type' => 7, 'rep_val' => ceil($item_set['add_time'] / (24 * 3600)))); $attr_mag = array(); $attr_mag[] = Language_Message::make_message('80038', $param); $msg_out = array(0 => $attr_mag, 1 => 2000); Protocol::input($player_id, 8, 7, 742, $msg_out); Protocol_Player::p2c_part_update($player_id, array('vip' => $item_set['vip_level'], 'vip_temp_time' => $item_set['add_time'])); #广播通知 $replace_info = array(); $replace_info[] = array('rep_type' => 7, 'txt' => $player_info['name']); $replace_info[] = array('rep_type' => 7, 'txt' => $item_set['vip_level']); $this->get_game('SystemNotice')->push_sys_notice($player_id, 130, 0, $replace_info, $item_set['vip_level']); #vip增加背包格子数量 $out = $this->get_game('PlayerBag')->get_vip_bag_storage_num($player_id); Protocol::input($player_id, 8, 8, 844, $out); # 条件问卷查询推送 $this->get_game('ActivityQuestions')->get_cond_ids($player_id); #更新签到奖励 $this->get_game('DailySign')->async_trigger_daily_sign($player_id, $item_set['vip_level']); #添加日志 $log_data = array('player_id' => $player_id, 'channel' => 3, 'item_level' => $player_info['vip'], 'item_num' => $player_info['vip_exp'], 'amount' => 0, 'after_amount' => $player_info['vip_exp'], 'after_attr' => $update_data['vip']); Log_Common::getInstance()->add_log($log_data); return true; } else { $this->throw_error(10110, 2010088); return false; } return true; } else { return false; } } else { $this->throw_error(80037); } return true; }
/** * 英雄潜能升级 * @param $player_id 玩家ID * @param $hero_id 英雄ID * @param $attr_type 升级的属性(1:攻击2:生命3:防御) * @param $upgrade_type 0:单次升级1:批量升级 */ public function potential_upgrade($player_id, $hero_id, $attr_type, $upgrade_type) { $player_id = intval($player_id); $hero_id = strval($hero_id); $attr_type = intval($attr_type); $upgrade_type = intval($upgrade_type); if ($attr_type < 1 || $attr_type > 3) { $this->throw_error('10107'); //升级参数错误 } //获取英雄数据 $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'); //英雄不存在 } //是否有同类型已培养的英雄 $is_culture = $this->is_culture_hero($player_id, $hero_id, $hero_data['hero_code']); if (!$is_culture) { $this->throw_error('50117'); //已存在同类型英雄 } $upgrade_times = 1; $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'silver', 'ad_info', 'name', 'privilege_level')); if ($upgrade_type > 0) { #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10077); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10077); if ($vip_table['vip_level'] < 1 || $player_vip < $vip_table['vip_level']) { $this->throw_error('50401'); //vip等级不足 } $upgrade_times = 10; } //获取英雄潜能属性配置表 $hero_potential_base_table = $this->get_hero_potential_base_table($attr_type, $hero_data['potential_level']); if (!$hero_potential_base_table) { $this->throw_error('10109'); //配置表读取错误 } if ($hero_potential_base_table['prop_id'] && $hero_potential_base_table['prop_num']) { //获取玩家背包中的升级道具数量 $player_prop_num = $this->get_prop_num_by_player_bag($player_id, $hero_potential_base_table['prop_id']); if ($player_prop_num < $hero_potential_base_table['prop_num'] * $upgrade_times) { return array('0' => 3); //道具不足 } } //获取当前潜能等级属性最大值 $attr_max = $this->get_potential_attr_max($hero_data['potential_level'], $attr_type); $p_type = array_search($attr_type, $this->potential_type); $log_front_type_attr = $hero_data['potential_' . $p_type]; $log_front_attr = json_encode($hero_data); for ($i = 0; $i < $upgrade_times; $i++) { if ($hero_potential_base_table['coin_num']) { //金币是否足够 $is_coin_num_res = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $hero_potential_base_table['coin_num'], 0); if ($is_coin_num_res === 10113) { return array('0' => 2); //金币不足 } } //英雄潜能属性是否已满 if ($hero_data['potential_' . $p_type] >= $attr_max) { if ($upgrade_type > 0 && $i > 0) { break; } else { return array('0' => 4); //潜能属性已满 } } //潜能属性升级 $add_attr = $this->get_potential_upgrade_attr($hero_potential_base_table['prop_id'], $attr_type); $hero_data['add_attr'] += $add_attr; $hero_data['potential_' . $p_type] += $add_attr; } $deduct_prop_num = $i * $hero_potential_base_table['prop_num']; $hero_data['potential_' . $p_type] = $hero_data['potential_' . $p_type] > $attr_max ? $attr_max : $hero_data['potential_' . $p_type]; $is_upgrade_res = false; //当前提升的潜能属性满,判断是否需要升阶 if ($hero_data['potential_' . $p_type] >= $attr_max) { $is_upgrade_res = $this->is_up_potential_level($attr_type, $hero_data); if ($is_upgrade_res) { $hero_data['potential_level']++; } } $rune_data = Com_FmtData::cus_json_decode($hero_data['rune_hole_list']); //战斗力计算 $hero_data['fight'] = $this->calc_fight($hero_data['player_id'], $hero_data, $hero_data['fit'], $rune_data, $hero_data['star_add_attr_per'], $hero_data['skill_list']); //计算当前等级潜能百分比 $hero_data['potential_per'] = $this->compute_potential_per($hero_data); $this->start_trans(); if ($is_upgrade_res) { $update_field = array('potential_' . $p_type, 'fight', 'potential_level', 'potential_per'); } else { $update_field = array('potential_' . $p_type, 'fight', 'potential_per'); } //更新redis,sql数据 $update_res = $this->update_db($player_id, $update_field, $hero_data, 515); if (!$update_res) { $this->throw_error('10104'); } if ($hero_potential_base_table['prop_id'] && $deduct_prop_num) { //删除道具 $this->deduct_prop_num_by_prop_id($player_id, $hero_potential_base_table['prop_id'], $deduct_prop_num, 515, $player_info); } if ($hero_potential_base_table['coin_num']) { //扣金币 $deduct_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 515); #$deduct_res = $this->deduct_coin($player_id, $hero_potential_base_table['coin_num'], 'silver'); if (!$deduct_res) { $this->throw_error('10104'); } } //更新英雄培养数据 $this->update_hero_culture_data($player_id, $hero_id, $hero_data['hero_code']); $this->get_data('RankList')->update_hero_rank($hero_id, $hero_data['fight']); $this->commit(); $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 12, $hero_data['potential_level'], 8); #每日活跃度更新 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2201); #更新日常任务 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 112, 112, 1); #引导任务 $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 6, $i); if ($is_upgrade_res) { #公告广播 $arr_replace = array(); $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id, 'rep_color' => "ffb901"); $arr_replace[] = array('rep_type' => 3, 'rep_val' => $hero_data['hero_code'], 'rep_player_id' => $player_id, 'rep_pid' => $hero_id); $arr_replace[] = array('rep_type' => 7, 'txt' => $hero_data['potential_level'], 'rep_color' => "ffb901"); $this->get_game('SystemNotice')->push_sys_notice($player_id, 23, $hero_data['potential_level'], $arr_replace); } #更新日志 $log_data = array('player_id' => $player_id, 'channel' => 18, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'type' => 6, 'cmd_id' => 515, 'item_id' => $hero_id, 'item_name' => $hero_data['name'], 'item_quality' => $hero_data['quality'], 'item_level' => $hero_data['level'], 'front_attr' => $log_front_attr, 'after_attr' => json_encode($hero_data), 'add_time' => time()); Log_Common::getInstance()->add_log($log_data); $log_data = array('player_id' => $player_id, 'channel' => 43, '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' => 515, 'name' => $hero_data['name'], 'quality' => $hero_data['quality'], 'level' => $hero_data['level'], 'potential_level' => $hero_data['potential_level'], 'attr_type' => $attr_type, 'amount' => $log_front_type_attr, 'after_amount' => $hero_data['potential_' . $p_type], 'add_time' => time()); Log_Common::getInstance()->add_log_by_table($log_data, 'log_hero_potential'); return array('0' => 1, '1' => $attr_type, '2' => $hero_data['add_attr']); }
/** * @Purpose: * 内部获取炼金最大次数,使用次数,使用消耗 * @Param $player_id 玩家ID * @Param $player_info 玩家信息 */ public function get_exchange_coin_times_interface($player_id, $player_info) { if (empty($player_info)) { #获取玩家VIP $player_info = $this->get_data('Player')->get_player_info($player_id, array('privilege_level', 'level', 'vip')); } #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10022); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } if ($player_vip > 0) { #获取VIP配置表免费次数配置 $free_times_vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, 10022); if (!$free_times_vip_table) { $this->throw_error('10109'); #配置表读取错误 } } $max_times = $free_times_vip_table['max_times'] + $this->gold_ex_free_times; #获取VIP类型 $vip_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10023); if ($vip_type['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $player_info['privilege_level']; } else { $player_vip = $player_info['vip']; } if ($player_vip > 0) { #获取VIP配置表次数配置 $times_vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info($player_vip, 10023); if (!$times_vip_table) { $this->throw_error('10109'); #配置表读取错误 } } $max_times += $times_vip_table['max_times'] + $this->gold_ex_times_limit; #获取兑换次数信息 $exchange_data = $this->get_data('PlayerCoinExchange')->get_gold_exchange_info($player_id, 'day'); $used_times = $exchange_data['used_free_times'] + $exchange_data['used_times']; $free_times = $free_times_vip_table['max_times'] + $this->gold_ex_free_times - $exchange_data['used_free_times']; $free_times = $free_times > 0 ? $free_times : 0; $expend_gold = 0; if ($free_times < 1) { $gold_exchange = $this->get_exchange_data($exchange_data['used_times'] + 1); $expend_gold = $gold_exchange['gold_cost']; } return array('used_times' => intval($used_times), 'max_times' => intval($max_times), 'expend_gold' => intval($expend_gold)); }
/** * 把任务处理放到预处理队列 * @Param $player_id 玩家ID * @Param $vip_level VIP等级 */ public function async_trigger_update_sweep_state($player_id, $vip_level) { $vip_level = intval($vip_level); #获取VIP配置表副本限制 $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10008); if ($vip_table['vip_level'] < 1 || $vip_level < $vip_table['vip_level']) { return FALSE; } $data['player_id'] = $player_id; $data['vip_level'] = $vip_level; return Com_Queued::send('async_update_sweep_state', json_encode($data)); }
/** * 1202: 获取天梯挑战双方战斗信息 * @note 如果用$tgt_player_id[对手ID] + $mon_offset[怪物位置偏移量] + $reward_buff_offset[额外奖励buff位置偏移量]作为挑战参数,则三者的参数验证比较复杂 * @param $opponent_seq 对手列表的唯一对手序号,方便参数验证 * @return bool */ public function challenge_battle($player_id, $opponent_seq) { # 参数合法性校验 $latest_opponent_list = $this->get_data('Challenge')->get_player_latest_opponent_list($player_id); if (empty($latest_opponent_list) || empty($latest_opponent_list[$opponent_seq])) { $this->throw_error('120110'); # 天梯挑战参数不合法 } # 当天天梯剩余可用挑战次数验证 $challenge_battle_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'challenge_battle_num'); $challenge_battle_buy_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'challenge_battle_buy_num'); if (empty($challenge_battle_num)) { $challenge_battle_num = 0; } if (empty($challenge_battle_buy_num)) { $challenge_battle_buy_num = 0; } $current_challenge_avail_battle_num = $challenge_battle_buy_num * 5 + $this->challenge_battle_stint - $challenge_battle_num; if ($current_challenge_avail_battle_num <= 0) { $this->throw_error('120112'); # 天梯剩余可用挑战次数不足 } # 战前排位优先 $tgt_rank = $latest_opponent_list[$opponent_seq]['rank']; $tgt_player_id = $latest_opponent_list[$opponent_seq]['player_id']; $mon_offset = $latest_opponent_list[$opponent_seq]['mon_offset']; $reward_buff_type = $latest_opponent_list[$opponent_seq]['reward_buff_type']; $reward_buff_offset = $latest_opponent_list[$opponent_seq]['reward_buff_offset']; # NOTE: 因为怪物的sort_weight = 2 * mon_offset - 1;故而mon_offset临近的两个怪物中间一定会有一个玩家存在; # 例如mon_offset=[6,7]的怪物,其sort_weight为[11,13],则中间值sort_weight=12的一定是rank=6的实际玩家,故而向后取序号一定可以取到玩家 $dummy_player_id = $mon_offset ? $latest_opponent_list[$opponent_seq - 1]['player_id'] : 0; # 挑战怪物时,需要取怪物后一位排名玩家属性 $player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info($player_id); # 选择挑战对手时,本人的最新排名信息 if ($player_rank_info['challenge_status'] == 1 || $player_rank_info['challenge_status'] == 2) { # --------------------------------------------------------------------- # 验证对手列表是否过于陈旧(第一位) # --------------------------------------------------------------------- /** # 获取最新的天梯对手玩家列表 list($opponent_list, $opponent_player_ids, $hold_monster_info) = $this->get_opponent_list($player_rank_info); # 对对手列表添加额外奖励buff信息 $opponent_list = $this->challenge_reward_buff_handle($opponent_list, $player_id, $player_rank_info['challenge_status']); # 获取简化的对手列表 $simplified_oppo_list = $this->get_simplified_opponent_list($opponent_list); $is_diff = $this->diff_oppo_list($simplified_oppo_list, $latest_opponent_list); if (!empty($is_diff)) { $latest_challenge_list = $this->get_challenge_list($player_id); Protocol::input($this->_authuser['player_id'],3,12,1201,$latest_challenge_list); $this->throw_error('120115'); # 天梯列表过于陈旧,刷新后请重新选择对手 } **/ # --------------------------------------------------------------------- # 非怪物时,验证对手排位变化,若发生变化,则变更对手为该排位上的最新对手(第二位),由于上一步的确保,此步骤其实是多余的 # --------------------------------------------------------------------- if (empty($mon_offset)) { $tgt_player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info($tgt_player_id); if ($tgt_player_rank_info['rank'] != $tgt_rank) { $tgt_player_rank_info = $this->get_data('Challenge')->get_player_challenge_rank_info_by_rank($tgt_rank); $tgt_player_id = $tgt_player_rank_info['player_id']; #$this->throw_error('120113'); # 对手排位已改变,请更新对手列表后再挑战 } } # --------------------------------------------------------------------- # 验证对手是否已经在天梯挑战过程中(第三位) # --------------------------------------------------------------------- if (empty($mon_offset)) { if (!empty($tgt_player_rank_info['is_in_battle']) && $this->current_time < $tgt_player_rank_info['in_battle_time'] + $this->challenge_battle_vtime) { $this->throw_error('120114'); # 对手正在天梯战斗中,请稍后再战或更换对手 } } else { $monster_info = $this->get_data('Challenge')->get_challenge_monster_info($mon_offset); if (!empty($monster_info['is_in_battle']) && $this->current_time < $monster_info['in_battle_time'] + $this->challenge_battle_vtime) { $this->throw_error('120114'); # 对手正在天梯战斗中,请稍后再战或更换对手 } } } # 是否允许挑战校验,检测是否战斗CD超过规定值 $cd_acc_lock = $this->get_data('Challenge')->get_cd_acc_lock($player_id); # 获取天梯挑战CD时间累计锁状态 $remain_cd = $this->get_data('Challenge')->get_challenge_remain_cd($player_id); if (!empty($cd_acc_lock)) { # CD时间累计锁打开,不再允许CD累计 if ($remain_cd > 0) { $this->throw_error('120135'); # 天梯挑战冷却中[上次超过上限后CD尚未清零,CD累计锁尚未关闭] } } else { # CD时间累计锁关闭,允许CD累计 if ($remain_cd >= $this->challenge_battle_cd_stint) { $this->throw_error('120105'); # 天梯挑战冷却中,可花费钻石清除[CD累计值超过上限] } } # 是否允许挑战校验,检测是否在上一场战斗CD中,本人 $last_battle_log = $this->get_data('Challenge')->get_challenge_battle_log_by_player_id($player_id); if ($last_battle_log['battle_status'] == 0 && $this->current_time < $last_battle_log['reg_time'] + $this->challenge_battle_vtime) { $this->throw_error('120101'); # 天梯战斗CD中 } # 验证mon_offset是否合法 if (!empty($mon_offset)) { $monster_info = $this->get_data('Challenge')->get_challenge_monster_info($mon_offset); if (empty($monster_info)) { $this->throw_error('120109'); # 天梯挑战怪物不存在或已被击杀 } } $player_data = $this->get_player_whole_attr($player_id); $player_info = $this->get_data('Player')->get_player_info($player_id); # 连败时的战力加成处理 if ($player_info['challenge_cont_lose'] > 0) { $ability_add_info = Cache_Ladder::getInstance()->get_ability_add_info($player_info['challenge_cont_lose']); if (empty($ability_add_info)) { $this->throw_error('120106'); # 没有连胜或连败的加成配置信息 } $player_data['sum_fpower'] = $player_data['sum_fpower'] * (1 + intval($ability_add_info['ability_add'] / 100)); } if ($mon_offset) { # 玩家挑战NPC $dummy_player_data = $this->get_player_whole_attr($dummy_player_id); # 虚拟玩家属性 #Com_Log::debug_write('xgame.challenge', "$player_id challenge $tgt_player_id " . json_encode($dummy_player_data)); # 属性折扣处理 $this->battle_attr_addition_handle($player_data); SynPlayer::set_syn_data($player_data); $synPlayerData = SynPlayer::get_data(); SynPlayer::set_syn_data($dummy_player_data); $synTgtPlayerData = SynPlayer::get_data(); $data = array('ladder_id' => 0, 'role_id_0' => $player_data['player_id'], 'role_name_0' => $player_data['name'], 'career_type_0' => $player_data['career_type'], 'masks_0' => $synPlayerData['m'], 'values_0' => $synPlayerData['u'], 'role_id_1' => $dummy_player_data['player_id'], 'role_name_1' => $dummy_player_data['name'], 'career_type_1' => $dummy_player_data['career_type'], 'masks_1' => $synTgtPlayerData['m'], 'values_1' => $synTgtPlayerData['u'], 'monster_npc_sid' => $tgt_player_id, 'extra_buff_id0' => 0, 'extra_buff_id1' => 0); } else { # 玩家挑战玩家 $tgt_player_data = $this->get_player_whole_attr($tgt_player_id); #Com_Log::debug_write('xgame.challenge', "$player_id challenge $tgt_player_id " . json_encode($tgt_player_data)); #Com_Log::debug_write('xgame.challenge', "$player_id challenge $tgt_player_id skill_infos_tgt " . json_encode($tgt_player_data['skill_infos'])); # 属性折扣处理 $this->battle_attr_discount_handle($player_data, $tgt_player_data); SynPlayer::set_syn_data($player_data); $synPlayerData = SynPlayer::get_data(); SynPlayer::set_syn_data($tgt_player_data); $synTgtPlayerData = SynPlayer::get_data(); $data = array('ladder_id' => 0, 'role_id_0' => $player_data['player_id'], 'role_name_0' => $player_data['name'], 'career_type_0' => $player_data['career_type'], 'masks_0' => $synPlayerData['m'], 'values_0' => $synPlayerData['u'], 'role_id_1' => $tgt_player_data['player_id'], 'role_name_1' => $tgt_player_data['name'], 'career_type_1' => $tgt_player_data['career_type'], 'masks_1' => $synTgtPlayerData['m'], 'values_1' => $synTgtPlayerData['u'], 'monster_npc_sid' => 0, 'extra_buff_id0' => 0, 'extra_buff_id1' => 0); } # 获取挑战额外加成BUFF可用加成次数 $second_last_login_time = !empty($player_info['second_last_login_time']) ? $player_info['second_last_login_time'] : $player_info['login_time']; $extra_buff_avail_num = $this->get_challenge_battle_extra_buff_avail_num($player_id, $second_last_login_time); # 赋值额外加成buff并消耗1次使用次数 if ($extra_buff_avail_num > 0) { $data['extra_buff_id0'] = $this->extra_buff_id_self; $extra_buff_avail_num -= 1; $extra_buff_avail_num = max($extra_buff_avail_num, $this->extra_buff_avail_num_stint); $re = $this->get_data('Challenge')->set_player_extra_buff_avail_num($player_id, $extra_buff_avail_num); $this->write_check($re, 3010491); } # 第一次天梯挑战则加一个额外buff if (empty($player_rank_info['in_battle_time'])) { $data['extra_buff_id0'] = $this->extra_buff_id_self; $data['extra_buff_id1'] = $this->extra_buff_id_opponent; } # 获取唯一的战斗序列号 $battle_seq = $this->get_data('Challenge')->get_new_challenge_battle_seq($player_id); $data['ladder_id'] = $battle_seq; $this->start_trans(); # 增加天梯挑战cd时间,只有当vip等级小于某个值时才有挑战CD $vip_limit_type = Cache_VipLevelLimit::getInstance()->get_limit_info_func_id(10013); $vip_limit_info = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10013); if (!empty($vip_limit_type) && !empty($vip_limit_info)) { # 有vip限制 if ($vip_limit_type['fun_type'] == 1) { # vip限制 if ($player_info['vip'] < $vip_limit_info['vip_level']) { $re = $this->get_data('Challenge')->add_challenge_battle_cd($player_id, $this->challenge_battle_cd_time); $this->write_check($re, 3010512); } } elseif ($vip_limit_type['fun_type'] == 2) { # 特权限制 $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); if ($player_info['privilege_level'] < $vip_limit_info['vip_level'] || $left_time == 0) { $re = $this->get_data('Challenge')->add_challenge_battle_cd($player_id, $this->challenge_battle_cd_time); $this->write_check($re, 3010512); } } } else { # 无vip限制 $re = $this->get_data('Challenge')->add_challenge_battle_cd($player_id, $this->challenge_battle_cd_time); $this->write_check($re, 3010516); } # 更新天梯挑战次数 $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'challenge_battle_num', 1); $this->write_check($re, 3010521); # 记录挑战日志,注意要以两种方式记录,以battle_seq为key和以player_id为key两种,后面那种允许覆盖,仅记录玩家最后一次挑战信息 $battle_log = array('battle_seq' => $battle_seq, 'player_id' => $player_id, 'tgt_player_id' => $tgt_player_id, 'battle_status' => 0, 'reg_time' => $this->current_time, 'mon_offset' => $mon_offset, 'battle_result' => 0, 'reward_buff_type' => $reward_buff_type, 'reward_buff_offset' => $reward_buff_offset); $re = $this->get_data('Challenge')->update_challenge_battle_log($battle_log); $this->write_check($re, 3010536); # 更新战斗状态 if ($player_rank_info['challenge_status'] == 1 || $player_rank_info['challenge_status'] == 2) { # 真实天梯对手才需要更新 $player_rank_info['is_in_battle'] = 1; $player_rank_info['in_battle_time'] = $this->current_time; $re = $this->get_data('Challenge')->update_challenge_rank_info($player_rank_info); $this->write_check($re, 3010543); if (empty($mon_offset)) { $tgt_player_rank_info['is_in_battle'] = 1; $tgt_player_rank_info['in_battle_time'] = $this->current_time; $re = $this->get_data('Challenge')->update_challenge_rank_info($tgt_player_rank_info); $this->write_check($re, 3010548); } else { $monster_info['is_in_battle'] = 1; $monster_info['in_battle_time'] = $this->current_time; $re = $this->get_data('Challenge')->update_challenge_monster_info($monster_info); $this->write_check($re, 3010553); } } $this->commit(); //找回资源埋点 $this->get_game('GetBackCurrency')->add_function_day_times($player_id, 5); # 蛋疼的次数同步埋点 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040); # 推送C++战斗双方属性信息 Protocol::input($player_id, 7, 4, 428, $data); # 每日活跃任务埋点 $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 3002, 1, 1); # 记录行为 unset($data['masks_0'], $data['values_0'], $data['masks_1'], $data['values_1']); $data_json = json_encode($data); Com_Log::write('xgame.challenge', "{$player_id}\t" . "challenge_battle\t" . "{$data_json}\t"); $out = array('result' => 1); return $out; }
public function strenglen_action($player_id, $id) { $player_id = intval($player_id); $id = intval($id); $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'name', 'silver', 'ticket', 'gold', 'player_id', 'level', 'vip', 'fame', 'privilege_level')); $level_info = $this->get_union_by_id($id); if ($player_info['union_id'] == 0) { $this->throw_error(171101); } if (empty($level_info)) { $this->throw_error('10222', 2010069); } if ($level_info['type_id'] == 2) { $vip_limit = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10040); if (!empty($vip_limit)) { if ($player_info['vip'] < $vip_limit['vip_level']) { $this->throw_error('11089'); } } } elseif ($level_info['type_id'] == 3) { $vip_limit = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10041); if (!empty($vip_limit)) { if ($player_info['vip'] < $vip_limit['vip_level']) { $this->throw_error('11089'); } } } #判断消耗 $res = array(); $res['res'] = 1; #1强化成功 2金币不足 3次数用完 $old = 0; $arr_consume = array(); if ($level_info['cost_type'] == 3) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', abs($level_info['cost_num'])); } elseif ($level_info['cost_type'] == 2 || $level_info['cost_type'] == 20) { #先扣除彩钻 $cost = abs($level_info['cost_num']); $ticket = 0; $gold = $cost; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] >= $cost) { $ticket = $cost; $gold = 0; } else { $ticket = $player_info['ticket']; $gold = $cost - $player_info['ticket']; } } $arr_consume = array('price' => $cost, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost, 1, 1); } else { $this->throw_error('10222', 2010070); } #判断今日次数 $union_conf = Cache_UnionBase::getInstance()->get_union_conf(); if (empty($union_conf)) { $this->throw_error(10222, 2010071); } else { if (isset($union_conf['max_bomb_time'])) { $used = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_bomb_count'); if ($used >= $union_conf['max_bomb_time']) { $this->throw_error(174401); } } else { $this->throw_error(10222, 2010072); } } $res['res'] = 1; $union_info = $this->get_data('UnionInfo')->get_union_info($player_info['union_id']); $res['bomb_exp'] = isset($union_info['bomb_exp']) ? $union_info['bomb_exp'] : 0; $res['max_exp'] = $level_info['max_exp']; $res['bomb_level'] = $level_info['level']; if ($res['res'] == 1) { #扣消耗 #$this->start_trans(); $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1723, array(), $arr_consume); if (false !== $result) { #保存记录 $this->save_strength_log($player_info['union_id'], $player_id, $player_info['name'], $level_info); #福利大厅任务接口 if ($level_info['type_id'] == 3) { $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9040_2'); } $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9040_1'); $update = array(); $update['fund'] = (isset($union_info['fund']) ? $union_info['fund'] : 0) + $level_info['union_fund']; $update['bomb_exp'] = (isset($union_info['bomb_exp']) ? $union_info['bomb_exp'] : 0) + $level_info['bomb_exp']; $update['bomb_up_exp'] = (isset($union_info['bomb_up_exp']) ? $union_info['bomb_up_exp'] : 0) + $level_info['bomb_exp']; $update['bomb_level'] = isset($union_info['bomb_level']) ? $union_info['bomb_level'] : 1; #判断是否升级 $up = false; if ($update['bomb_up_exp'] >= $level_info['max_exp']) { $nowLvl = isset($union_info['bomb_level']) ? $union_info['bomb_level'] : 1; if ($union_info['union_level'] > $nowLvl) { $update['bomb_level'] = $nowLvl + 1; $update['bomb_up_exp'] -= $level_info['max_exp']; $level_info['max_exp'] = $this->get_max_exp($update['bomb_level']); $up = true; } else { $update['bomb_up_exp'] = $level_info['max_exp']; $update['bomb_level'] = $nowLvl; } } if ($up) { //添加日志 $arr_replace = array(); $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $player_info['union_id'], 173902, $arr_replace); $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 23, $update['bomb_level'], 2); } //添加日志 $arr_replace = array(); $type_name = ''; if ($level_info['type_id'] == 1) { $type_name = '初级强化'; } elseif ($level_info['type_id'] == 2) { $type_name = '中级强化'; } elseif ($level_info['type_id'] == 3) { $type_name = '高级强化'; $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 16, 1, 1); } $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id); $arr_replace[] = array('rep_type' => 7, 'rep_val' => $type_name); #强化类型 $arr_replace[] = array('rep_type' => 7, 'rep_val' => $level_info['player_dedicate']); #公会贡献 $arr_replace[] = array('rep_type' => 7, 'rep_val' => $level_info['union_fund']); #公会资金 $objUnionBaseGame = $this->get_game('UnionBase'); $objUnionBaseGame->sys_add_union_log($player_id, $player_info['union_id'], 173901, $arr_replace); #贡献玩家贡献-声望 $this->get_game('Reward')->send_reward($player_id, array(array('type' => Cache_FbLoot::getInstance()->get_item_key(14), 'item_id' => 14, 'item_num' => $level_info['fame'])), array('cmd_id' => '1723')); $myinfo = $this->get_data("UnionPlayer")->get_union_player_info($player_info['union_id'], $player_id); $myold = isset($myinfo['total_dedicate']) ? $myinfo['total_dedicate'] : 0; $myinfo['total_dedicate'] = $myold + $level_info['player_dedicate']; $this->get_game("UnionPlayer")->add_player_dedicate($player_id, $level_info['player_dedicate']); $this->get_data("UnionInfo")->update_union_info($player_info['union_id'], $update); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'union_bomb_count'); $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $used + 1, $union_conf['max_bomb_time'], 3, 3); $res['bomb_exp'] = $update['bomb_up_exp']; $res['max_exp'] = $level_info['max_exp']; $res['bomb_level'] = $update['bomb_level']; $res['id'] = $id; $res['total_dedicate'] = $myold + $level_info['player_dedicate']; $res['fund'] = $update['fund']; $res['fame'] = $player_info['fame'] + $level_info['fame']; #变形金刚让加一个声望字段 $this->get_game('Reward')->add_reward_log(); #$this->commit(); #任务埋点 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 12, 1, 1); //公会贡献-流水日志 $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $level_info['player_dedicate'], 'amount' => $myold, 'after_amount' => $myinfo['total_dedicate'], 'cmd_id' => 1723); Log_Common::getInstance()->add_log($log_data); $this->get_game('Union')->Sync_Union_msg($player_info['union_id']); } else { #$this->rollback(); $this->throw_error('10110', 2010073); } } return $res; }
public function athena_replace($player_id, $sid, $type) { $player_id = intval($player_id); $res = array(); $res['res'] = 1; $set = Cache_Athena::getInstance()->get_athena_set($sid); $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'athena_resume_count'); if ($used_time > 0) { $this->throw_error(11001); #次数已用完 } if (empty($set)) { $this->throw_error(10222, 2010018); } $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10021); if (empty($vip_set) || $set['athena_resume_cost_num'] < 0) { $this->throw_error(10222, 2010019); } $p_info = $this->get_data('Player')->get_player_info($player_id, array('gold', 'silver', 'vip', 'level', 'player_id', 'ticket', 'privilege_level')); #判断vip级别 if (intval($p_info['vip']) >= $vip_set['vip_level'] || $vip_set['vip_level'] <= $p_info['privilege_level']) { if ($set['athena_resume_cost_type'] == 1) { $this->get_data('Player')->check_player_resource($player_id, $p_info, '-', 'silver', $set['athena_resume_cost_num']); } $arr_consume = array(); if ($set['athena_resume_cost_type'] == 2 || $set['athena_resume_cost_type'] == 20) { /***************/ $ticket = 0; $gold = $set['athena_resume_cost_num']; if ($p_info['ticket'] > 0) { if ($p_info['ticket'] >= $set['athena_resume_cost_num']) { $ticket = $set['athena_resume_cost_num']; $gold = 0; } else { $ticket = $p_info['ticket']; $gold = $set['athena_resume_cost_num'] - $p_info['ticket']; } } $arr_consume = array('price' => $set['athena_resume_cost_num'], 'gold' => $gold, 'ticket' => $ticket, 'count' => 1); #数据中心推送 /**************/ $this->get_data('Player')->check_player_resource($player_id, $p_info, '-', 'gold', $set['athena_resume_cost_num'], 1, 1); } $result = $this->get_data('Player')->update_player_resource($player_id, $p_info, 1109, array(), $arr_consume); if (true === $result) { Protocol::input($player_id, 7, 4, 450, 1); $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'athena_resume_count'); $res['res'] = 1; $res['type'] = $type; $res['left'] = 0; } else { $this->throw_error(10110, 2010020); } } else { $this->throw_error(11002); #vip等级不够 } return $res; }
/** * 检查是否满足创建公会 * @param unknown $player_id * @param unknown $name * @param unknown $introduce * @return string */ protected function check_create_union($player_id, $name, $introduce, &$playerInfo, &$unionCreatConfig, &$arr_consume = array()) { //已有公会 if ($playerInfo['union_id']) { $this->throw_error('170101'); } //level等级不足 if ($playerInfo['level'] < $unionCreatConfig['level_need']) { $this->throw_error('170105'); } $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10027); if ($vip_table['fun_type'] == 1) { $player_vip = $playerInfo['vip']; } elseif ($vip_table['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $playerInfo['privilege_level']; } #获取VIP配置表限制 $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10027); if ($vip_table['vip_level'] < 1 || $player_vip < $vip_table['vip_level']) { $this->throw_error('170106'); //vip等级不足 } $field = Cache_FbLoot::getInstance()->get_item_key($unionCreatConfig['cost_type']); #先扣除彩钻 $ticket = 0; $price = $unionCreatConfig['cost_num']; if ($field == "gold") { if ($playerInfo['ticket'] > 0) { if ($playerInfo['ticket'] >= $unionCreatConfig['cost_num']) { $ticket = $unionCreatConfig['cost_num']; $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $unionCreatConfig['cost_num']); $unionCreatConfig['cost_num'] = 0; } else { $ticket = $playerInfo['ticket']; $unionCreatConfig['cost_num'] = $unionCreatConfig['cost_num'] - $playerInfo['ticket']; $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $playerInfo['ticket']); } } $arr_consume = array('price' => $price, 'gold' => $unionCreatConfig['cost_num'], 'ticket' => $ticket, 'count' => 1); #数据中心推送 } $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', $field, $unionCreatConfig['cost_num']); //公会名称 $name = trim($name); if (!$name) { //公会名称不能为空 $this->throw_error('170102'); } $nameCheck = Com_Filter::check_str($name, 3, 12); if ($nameCheck == -1) { //长度不符法 $this->throw_error('170104'); } else { if ($nameCheck < 0) { //名称不合法 $this->throw_error('170103'); } else { if (is_numeric($name)) { //名称不为纯数字 $this->throw_error('170111'); } else { if (!Com_Filter::check_badWord($name)) { ///名称不合法 $this->throw_error('170103'); } } } } //宣言 $this->check_introduce($introduce); //公会名称唯一 $info = $this->get_data('UnionInfo')->get_union_name($name); if (!empty($info)) { $this->throw_error('170107'); } }
/** * 获取离线奖励 * @param int player_id 玩家id * @param int type 领取类型 1,基本;2,两倍;3,三倍 */ public function get_reward($player_id, $type) { $player_id = intval($player_id); if (!in_array($type, array(1, 2, 3))) { //参数错误 $this->throw_error(10107, 6010018); } $pinfo = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'last_offline_time', 'offline_reward_status'))); if (2 == $pinfo['offline_reward_status']) { //已领取 $this->throw_error(6010019); } if (!$pinfo['last_offline_time'] || 0 == $pinfo['offline_reward_status']) { //不可领 $this->throw_error(6010020); } if ($pinfo['last_offline_time'] < $this->_reward_min_time) { $this->throw_error(6010020, 6010021); } $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($pinfo['vip'], 10050); $vip_time = 1; if (!empty($vip_set)) { $vip_time = $vip_set['max_times']; } if (2 == $type && $vip_time < 2) { $this->throw_error(6010020); } if (3 == $type && $vip_time < 3) { $this->throw_error(6010020); } $offline_time = min($this->_reward_max_time, $pinfo['last_offline_time']); $ret = $this->get_exp($pinfo['level'], $offline_time); $exp = $ret['exp']; $cost = $ret['cost']; if (!$cost) { $this->throw_error(10222, 6010095); } $silver = $this->get_silver($offline_time); $reward[] = array('type' => Cache_Currency::getInstance()->get_key(1), 'item_id' => 1, 'item_num' => $exp * $type); $reward[] = array('type' => Cache_Currency::getInstance()->get_key(3), 'item_id' => 3, 'item_num' => $silver * $type); $this->start_trans(); if (3 == $type) { $item_id = 20; $item_num = $cost; $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id); $arr_consume = Com_Util::get_consume_info_for_data_center($pinfo, $item_key, $item_num, 1, $item_id); $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', $item_key, $item_num, 1, $item_id); $re = $this->get_data('Player')->update_player_resource($player_id, $pinfo, '2014', array(), $arr_consume); $this->write_check($re, 6010023); } $this->get_data('Player')->update_player_info($player_id, array('offline_reward_status' => 2)); //更新状态 $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2014', 'bind_flag' => 0)); $this->write_check_strict($re, 6010024); $this->commit(); $this->get_game('Reward')->add_reward_log(true); //修改数字 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130); return array('res' => 1, 'reward_list' => $reward); }