Example #1
0
 /**
  * 购买特惠礼包
  * @param int player_id 玩家id
  * @param int gid 礼包id
  * @return array
  */
 public function gift_package_buy($player_id, $gid)
 {
     $player_id = intval($player_id);
     $gid = intval($gid);
     if (!$gid) {
         $this->throw_error(10107, 6010077);
     }
     //获取奖励配置
     if (!($set_gift_package = Cache_NewServerActivity::getInstance()->get_gift_package($gid))) {
         $this->throw_error(6010045, 6010052);
     }
     //是否已买过
     $activity_player = $this->get_data('NewServerActivity')->get_player_info($player_id, array('gift_info'));
     if (isset($activity_player['gift_info']) && is_array($activity_player['gift_info']) && in_array($gid, $activity_player['gift_info'])) {
         $this->throw_error(6010053);
     }
     if (!is_array($activity_player['gift_info'])) {
         $activity_player['gift_info'] = array();
     }
     $activity_player['gift_info'][] = $gid;
     $pinfo = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'career_type')));
     $costs = explode(':', $set_gift_package['price']);
     $item_id = $costs[0];
     $cost_num = $costs[1];
     $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id);
     $career_type = $pinfo['career_type'];
     $reward = array();
     $rewards = explode('|', $set_gift_package['item_info']);
     foreach ($rewards as $value) {
         $tmp = explode(':', $value);
         if (count($tmp) > 1) {
             if ($career_type && isset($tmp[2]) && $tmp[2] && $career_type != $tmp[2]) {
                 continue;
             }
             $reward[] = array('type' => Cache_Currency::getInstance()->get_key($tmp[0]), 'item_id' => $tmp[0], 'item_num' => $tmp[1]);
         } else {
             $this->throw_error(10222, 6010054);
         }
     }
     $up_arr = array('player_id' => $player_id, 'gift_info' => $activity_player['gift_info']);
     $arr_consume = Com_Util::get_consume_info_for_data_center($pinfo, $item_key, $cost_num, 1, $item_id);
     $this->get_data('Player')->check_player_resource($player_id, $pinfo, '-', $item_key, $cost_num, 1, $item_id);
     $this->start_trans();
     $re = $this->get_data('Player')->update_player_resource($player_id, $pinfo, 2313, array(), $arr_consume);
     $this->write_check($re, 6010055);
     $re = $this->get_data('NewServerActivity')->update_player_info($player_id, $up_arr);
     $this->write_check($re, 6010056);
     $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2313, 'bind_flag' => 0));
     $this->write_check_strict($re, 6010057);
     $this->commit();
     $this->get_game('Reward')->add_reward_log(true);
     $data = $this->get_gift_package_panel($player_id);
     Protocol::input($player_id, 8, 23, 2312, $data);
     return array('res' => 1);
 }
Example #2
0
 public function enhanced_refine($player_id, $player_prop_id, $refine_attr_seq, $add_success_rate)
 {
     #$this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_enhanced_refine);
     $this->param_check_numeric(array($player_id, $refine_attr_seq));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (!$player_equip_info) {
         $this->throw_error('80013');
         # 玩家没有该装备!
     }
     if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) {
         $this->throw_error('81105');
         # 首充装备不允许精练
     }
     $out_850 = array('player_prop_id' => $player_prop_id, 'result' => 0);
     # 洗练属性检查
     if (empty($player_equip_info['refine_info'])) {
         $this->throw_error('81008');
         # 洗练属性为空,不能精炼
     }
     # 获取洗练属性key
     /**
     		foreach ($player_equip_info['refine_info']['attr_info'] as $attr_seq => $attr_info) {
     			if ($attr_info['attr_seq'] == $refine_attr_seq) {
     				$en_refine_attr_key = $attr_info['attr_key'];
     				break;
     			}
     		}
     		**/
     if (!isset($player_equip_info['refine_info']['attr_info'][$refine_attr_seq])) {
         $this->throw_error('81009');
         # 精炼属性异常,选择的精炼属性不存在
     }
     $refine_info = $player_equip_info['refine_info'];
     $refine_attr = $player_equip_info['refine_attr'];
     $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']);
     if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] >= $player_equip_info['level'] && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) {
         $this->throw_error('81010');
         # 精炼属性已满
     }
     # 计算成功率 + 货币消耗
     $refine_info_mod = $this->get_en_refine_success_rate_and_cost_currency($refine_info);
     list($cost_currency_type, $cost_currency_value) = explode(":", $refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_cost_currency']);
     if ($add_success_rate) {
         $refine_info_mod['en_refine_success_rate'] += $this->add_success_rate;
     }
     $before_refine_attr = isset($player_equip_info['refine_attr']) ? $player_equip_info['refine_attr'] : array();
     $before_refine_info = isset($player_equip_info['refine_info']) ? $player_equip_info['refine_info'] : array();
     # 更新洗练属性 + 消耗货币
     $this->start_trans();
     $success_flag = false;
     if (Com_Random::probability($refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_success_rate'], 10000)) {
         if ($refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']) {
             $delta = ceil($refine_info_mod['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']);
         } else {
             $delta = 0;
         }
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] += $delta;
         if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] > $refine_info['attr_info'][$refine_attr_seq]['attr_stint']) {
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['attr_stint'];
         }
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] += 1;
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] = 0;
         $refine_info['attr_info'][$refine_attr_seq]['attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['refine_attr_value'] + $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'];
         # 升级
         $en_refine_lv_stint = $this->get_en_refine_lv_stint($player_equip_info['level']);
         $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']);
         if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] < $en_refine_lv_stint && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) {
             # 获取精练属性基础值
             $attr_value_info_en_refine_old = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] += $this->en_refine_lv_delta;
             $attr_value_info_en_refine = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             if (empty($attr_value_info_en_refine)) {
                 $this->throw_error('81011');
                 # 获取洗练属性值配置失败
             }
             $attr_key = $refine_info['attr_info'][$refine_attr_seq]['attr_key'];
             $attr_ratio = $refine_info['attr_info'][$refine_attr_seq]['attr_ratio'];
             $refine_info['attr_info'][$refine_attr_seq]['attr_limit'] = ceil(($attr_value_info_en_refine[$attr_key] - $attr_value_info_en_refine_old[$attr_key]) * ($attr_ratio / 10000));
             $en_refine_conf = Cache_Refine::getInstance()->get_equip_enhanced_refine_base_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             $refine_info['attr_info'][$refine_attr_seq]['attr_section'] = $en_refine_conf['section'];
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] = 0;
         }
         $refine_attr[$refine_attr_seq] = array($refine_info['attr_info'][$refine_attr_seq]['attr_key'] => $refine_info['attr_info'][$refine_attr_seq]['attr_value']);
         $out_850['result'] = 1;
         $success_flag = true;
     } else {
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] += 1;
         # 连续失败精炼次数
     }
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     if ($add_success_rate) {
         $cost_currency_key_other = Cache_Currency::getInstance()->get_key($this->add_success_rate_cost_cur_type);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key_other, $this->add_success_rate_cost_cur_value, 1, 0);
     }
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '850');
     $this->write_check($re, 3010132);
     $update_field = array('refine_attr' => $refine_attr, 'refine_info' => $refine_info);
     $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $update_field);
     $this->write_check($re, 3010414);
     $this->commit();
     # 提示购买成功消息
     if ($success_flag) {
         $message = array('texts' => array(array('code' => 81014, 'content' => array(), 'params' => array(array(array('txt' => '', 'type' => 6, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_key'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_value'] - $before_refine_info['attr_info'][$refine_attr_seq]['attr_value'], 'param' => ''))))), 'delay' => 0);
     } else {
         $message = array('texts' => array(array('code' => 81015, 'content' => array(), 'params' => array())), 'delay' => 0);
     }
     Protocol::input($player_id, 3, 7, 742, $message);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_id, 'item_id_master' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'item_position' => $player_equip_info['item_position'], 'action_type' => 2, 'before_refine_attr' => $before_refine_attr, 'after_refine_attr' => $player_equip_info['refine_attr'], 'before_refine_info' => $before_refine_info, 'after_refine_info' => $player_equip_info['refine_info']);
     Log_Forge::getInstance()->add_log($log_info, 'refine');
     # 刷新玩家属性
     if ($player_equip_info['item_position'] == 3) {
         $this->get_game('EquipAttr')->equip_attr($player_id);
     }
     # 粘806 + 通知道具变更信息
     $player_equip_info['refine_attr'] = $update_field['refine_attr'];
     $player_equip_info['refine_info'] = $update_field['refine_info'];
     $ndata = array($player_equip_info);
     Protocol_Prop::prop_806($player_id, $ndata);
     $out_849 = $this->get_enhanced_refine_info($player_id, $player_prop_id, $refine_attr_seq);
     Protocol::input($player_id, 3, 8, 849, $out_849);
     return $out_850;
 }
Example #3
0
 public function get_event_reward($player_id, $event_id, $reward_id, $event_template)
 {
     $this->param_check_numeric(array($player_id, $event_id, $reward_id));
     # 加锁失败
     if (!Com_Lock::lock("lock|get_event_reward|player_id={$player_id}")) {
         $this->throw_error('170501');
         # 系统繁忙
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level', 'map_id')));
     if ($player_info['map_id'] == 2100) {
         $this->throw_error('12012');
         # 请在完成序章后领取
     }
     # 获取活动配置
     $event_info = $this->get_data('Event')->get_event_info($event_id);
     if (empty($event_info) || empty($event_info['event_reward_info'])) {
         $this->throw_error('12004');
         # 无效的活动,未找到活动配置信息
     }
     $reward_id_array = explode(':', $event_info['event_reward_info']);
     if (!in_array($reward_id, $reward_id_array)) {
         $this->throw_error('12006');
         # 无效的奖励,未找到活动奖励配置信息
     }
     # NOTE: 因为允许在活动结束后领奖,所以领奖时不用活动开启时间段[open_date_head,open_date_tail]做检测
     if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) {
         $this->throw_error('12005');
         # 未到或已超过活动奖励领取时间
     }
     # 获取奖励配置
     $reward_info = $this->get_data('Event')->get_reward_info($reward_id);
     if (empty($reward_info) || empty($reward_info['cond_func'])) {
         $this->throw_error('12006');
         # 无效的奖励,未找到活动奖励配置信息
     }
     if (!empty($reward_info['valid_date_head']) || !empty($reward_info['valid_date_tail'])) {
         if ($reward_info['valid_date_head'] > $this->current_time || $reward_info['valid_date_tail'] < $this->current_time) {
             $this->throw_error('12007');
             # 未到或已超过活动奖励有效时间
         }
     }
     /**
     		# --------------------------------------------------------------------
     		# 活动领奖周期内的领奖次数上限判断
     		# --------------------------------------------------------------------
     		if (!empty($event_info['event_reward_stint']) && !empty($event_info['event_reward_cycle'])) {
     			# 向上取整获取最大领奖期数
     			$max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $event_info['event_reward_cycle']);
     			for($i = 1; $i <= $max_cycle; $i++) {
     				$cycle_head = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * ($i - 1); 	# 领奖周期首部时间
     				$cycle_tail = $event_info['reward_date_head'] + $event_info['event_reward_cycle'] * $i - 1;		# 领奖周期尾部时间,减一是为了相邻两个区间没有交集
     				if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内
     					continue; 
     				} else {
     					# 获取该周期内的领奖次数
     					list($reward_record, $reward_record_count) = $this->get_data('Event')->get_event_reward_record_part($player_id, $event_id, $cycle_head, $cycle_tail);
     					if ($reward_record_count >= $event_info['event_reward_stint']) {
     						$this->throw_error('12008'); # 已达到活动领奖周期内的领取次数上限
     					}
     					break;
     				}
     			}
     		}
     
     		# --------------------------------------------------------------------
     		# 奖励领奖周期内的领奖次数上限判断,NOTO:没有考虑循环奖励的领取上限不仅由reward_gain_stint决定,还由循环达成数loop_num决定
     		# --------------------------------------------------------------------
     		if (!empty($reward_info['reward_gain_stint']) && !empty($reward_info['reward_gain_cycle'])) {
     			# 向上取整获取最大领奖期数
     			$max_cycle = ceil(($event_info['reward_date_tail'] - $event_info['reward_date_head']) / $reward_info['reward_gain_cycle']);
     			for($i = 1; $i <= $max_cycle; $i++) {
     				$cycle_head = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * ($i - 1); 	# 领奖周期首部时间
     				$cycle_tail = $event_info['reward_date_head'] + $reward_info['reward_gain_cycle'] * $i - 1;		# 领奖周期尾部时间,减一是为了相邻两个区间没有交集
     				if ($this->current_time < $cycle_head || $this->current_time > $cycle_tail) { # 当前时间不在该领奖周期内
     					continue; 
     				} else {
     					# 获取该周期内的领奖次数
     					list($reward_record, $reward_record_count) = $this->get_data('Event')->exactly_get_event_reward_record_part($player_id, $event_id, $reward_id, $cycle_head, $cycle_tail);
     					if ($reward_record_count >= $reward_info['reward_gain_stint']) {
     						$this->throw_error('12009'); # 已达到奖励领奖周期内的领取次数上限
     					}
     					break;
     				}
     			}
     		}
     		**/
     # 进度计算
     $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']);
     $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params);
     # 剩余领奖次数计算
     list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward_info, $ret);
     if (empty($real_remain_gain_num)) {
         $this->throw_error('12009');
         # 已达到奖励领奖周期内的领取次数上限
     }
     # --------------------------------------------------------------------
     # 奖励达成条件判断
     # --------------------------------------------------------------------
     # 进度计算
     $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward_info['reward_id'], 'reward_type' => $reward_info['reward_type'], 'reward_billing_cycle' => $reward_info['reward_billing_cycle']);
     $ret = $this->call_cond_func($player_id, $reward_info['cond_func'], $reward_info['cond_func_relation'], $sys_params);
     if (empty($ret['status'])) {
         $this->throw_error('12010');
         # 未达到奖励的领取条件
     }
     # --------------------------------------------------------------------
     # 发奖 + 消耗道具 + 并刷新奖励信息
     # --------------------------------------------------------------------
     $this->start_trans();
     # 消耗道具
     if (!empty($reward_info['consume_info'])) {
         $consume_currency = false;
         $arr_logs_consume = array();
         $reward_item_info_arr = explode("|", $reward_info['consume_info']);
         $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2304);
         foreach ($reward_item_info_arr as $item_info) {
             list($item_id, $item_num) = explode(":", $item_info);
             $item_key = Cache_PropLoot::getInstance()->get_item_key($item_id);
             if ($item_key == 'prop') {
                 # 消耗道具
                 # deduct_prop_by_prop_id方法中有判断道具是否足够,故外层不判断
                 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $item_id, $item_num, $arr_logs_consume, 0, $log_param);
                 $this->write_check($re, 3010311);
             } else {
                 # 消耗资源
                 $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $item_key, $item_num);
                 $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $item_key, $item_num, 1, $item_id);
                 $consume_currency = true;
             }
         }
         if ($consume_currency) {
             $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2304', array(), $arr_consume);
             $this->write_check($re, 3010332);
         }
     }
     # 奖励道具
     $reward = array();
     $reward_detail = array();
     if (!empty($reward_info['reward_info'])) {
         $reward_item_info_arr = explode("|", $reward_info['reward_info']);
         foreach ($reward_item_info_arr as $item_info) {
             list($item_id, $item_num, $item_tag) = explode(":", $item_info);
             $reward_detail[$item_id] = $item_num;
         }
     }
     $this->get_game('Reward')->gen_reward_array($reward_detail, $reward);
     $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2304', 'bind_flag' => 0));
     $this->write_check_strict($re, 3010347);
     # 记录奖励领取日志
     $re = $this->get_data('Event')->record_player_event_reward($player_id, $event_id, $reward_id, $this->current_time);
     $this->write_check($re, 3010351);
     $this->commit();
     # 蛋疼的次数同步埋点
     if ($event_template == 2) {
         # 充值回馈需要同步次数变更
         $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1260);
     }
     # 粘806 + 通知道具变更信息
     $ndata = array();
     if (!empty($arr_logs_consume)) {
         foreach ($arr_logs_consume as $k => $v) {
             # 消耗的道具
             $ndata[] = $v;
         }
         Protocol_Prop::prop_806($player_id, $ndata);
     }
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $ret = $this->get_game('Reward')->add_reward_log(true);
     #-----------------------------------------------------------------
     # 重新获取奖励项列表
     #-----------------------------------------------------------------
     $event_reward_list = array();
     $special_reward_list = array();
     if (!empty($event_info['event_reward_info'])) {
         $reward_id_array = explode(':', $event_info['event_reward_info']);
         #echo "</br>===============".$event_info['event_id']."==================</br>";
         #var_export($reward_id_array);
         $reward_info = $this->get_data('Event')->multi_get_reward_info($reward_id_array);
         #var_export($reward_info);
         # 对奖励列表升序排序
         Com_Array::multisort($reward_info, array('reward_priority' => 'asc'));
         foreach ($reward_info as $reward) {
             #echo "</br>===============reward_id:".$reward['reward_id']."==================</br>";
             # 获取奖励的具体道具列表
             $reward_item_list = array();
             if (!empty($reward['reward_info'])) {
                 $reward_item_info_arr = explode("|", $reward['reward_info']);
                 foreach ($reward_item_info_arr as $item_info) {
                     list($item_id, $item_num, $item_tag) = explode(":", $item_info);
                     $item_config = Cache_Prop::getInstance()->get_prop_info($item_id);
                     $item_config['item_num'] = $item_num;
                     $item_struct = Struct_Prop::get_prop_struct($item_config);
                     $reward_item_list[$item_id] = $item_struct;
                     if ($item_tag == $this->reward_item_tag_for_special) {
                         $special_reward_list[$item_id] = $item_struct;
                     }
                 }
             }
             # 进度计算
             $sys_params = array('event_id' => $event_info['event_id'], 'announce_date_head' => $event_info['announce_date_head'], 'announce_date_tail' => $event_info['announce_date_tail'], 'open_date_head' => $event_info['open_date_head'], 'open_date_tail' => $event_info['open_date_tail'], 'reward_id' => $reward['reward_id'], 'reward_type' => $reward['reward_type'], 'reward_billing_cycle' => $reward['reward_billing_cycle']);
             $ret = $this->call_cond_func($player_id, $reward['cond_func'], $reward['cond_func_relation'], $sys_params);
             # 剩余领奖次数计算
             list($real_remain_gain_num, $reward_remain_gain_num, $config_gain_stint) = $this->_cal_reward_remain_gain_num($player_id, $event_info, $reward, $ret);
             # 领奖状态判定
             if ($event_info['reward_date_head'] > $this->current_time || $event_info['reward_date_tail'] < $this->current_time) {
                 $reward_status = 0;
                 # 未到或已超过活动奖励领取时间
             } elseif ((!empty($reward['valid_date_head']) || !empty($reward['valid_date_tail'])) && ($reward['valid_date_head'] > $this->current_time || $reward['valid_date_tail'] < $this->current_time)) {
                 $reward_status = 0;
                 # 未到或已超过活动奖励有效时间
             } elseif (empty($real_remain_gain_num)) {
                 # 用实际剩余领奖次数判断领奖状态
                 $reward_status = 0;
             } else {
                 $reward_status = $ret['status'];
             }
             # 可领奖总数计算
             if ($reward_status) {
                 $can_receive_reward_num += 1;
             }
             $event_reward_list[] = array('reward_id' => $reward['reward_id'], 'reward_cond' => $reward['cond_desc'], 'reward_item_list' => $reward_item_list, 'reward_progress_head' => $ret['progress_head'], 'reward_progress_tail' => $ret['progress_tail'], 'reward_remain_gain_num' => $reward_remain_gain_num, 'reward_status' => $reward_status, 'reward_type' => $reward['reward_type'], 'consume_info' => $reward['consume_info'], 'reward_gain_stint' => $config_gain_stint);
         }
     }
     $out_2304 = array('event_tag' => $event_info['event_tag'], 'event_id' => $event_id, 'event_reward_list' => $event_reward_list, 'event_template' => $event_template);
     # 记录行为
     Com_Log::write('xgame.event', "{$player_id}\t" . "get_event_reward\t" . "{$event_id}\t" . "{$reward_id}\t");
     return $out_2304;
 }
Example #4
0
 /**
  * 领取所有资源
  * @param int player_id 玩家id
  * @param int type 领取类型 1,免费;2,消耗钻石
  */
 public function get_back_all($player_id, $type)
 {
     $player_id = intval($player_id);
     if (!in_array($type, array(1, 2))) {
         //参数错误
         $this->throw_error(10107, 6010018);
     }
     $df = 0;
     $data = $this->get_data('GetBackCurrency')->get_yesterday_info($player_id, $df);
     if ($data['reward_num'] < 1) {
         //无资源可以找回
         $this->throw_error(6010109, 6010114);
     }
     if ($data['is_vip']) {
         $type = 2;
     }
     $cost_currency_value = 0;
     $reward_detail = array();
     foreach ($data['func_info'] as &$func) {
         if (1 == $func['reward_status']) {
             if (!$data['is_vip'] && 2 == $type) {
                 $value = explode(':', $func['cost_num']);
                 $cost_currency_type = $value[0];
                 $cost_currency_value += $value[1];
             }
             if (!empty($func['reward'])) {
                 $reward_array = explode("|", $func['reward']);
                 foreach ($reward_array as $reward) {
                     list($item_idx, $item_num) = explode(":", $reward);
                     if (empty($item_num)) {
                         continue;
                     }
                     if (1 == $type) {
                         $item_num = ceil($item_num / 2);
                     }
                     $reward_detail[$item_idx] += intval($item_num);
                 }
             }
             $func['reward_status'] = 2;
         }
     }
     if (!$reward_detail) {
         $this->throw_error(6010109, 6010115);
     }
     $send_reward = array();
     $this->get_game('Reward')->gen_reward_array($reward_detail, $send_reward);
     if ($cost_currency_value) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
         $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
         $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $data['reward_num'], $cost_currency_type);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     }
     $arr_up['func_info'] = $data['func_info'];
     $arr_up['reward_num'] = 0;
     $this->start_trans();
     $result = $this->get_data('GetBackCurrency')->update_player_info($player_id, $data['day'], $arr_up);
     if ($result) {
         $result = $this->get_game('Reward')->send_reward($player_id, $send_reward, array('cmd_id' => 2021));
         if ($result !== true) {
             $this->throw_error($result);
         }
     }
     if ($cost_currency_value) {
         if ($result) {
             $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2021, array(), $arr_consume);
         }
     }
     if ($result) {
         $this->commit();
         $this->get_game('Reward')->add_reward_log(true);
     } else {
         $this->rollback();
         $this->throw_error('10101', 6010116);
     }
     $data = $this->get_panel($player_id);
     Protocol::input($player_id, 8, 20, 2019, $data);
     //该死的同步次数
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130);
     return array('res' => 1);
 }
Example #5
0
 /**
  * 获取离线奖励
  * @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);
 }
Example #6
0
 /**
  * @Purpose:
  * 提升英雄成长值
  * @Param $player_id 
  * @Param $hero_id
  * @Param $state 0普通提升 1批量提升
  * @Param $auto 为1时表示道具不足时从上次自动购买道具
  */
 public function player_hero_grow_upgrade($player_id, $hero_id, $state, $auto = 0)
 {
     $player_id = intval($player_id);
     $hero_id = strval($hero_id);
     $obj_player_hero_data = $this->get_data('PlayerHero');
     $hero_data = $obj_player_hero_data->get_player_hero_info($player_id, $hero_id);
     if (empty($hero_data)) {
         $this->throw_error('10102');
         #英雄不存在
     }
     $hero_conf = Cache_HeroAttr::getInstance()->get_hero_attr_info($hero_data['hero_code']);
     if (empty($hero_conf)) {
         $this->throw_error('50120');
         #英雄配置错误
     }
     if ($hero_data['grow_rate'] >= $hero_conf['grow_limit']) {
         $this->throw_error('50121');
         #成长值已达上限
     }
     $obj_hero_grow = $this->get_data('PlayerHeroGrow');
     $hero_grow_id = $obj_hero_grow->get_player_hero_grow_data($hero_id);
     $hero_grow_conf = array();
     $findFlag = false;
     if (!$hero_grow_id) {
         $findFlag = true;
     } else {
         $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id);
         if (empty($hero_grow_conf)) {
             $findFlag = true;
         } else {
             if ($hero_data['grow_rate'] < $hero_grow_conf['grow_left'] || $hero_data['grow_rate'] >= $hero_grow_conf['grow_right']) {
                 #区间错误
                 $findFlag = true;
             }
         }
     }
     if ($findFlag) {
         #启动自动纠错
         $hero_grow_id = $this->find_hero_grow_id($hero_data['grow_rate'], $hero_grow_conf);
         if (!$hero_grow_id) {
             $this->throw_error('10111');
             #配置错误
         }
     }
     if (empty($hero_grow_conf)) {
         $this->throw_error('10111');
     }
     $obj_prop_game = $this->get_game('Prop');
     $obj_shop_game = $this->get_game('Shop');
     $consume_props = $last_props = $arr_consume = $arr_shop_log = array();
     $last_props[$hero_grow_conf['item_id']] = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $hero_grow_conf['item_id']));
     if (empty($auto) && $last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) {
         $this->throw_error('50107');
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $crit_counter = 0;
     #暴击计数
     $counter = 10;
     #while执行计数
     $sum_rand_grow_val = 0;
     #总提升数量
     $new_hero_grow_val = 0;
     #新的成长值
     $upgrade_times = $counter;
     $error_code = 0;
     $update_gold = false;
     #是否更新彩钻或钻石资源
     do {
         $need_buy_prop_nums = 0;
         #每次执行所需要的材料需在商城购买的数量
         if ($last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) {
             $last_props[$hero_grow_conf['item_id']] = 0;
             $need_buy_prop_nums = $hero_grow_conf['item_nums'] - $last_props[$hero_grow_conf['item_id']];
             if ($last_props[$hero_grow_conf['item_id']] > 0) {
                 $consume_props[$hero_grow_conf['item_id']] += $last_props[$hero_grow_conf['item_id']];
             }
         } else {
             $last_props[$hero_grow_conf['item_id']] -= $hero_grow_conf['item_nums'];
             #剩余数量
             $consume_props[$hero_grow_conf['item_id']] += $hero_grow_conf['item_nums'];
             #消耗数量
         }
         if ($need_buy_prop_nums > 0) {
             #材料不足需要在商城购买
             $update_gold = true;
             $buy_prop_info = $obj_shop_game->shortcut_purchase_interface($hero_grow_conf['item_id'], 1);
             if (empty($buy_prop_info['item_price'])) {
                 $this->throw_error('130001');
                 #商城没有出售该道具
             }
             list($cost_currency_type, $cost_currency_value) = each($buy_prop_info['item_price']);
             $cost_currency_value *= $need_buy_prop_nums;
             $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
             $arr_tmp_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $need_buy_prop_nums);
             if (!empty($arr_tmp_consume)) {
                 $arr_consume['price'] += $arr_tmp_consume['price'];
                 $arr_consume['gold'] += $arr_tmp_consume['gold'];
                 $arr_consume['ticket'] += $arr_tmp_consume['ticket'];
                 $arr_consume['count'] += $arr_tmp_consume['count'];
             }
             #虚拟商城记录日志
             if (!isset($arr_shop_log[$hero_grow_conf['item_id']])) {
                 $arr_shop_log[$hero_grow_conf['item_id']]['cost_resource_id'] = $cost_currency_type;
             }
             $arr_shop_log[$hero_grow_conf['item_id']]['item_num'] += $need_buy_prop_nums;
             $arr_shop_log[$hero_grow_conf['item_id']]['cost_resource_num'] += $cost_currency_value;
             $error_code = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 0, $cost_currency_type);
             if ($error_code !== true) {
                 if ($counter == 10) {
                     #首次执行如果资源不足则退出
                     $this->throw_error($error_code);
                 }
                 break;
             }
         }
         $counter--;
         $rand_val = 0;
         $is_crit = Com_Random::probability($hero_grow_conf['crit_rate']);
         if ($is_crit) {
             $crit_counter++;
             $rand_val = $this->parse_data($hero_grow_conf['val_crit']);
         } else {
             $rand_val = $this->parse_data($hero_grow_conf['val_nor']);
         }
         if (!$rand_val) {
             $this->throw_error('50122');
             #英雄成长配置表解析错误
         }
         #单次随机值
         $real_rand_val = Com_Random::get_probability_key($rand_val);
         #批量随机值之和
         $sum_rand_grow_val += $real_rand_val;
         #英雄的新成长值
         $new_hero_grow_val = $hero_data['grow_rate'] + $sum_rand_grow_val;
         if ($new_hero_grow_val >= $hero_conf['grow_limit']) {
             #超过英雄成长值上限
             $new_hero_grow_val = $hero_conf['grow_limit'];
             $sum_rand_grow_val = $hero_conf['grow_limit'] - $hero_data['grow_rate'];
             break;
         }
         #移动至下一个成长值区间
         if ($new_hero_grow_val > $hero_grow_conf['grow_right']) {
             $hero_grow_id++;
             $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id);
             if (empty($hero_grow_conf)) {
                 break;
             }
             if (!isset($last_props[$hero_grow_conf['item_id']])) {
                 $last_props[$hero_grow_conf['item_id']] = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $hero_grow_conf['item_id']));
             }
         }
         if (empty($auto) && $last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) {
             #道具不足
             break;
         }
     } while ($counter > 0 && $state > 0);
     #控制循环数量防止进入死循环
     $this->start_trans();
     $result = true;
     if ($update_gold) {
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 557, array(), $arr_consume);
         $this->write_check($result, 3010476);
     }
     if (!empty($consume_props)) {
         $log_param = array('cmd_id' => 557, 'level' => $player_info['level'], 'vip' => $player_info['vip']);
         $logs = array();
         foreach ($consume_props as $prop_id => $prop_nums) {
             #批量扣除多个道具如果可能
             $result = $obj_prop_game->deduct_prop_by_prop_id($player_id, $prop_id, $prop_nums, $logs, 1, $log_param);
             if (!$result) {
                 $this->throw_error('10101');
             }
         }
     }
     if ($result) {
         $hero_data['grow_rate'] = $new_hero_grow_val;
         $hero_data['fight'] = $this->calc_fight($player_id, $hero_data, $hero_data['fit'], $hero_data['rune_hole_list'], $hero_data['star_add_attr_per'], $hero_data['skill_list']);
         $update_field['grow_rate'] = $hero_data['grow_rate'];
         $update_field['fight'] = $hero_data['fight'];
         $result = $this->update_db($player_id, $update_field, $hero_data, 557);
         $this->get_data('RankList')->update_hero_rank($hero_id, $hero_data['fight']);
     }
     if ($result) {
         $this->commit();
         $obj_hero_grow->set_player_hero_grow_data($hero_id, $hero_grow_id);
         $n_hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id);
         #引导任务
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 26, $upgrade_times - $counter);
         $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 37, $hero_data['grow_rate'] + $hero_data['fit_grow'], 8);
         if (!empty($arr_shop_log)) {
             foreach ($arr_shop_log as $item_id => $item_info) {
                 $obj_shop_game->add_dummy_shop_log($player_id, $player_info, $item_id, $item_info['item_num'], $item_info['cost_resource_id'], $item_info['cost_resource_num'], 557);
             }
         }
         return array('res' => $crit_counter, 'rand_val' => $sum_rand_grow_val, 'cur_grow_val' => $new_hero_grow_val, 'effect' => 10000 * round($this->calc_grow_attar($new_hero_grow_val, $hero_conf['grow']), 4), 'prop_id' => $n_hero_grow_conf['item_id'], 'prop_nums' => $n_hero_grow_conf['item_nums'], 'nor_desc' => $n_hero_grow_conf['nor_desc'], 'crit_desc' => $n_hero_grow_conf['crit_desc']);
     } else {
         $this->throw_error('10101');
     }
 }
Example #7
0
 public function buy($player_id, $shop_tag_id, $shop_sub_tag_id, $item_id, $item_num, $currency_type)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     $this->param_check_numeric(array($player_id, $shop_tag_id, $shop_sub_tag_id, $item_id, $item_num, $currency_type));
     # 加锁失败
     if (!Com_Lock::lock("lock|shop_buy|player_id={$player_id}")) {
         $this->throw_error('170501');
         # 系统繁忙
     }
     # 获取商城道具信息
     $item_info = Cache_Shop::getInstance()->get_shop_item_info($shop_tag_id, $shop_sub_tag_id, $item_id);
     if (empty($item_info)) {
         $this->throw_error('130001');
         # 商城没有出售该道具
     }
     # 限时校验
     if (!empty($item_info['sell_start_time']) && $item_info['sell_start_time'] > $this->current_time || !empty($item_info['sell_end_time']) && $item_info['sell_end_time'] < $this->current_time) {
         $this->throw_error('130002');
         # 商城道具限时售卖尚未开始或已经结束
     }
     # 限量校验
     if (!empty($item_info['personal_deal_limit'])) {
         # 获取当日个人累计交易数量
         $daily_start_time = mktime(0, 0, 0);
         $daily_end_time = mktime(23, 59, 59);
         $already_deal_num = $this->get_data('Shop')->get_daily_personal_deal_num($daily_start_time, $daily_end_time, $item_id, $player_id);
         if ($already_deal_num + $item_num > $item_info['personal_deal_limit']) {
             $this->throw_error('130003');
             # 商城道具个人购买数量超过限额
         }
     }
     if (!empty($item_info['whole_deal_limit'])) {
         # 获取当日全服累计交易数量
         $daily_start_time = mktime(0, 0, 0);
         $daily_end_time = mktime(23, 59, 59);
         $already_deal_num = $this->get_data('Shop')->get_daily_whole_deal_num($daily_start_time, $daily_end_time, $item_id);
         if ($already_deal_num + $item_num > $item_info['whole_deal_limit']) {
             $this->throw_error('130004');
             # 商城道具全服购买数量超过限额
         }
     }
     # 获取消耗资源类型与值
     $cost_currency_value = 0;
     if (!empty($item_info['item_price'])) {
         $item_price = explode("|", $item_info['item_price']);
         foreach ($item_price as $price_string) {
             list($cur_type, $cur_value) = explode(":", $price_string);
             if ($cur_type == $currency_type) {
                 $cost_currency_value = $cur_value;
                 break;
             }
         }
     }
     if (empty($cost_currency_value)) {
         $this->throw_error('130005');
         # 商城道具购买价格为零
     }
     $price = 0;
     # 计算价格与折扣,对于限时折扣,可能存在临界情况,玩家看到限时折扣尚未结束,实际服务端已经结束限时折扣的情况
     if (!empty($item_info['discount'])) {
         $item_info = $this->flush_time_limit_discount($item_info);
         # 刷新后折扣可能变为0
         if (!empty($item_info['discount'])) {
             $price = ceil($cost_currency_value * $item_info['discount'] / 10000);
             $cost_currency_value = $price * $item_num;
         } else {
             $price = $cost_currency_value;
             $cost_currency_value = $cost_currency_value * $item_num;
         }
     } else {
         $price = $cost_currency_value;
         $cost_currency_value = $cost_currency_value * $item_num;
     }
     # 消耗虚拟货币校验
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $cost_currency_key = Cache_Currency::getInstance()->get_key($currency_type);
     $this->start_trans();
     # 消耗虚拟货币
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $item_num);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $currency_type);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1302', array(), $arr_consume);
     $this->write_check($re, 3010162);
     # 发送道具
     $reward = array();
     $reward[] = array('type' => 'prop', 'item_id' => $item_id, 'item_num' => $item_num);
     $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '1302'));
     #send_reward失败时,会返回各种失败情况的错误码
     $this->write_check_strict($re, 3010168);
     $sendarrLogs = $this->get_game('Reward')->get_prop_log();
     # 记录商城交易日志
     $deal_log = array('player_id' => $player_id, 'deal_time' => $this->current_time, 'item_id' => $item_id, 'item_num' => $item_num, 'item_status' => $item_info['item_status'], 'cost_currency_type' => $currency_type, 'cost_currency_value' => $cost_currency_value, 'discount' => $item_info['discount']);
     $re = $this->get_data('Shop')->record_shop_deal_log($deal_log);
     $this->write_check($re, 3010183);
     $this->commit();
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $this->get_game('Reward')->add_reward_log();
     # 通知玩家信息变更[必须放在commit之后]
     //		Protocol_Player::p2c_part_update($player_id, array($cost_currency_key => ''));
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 11, $item_id, $item_num);
     //收集道具任务触发
     $out = array('result' => 1);
     # 日常活跃度处理
     $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 4000);
     $prop_info = Cache_Prop::getInstance()->get_prop_info($item_id);
     # --------------------------------------------------------------------
     # 公告
     # --------------------------------------------------------------------
     $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 100), array('rep_type' => 2, 'rep_val' => $item_id, 'rep_player_id' => $player_id, 'rep_pid' => $sendarrLogs[0]['player_prop_id']));
     $this->get_game('SystemNotice')->push_sys_notice($player_id, 100, 0, $replace_info, 0, $prop_info['need_broad_cast']);
     # --------------------------------------------------------------------
     # 活动日志记录
     # --------------------------------------------------------------------
     $event_log_info = array('log_type' => 'shop', 'player_id' => $player_id, 'reg_time' => $this->current_time, 'item_id' => $item_id, 'item_num' => $item_num);
     $this->get_game('Event')->async_deal_event_log($event_log_info);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'item_id' => $item_id, 'item_name' => $prop_info['name'], 'item_quality' => $prop_info['quality'], 'item_num' => $item_num, 'resource_id' => $currency_type, 'resource_num' => $cost_currency_value, 'cmd2_id' => 1302);
     Log_Shop::getInstance()->add_log($log_info);
     return $out;
 }
Example #8
0
 public function fund_invest($player_id, $fund_id)
 {
     $this->param_check_numeric(array($player_id, $fund_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取基金配置信息
     $fund_conf = Cache_Finance::getInstance()->get_fund_conf($fund_id);
     if (empty($fund_conf)) {
         $this->throw_error(110001);
         # 获取基金信息失败
     }
     # 判断活动时间
     $remain_time = $this->_cal_invest_remain_time();
     if ($remain_time <= 0) {
         $this->throw_error(110004);
         # 不在基金投资有效期内,不能投资
     }
     # 获取玩家某种类型基金的交易日志
     $deal_log = $this->get_data('Finance')->get_player_fund_deal_log($player_id, $fund_conf['fund_type']);
     if (!empty($deal_log)) {
         $this->throw_error(110006);
         # 已购买此种类型基金,不能重复购买
     }
     $this->start_trans();
     # 资源消耗
     $cost_cur_key = Cache_Currency::getInstance()->get_key($this->fund_invest_cur_id);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_cur_key, $fund_conf['fund_price']);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_cur_key, $fund_conf['fund_price'], 1, 0);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2703', array(), $arr_consume);
     $this->write_check($re, 3010225);
     # 更新交易记录
     $deal_log = array('player_id' => $player_id, 'fund_id' => $fund_id, 'fund_type' => $fund_conf['fund_type'], 'deal_time' => $this->current_time, 'invest_num' => $fund_conf['fund_price'], 'invest_level' => $player_info['level'], 'fund_status' => 0);
     $re = $this->get_data('Finance')->insert_fund_deal_log($deal_log);
     $this->write_check($re, 3010227);
     $this->commit();
     # 可领收益档次刷新埋点
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, $this->func_id);
     # 刷新基金列表
     $out_2701 = $this->get_fund_list($player_id, $fund_conf['fund_type']);
     Protocol::input($player_id, 3, 27, 2701, $out_2701);
     # 记录行为
     Com_Log::debug_write('xgame.finance', "{$player_id}\t" . "fund_invest\t" . "{$fund_id}\t");
     $out_2703 = array('fund_type' => $fund_conf['fund_type']);
     return $out_2703;
 }
Example #9
0
 /**
  * 复活
  * @param int $player_id 玩家id 
  * @return array 
  */
 public function relive($player_id)
 {
     $res = array();
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     //配置
     $kf_duel_conf = Cache_CrossDuel::getInstance()->get_battle_conf(41001);
     if (!$kf_duel_conf) {
         $this->throw_error(10222, 6010106);
     }
     $purchase_relive_cost = explode(":", $kf_duel_conf['relive_price']);
     $cost_currency_value = $purchase_relive_cost[1];
     $cost_currency_type = $purchase_relive_cost[0];
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->start_trans();
     $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1237, array(), $arr_consume);
     if (true === $result) {
         $this->commit();
         Protocol::input($player_id, 7, 4, 559, 0);
         //成功通知C++
     } else {
         $this->rollback();
         $this->throw_error(10110, 6010107);
     }
     $res['res'] = 1;
     return $res;
 }
Example #10
0
 public function equip_intensify($player_id, $player_prop_id, $auto_buy, $bless_item_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_intensifier);
     # 参数检查
     $this->param_check_numeric(array($player_id, $auto_buy, $bless_item_id), 0);
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (empty($player_equip_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) {
         $this->throw_error('81101');
         # 首充装备不允许强化
     }
     # 获取强化等级上限
     $intensify_lv_limit = $this->get_intensify_lv_limit_by_item_level($player_equip_info['level']);
     if ($player_equip_info['intensive_level'] >= $intensify_lv_limit) {
         $this->throw_error('80310');
         //已满级
     }
     # 强化配置信息检查
     $intensify_config = Cache_Forge::getInstance()->get_intensify_info($player_equip_info['intensive_level'] + 1, 1);
     # 强化所需宝石检查
     $player_gems = 0;
     # 添加了自动购买强化宝石的逻辑,故没有该材料时不能报错
     $player_gems_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $intensify_config['item_id'], 1);
     if (!empty($player_gems_info)) {
         $gems = array_values($player_gems_info);
         foreach ($gems as $key => $val) {
             $player_gems += $val['item_num'];
         }
     }
     # 以下三种情况下的失败,前端要求仍然返回816协议下行,防止自动强化处理异常
     if ($player_info['silver'] < $intensify_config['silver_num']) {
         $extra_816 = array('is_failed' => 2, 'intensive_info' => array());
         Protocol::input($player_id, 3, 8, 816, $extra_816);
         $message = array('texts' => array(array('code' => 10113, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
         #$this->throw_error('10113'); # 银两不足
     }
     if (!$auto_buy && $player_gems < $intensify_config['item_num']) {
         $extra_816 = array('is_failed' => 3, 'intensive_info' => array());
         Protocol::input($player_id, 3, 8, 816, $extra_816);
         $message = array('texts' => array(array('code' => 80312, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
         #$this->throw_error('80312'); # 玩家强化的强化宝石不足!
     }
     if (!empty($bless_item_id)) {
         # 玩家强化的祝福石不足!
         # 强化所需祝福石检查
         $player_bless_item_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $bless_item_id, 1);
         if (empty($player_bless_item_info)) {
             $extra_816 = array('is_failed' => 4, 'intensive_info' => array());
             Protocol::input($player_id, 3, 8, 816, $extra_816);
             $message = array('texts' => array(array('code' => 80320, 'content' => array(), 'params' => array())), 'delay' => 0);
             Protocol::input($player_id, 3, 7, 742, $message);
             return;
         }
     }
     # 成功率判断
     $flag = false;
     if ($player_equip_info['intensive_lose_times'] >= $intensify_config['lose_num']) {
         $flag = true;
     } else {
         $intensify_success_rate = $intensify_config['chance'];
         if (!empty($bless_item_id)) {
             $intensify_bless_info = Cache_Forge::getInstance()->get_intensify_bless_info_by_item_id($bless_item_id, 1);
             $intensify_success_rate += $intensify_bless_info['add_success_rate'];
         }
         if (Com_Random::probability($intensify_success_rate, 10000)) {
             $flag = true;
         }
     }
     # 强化处理
     $before_intensive_desc = $player_equip_info['intensive_desc'];
     $after_intensive_desc = $this->equip_intensify_handle($flag, $player_id, $player_gems, $player_info, $player_equip_info, $intensify_config, $auto_buy, $bless_item_id);
     # 强化成功后,当前装备的强化等级加1
     if ($flag) {
         $player_equip_info['intensive_level'] += 1;
         # 添加好友动态消息
         $prop_info = Cache_Prop::getInstance()->get_prop_info($player_equip_info['prop_id']);
         $param = array(1 => "0|{$player_equip_info['intensive_level']}|1", 2 => "1|{$player_equip_info['prop_id']},{$prop_info['name']},{$player_equip_info['quality']}|2");
         //$this->get_game("PlayerFriend")->add_friend_news_by_type($player_id, 1, 3, 1, $param);
         # --------------------------------------------------------------------
         # 公告
         # --------------------------------------------------------------------
         $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 2, 'rep_val' => $player_equip_info['prop_id'], 'rep_player_id' => $player_id, 'rep_pid' => $player_equip_info['player_prop_id']), array('rep_type' => 7, 'txt' => $player_equip_info['intensive_level']));
         $this->get_game('SystemNotice')->push_sys_notice($player_id, 61, $player_equip_info['intensive_level'], $replace_info);
         # 强化公告
         if ($player_equip_info['type'] == 1) {
             $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 6, "1:" . $player_equip_info['quality'] . ":" . $player_equip_info['star_level'] . ":" . intval($player_equip_info['intensive_level']) . ":{$player_equip_info['player_prop_id']}", 4);
         } else {
             if ($player_equip_info['type'] == 6) {
                 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 35, "1:" . $player_equip_info['quality'] . ":" . $player_equip_info['star_level'] . ":" . intval($player_equip_info['level']) . ":{$player_equip_info['player_prop_id']}", 4);
             }
         }
     } else {
         # 失败时提示消息
         /**
         			$player_equip_info['intensive_lose_times'] += 1;
         			$sure_succeed = $intensify_config['lose_num'] - $player_equip_info['intensive_lose_times']; # 剩余必定成功次数
         			if ($sure_succeed < 0) $sure_secceed = 0;
         			$message = array(
         				'texts'	=> array(
         					array(
         						'code' 		=> 80906, 
         						'content' 	=> array(), 
         						'params' 	=> array(
         							array (
         								array('txt' => '', 'type' => 7, 'value' => $sure_succeed, 'param' => '')
         							),
         						),
         					),
         				),	
         				'delay'	=> 0,
         			);
         			**/
         $message = array('texts' => array(array('code' => 80919, 'content' => array(), 'params' => array())));
         Protocol::input($player_id, 3, 7, 742, $message);
     }
     $out_816 = array();
     $out_816['is_failed'] = $flag ? 0 : 1;
     # 强化成功后,获取下一级强化信息,若已满级,则可忽略满级标识以外信息内容,9->10级时,失败仍然会返回满级标识,进入下面if结构
     if ($player_equip_info['intensive_level'] >= $intensify_lv_limit) {
         $silver_index = Cache_Currency::getInstance()->get_index('silver');
         $out_816['intensive_info'] = array('result' => 1, 'item_pid' => $player_prop_id, 'upgrade_item' => array(), 'success_per' => 0, 'success_num' => 0, 'fail_num' => 0, 'expend_prop' => "{$intensify_config['item_id']}:{$intensify_config['item_num']}", 'expend_currency' => "{$silver_index}:{$intensify_config['silver_num']}", 'max_intensify_lv' => $intensify_lv_limit);
     } else {
         $ret = $this->get_equip_intensify_info($player_id, $player_prop_id);
         $out_816['intensive_info'] = $ret[0];
     }
     # 通知玩家信息变更[必须放在commit之后]
     # 日常活跃度处理
     $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2000);
     # 日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 107, 107, 1);
     # 引导任务埋点
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 15, 1);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id' => $player_prop_id, 'item_id' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'before_level' => $flag ? $player_equip_info['intensive_level'] - 1 : $player_equip_info['intensive_level'], 'after_level' => $player_equip_info['intensive_level'], 'before_attr_add' => $before_intensive_desc, 'after_attr_add' => $after_intensive_desc);
     Log_Forge::getInstance()->add_log($log_info, 'intensify');
     Protocol::input($player_id, 3, 8, 816, $out_816);
 }
Example #11
0
 /**
  * 刷新任务榜单
  * @param $player_id
  * @param $flush_type	刷新类型:0自动刷新【领取奖励|定时】,1钻石刷新
  * @return array
  * @note daily_flush_count包含gold_last_count,即钻石刷新是每日刷新的子集
  */
 private function flush_task($player_id, $flush_type)
 {
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level')));
     $player_task = $this->get_data('PlayerTask')->get_task_info($player_id);
     # 刷新只出现在玩家没有接取任何任务或接取但完成了所有已接取任务的情况下
     # --------------------------------------------------------------------
     $hold_unfinished = false;
     # 是否有已接取但未完成的任务
     foreach ($player_task['daily_val'] as $task_info) {
         if ($task_info['task_status'] == 1) {
             $hold_unfinished = true;
             break;
         }
     }
     if ($hold_unfinished) {
         $task_hash = $player_task['daily_val'];
         return $task_hash;
     }
     # --------------------------------------------------------------------
     # 重置任务每日的刷新次数及最后刷新时间
     if ($player_task['daily_last_flush_time'] < $this->start_unix_timestamp) {
         $player_task['daily_flush_count'] = 0;
     }
     $player_task['daily_last_flush_time'] = $this->current_time;
     $task_flush_cost_cur_value = 0;
     # 手动刷新货币消耗
     if ($flush_type == 1) {
         # 获取当日已刷新次数
         $daily_task_paid_flush_count = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'daily_task_paid_flush_count');
         if (empty($daily_task_paid_flush_count)) {
             $daily_task_paid_flush_count = 0;
         }
         $player_task['gold_last_flush_time'] = $this->current_time;
         # 获取刷新货币消耗数量
         list($task_flush_cost_cur_type, $task_flush_cost_cur_value) = $this->get_task_flush_cost_cur_value($daily_task_paid_flush_count, $player_info);
         $cost_currency_key = Cache_Currency::getInstance()->get_key($task_flush_cost_cur_type);
     }
     # 按照玩家等级随机获取N个日常任务类型
     list($task_type_hash, $task_type_num) = Cache_TaskDaily::getInstance()->get_daily_task_step_type_list($player_info['level'], $this->task_list_stint);
     if (empty($task_type_hash) || $task_type_num != $this->task_list_stint) {
         $this->throw_error('10011');
         # 获取日常任务榜异常
     }
     # 按照上述获取的日常任务类型,获取特定的日常任务
     $task_hash = array();
     # 统计4|5星以上星级个数
     $star_4_num = 0;
     $star_5_num = 0;
     $used_kill_npc_sid = array();
     # 针对116类型的杀怪日常任务,记录已经使用的task_daily_kill_npc表sid字段
     foreach ($task_type_hash as $task_step_type) {
         $task_list = Cache_TaskDaily::getInstance()->get_daily_task_list_by_type($task_step_type, 1, $player_info['level'], $used_kill_npc_sid);
         if (empty($task_list)) {
             $this->throw_error('10011');
         }
         foreach ($task_list as $task_info) {
             # 应用特殊规则
             $task_info = $this->daily_task_rule_apply($player_id, $task_info);
             # 获取任务唯一序号,由于任务ID可重复,故不能使用task_id作为唯一序号
             $task_seq = $this->get_data('PlayerTask')->get_new_task_seq();
             # 为任务赋予任务步骤,任务状态,任务目标等,并统计4星以上星级个数
             $task_hash[$task_seq] = $task_info;
             $task_hash[$task_seq]['task_seq'] = $task_seq;
             $task_hash[$task_seq]['step'] = 1;
             $task_hash[$task_seq]['task_steps'] = 1;
             $task_hash[$task_seq]['task_status'] = 0;
             # 0未接 1已接 2已完成
             $task_hash[$task_seq]['step_type'] = $task_info['task_step_type'];
             #$task_hash[$task_seq]['city_id'] = $task_info['city_id'];
             # 除116类型外,关联的主线任务ID,即task_config表与task_step_config表的task_id
             $task_hash[$task_seq]['kill_npc_sid'] = $task_info['kill_npc_sid'];
             $task_step_config = array('step_type' => $task_info['task_step_type'], 'dup_id' => $task_info['dup_id'] ? $task_info['dup_id'] : 0, 'dup_cle_grade' => $task_info['dup_cle_grade'] ? $task_info['dup_cle_grade'] : 0, 'kill_npc' => $task_info['kill_npc'], 'task_req_act_num' => $task_info['task_req_act_num'], 'pay_npc_id' => $task_info['dialog_task_id'] ? $task_info['dialog_task_id'] : 0, 'func_id' => $task_info['func_id'], 'func_param' => $task_info['func_param'], 'kill_npc_sid' => $task_info['kill_npc_sid']);
             $task_hash[$task_seq]['target'] = $this->get_game('TaskMain')->get_target_val($player_id, $task_step_config);
             if ($task_hash[$task_seq]['star'] >= 4) {
                 $star_4_num++;
             }
             if ($task_hash[$task_seq]['star'] >= 5) {
                 $star_5_num++;
             }
         }
     }
     /**
     		# 保底每一次至少一个4星以上任务,每第三次重置至少一个5星以上任务,保底使用daily_flush_count次数计算
     		if (($player_task['daily_flush_count'] + 1) % 3 == 0) {
     			if ($star_5_num <= 0) {
     				$this->replace_one_special_task($task_hash, $player_info['level'], 5,$player_id);
     			}
     		} else {
     			if ($star_4_num <= 0) {
     				$this->replace_one_special_task($task_hash, $player_info['level'], 4,$player_id);
     			}
     		}
     		**/
     if (count($task_hash) != $this->task_list_stint) {
         $this->throw_error('10011');
     }
     $task_hash = $this->convert_task_info($task_hash);
     $this->start_trans();
     # 消耗金币
     if ($flush_type == 1) {
         $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $task_flush_cost_cur_value);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $task_flush_cost_cur_value, 1, 1);
         $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1012', array(), $arr_consume);
         $this->write_check($re, 3010762);
     }
     # 更新赏金任务
     $player_task['daily_val'] = $task_hash;
     $player_task['daily_flush_count']++;
     if ($flush_type == 1) {
         # 更新日常任务刷新次数
         $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'daily_task_paid_flush_count', 1);
         $this->write_check($re, 3010771);
     }
     $task_update_fields['daily_val'] = $player_task['daily_val'];
     $task_update_fields['daily_flush_count'] = $player_task['daily_flush_count'];
     $task_update_fields['daily_last_flush_time'] = $player_task['daily_last_flush_time'];
     $task_update_fields['gold_last_flush_time'] = $player_task['gold_last_flush_time'];
     $this->get_data('PlayerTask')->set_task_info($player_id, $task_update_fields);
     $this->commit();
     if ($flush_type == 1) {
         # --------------------------------------------------------------------
         # 刷新消息提示
         # --------------------------------------------------------------------
         $message = array('texts' => array(0 => array('code' => 10022, 'content' => array(), 'params' => array(array(array('txt' => '', 'type' => 2, 'value' => $task_flush_cost_cur_type, 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $task_flush_cost_cur_value, 'param' => ''))))), 'delay' => 0);
         #Com_Log::write('xcg', var_export($message, true));
         Protocol::input($player_prop_info['player_id'], 3, 7, 742, $message);
     }
     return $task_hash;
 }
Example #12
0
 /**
  * [train_upgrade 女神强化]
  * @param  [type] $player_id   [玩家ID]
  * @param  [type] $fairy_id    [女神ID]
  * @param  [type] $auto_buy    [是否自动购买]
  * @param  [type] $improve_per [是否提高成功率]
  * @return [type]              [0成功,1概率失败,2金币不足失败,3材料不足失败]
  */
 public function train_upgrade($player_id, $fairy_id, $auto_buy, $improve_flag)
 {
     # 参数检查
     $this->param_check_numeric(array($player_id, $auto_buy, $improve_flag), 0);
     # 获取玩家货币信息
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     # 获取玩家女神信息
     $fairy_info = $this->get_data('Fairy')->get_player_fairy_info($fairy_id);
     if (!$fairy_info) {
         $this->throw_error('10112');
         //获取女神信息失败
     }
     # 获取强化等级上限
     $max_train_lv = Cache_FairyTrain::getInstance()->get_max_train_lv();
     if (!empty($max_train_lv)) {
         $max_train_lv = $this->max_train_lv;
     }
     if ($fairy_info['train_level'] >= $max_train_lv) {
         $this->throw_error('80310');
         //已满级
     }
     # 获取升级到下一级的培养数据
     $trainConfigs = $this->get_cache_table_data('fairy_train_table', array("lvl" => $fairy_info['train_level']));
     if (!$trainConfigs[0] || empty($trainConfigs[0]['expend'])) {
         $this->throw_error('10109');
         //配置表读取错误
     }
     $train_config = $trainConfigs[0];
     // 消耗需求
     $cost_material = explode("|", $train_config['expend']);
     //升级下一级消耗
     $costItemInfo = explode(':', $cost_material[0]);
     //道具消耗
     $costGoldInfo = !empty($cost_material[1]) ? explode(':', $cost_material[1]) : 0;
     //金币消耗
     #当期女神品阶是否达到强化品阶
     if ($fairy_info['level'] < $train_config['fairy_lvl']) {
         $out_536 = array('result' => 5);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 536002, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         //536002 玩家的女神品阶没有达到当前强化需求
         return;
     }
     # 强化所需材料检查
     $cost_item_id = $costItemInfo[0];
     $cost_item_num = intval($costItemInfo[1]);
     # 获取包裹中资源数量
     $player_item_num = 0;
     # 添加了自动购买逻辑,故没有该材料时不能报错
     $player_item_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $cost_item_id, 1);
     if (!empty($player_item_info)) {
         $items = array_values($player_item_info);
         foreach ($items as $key => $val) {
             $player_item_num += $val['item_num'];
         }
     }
     # 强化所需金币
     $cost_silver_num = 0;
     $cost_silver_num = is_array($costGoldInfo) ? intval($costGoldInfo[1]) : 0;
     #勾选使用钻石提高成功率时钻石消耗
     $cost_gold_num = 0;
     if ($improve_flag) {
         $cost_gold_num = $train_config['success_buy_gold'];
     }
     # 金币不足
     if ($player_info['silver'] < $cost_silver_num) {
         $out_536 = array('result' => 2);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 10113, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
     }
     # 钻石不足
     if ($improve_flag && $player_info['gold'] < $cost_gold_num) {
         $out_536 = array('result' => 3);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 10108, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
     }
     # 材料不足 玩家升级的女神之泪不足
     if (!$auto_buy && $player_item_num < $cost_item_num) {
         $out_536 = array('result' => 4);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 536001, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
     }
     # 成功率判断
     $flag = false;
     $current_success_rate = $train_config['success_rate'];
     # 如果勾选了金币购买成功率
     if ($improve_flag) {
         $current_success_rate += $train_config['success_buy_rate'];
     }
     # 成功率大于等于100%必定成功
     if ($current_success_rate >= 100) {
         $flag = true;
     } else {
         # 根据概率值返回是否成功
         if (Com_Random::probability($current_success_rate, 100)) {
             $flag = true;
         }
     }
     # 强化处理
     $old_fairy_info = $fairy_info;
     $this->_train_handle($flag, $player_id, $cost_item_id, $cost_item_num, $player_item_num, $cost_silver_num, $cost_gold_num, $player_info, $fairy_info, $auto_buy, $improve_flag);
     # 强化成功
     if ($flag) {
         #引导任务
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 27, 1);
         $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 38, $fairy_info['train_level'], 8);
     } else {
         # 失败时提示消息
         #失败返还一半消耗
         $call_back_silver = floor($cost_silver_num / 2);
         $this->_return_faile_silver($player_id, $call_back_silver);
         $message = array('texts' => array(array('code' => 80910, 'content' => array(), 'params' => array())));
         Protocol::input($player_id, 3, 7, 742, $message);
     }
     # 游戏日志记录
     $log_data = array('player_id' => $player_id, 'channel' => 536, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'ad_info' => $player_info['ad_info'], 'cmd_id' => 536, 'player_fairy_id' => $fairy_id, 'fairy_code' => $fairy_info['fairy_code'], 'type' => $fairy_info['type'], 'old_train_level' => $old_fairy_info['train_level'], 'new_train_level' => $fairy_info['train_level'], 'old_train_attr' => json_encode($old_fairy_info['train_attr']), 'new_train_attr' => $flag ? $fairy_info['train_attr'] : json_encode($fairy_info['train_attr']), 'flag' => $flag ? 1 : 0);
     Log_Common::getInstance()->add_log_by_table($log_data, 'log_fairy_train');
     $out_536['result'] = $flag ? 0 : 1;
     Protocol::input($player_id, 3, 5, 536, $out_536);
 }
Example #13
0
 /**
  * @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);
 }
Example #14
0
 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;
 }
Example #15
0
 public function get_equips_info($type, $player_id, $pp_id, $pp_inherit_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     # 参数检查
     $this->param_check_numeric(array($type, $player_id), 0);
     # 玩家检测
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
     }
     # 传承道具检测
     $player_props_info = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, array($pp_id, $pp_inherit_id));
     if (empty($player_props_info[$pp_id]) || empty($player_props_info[$pp_inherit_id])) {
         $this->throw_error('80013');
     }
     if (Com_Util::is_first_charge_item($player_props_info[$pp_id]['prop_id']) || Com_Util::is_first_charge_item($player_props_info[$pp_inheirt_id]['prop_id'])) {
         $this->throw_error('81102');
         # 首充装备不允许传承
     }
     $cost_prop_flag = true;
     # 是否消耗道具标识,同等级传承不能消耗道具
     # 传承等级判断
     if ($player_props_info[$pp_id]['level'] > $player_props_info[$pp_inherit_id]['level']) {
         $this->throw_error('80504');
     } elseif ($player_props_info[$pp_id]['level'] == $player_props_info[$pp_inherit_id]['level']) {
         $cost_prop_flag = false;
         # 传承品质判断
         if ($player_props_info[$pp_id]['quality'] > $player_props_info[$pp_inherit_id]['quality']) {
             $this->throw_error('80502');
         } elseif ($player_props_info[$pp_id]['quality'] == $player_props_info[$pp_inherit_id]['quality']) {
             # 传承星级判断
             if ($player_props_info[$pp_id]['star_level'] >= $player_props_info[$pp_inherit_id]['star_level']) {
                 $this->throw_error('80505');
                 # 继承装备星级低于传承装备,无法传承
             }
         }
     }
     # 传承类型判断
     if ($player_props_info[$pp_id]['sub_type'] != $player_props_info[$pp_inherit_id]['sub_type']) {
         $this->throw_error('80503');
     }
     # --------------------------------------------------------------------
     # 传承与继承装备变化字段
     # --------------------------------------------------------------------
     $update_fields_for_inherit = array();
     # 继承装备
     $update_fields = array();
     # 传承装备
     # --------------------------------------------------------------------
     # 强化处理:强化等级取二者较高保留
     # --------------------------------------------------------------------
     $is_inherit_intensify = $this->inherit_handle_for_intensify($player_props_info[$pp_id], $player_props_info[$pp_inherit_id], $update_fields_for_inherit);
     # --------------------------------------------------------------------
     # 镶嵌宝石处理,记录需要发放的宝石 NOTE:如果取消注释,则之后一定要对$update_fields中的宝石相关field项进行置空操作
     # --------------------------------------------------------------------
     #$send_gems = $this->inherit_handle_for_inlay_gem($player_props_info[$pp_id], $player_props_info[$pp_inherit_id], $update_fields_for_inherit);
     # --------------------------------------------------------------------
     # 吞噬属性处理,取二者较高保留
     # --------------------------------------------------------------------
     $is_inherit_swallow = $this->inherit_handle_for_swallow_info($player_props_info[$pp_id], $player_props_info[$pp_inherit_id], $update_fields_for_inherit);
     # --------------------------------------------------------------------
     # 星图处理,A覆盖B NOTE:如果取消注释,则之后一定要对$update_fields中的星图相关field项进行置空操作
     # --------------------------------------------------------------------
     #$send_starmap = $this->inherit_handle_for_starmap($player_props_info[$pp_id], $player_props_info[$pp_inherit_id], $update_fields_for_inherit);
     # --------------------------------------------------------------------
     # 洗练处理:A覆盖B,并将B的配置相关信息按等级重置
     # --------------------------------------------------------------------
     $is_inherit_refine = $this->inherit_handle_for_refine($player_props_info[$pp_id], $player_props_info[$pp_inherit_id], $update_fields_for_inherit);
     # 传承装备 有传承的属性需要置空,没传承的属性需要保留
     if ($is_inherit_intensify) {
         $prop_config = Cache_Prop::getInstance()->get_prop_info($pp_id);
         $update_fields['intensive_level'] = 0;
         $update_fields['intensive_lose_times'] = 0;
         $update_fields['intensive_desc'] = array();
         $update_fields['equip_view'] = $prop_config['equip_view'];
     }
     if ($is_inherit_swallow) {
         $update_fields['swallow_info'] = array();
     }
     if ($is_inherit_refine) {
         list($refine_attr, $refine_info) = $this->get_game('EquipRefine')->extend_refine($player_props_info[$pp_id]['sub_type'], $player_props_info[$pp_id]['level']);
         $update_fields['refine_attr'] = $refine_attr;
         $update_fields['refine_info'] = $refine_info;
     }
     # 更新传承与被传承的装备信息
     if ($type) {
         if (!$is_inherit_intensify && !$is_inherit_swallow && !$is_inherit_refine) {
             $this->throw_error('80506');
             # 传承装备的属性小于继承装备,无需进行操作
         }
         $this->start_trans();
         # --------------------------------------------------------------------
         # 通用消耗处理
         # --------------------------------------------------------------------
         $forge_common_info = Cache_Forge::getInstance()->get_forge_common_info($player_props_info[$pp_inherit_id]['level'], 1);
         if (!empty($forge_common_info['inherit_cost'])) {
             # 消耗的货币|消耗的道具
             list($cost_currency, $cost_prop) = $this->get_common_depletion_detail($forge_common_info['inherit_cost']);
             if (!empty($cost_currency)) {
                 foreach ($cost_currency as $key => $value) {
                     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $key, $value);
                     # 传承货币消耗策划配多种时,此处的数据不准确,目前只配1种
                     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $key, $value, 1, 1);
                 }
                 $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '826', array(), $arr_consume);
                 $this->write_check($re, 3010178);
             }
             if (!empty($cost_prop) && $cost_prop_flag) {
                 # 消耗道具
                 $arr_logs_cost = array();
                 $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 826);
                 foreach ($cost_prop as $prop_id => $prop_num) {
                     $result = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $prop_id, $prop_num, $arr_logs_cost, 0, $log_param);
                 }
             }
         }
         # --------------------------------------------------------------------
         # 多余宝石,多余星图发放
         # --------------------------------------------------------------------
         $reward = array();
         if (!empty($send_gems)) {
             foreach ($send_gems as $k => $v) {
                 $reward[] = array('type' => 'prop', 'item_id' => $k, 'item_num' => $v);
             }
         }
         if (!empty($send_starmap)) {
             $reward[] = array('type' => 'prop', 'item_id' => $send_starmap, 'item_num' => 1);
         }
         if (!empty($reward)) {
             $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 826));
             #send_reward失败时,会返回各种失败情况的错误码
             $this->write_check_strict($re, 3010203);
             $arr_logs = $this->get_game('Reward')->get_prop_log();
         }
         # --------------------------------------------------------------------
         # 传承与继承装备更新
         # --------------------------------------------------------------------
         if (!empty($update_fields_for_inherit)) {
             $re = $this->get_data('PlayerProp')->update_player_prop($player_props_info[$pp_inherit_id], $update_fields_for_inherit);
             $this->write_check($re, 3010211);
         }
         if (!empty($update_fields)) {
             $re = $this->get_data('PlayerProp')->update_player_prop($player_props_info[$pp_id], $update_fields);
             $this->write_check($re, 3010214);
         }
         $this->commit();
         # --------------------------------------------------------------------
         # 游戏日志记录
         # --------------------------------------------------------------------
         $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_props_info[$pp_inherit_id]['player_prop_id'], 'item_id_master' => $player_props_info[$pp_inherit_id]['prop_id'], 'item_type' => $player_props_info[$pp_inherit_id]['type'], 'item_sub_type' => $player_props_info[$pp_inherit_id]['sub_type'], 'item_quality' => $player_props_info[$pp_inherit_id]['quality'], 'item_level' => $player_props_info[$pp_inherit_id]['level'], 'item_star_level' => $player_props_info[$pp_inherit_id]['star_level'], 'player_prop_id_slave' => $player_props_info[$pp_id]['player_prop_id'], 'item_id_slave' => $player_props_info[$pp_id]['prop_id'], 'before_intensive_level' => $player_props_info[$pp_inherit_id]['intensive_level'], 'after_intensive_level' => isset($update_fields_for_inherit['intensive_level']) ? $update_fields_for_inherit['intensive_level'] : $player_props_info[$pp_inherit_id]['intensive_level'], 'before_intensive_desc' => $player_props_info[$pp_inherit_id]['intensive_desc'], 'after_intensive_desc' => isset($update_fields_for_inherit['intensive_desc']) ? $update_fields_for_inherit['intensive_desc'] : $player_props_info[$pp_inherit_id]['intensive_desc'], 'before_inlay_gems_lv' => $player_props_info[$pp_inherit_id]['inlay_gems_lv'], 'after_inlay_gems_lv' => isset($update_fields_for_inherit['inlay_gems_lv']) ? $update_fields_for_inherit['inlay_gems_lv'] : $player_props_info[$pp_inherit_id]['inlay_gems_lv'], 'before_inlay_gems' => $player_props_info[$pp_inherit_id]['inlay_gems'], 'after_inlay_gems' => isset($update_fields_for_inherit['inlay_gems']) ? $update_fields_for_inherit['inlay_gems'] : $player_props_info[$pp_inherit_id]['inlay_gems'], 'before_starmap_id' => $player_props_info[$pp_inherit_id]['star_map_id'], 'after_starmap_id' => isset($update_fields_for_inherit['star_map_id']) ? $update_fields_for_inherit['star_map_id'] : $player_props_info[$pp_inherit_id]['star_map_id'], 'before_starmap_desc' => $player_props_info[$pp_inherit_id]['star_map_desc'], 'after_starmap_desc' => isset($update_fields_for_inherit['star_map_desc']) ? $update_fields_for_inherit['star_map_desc'] : $player_props_info[$pp_inherit_id]['star_map_desc'], 'before_swallow_info' => $player_props_info[$pp_inherit_id]['swallow_info'], 'after_swallow_info' => isset($update_fields_for_inherit['swallow_info']) ? $update_fields_for_inherit['swallow_info'] : $player_props_info[$pp_inherit_id]['swallow_info']);
         Log_Forge::getInstance()->add_log($log_info, 'inherit');
         # ------------------------------------------------------------
         # 更新传承与继承装备信息
         # ------------------------------------------------------------
         if (!empty($update_fields_for_inherit)) {
             foreach ($update_fields_for_inherit as $k => $v) {
                 $player_props_info[$pp_inherit_id][$k] = $v;
             }
         }
         if (!empty($update_fields)) {
             foreach ($update_fields as $k => $v) {
                 $player_props_info[$pp_id][$k] = $v;
             }
         }
         # ------------------------------------------------------------
         # 若传承或被传承装备有其一在玩家身上,则刷新玩家属性
         # ------------------------------------------------------------
         if ($player_props_info[$pp_inherit_id]['item_position'] == 3 || $player_props_info[$pp_id]['item_position'] == 3) {
             $this->get_game('EquipAttr')->equip_attr($player_id);
         }
         # ------------------------------------------------------------
         # 粘806 + 通知道具变更信息
         # ------------------------------------------------------------
         $this->get_game('Reward')->add_reward_log();
         # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志
         $ndata = array();
         $ndata[] = $player_props_info[$pp_inherit_id];
         $ndata[] = $player_props_info[$pp_id];
         if (!empty($arr_logs_cost)) {
             foreach ($arr_logs_cost as $k => $v) {
                 # 消耗的道具
                 $ndata[] = $v;
             }
         }
         Protocol_Prop::prop_806($player_id, $ndata);
         $out_825 = array(0 => $pp_id, 1 => $pp_inherit_id, 2 => Struct_Prop::get_prop_struct($player_props_info[$pp_inherit_id]));
         $out_825[3] = $this->get_inherit_consume_info($player_props_info[$pp_inherit_id]['level'], $cost_prop_flag);
         Protocol::input($player_id, 3, 8, 825, $out_825);
         /*old
         		$out_826 = array(
         			'pp_id'					=> $pp_id,
         			'pp_inherit_id'			=> $pp_inherit_id,
         			'pp_box_info' 			=> array('item_position' => 1, 'grid' => $player_props_info[$pp_id]['grid']),
         			'pp_inherit_box_info'	=> array('item_position' => 1, 'grid' => $player_props_info[$pp_inherit_id]['grid']),
         		);
         		*/
         $out_826 = array('pp_prop_info' => Struct_Prop::get_prop_struct($player_props_info[$pp_id]), 'pp_inherit_prop_info' => Struct_Prop::get_prop_struct($player_props_info[$pp_inherit_id]));
         return $out_826;
     } else {
         if (!empty($update_fields_for_inherit)) {
             foreach ($update_fields_for_inherit as $k => $v) {
                 $player_props_info[$pp_inherit_id][$k] = $v;
             }
         }
         if (!empty($update_fields)) {
             foreach ($update_fields as $k => $v) {
                 $player_props_info[$pp_id][$k] = $v;
             }
         }
         $out_825 = array(0 => $pp_id, 1 => $pp_inherit_id, 2 => Struct_Prop::get_prop_struct($player_props_info[$pp_inherit_id]));
         $out_825[3] = $this->get_inherit_consume_info($player_props_info[$pp_inherit_id]['level'], $cost_prop_flag);
         return $out_825;
     }
 }
Example #16
0
 /**
  * 购买次数
  * @param $player_id
  * @return array
  */
 public function add_fight_times($player_id)
 {
     $p_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_grab_domain_add_times');
     $p_num = $p_num ? $p_num : 0;
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $vip_level = $player_info['vip'] ? $player_info['vip'] : 0;
     //获取购买消耗信息
     $buy_times_info = Cache_UnionGrabDomain::getInstance()->get_buy_times_info($vip_level);
     //获取购买次数上限
     $times_limit = $this->get_buy_max_times($player_id, $buy_times_info);
     if ($p_num >= $times_limit) {
         // 你不能再增加进攻次数了
         if (10 > $vip_level) {
             $this->throw_error(6010121);
         } else {
             $this->throw_error(6010146);
         }
     }
     $purchase_times_cost = explode("|", $buy_times_info['cost_num']);
     $cost_currency_value = intval($purchase_times_cost[$p_num]);
     $cost_currency_type = $buy_times_info['cost_type'];
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->start_trans();
     $result = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'union_grab_domain_add_times');
     if ($result) {
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2602, array(), $arr_consume);
     }
     if ($result) {
         $this->commit();
         $max_time = $p_num + 1;
         $grab_domain_conf = Cache_UnionGrabDomain::getInstance()->get_base_conf();
         $max_fight_times = $grab_domain_conf['times'];
         $cur_num = intval($this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_grab_domain_use_times'));
         if ($max_time >= $times_limit) {
             //到了最大次数 前端不弹提示框 这里约定传 null
             $next_cost = '';
         } else {
             $p_num = $p_num + 1;
             $next_cost = intval($purchase_times_cost[$p_num]);
             $next_cost = $cost_currency_type . ':' . $next_cost;
         }
         Protocol_Msg::msg($player_id, 12017);
         //给前端提示 购买成功
         return array('cur_num' => $cur_num, 'max_time' => $max_time + $max_fight_times, 'next_cost' => $next_cost);
     } else {
         $this->rollback();
         $this->throw_error('10110', 6010122);
     }
 }
Example #17
0
 public function upgrade_rune($player_id, $rune_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_skill);
     $this->param_check_numeric(array($player_id, $rune_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level', 'career_type')));
     $get_field = Protocol_Player::get_player_attr_detail_key();
     $get_field[] = 'skill_starmap_info';
     $get_field[] = 'skill_info';
     $get_field[] = 'skill_rune_info';
     $get_field[] = 'dower_info';
     $arr_player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, $get_field);
     # 获取当前符文等级
     $now_level = 0;
     if (!empty($arr_player_detail['skill_rune_info'])) {
         foreach ($arr_player_detail['skill_rune_info'] as $sid => $rune_info) {
             foreach ($rune_info as $rid => $rinfo) {
                 if ($rid == $rune_id) {
                     $now_level = $rinfo['level'];
                     break;
                 }
             }
         }
     }
     $rune_config = Cache_SkillRune::getInstance()->get_skill_rune_info_by_rl($rune_id, $now_level + 1, 1);
     $skill_id = $rune_config['skill_id'];
     Com_Log::write('xgame.skill.debug', "rune==============" . $player_id . ":" . $rune_config['sid'] . ":" . $rune_config['rune_level']);
     if (!isset($arr_player_detail['skill_info'][$skill_id])) {
         $this->throw_error('60014');
         //技能与符文配置不一致
     }
     if ($arr_player_detail['skill_info'][$skill_id]['level'] < $rune_config['require_skill_level']) {
         $this->throw_error('60020');
         //未达到激活符文所需技能等级
     }
     # 首次激活需要判断前置符文是否已经激活【技能对应的多个符文序列必须按顺序激活,由配置表skill_rune中的rune_seq决定顺序】
     if ($now_level == 0 && $rune_config['rune_seq'] != 1) {
         $rune_seq = Cache_SkillRune::getInstance()->get_skill_rune_info_by_seq($skill_id, $rune_config['rune_seq'] - 1, 1);
         if (!isset($arr_player_detail['skill_rune_info'][$skill_id][$rune_seq['sid']])) {
             $this->throw_error('60016');
             //该符文不能被激活,请先激活上一符文再继续
         }
     }
     $this->start_trans();
     # 消耗激活所需资源
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $rune_config['cost_silver'], 1, 1);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'crystal', $rune_config['cost_skill_point'], 1, 1);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '604');
     $this->write_check($re, 3010598);
     # 更新技能符文信息
     if ($now_level == 0) {
         $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] = 1;
         $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['rune_index'] = $rune_config['rune_seq'];
     } else {
         $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level'] += 1;
     }
     $re = $this->get_data('PlayerDetail')->update_player_detail($player_id, $arr_player_detail);
     $this->write_check($re, 3010608);
     $this->commit();
     //同步人物属性
     $arr_part_update['skill_infos'] = '';
     $arr_part_update['player_data'] = array('player_detail' => $arr_player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']));
     Protocol_Player::p2c_part_update($player_id, $arr_part_update);
     if ($now_level == 0) {
         # 首次激活
         $out[0] = intval(1);
         $out[1] = intval($skill_id);
         $out[2] = intval($rune_id);
         $ac_info = array();
         //符文状态  0未激活 1 可激活 2 已经激活
         $rune_info = Cache_SkillRune::getInstance()->get_skill_rune_list_group($skill_id, 1);
         foreach ($rune_info as $k => $v) {
             if (isset($arr_player_detail['skill_rune_info'][$skill_id][$v['sid']])) {
                 $ac_info[] = array(0 => intval($v['sid']), 1 => 2);
             } elseif ($rune_config['rune_seq'] + 1 == $v['rune_seq'] && $arr_player_detail['skill_info'][$skill_id]['level'] >= $v['require_skill_level']) {
                 $ac_info[] = array(0 => intval($v['sid']), 1 => 1);
             } else {
                 $ac_info[] = array(0 => intval($v['sid']), 1 => 0);
             }
         }
         $out[3] = $ac_info;
         $this->handle_rune_refer_achieve($player_id);
         $skill_config = Cache_Skill::getInstance()->get_skill_infobysl($skill_id, 1);
         //            Com_Log::write('trigger_guid_task.'.$player_id,"skill:".var_export($skill_config,true));
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 1, 1, $skill_config['keyboard']);
         #引导任务
     } else {
         # 升级
         $out[0] = 1;
         $out[1] = intval($rune_id);
         $out[2] = intval($arr_player_detail['skill_rune_info'][$rune_config['skill_id']][$rune_id]['level']);
         $out[3] = intval($player_info['crystal']);
     }
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'skill_id' => $skill_id, 'rune_id' => $rune_id, 'rune_seq' => $rune_config['rune_seq'], 'before_level' => $now_level, 'after_level' => $arr_player_detail['skill_rune_info'][$skill_id][$rune_id]['level']);
     Log_Skill::getInstance()->add_log($log_info, 'rune');
     return $out;
 }
Example #18
0
 public function fund_invest($player_id, $fund_id)
 {
     $this->param_check_numeric(array($player_id, $fund_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取基金配置信息
     $fund_conf = Cache_Finance::getInstance()->get_fund_conf($fund_id);
     if (empty($fund_conf)) {
         $this->throw_error(110001);
         # 获取基金信息失败
     }
     # 判断活动时间
     $remain_time = $this->_cal_invest_remain_time();
     if ($remain_time <= 0) {
         $this->throw_error(110004);
         # 不在基金投资有效期内,不能投资
     }
     # 获取玩家某种类型基金的投资情况
     list($invest_acc, $invest_lvl, $invest_time) = $this->get_data('Finance')->get_player_fund_invest_log_by_type($player_id, $fund_conf['fund_type']);
     # 计算投资差额
     if ($fund_conf['fund_price'] <= $invest_acc) {
         $this->throw_error(110005);
         # 不能减少基金已投资金额
     } else {
         $delta = $fund_conf['fund_price'] - $invest_acc;
     }
     $this->start_trans();
     # 资源消耗
     $cost_cur_key = Cache_Currency::getInstance()->get_key($this->fund_invest_cur_id);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_cur_key, $delta);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_cur_key, $delta, 1, 0);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2703', array(), $arr_consume);
     $this->write_check($re, 3010225);
     # 更新投资记录
     $invest_log = array('player_id' => $player_id, 'fund_type' => $fund_conf['fund_type'], 'invest_time' => $this->current_time, 'invest_num' => $delta, 'invest_level' => $player_info['level']);
     $re = $this->get_data('Finance')->insert_fund_invest_log($invest_log);
     $this->write_check($re, 3010227);
     $this->commit();
     # 刷新基金列表
     $out_2701 = $this->get_fund_list($player_id, $fund_conf['fund_type']);
     Protocol::input($player_id, 3, 27, 2701, $out_2701);
     # 记录行为
     Com_Log::debug_write('xgame.finance', "{$player_id}\t" . "fund_invest\t" . "{$fund_id}\t");
     $out_2703 = array('fund_type' => $fund_conf['fund_type']);
     return $out_2703;
 }
Example #19
0
 /**
  * @Purpose:
  * 购买金蛋活动挑战次数
  * @param $player_id 玩家ID
  */
 public function buy_egg_active_times($player_id)
 {
     $player_id = intval($player_id);
     $buy_times_table = Cache_BuyTimes::getInstance()->get_buy_times_info(9);
     if (!$buy_times_table) {
         $this->throw_error('113602');
         #buy_times配置表读取错误
     } else {
         if (!isset($buy_times_table['max_times']) || $buy_times_table['max_times'] < 1) {
             $this->throw_error('113701');
             #buy_times配置表的max_times字段配置错误
         } else {
             if (!isset($buy_times_table['cost_num']) || empty($buy_times_table['cost_num'])) {
                 $this->throw_error('113702');
                 #buy_times配置表的cost_num字段配置错误
             } else {
                 if (!isset($buy_times_table['cost_type']) || $buy_times_table['cost_type'] < 1) {
                     $this->throw_error('113704');
                     #buy_times配置表的cost_type配置错误
                 } else {
                     if (!isset($buy_times_table['per_num']) || $buy_times_table['per_num'] < 1) {
                         $this->throw_error('113705');
                         #buy_times配置表的per_num配置错误
                     }
                 }
             }
         }
     }
     #获取玩家已购买的次数
     $player_times = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'buy_egg_active_times');
     #$player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'ticket', 'gold', 'privilege_level'));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'ticket', 'gold', 'silver', 'privilege_level')));
     if ($player_times >= $buy_times_table['max_times']) {
         $this->throw_error('10225');
         #购买次数已满
     }
     $cost_num = explode("|", $buy_times_table['cost_num']);
     $expend_coin = $cost_num[$player_times];
     if ($expend_coin < 1) {
         $this->throw_error('113703');
         #buy_times配置表的cost_num字段配置消耗不足
     }
     $cost_currency_key = Cache_Currency::getInstance()->get_key($buy_times_table['cost_type']);
     if (empty($cost_currency_key)) {
         $this->throw_error('113704');
         #buy_times配置表的cost_type配置错误
     }
     # 消耗货币
     /***************/
     $ticket = 0;
     $gold = $expend_coin;
     if ($player_info['ticket'] > 0) {
         if ($player_info['ticket'] >= $expend_coin) {
             $ticket = $expend_coin;
             $gold = 0;
         } else {
             $ticket = $player_info['ticket'];
             $gold = $expend_coin - $player_info['ticket'];
         }
     }
     $arr_consume = array('price' => $expend_coin, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1);
     #数据中心推送
     /***************/
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $expend_coin, 1, $buy_times_table['cost_type']);
     $this->start_trans();
     #增加挑战次数
     $add_res = $this->get_data('PlayerDailyTime')->pre_add_used_time($player_id, 'add_egg_active_times', $buy_times_table['per_num']);
     if (!$add_res) {
         $this->throw_error('10104');
     }
     #增加购买次数
     $add_buy_res = $this->get_data('PlayerDailyTime')->pre_add_used_time($player_id, 'buy_egg_active_times');
     if (!$add_buy_res) {
         $this->throw_error('10104');
     }
     #扣货币
     $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 758, array(), $arr_consume);
     if (!$update_res) {
         $this->throw_error('10104');
     }
     $this->commit();
     $cost_type = 0;
     $cost_num = 0;
     $add_times = 0;
     if ($player_times + 1 < $buy_times_table['max_times']) {
         $num = explode("|", $buy_times_table['cost_num']);
         $cost_num = $num[$player_times + 1];
         $cost_type = $buy_times_table['cost_type'];
         $add_times = $buy_times_table['per_num'];
     }
     return array('id' => intval($cost_type), 'num' => intval($cost_num), 'add_times' => intval($add_times));
 }
Example #20
0
 public function clear_challenge_battle_cd($player_id)
 {
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取挑战剩余cd时间
     $remain_cd = $this->get_data('Challenge')->get_challenge_remain_cd($player_id);
     $this->start_trans();
     # 消耗虚拟货币
     $cost_currency_key = Cache_Currency::getInstance()->get_key($this->clear_cd_cost_currency_type);
     $cost_currency_value = Formula_Ladder::challenge_cd_prize($remain_cd);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1207', array(), $arr_consume);
     $this->write_check($re, 3011487);
     # 清除天梯挑战cd时间
     $re = $this->get_data('Challenge')->clear_remain_cd($player_id);
     $this->write_check($re, 3011491);
     $this->commit();
     $out = array('result' => 1);
     # 记录行为
     Com_Log::write('xgame.challenge', "{$player_id}\t" . "clear_challenge_battle_cd\t");
     return $out;
 }
Example #21
0
 public function compose($player_id, $target_id, $comp_type, $comp_sub_type, $auto_buy, $onekey)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     # 参数校验,comp_sub_type允许为0
     $this->param_check_numeric(array($player_id, $target_id, $comp_type, $comp_sub_type), 0);
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level')));
     # 一键合成不允许自动购买
     if ($onekey) {
         $auto_buy = 0;
     }
     # 获取具体合成信息
     $comp_info = Cache_ItemCompose::getInstance()->get_item_compose_info_by_target_id($target_id);
     if (empty($comp_info)) {
         $this->throw_error('90002');
         # 没有配置该道具的合成信息
     }
     $comp_type = $comp_info['comp_type'];
     $comp_sub_type = $comp_info['comp_sub_type'];
     /** 由于前端问题,传参此处可能报异常,反正这两个参数不实用,故忽略
     		if ($comp_info['comp_type'] != $comp_type || $comp_info['comp_sub_type'] != $comp_sub_type) {
     			$this->throw_error('90003'); # 合成参数异常
     		}
     		**/
     # 检查消耗情况
     $cost_material_info_hash = array();
     # 消耗材料信息哈希,为了方便一次性查找所有消耗材料的持有数
     for ($i = 1; $i <= 5; $i++) {
         if (!empty($comp_info['m' . $i . '_id']) && !empty($comp_info['m' . $i . '_amount'])) {
             $cost_material_info_hash[$comp_info['m' . $i . '_id']] = $comp_info['m' . $i . '_amount'];
         }
     }
     # --------------------------------------------------------------------
     # 计算可一键合成的产物数量
     # --------------------------------------------------------------------
     $onekey_num_list = array();
     # 每项材料可以满足合成条件几次
     if (!empty($cost_material_info_hash)) {
         $material_hold_nums = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, array_keys($cost_material_info_hash));
         foreach ($cost_material_info_hash as $m_id => $m_amount) {
             $onekey_num_list[$m_id] = intval($material_hold_nums[$m_id] / $m_amount);
         }
     }
     $onekey_num = min($onekey_num_list);
     # 木桶原理,能一键合成的产物数由最少材料项决定
     if ($onekey) {
         if (empty($onekey_num)) {
             $this->throw_error('90004');
             # 合成所需材料不足
         }
         $onekey_num = min($onekey_num, intval($player_info['silver'] / $comp_info['cost']));
         # 木桶原理,能一键合成的产物数还由玩家持有货币决定
         if (empty($onekey_num)) {
             $this->throw_error('10113');
             # 金币不足
         }
     } else {
         if (empty($onekey_num) && empty($auto_buy)) {
             $this->throw_error('90004');
             # 合成所需材料不足
         }
         $onekey_num = 1;
         # 非一键合成一次只允许合成一件
     }
     $this->start_trans();
     # 消耗虚拟货币
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $comp_info['cost'] * $onekey_num, 1, 1);
     # 消耗材料
     $arr_logs = array();
     $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2202);
     foreach ($cost_material_info_hash as $m_id => $m_amount) {
         $hold_num = !empty($material_hold_nums[$m_id]) ? $material_hold_nums[$m_id] : 0;
         if (!empty($auto_buy) && $hold_num < $m_amount) {
             # 一定是单次合成
             # 获取正确的单价
             $price_info = $this->get_game('Shop')->shortcut_purchase_interface($m_id, 1);
             if (empty($price_info['item_price'])) {
                 $this->throw_error('130001');
                 # 商城没有出售该道具
             }
             # 策划价格配置多项时,选其中一项
             list($cur_idx, $cur_val) = each($price_info['item_price']);
             $price = $cur_val;
             $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx);
             $cost_currency_value = intval($cur_val * ($m_amount - $hold_num));
             $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cur_idx);
             if ($hold_num > 0) {
                 # 该方法在道具不足时会报错,无需外层再判断是否道具足够
                 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $material_hold_nums[$m_id], $arr_logs, 0, $log_param);
                 $this->write_check($re, 3010156);
             }
             # 若有购买缺少材料,记录虚假商城购买日志
             if ($cost_currency_value > 0) {
                 $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $m_id, intval($m_amount - $hold_num), $cur_idx, $cost_currency_value, 2202);
             }
         } else {
             # 可能单次,可能一键
             # 该方法在道具不足时会报错,无需外层再判断是否道具足够
             $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $m_amount * $onekey_num, $arr_logs, 0, $log_param);
             $this->write_check($re, 3010161);
         }
     }
     # TODO: 数据中心推送
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2202');
     $this->write_check($re, 3010167);
     #---------------------------------------------------------------------
     # 按概率计算成功次数
     #---------------------------------------------------------------------
     $success_num = 0;
     for ($i = 1; $i <= $onekey_num; $i++) {
         if (Com_Random::probability($comp_info['succ_rate'], 10000)) {
             # 成功
             $success_num += 1;
         }
     }
     if ($success_num) {
         # 成功
         # 发送道具
         $reward[] = array('type' => 'prop', 'item_id' => $target_id, 'item_num' => $success_num);
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2202));
         #send_reward失败时,会返回各种失败情况的错误码
         $this->write_check_strict($re, 3010173);
     }
     # 记录合成日志
     $this->commit();
     # --------------------------------------------------------------------
     # 通知道具变更,粘包806
     # --------------------------------------------------------------------
     $this->get_game('Reward')->add_reward_log();
     # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志
     if (!empty($arr_logs) && is_array($arr_logs)) {
         $ndata = array();
         foreach ($arr_logs as $key => $val) {
             $ndata[] = $val;
         }
         Protocol_Prop::prop_806($player_id, $ndata);
     }
     # --------------------------------------------------------------------
     # 刷新2201协议
     # --------------------------------------------------------------------
     $data_2201 = $this->get_compose_info($player_id, $comp_type, $comp_sub_type);
     Protocol::input($player_id, 3, 22, 2201, $data_2201);
     # 记录行为
     Com_Log::write('xgame.compose', "{$player_id}\t" . "{$target_id}\t" . "{$auto_buy}\t" . "{$onekey}\t" . "{$onekey_num}\t" . "{$success_num}\t");
     # 日常任务埋点,宝石合成才触发,考虑宝石种类可能包含多种,不方便使用$arr_logs[0]['type'] == 3 && $arr_logs[0]['sub_type'] == 6类似条件
     #if ($comp_type == $this->comp_type_for_gem) { # 改为任意合成都算
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 109, 109, $onekey_num);
     #}
     #引导任务
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 12, $onekey_num);
     # --------------------------------------------------------------------
     # 公告
     # --------------------------------------------------------------------
     $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 70), array('rep_type' => 2, 'rep_val' => $target_id));
     $prop_info = Cache_Prop::getInstance()->get_prop_info($target_id);
     $this->get_game('SystemNotice')->push_sys_notice($player_id, 70, 0, $replace_info, 0, $prop_info['need_broad_cast']);
     $out_2202 = array('result' => 1);
     return $out_2202;
 }
Example #22
0
 /**
  * @Purpose:
  * 翅膀装备传承
  * @Param $player_id 玩家ID
  * @Param $inherit_equip_pid 传承装备ID
  * @Param $be_inherit_equip_pid 继承装备ID
  */
 public function wing_equip_inherit($player_id, $inherit_equip_pid, $be_inherit_equip_pid)
 {
     $player_id = intval($player_id);
     $inherit_equip_pid = strval($inherit_equip_pid);
     $be_inherit_equip_pid = strval($be_inherit_equip_pid);
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'career_type', 'level', 'vip', 'privilege_level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     $player_prop_list = $this->get_data('PlayerProp')->get_player_prop_detail_multi($player_id, array($inherit_equip_pid, $be_inherit_equip_pid));
     $inherit_equip_info = $player_prop_list[$inherit_equip_pid];
     $be_inherit_equip_info = $player_prop_list[$be_inherit_equip_pid];
     if (empty($inherit_equip_info) || empty($be_inherit_equip_info)) {
         $this->throw_error('80013');
     } else {
         if ($inherit_equip_info['sub_type'] == 7 || $be_inherit_equip_info['sub_type'] == 7) {
             $this->throw_error('10110');
             #数据错误
         }
     }
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
     if (empty($player_detail['wing_info'][$inherit_equip_info['vocation_limit']]) || empty($player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']])) {
         $this->throw_error('10110');
         #数据错误
     }
     $inherit_table = Cache_WingEquipment::getInstance()->get_wing_equip_inherit_info(array('item_level' => $be_inherit_equip_info['level']));
     if (empty($inherit_table)) {
         $this->throw_error('10109');
         #配置表读取错误
     } else {
         if (empty($inherit_table['expend_prop'])) {
             $this->throw_error('150022');
             #wing_equip_inherit配置表的expend_prop字段配置错误
         }
     }
     $prop_list = $this->format_table_field($inherit_table['expend_prop']);
     if (!Com_Array::is_good_arr($prop_list)) {
         $this->throw_error('150022');
         #wing_equip_inherit配置表的expend_prop字段配置错误
     }
     #道具检测
     $arr_consume = array();
     foreach ($prop_list as $id => $num) {
         if (empty($id) || empty($num)) {
             $this->throw_error('150022');
             #wing_equip_inherit配置表的expend_prop字段配置错误
         }
         $cost_currency_key = Cache_Currency::getInstance()->get_key($id);
         if ($cost_currency_key == 'prop') {
             #传承装备和继承装备等级不同时,才需要消耗道具
             if ($inherit_equip_info['level'] != $be_inherit_equip_info['level']) {
                 $this->get_game('Prop')->check_player_prop($player_id, $player_info, $id, $num, $arr_consume);
             }
         } else {
             if (empty($cost_currency_key)) {
                 $this->throw_error('150022');
                 #wing_equip_inherit配置表的expend_prop字段配置错误
             }
             $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $num, 1, $id);
         }
     }
     #如果是已装备的,传承前先清楚原来的装备属性
     if ($inherit_equip_info['item_position'] == $this->wing_pos) {
         $wing_attr = $player_detail['wing_info'][$inherit_equip_info['vocation_limit']];
         $wing_attr['equipment'][$inherit_equip_info['sub_type']] = array();
         $arr_remove_prop_detail = $inherit_equip_info;
         Struct_Prop::get_item_additions($arr_remove_prop_detail);
         $wing_attr['fight'] -= $arr_remove_prop_detail['fpower'];
         $wing_attr['fight'] = $wing_attr['fight'] > 0 ? $wing_attr['fight'] : 0;
         $wing_attr['equipment_fight'] -= $arr_remove_prop_detail['fpower'];
         $wing_attr['equipment_fight'] = $wing_attr['equipment_fight'] > 0 ? $wing_attr['equipment_fight'] : 0;
         $player_detail['wing_info'][$inherit_equip_info['vocation_limit']] = $wing_attr;
     }
     if ($be_inherit_equip_info['item_position'] == $this->wing_pos) {
         $be_wing_attr = $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']];
         $be_wing_attr['equipment'][$be_inherit_equip_info['sub_type']] = array();
         $arr_remove_prop_detail = $be_inherit_equip_info;
         Struct_Prop::get_item_additions($arr_remove_prop_detail);
         $be_wing_attr['fight'] -= $arr_remove_prop_detail['fpower'];
         $be_wing_attr['fight'] = $be_wing_attr['fight'] > 0 ? $be_wing_attr['fight'] : 0;
         $be_wing_attr['equipment_fight'] -= $arr_remove_prop_detail['fpower'];
         $be_wing_attr['equipment_fight'] = $be_wing_attr['equipment_fight'] > 0 ? $be_wing_attr['equipment_fight'] : 0;
         $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']] = $be_wing_attr;
     }
     #传承
     $update_equip_list = $this->get_inherit_wing_equip($inherit_equip_info, $be_inherit_equip_info);
     $is_update_wing = false;
     $is_update_be_wing = false;
     #如果是已装备的,重新计算翅膀战斗力
     if ($inherit_equip_info['item_position'] == $this->wing_pos) {
         $wing_attr = $player_detail['wing_info'][$inherit_equip_info['vocation_limit']];
         $wing_attr['equipment'][$inherit_equip_info['sub_type']] = $inherit_equip_info;
         $wing_attr['equip_attr'] = $this->get_wing_equip_attr($wing_attr['equipment']);
         $arr_prop_detail = $inherit_equip_info;
         Struct_Prop::get_item_additions($arr_prop_detail);
         $wing_attr['fight'] += $arr_prop_detail['fpower'];
         $wing_attr['equipment_fight'] += $arr_prop_detail['fpower'];
         $player_detail['wing_info'][$inherit_equip_info['vocation_limit']] = $wing_attr;
         $is_update_wing = true;
     }
     if ($be_inherit_equip_info['item_position'] == $this->wing_pos) {
         $be_wing_attr = $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']];
         $be_wing_attr['equipment'][$be_inherit_equip_info['sub_type']] = $be_inherit_equip_info;
         $be_wing_attr['equip_attr'] = $this->get_wing_equip_attr($be_wing_attr['equipment']);
         $arr_prop_detail = $be_inherit_equip_info;
         Struct_Prop::get_item_additions($arr_prop_detail);
         $be_wing_attr['fight'] += $arr_prop_detail['fpower'];
         $be_wing_attr['equipment_fight'] += $arr_prop_detail['fpower'];
         $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']] = $be_wing_attr;
         $is_update_be_wing = true;
     }
     $this->start_trans();
     #更新道具属性
     if (!empty($update_equip_list[$inherit_equip_pid])) {
         $update_res = $this->get_data('PlayerProp')->update_player_prop($inherit_equip_info, $update_equip_list[$inherit_equip_pid]);
         if (!$update_res) {
             $this->throw_error('10104');
         }
     }
     if (!empty($update_equip_list[$be_inherit_equip_pid])) {
         $update_res = $this->get_data('PlayerProp')->update_player_prop($be_inherit_equip_info, $update_equip_list[$be_inherit_equip_pid]);
         if (!$update_res) {
             $this->throw_error('10104');
         }
     }
     #更新翅膀战斗力
     if ($is_update_wing || $is_update_be_wing) {
         $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info']));
         if (!$update_res) {
             $this->throw_error('10104');
         }
     }
     foreach ($prop_list as $id => $num) {
         if (empty($id) || empty($num)) {
             $this->throw_error('150022');
             #wing_equip_inherit配置表的expend_prop字段配置错误
         }
         $cost_currency_key = Cache_Currency::getInstance()->get_key($id);
         if ($cost_currency_key == 'prop') {
             #传承装备和继承装备等级不同时,才需要消耗道具
             if ($inherit_equip_info['level'] != $be_inherit_equip_info['level']) {
                 $this->get_game('Prop')->dedcut_player_prop($player_id, $player_info, 1512);
             }
         } else {
             if (empty($cost_currency_key)) {
                 $this->throw_error('150022');
                 #wing_equip_inherit配置表的expend_prop字段配置错误
             }
             #扣货币
             $deduct_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1512, array(), $arr_consume);
             if (!$deduct_res) {
                 $this->throw_error('10104');
             }
         }
     }
     if ($is_update_wing && $player_detail['wing_info'][$inherit_equip_info['vocation_limit']]['fight'] > 0) {
         $wing_fight = $player_detail['wing_info'][$inherit_equip_info['vocation_limit']]['fight'];
         $this->get_data('RankList')->update_wing_rank($player_id, $inherit_equip_info['vocation_limit'], $wing_fight);
     }
     if ($is_update_be_wing && $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']]['fight'] > 0) {
         $wing_fight = $player_detail['wing_info'][$be_inherit_equip_info['vocation_limit']]['fight'];
         $this->get_data('RankList')->update_wing_rank($player_id, $be_inherit_equip_info['vocation_limit'], $wing_fight);
     }
     $this->commit();
     $ndata = array();
     if (!$is_update_wing) {
         $ndata[] = $inherit_equip_info;
     }
     if (!$is_update_be_wing) {
         $ndata[] = $be_inherit_equip_info;
     }
     if (!empty($ndata)) {
         #806通知前端道具属性变更
         Protocol_Prop::prop_806($player_id, $ndata);
     }
     if ($is_update_wing || $is_update_be_wing) {
         #同步翅膀属性
         $str = $this->get_activation_wing_interface($player_id, $player_detail['wing_info']);
         Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']))));
     }
     $rtn_data = array('inherit_equip_info' => empty($inherit_equip_info) ? array() : Struct_Prop::get_prop_struct($inherit_equip_info), 'be_inherit_equip_info' => empty($be_inherit_equip_info) ? array() : Struct_Prop::get_prop_struct($be_inherit_equip_info));
     return $rtn_data;
 }
Example #23
0
 public function gain_free_reward($player_id, $plm_id)
 {
     $this->param_check_numeric(array($player_id, $plm_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取议会配置信息
     $plm_conf = Cache_MagicParliament::getInstance()->get_parliament_conf($plm_id);
     if (empty($plm_conf)) {
         $this->throw_error('100002');
         # 获取魔法议会配置失败
     }
     # 议会免费奖励领取上限
     $free_reward_gain_stint = $this->get_free_reward_gain_stint($plm_id, $plm_conf);
     # 获取玩家当日免费奖励领取次数
     $free_reward_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     # 判断上限
     if ($free_reward_num >= $free_reward_gain_stint) {
         $this->throw_error('100008');
         #  魔法议会免费领奖次数超过上限
     }
     $this->start_trans();
     # 更新免费奖励领取次数
     $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     $this->write_check($re, 3010223);
     # 发放免费奖励
     $reward = array();
     $reward_detail = $this->get_game('Reward')->get_reward_detail($plm_conf['free_reward']);
     $this->get_game('Reward')->gen_reward_array($reward_detail, $reward);
     if (!empty($reward)) {
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2506'), 1);
         $this->write_check_strict($re, 3010411);
     }
     # 记录行为日志
     $action_log = array('player_id' => $player_id, 'reg_time' => $this->current_time, 'plm_id' => $plm_id, 'action_type' => 3, 'reward_info' => json_encode($reward_detail));
     $re = $this->get_data('MagicParliament')->record_action_log($action_log);
     $this->write_check_strict($re, 3010445);
     $this->commit();
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $ret = $this->get_game('Reward')->add_reward_log(true);
     # 刷新议会信息
     $out_2503 = $this->init_magic_parliament_deatil($player_id, $plm_id);
     Protocol::input($player_id, 3, 25, 2503, $out_2503);
     # 记录行为
     Com_Log::debug_write('xgame.magic_parliament', "{$player_id}\t" . "gain_free_reward\t" . "{$plm_id}\t");
     $out_2506 = array();
     return $out_2506;
 }
Example #24
0
 public function buy($player_id, $map_id, $question_id, $buy_type)
 {
     $this->param_check_numeric(array($player_id, $map_id, $question_id));
     # --------------------------------------------------------------------
     # 获取购买消耗信息,购买次数,
     # --------------------------------------------------------------------
     if ($buy_type == 1) {
         $buy_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->daily_double_reward_buy_num_normal);
         $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info($this->double_reward_buy_type_normal, 1);
         $dr_status = $this->get_data('AthenaQuestion')->get_question_double_reward_status($player_id, $map_id, $question_id);
         if ($dr_status) {
             $this->throw_error('190007');
             # 该题已购买过双倍奖励
         }
         $cmd2 = 1152;
     } elseif ($buy_type == 2) {
         $buy_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->daily_peek_buy_num);
         $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info($this->peek_answer_buy_type, 1);
         $cmd2 = 1153;
     } else {
         $this->throw_error('10107');
         # 参数错误
     }
     if (empty($buy_num)) {
         $buy_num = 0;
     }
     if ($buy_num >= $buy_times_info['max_times']) {
         $this->throw_error('10225');
         # 已达到最大购买次数
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取消耗资源类型与值
     list($cost_currency_type, $cost_currency_value) = $this->get_next_buy_price($buy_num, $buy_times_info);
     $this->start_trans();
     # 消耗虚拟货币
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, $cmd2, array(), $arr_consume);
     $this->write_check($re, 3010179);
     # 更新购买次数
     if ($buy_type == 1) {
         $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->daily_double_reward_buy_num_normal, 1);
         $this->write_check($re, 3010197);
         # 该题号标记双倍奖励状态
         $re = $this->get_data('AthenaQuestion')->set_question_double_reward_status($player_id, $map_id, $question_id);
         $this->write_check($re, 3010201);
         # 通知C++购买双倍奖励
         Protocol::input($player_id, 7, 4, 553, array('question_id' => $question_id, 'double_score' => 1, 'cheat_answer' => 0));
     } elseif ($buy_type == 2) {
         $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->daily_peek_buy_num, 1);
         $this->write_check($re, 3010197);
         # 通知C++购买偷看答案
         Protocol::input($player_id, 7, 4, 553, array('question_id' => $question_id, 'double_score' => 0, 'cheat_answer' => 1));
     }
     $this->commit();
     list($cost_currency_type, $cost_currency_value) = $this->get_next_buy_price($buy_num + 1, $buy_times_info);
     $cost_currency_info = "{$cost_currency_type}:{$cost_currency_value}";
     $out = array('result' => 1, 'next_buy_price' => $cost_currency_info, 'buy_num' => $buy_num + 1);
     return $out;
 }