コード例 #1
0
ファイル: UnionPlayer.php プロジェクト: bluefan/phpsource
 /**
  * 全服邀请
  */
 public function all_service_invite_union($player_id)
 {
     $player_id = intval($player_id);
     $playerInfo = $this->get_data('Player')->get_player_info($player_id, array("union_id", "silver", "union_name", "gold", "ticket", "level", "vip", "name", "union_job", "privilege_level"));
     if (!$playerInfo['union_id']) {
         $this->throw_error('171101');
         //没有加入公会
     }
     $union_conf = Cache_UnionBase::getInstance()->get_union_conf();
     if (empty($union_conf)) {
         $this->throw_error(10222, 5011990);
     }
     if (!isset($union_conf['world_invite'])) {
         $this->throw_error(10222, 5011993);
     }
     list($cost_currency_type, $cost_currency_value) = explode(":", $union_conf['world_invite']);
     # 消耗虚拟货币
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($playerInfo, $cost_currency_key, $cost_currency_value);
     $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     $re = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, '1789', array(), $arr_consume);
     $this->write_check($re, 5012009);
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 7, 'txt' => $playerInfo['union_name']);
     $arr_replace[] = array('rep_type' => 10, 'txt' => "#1", 'rep_val' => 1703, 'rep_param' => array($playerInfo['union_id']));
     $msg = Language_Message::make_message(178901, $arr_replace, 0, '', true);
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 1, 1);
 }
コード例 #2
0
ファイル: AutoPve.php プロジェクト: bluefan/phpsource
 /**
  * 毁灭奥克兰副本复活
  * @param unknown $player_id
  * $type 1消耗 2不消耗
  */
 public function destroy_akland_relive($player_id, $type)
 {
     $type = intval($type);
     if ($type == 1) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array("privilege_level", "ticket", "level", "vip", "map_id", "gold", 'player_id'));
         # 消耗虚拟货币
         $cost_currency_type = 2;
         $cost_currency_value = 5;
         $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
         $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
         $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '748', array(), $arr_consume);
         $this->write_check($re, 5010174);
         $this->start_trans();
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 748, array(), $arr_consume);
         $this->write_check($re, 5010177);
     }
     $this->commit();
     Protocol::input($player_id, 7, 4, 560, array($type));
 }
コード例 #3
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);
 }
コード例 #4
0
ファイル: EquipInherit.php プロジェクト: bluefan/phpsource
 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;
     }
 }
コード例 #5
0
ファイル: GetBackCurrency.php プロジェクト: bluefan/phpsource
 /**
  * 领取所有资源
  * @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);
 }
コード例 #6
0
ファイル: OfflineReward.php プロジェクト: bluefan/phpsource
 /**
  * 获取离线奖励
  * @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);
 }
コード例 #7
0
ファイル: UnionGrabDomain.php プロジェクト: bluefan/phpsource
 /**
  * 购买次数
  * @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);
     }
 }
コード例 #8
0
ファイル: GrabTreasure.php プロジェクト: bluefan/phpsource
 /**
  * 购买挑战次数
  * @param unknown $player_id
  */
 public function buy_grab_treasure_times($player_id)
 {
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'gold', 'silver', 'ticket', 'privilege_level', 'vip'));
     # 获取当日已挑战次数及其购买次数
     $battle_buy_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grab_treasure_battle_buy_times');
     if (empty($battle_buy_num)) {
         $battle_buy_num = 0;
     }
     # 获取购买消耗信息
     $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info($this->grab_treasure_battle_buy_type, 1);
     # 获取购买次数上限
     $buy_stint = $this->get_grab_treasure_num_buy_stint($player_id, $this->grab_treasure_battle_buy_type, $buy_times_info);
     # 购买次数上限检查
     if ($battle_buy_num >= $buy_stint) {
         $this->throw_error('10225');
         # 已达到最大购买次数
     }
     # 获取消耗资源类型与值
     $cost_currency_type = $buy_times_info['cost_type'];
     $cost_currency_value = Cache_BuyTimes::getInstance()->cal_buy_price($battle_buy_num, $buy_times_info['cost_num'], "|", 1);
     $this->start_trans();
     # 消耗虚拟货币
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '1223', array(), $arr_consume);
     $this->write_check($re, 5010391);
     # 更新当日挑战次数及挑战次数购买次数
     $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'grab_treasure_battle_buy_times', 1);
     $this->write_check($re, 5010395);
     $this->commit();
     # 当前挑战次数上限
     $current_battle_num_max = ($battle_buy_num + 1) * $buy_times_info['per_num'] + $this->grab_treasure_max_times;
     # 剩余挑战次数可购买次数
     $battle_num_buy_remain = $buy_stint - $battle_buy_num - 1 > 0 ? $buy_stint - $battle_buy_num - 1 : 0;
     list($cost_currency_type, $cost_currency_value) = $this->get_grab_treasure_battle_next_buy_price($player_id, $buy_times_info);
     $battle_num_next_buy_price = "{$cost_currency_type}:{$cost_currency_value}";
     $out = array('current_battle_num_max' => $current_battle_num_max, 'battle_num_buy_remain' => $battle_num_buy_remain, 'battle_num_next_buy_price' => $battle_num_next_buy_price);
     # 提示购买成功消息
     $message = array('texts' => array(), 'delay' => 0);
     $message['texts'][] = array('code' => 10237, 'content' => array(), 'params' => array());
     Protocol::input($player_id, 3, 7, 742, $message);
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040);
     return $out;
 }
コード例 #9
0
ファイル: Finance.php プロジェクト: bluefan/phpsource
 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;
 }
コード例 #10
0
ファイル: KFDuel.php プロジェクト: bluefan/phpsource
 /**
  * 复活
  * @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;
 }
コード例 #11
0
ファイル: TaskHandler.php プロジェクト: bluefan/phpsource
 /**
  * 刷新任务榜单
  * @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;
 }
コード例 #12
0
 protected function equip_intensify_handle($flag, $player_id, $player_gems, $player_info, $player_equip_info, $intensify_config, $auto_buy, $bless_item_id)
 {
     if ($flag) {
         # 成功
         $player_equip_info['intensive_lose_times'] = 0;
         $player_equip_info['intensive_level'] += 1;
         $player_equip_info['intensive_desc'] = Game_EquipIntensifier::get_latest_intensive_desc($player_equip_info, $intensify_config);
         if ($player_equip_info['star_map_id']) {
             # 获取最新星图状态desc
             $player_equip_info['star_map_desc'] = $this->get_game('EquipStarMap')->get_latest_starmap_desc($player_equip_info);
         }
     } else {
         # 失败
         $player_equip_info['intensive_lose_times'] += 1;
     }
     $this->start_trans();
     # 玩家银两更新
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $intensify_config['silver_num'], 1, 1);
     # 强化特效信息更新
     $equip_view = $player_equip_info['equip_view'];
     if ($equip_view[0]) {
         $weapon_effect = Cache_WeaponEffect::getInstance()->get_weapon_effect($equip_view[0], $player_equip_info['intensive_level']);
         if ($weapon_effect && $weapon_effect['effect_id']) {
             $equip_view[2] = $weapon_effect['effect_id'];
         }
     }
     $equip_update_field = array('intensive_lose_times' => $player_equip_info['intensive_lose_times'], 'intensive_level' => $player_equip_info['intensive_level'], 'intensive_desc' => $player_equip_info['intensive_desc'], 'star_map_desc' => $player_equip_info['star_map_desc'], 'equip_view' => $equip_view);
     $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $equip_update_field);
     $this->write_check($re, 3010414);
     $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 816);
     # 消耗祝福石
     if (!empty($bless_item_id)) {
         $arr_logs_bless_item = array();
         $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $bless_item_id, 1, $arr_logs_bless_item, 0, $log_param);
         $this->write_check($re, 3010422);
     }
     # 消耗强化宝石和钻石【勾选自动购买时当所需强化宝石不足时需要消耗钻石】
     $gem_cost_num = $intensify_config['item_num'];
     $cost_currency_type = 0;
     $cost_currency_value = 0;
     $price = 0;
     if ($auto_buy) {
         if ($player_gems < $intensify_config['item_num']) {
             $gem_cost_num = $player_gems;
             # 获取正确的强化宝石的单价
             $intensify_gem_info = $this->get_game('Shop')->shortcut_purchase_interface($intensify_config['item_id'], 1);
             if (empty($intensify_gem_info['item_price'])) {
                 $this->throw_error('80318');
                 # 商城强化宝石没有配置价格
             }
             # 策划价格配置多项时,选其中一项
             list($cur_type, $cur_val) = each($intensify_gem_info['item_price']);
             $price = $cur_val;
             $cost_currency_type = $cur_type;
             $cost_currency_value = intval($cur_val * ($intensify_config['item_num'] - $player_gems));
         }
     }
     if ($gem_cost_num > 0) {
         $arr_logs_gem = array();
         $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $intensify_config['item_id'], $gem_cost_num, $arr_logs_gem, 0, $log_param);
         $this->write_check($re, 3010449);
     }
     # 消耗虚拟货币
     if ($cost_currency_value > 0) {
         $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
         $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, intval($intensify_config['item_num'] - $player_gems));
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     }
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '816', array(), $arr_consume);
     $this->write_check($re, 3010476);
     $this->commit();
     # 若有购买缺少材料,记录虚假商城购买日志
     if ($cost_currency_value > 0) {
         $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $intensify_config['item_id'], intval($intensify_config['item_num'] - $player_gems), $cost_currency_type, $cost_currency_value, 816);
     }
     # 刷新玩家属性
     if ($player_equip_info['item_position'] == 3) {
         $this->get_game('EquipAttr')->equip_attr($player_id);
     }
     # 粘806 + 通知道具变更信息
     $ndata = array();
     $ndata[] = $player_equip_info;
     if (!empty($arr_logs_gem) && is_array($arr_logs_gem)) {
         foreach ($arr_logs_gem as $k => $v) {
             # 消耗的宝石
             $ndata[] = $v;
         }
     }
     if (!empty($arr_logs_bless_item)) {
         # 消耗的祝福石,祝福石只消耗1个
         $ndata[] = $arr_logs_bless_item[0];
     }
     Protocol_Prop::prop_806($player_id, $ndata);
     # 通知玩家信息变更[必须放在commit之后]
     return $player_equip_info['intensive_desc'];
 }
コード例 #13
0
ファイル: GrabMine.php プロジェクト: bluefan/phpsource
 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;
 }
コード例 #14
0
ファイル: S2P_4.php プロジェクト: bluefan/phpsource
 public function CMD2_557()
 {
     # 消耗虚拟货币
     $player_id = $this->_authuser['player_id'];
     $out = array('player_id' => $player_id, "code" => 0);
     $cost_currency_key = Cache_Currency::getInstance()->get_key(20);
     $cost_currency_value = 1;
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'gold', 'silver', 'ticket', 'privilege_level', 'vip'));
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value);
     $re = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 0, 20);
     if ($re !== true) {
         $out['code'] = 1;
     } else {
         $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '557', array(), $arr_consume);
         if (!$re) {
             $out['code'] = 1;
         }
     }
     Protocol::input($this->_authuser['player_id'], 5, 4, 557, $out);
 }
コード例 #15
0
ファイル: Finance_v1.php プロジェクト: bluefan/phpsource
 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;
 }
コード例 #16
0
ファイル: Hero.php プロジェクト: bluefan/phpsource
 /**
  * @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');
     }
 }
コード例 #17
0
ファイル: Challenge.php プロジェクト: bluefan/phpsource
 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;
 }
コード例 #18
0
ファイル: Shop.php プロジェクト: bluefan/phpsource
 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;
 }
コード例 #19
0
ファイル: Event.php プロジェクト: bluefan/phpsource
 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;
 }
コード例 #20
0
ファイル: MagicParliament.php プロジェクト: bluefan/phpsource
 public function use_privilege($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) || empty($plm_conf['use_privilege_cost_res'])) {
         $this->throw_error('100002');
         # 获取魔法议会配置失败
     }
     # 获取玩家当日行使特权次数
     $use_privilege_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_use_privilege_num_prefix, $plm_conf['plm_id']));
     # 判断上限
     if ($use_privilege_num >= $plm_conf['use_privilege_stint']) {
         $this->throw_error('100006');
         # 魔法议会占星|秘典|提案|试炼次数超过当日上限
     }
     # 判断权限
     $title_info_hash = $this->get_title_info_hash();
     if (!isset($title_info_hash[$plm_conf['use_privilege_req_title_id']]['title_holder'][$player_id])) {
         $this->throw_error('100007');
         # 未达到称号要求
     }
     # 获取议会人气值
     if ($plm_conf['plm_id'] == $this->sage_plm_id) {
         $popularity = $this->get_cross('PlayerDailyTime')->get_any_used_time($this->get_redis_key($this->daily_popularity_prefix, $plm_conf['plm_id']));
     } else {
         $popularity = $this->get_data('PlayerDailyTime')->get_any_used_time($this->get_redis_key($this->daily_popularity_prefix, $plm_conf['plm_id']));
     }
     # 获取人气值修正信息 && 等级修正信息 && 合并两个修正为一个
     $revise_info_1 = Cache_MagicParliament::getInstance()->get_revise_1($plm_conf['plm_id'], $popularity);
     $revise_info_2 = Cache_MagicParliament::getInstance()->get_revise_2($plm_conf['plm_id'], $player_info['level']);
     if (empty($revise_info_1)) {
         $this->throw_error('100003');
         # 获取人气值修正信息配置失败
     }
     if (empty($revise_info_2)) {
         $this->throw_error('100004');
         # 获取等级修正信息配置失败
     }
     $this->start_trans();
     # 资源消耗
     $cost_revise_array = $this->get_game('Reward')->merge_revise_info(array($revise_info_1['privilege_cost_revise'], $revise_info_2['privilege_cost_revise']), 1);
     $res_cost_list = explode("|", $plm_conf['use_privilege_cost_res']);
     foreach ($res_cost_list as $res_cost_string) {
         list($cost_cur_id, $cost_cur_val) = explode(":", $res_cost_string);
         if (!empty($cost_revise_array[$cost_cur_id])) {
             $cost_cur_val = intval($cost_cur_val * $cost_revise_array[$cost_cur_id] / 10000);
         }
         $cost_cur_key = Cache_Currency::getInstance()->get_key($cost_cur_id);
         $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_cur_key, $cost_cur_val);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_cur_key, $cost_cur_val, 1, 1);
     }
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2505', array(), $arr_consume);
     $this->write_check($re, 3010225);
     # 更新特权使用次数
     $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->get_redis_key($this->daily_use_privilege_num_prefix, $plm_conf['plm_id']));
     $this->write_check($re, 3010223);
     # 发放特权奖励
     $reward = array();
     $reward_revise_string = $this->get_game('Reward')->merge_revise_info(array($revise_info_1['privilege_reward_revise'], $revise_info_2['privilege_reward_revise']));
     $reward_detail = $this->get_game('Reward')->get_reward_detail_other_way($plm_conf['use_privilege_reward'], $reward_revise_string, 1);
     $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' => '2505'), 1);
         $this->write_check_strict($re, 3010274);
     }
     # 清空人气值 && 增加免费奖励累计次数
     if ($plm_conf['plm_id'] == $this->sage_plm_id) {
         $re = $this->get_cross('PlayerDailyTime')->set_any_used_time($this->get_redis_key($this->daily_popularity_prefix, $plm_conf['plm_id']), 0);
         $this->write_check_strict($re, 3010335);
         $re = $this->get_cross('PlayerDailyTime')->add_global_used_time($this->get_redis_key($this->daily_free_reward_num_acc_prefix, $plm_conf['plm_id']));
         $this->write_check_strict($re, 3010339);
     } else {
         $re = $this->get_data('PlayerDailyTime')->set_any_used_time($this->get_redis_key($this->daily_popularity_prefix, $plm_conf['plm_id']), 0);
         $this->write_check_strict($re, 3010345);
         $re = $this->get_data('PlayerDailyTime')->add_global_used_time($this->get_redis_key($this->daily_free_reward_num_acc_prefix, $plm_conf['plm_id']));
         $this->write_check_strict($re, 3010349);
     }
     # 记录行为日志
     $action_log = array('player_id' => $player_id, 'reg_time' => $this->current_time, 'plm_id' => $plm_id, 'action_type' => 2, 'reward_info' => json_encode($reward_detail));
     $re = $this->get_data('MagicParliament')->record_action_log($action_log);
     $this->write_check_strict($re, 3010369);
     $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" . "use_privilege\t" . "{$plm_id}\t" . json_encode($cost_revise_array) . "\t" . "{$reward_revise_string}\t");
     $out_2505 = array();
     return $out_2505;
 }
コード例 #21
0
ファイル: AthenaQuestion.php プロジェクト: bluefan/phpsource
 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;
 }