Beispiel #1
0
 public function run($player_id, $exec_num)
 {
     if (empty($player_id) || empty($exec_num)) {
         return array();
     }
     echo "</br>==========start[player_id={$player_id}&exec_num={$exec_num}]===========</br>";
     echo "</br></br>";
     $result_hash = array();
     foreach ($this->item_for_loot as $ifl_id) {
         $result_tmp = array();
         echo "</br>==========loop {$exec_num} times statistic for {$ifl_id}===========</br>";
         $item_config = Cache_Prop::getInstance()->get_prop_info($ifl_id);
         if (empty($item_config)) {
             continue;
         }
         for ($i = 0; $i < $exec_num; $i++) {
             $item_list = Cache_FbLoot::getInstance()->get_loot($item_config['loot_id'], $player_id);
             foreach ($item_list as $item) {
                 foreach ($this->item_for_stat as $ifs_id) {
                     if ($item['item_id'] == $ifs_id) {
                         $result_tmp[$ifs_id] += $item['item_num'];
                         $result_hash[$ifs_id] += $item['item_num'];
                     }
                 }
             }
         }
         var_export($result_tmp);
         echo "</br></br>";
     }
     return $result_hash;
 }
Beispiel #2
0
 public function Game_Over($player_id, $sid, $reward, $score = 0, $kill_count = 0, $is_win = 0, $silver = 0)
 {
     $player_id = intval($player_id);
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('player_id', 'gm', 'is_dummy'));
     if ($player_info['player_id'] <= 0 || $player_info['is_dummy'] > 0) {
         return false;
     }
     $used_time = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id);
     #只发一次奖励
     if (!isset($used_time['flame_battle_count']) || $used_time['flame_battle_count'] == 0 && $reward > 0) {
         $send_reward = array(array('type' => Cache_FbLoot::getInstance()->get_item_key(17), 'item_id' => 17, 'item_num' => $reward));
         if ($silver > 0) {
             $send_reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key(3), 'item_id' => 3, 'item_num' => $silver);
         }
         $result_s = $this->get_game('Reward')->send_reward($player_id, $send_reward, array('cmd_id' => '2018', 'bind_flag' => 0), 1);
         if (true === $result_s) {
             $this->get_game('Reward')->add_reward_log();
             //记录日志
             if (!empty($player_info) && ($player_info['gm'] == 0 || $player_info['gm'] == 3) && $player_info['is_dummy'] == 0) {
                 $this->get_data('FlameBattle')->set_level_list($player_id, $kill_count);
             }
             $this->get_data('FlameBattle')->set_flame_battle_data($player_id, array('total_score' => '+' . $reward));
         }
         $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'flame_battle_count');
         $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 3010, 1);
         $this->get_game('PlayerFunc')->sync_func_tips($player_id, 4100);
         //找回资源埋点
         $this->get_game('GetBackCurrency')->add_function_day_times($player_id, 15);
     }
     $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'flame_inspire_gold_count');
     #判断是否比上次大---活动
     if ($kill_count > $used_time['flame_battle_kill_count']) {
         $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'flame_battle_kill_count', $kill_count);
     }
     if ($is_win > $used_time['flame_battle_is_win']) {
         $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'flame_battle_is_win', $is_win);
     }
     if ($reward > $used_time['flame_battle_score']) {
         #改为可以兑换的战场积分
         $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'flame_battle_score', $reward);
     }
 }
Beispiel #3
0
 /**
  * 同意入会
  */
 public function agree_join($player_id, $agree_player_id, $union_id)
 {
     $agree_player_id = intval($agree_player_id);
     $union_id = intval($union_id);
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id);
     $this->start_trans();
     //检查操作权限
     if ($player_id != $agree_player_id) {
         $manager_auth = array(1, 2, 4);
         $this->check_option_auth($player_id, $unionPlayerInfo, $manager_auth);
     }
     $unionCreatConfig = Cache_UnionCreat::getInstance()->get_union_creat(2);
     $field = Cache_FbLoot::getInstance()->get_item_key($unionCreatConfig['cost_type']);
     $objPlayerData = $this->get_data('Player');
     $playerInfo = $objPlayerData->get_player_info($agree_player_id, array("is_online", "ticket", "union_id", "level", "vip", "privilege_level", $field));
     $objUnionApplyData = $this->get_data('UnionApply');
     $applyInfo = $objUnionApplyData->get_union_apply($union_id, $agree_player_id);
     if ($playerInfo["union_id"]) {
         if ($applyInfo) {
             //申请过其它公会记录删除
             $this->sys_clear_union_apply($agree_player_id);
         }
         $this->throw_error('170301');
         //已加入过公会
     }
     $arr_consume = array();
     if ($player_id != $agree_player_id) {
         if (!$applyInfo) {
             $this->throw_error('170502');
             //未找到申请记录
         }
     } else {
         if ($playerInfo['level'] < $unionCreatConfig['level_need']) {
             $this->throw_error('170110');
             //level等级不足
         }
         $cost_num = $unionCreatConfig['cost_num'];
         //消耗资源
         if ($unionCreatConfig['cost_num']) {
             if ($field == "gold") {
                 $ticket = 0;
                 if ($playerInfo['ticket'] > 0) {
                     if ($playerInfo['ticket'] >= $unionCreatConfig['cost_num']) {
                         $ticket = $unionCreatConfig['cost_num'];
                         $this->get_data('Player')->check_player_resource($agree_player_id, $playerInfo, '-', 'ticket', $unionCreatConfig['cost_num']);
                         $unionCreatConfig['cost_num'] = 0;
                     } else {
                         $ticket = $playerInfo['ticket'];
                         $unionCreatConfig['cost_num'] = $unionCreatConfig['cost_num'] - $playerInfo['ticket'];
                         $this->get_data('Player')->check_player_resource($agree_player_id, $playerInfo, '-', 'ticket', $playerInfo['ticket']);
                     }
                 }
                 $arr_consume = array('price' => $cost_num, 'gold' => $unionCreatConfig['cost_num'], 'ticket' => $ticket, 'count' => 1);
                 #数据中心推送
             }
             $this->get_data('Player')->check_player_resource($agree_player_id, $playerInfo, "-", $field, $unionCreatConfig['cost_num']);
         }
     }
     $objUnionInfoData = $this->get_data('UnionInfo');
     $unionInfo = $objUnionInfoData->get_union_info($union_id, array("player_num", "union_level", "union_name", "union_medal"));
     $unionBaseConfig = Cache_UnionBase::getInstance()->get_union_base_info($unionInfo["union_level"]);
     if ($unionInfo['player_num'] >= $unionBaseConfig['member_nums']) {
         $this->throw_error('170503');
         //人数已满
     }
     //加锁
     if (!Com_Lock::lock('lock|union_player|player_num|union_id=' . $union_id)) {
         //系统繁忙
         $this->throw_error('170501');
     }
     $retUnionPlayerHisInfo = true;
     $unionPlayer = array();
     $quit_time = 0;
     //玩家离开公会后,只要不加入到其他公会,其在原公会的所有贡献将不会被清空
     $objUnionPlayerHisData = $this->get_data('UnionPlayerHis');
     $playerHisData = $objUnionPlayerHisData->get_union_player_info($agree_player_id);
     if ($playerHisData) {
         if ($playerHisData['union_id'] == $union_id) {
             $playerHisData['job_id'] = $this->union_default_job_id;
             $playerHisData['add_time'] = time();
             $unionPlayer = $playerHisData;
         } else {
             $quit_time = $playerHisData['quit_time'];
         }
         //清除每日贡献
         $this->get_data("PlayerDailyTime")->set_used_time($agree_player_id, "union_player_contribute", 0);
         $retUnionPlayerHisInfo = $objUnionPlayerHisData->del_union_player($agree_player_id);
     }
     $this->get_game('UnionWanted')->init_player_union_wanted($agree_player_id, $union_id);
     if (empty($unionPlayer)) {
         //公会成员
         $unionPlayer['player_id'] = $agree_player_id;
         $unionPlayer['job_id'] = $this->union_default_job_id;
         $unionPlayer['total_dedicate'] = 0;
         //总贡献
         $unionPlayer['rep_time'] = time();
         $unionPlayer['add_time'] = time();
         $unionPlayer['quit_time'] = $quit_time;
     }
     $unionInfo['player_num'] = "+1";
     Com_Log::debug_write('update_union_info', "agree_join|unoin_id={$union_id}" . json_encode($unionInfo));
     $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $unionInfo);
     $retUnionPlayerInfo = $objUnionPlayerData->update_union_player_info($union_id, $agree_player_id, $unionPlayer);
     $setPlayerInfo = array("union_id" => $union_id, "union_name" => $unionInfo['union_name'], "union_job" => $unionPlayer['job_id']);
     if ($player_id == $agree_player_id && $cost_num) {
         $retPlayerInfo = $this->get_data('Player')->update_player_resource($agree_player_id, $playerInfo, 1705, $setPlayerInfo, $arr_consume);
     } else {
         $retPlayerInfo = $this->get_data('Player')->update_player_info($agree_player_id, $setPlayerInfo);
     }
     $retUnionApply = true;
     if ($player_id != $agree_player_id) {
         $retUnionApply = $objUnionApplyData->del_player_apply($union_id, $agree_player_id);
     }
     if ($retUnionPlayerInfo && $retUnionInfo && $retPlayerInfo && $retUnionApply && $retUnionPlayerHisInfo) {
         $this->commit();
         $this->get_game('Union')->Sync_Union_msg($union_id);
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     Protocol::input($player_id, 7, 4, 511, array($agree_player_id, $union_id, 0));
     if ($player_id == $agree_player_id) {
         $data = $this->get_game('UnionBase')->union_base_info($agree_player_id, $union_id);
         Protocol::input($player_id, 8, 17, 1707, $data);
     }
     //添加日志
     $objUnionBaseGame = $this->get_game('UnionBase');
     $objUnionBaseGame->sys_add_union_log($agree_player_id, $union_id, 173401);
     //清除申请其它公会记录
     $this->sys_clear_union_apply($agree_player_id);
     //添加公会勋章属性
     if (Com_Array::is_good_arr($unionInfo['union_medal'])) {
         $medal_id = array_pop($unionInfo['union_medal']);
         $this->get_game('UnionAchieve')->union_player_add_attr($union_id, $medal_id, $agree_player_id);
     }
     Protocol_Player::p2c_part_update($agree_player_id, array('union_id' => '', 'union_name' => '', 'union_job' => '', 'attr' => array()));
     //提醒玩家成功加入了公会
     if (intval($playerInfo['is_online']) == 1) {
         //直接弹出面板
         Protocol::input($agree_player_id, 8, 17, 1784, array());
     } else {
         $this->get_data('NewsTips')->update_player_tips($agree_player_id, 9, array("num" => 1, "tag" => $union_id));
     }
     $this->get_game('UnionGuide')->active_push_union_guide_info($agree_player_id);
     //公会成就任务
     $challenge_rank = $this->get_game('Challenge')->get_challenge_real_rank($agree_player_id);
     $this->get_game('UnionAchieve')->async_trigger_union_achieve($agree_player_id, 5, $challenge_rank, 3);
     $this->get_game('UnionAchieve')->async_trigger_union_achieve($agree_player_id, 7, $playerInfo['level'], 2);
     //广播新成员
     $agreePlayerInfo = $this->get_data('Player')->get_player_info($agree_player_id, array("name", "sum_fpower"));
     $agree_player_name = $agreePlayerInfo['name'];
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 0, 'txt' => $agree_player_name, 'rep_val' => $agree_player_id);
     $msg = Language_Message::make_message(171004, $arr_replace);
     Protocol::input($agree_player_id, 7, 4, 441, array($agree_player_id, 7, 1, $union_id, 0, 0, $msg, 7));
     #引导任务
     $this->get_game('TaskTrigger')->async_trigger_guide_task($agree_player_id, 8, 1);
     $this->get_data("Player")->del_no_union_player($agree_player_id);
     #公会成员战力
     $this->get_data("UnionInfo")->set_union_player_sum_fpower($union_id, $agree_player_id, $agreePlayerInfo['sum_fpower']);
     return array(1, $agree_player_id, $union_id);
 }
Beispiel #4
0
 /**
  * 钥匙开启宝箱掉落
  * @param $chest_entity_id
  * @param $key_item_sid
  * @param $fb_loot_sid
  */
 public function open_key_item_box($player_id, $chest_entity_id, $key_item_sid, $fb_loot_sid, $diamond_cost)
 {
     $out = array('chest_entity_id' => $chest_entity_id, 'success' => 0, 'items' => array(), 'silver' => 0, 'mojos' => 0);
     if ($key_item_sid > 0) {
         $num = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, $key_item_sid);
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('gold', 'vip', 'level', 'career_type'));
         $arr_logs = array();
         if ($num < 0) {
             return $out;
         }
         $result = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $key_item_sid, 1, $arr_logs, 1, array('cmd_id' => 105, 'level' => $player_info['level'], 'vip' => $player_info['vip']));
     } else {
         $result = true;
         #波兰让特殊处理 为0的时候 直接返回掉落的东西
     }
     if ($result) {
         $items = Cache_FbLoot::getInstance()->get_loot($fb_loot_sid, $player_id, $player_info);
         if (empty($items)) {
             return $out;
         }
         foreach ($items as $item) {
             if ($item['type'] == 'silver') {
                 $out['silver'] += $item['item_num'];
             } elseif ($item['type'] == 'crystal') {
                 $out['mojos'] += $item['item_num'];
                 //魔晶
             } elseif ($item['type'] == 'prop') {
                 for ($i = 0; $i < $item['item_num']; $i++) {
                     $out['items'][] = $item['item_id'];
                 }
             }
         }
         $out['success'] = 1;
         return $out;
     }
     return $out;
 }
Beispiel #5
0
 /**
  * @Purpose:
  * 累计登入抽奖
  * @Param $player_id 玩家ID
  */
 public function login_draw($player_id)
 {
     $player_id = intval($player_id);
     #获取累计登入数据
     $data = $this->get_data('DailySign')->get_daily_sign_info($player_id);
     if ($data) {
         if ($data['draw_info'] && !is_array($data['draw_info'])) {
             $draw_info = json_decode($data['draw_info'], true);
         } else {
             $draw_info = $data['draw_info'];
         }
         if (!Com_Array::is_good_arr($draw_info)) {
             $this->throw_error('200102');
             #没有奖励可以领取
         }
         foreach ($draw_info as $key => $draw) {
             if ($draw['state'] == 1) {
                 $login_table = $this->get_cache_table_data('login_table', null);
                 if (empty($login_table) || !Com_Array::is_good_arr($login_table)) {
                     $this->throw_error('10109');
                     //配置表读取错误
                 }
                 $draw_info[$key]['drawed_times']++;
                 if ($draw_info[$key]['drawed_times'] >= $login_table[$key]['draw_num']) {
                     $draw_info[$key]['state'] = 2;
                 }
                 $update_data['draw_info'] = json_encode($draw_info);
                 #获取掉落库随随机道具
                 $prop_info = Cache_FbLoot::getInstance()->get_loot($login_table[$key]['fb_loot_id'], $player_id);
                 $this->start_trans();
                 #更新抽奖信息
                 $update_res = $this->get_data('DailySign')->update_daily_sign($player_id, $update_data);
                 if (!$update_res) {
                     $this->throw_error('10104');
                 }
                 if (Com_Array::is_good_arr($prop_info)) {
                     #发送道具
                     $result = $this->get_game('Reward')->send_reward($player_id, $prop_info, array('cmd_id' => '2003', 'bind_flag' => 0), 1);
                     if ($result !== true) {
                         $this->throw_error('10104');
                     }
                 }
                 $this->commit();
                 $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130);
                 $this->get_game('Reward')->add_reward_log();
                 $next_draw_times = 0;
                 foreach ($login_table as $key => $login_data) {
                     $draw_data[] = array($login_data['cumulative_days'], $login_data['prop_info'], $draw_info[$key]['state']);
                     if ($next_draw_times == 0 && $login_data['cumulative_days'] > $data['login_times']) {
                         $next_draw_times = $login_data['cumulative_days'] - $data['login_times'];
                     }
                 }
                 $draw_data = $draw_data ? $draw_data : array();
                 return array($prop_info[0]['item_id'], $prop_info[0]['item_num'], $data['login_times'], $next_draw_times, $draw_data);
             }
         }
     }
     $this->throw_error('200102');
     #没有奖励可以领取
 }
Beispiel #6
0
 /**
  * 领取活跃度奖励
  * @param unknown $player_id
  * @param unknown $receive_sid
  */
 public function receive_active_reward($player_id, $sid)
 {
     $sid = intval($sid);
     $daily_active_reward_config = $this->get_cache_table_data("daliy_active_reward", array("sid" => $sid));
     if (empty($daily_active_reward_config)) {
         $this->throw_error('10006');
         //配置出错
     }
     $objDailyActiveReceiveData = $this->get_data('DailyActiveReceive');
     $active_receive_info = $objDailyActiveReceiveData->get_daily_active_receive_info($player_id);
     if (!isset($active_receive_info['receive_sid'])) {
         $active_receive_info['receive_sid'] = array();
     }
     if (in_array($sid, $active_receive_info['receive_sid'])) {
         $this->throw_error('120120');
         //已领取过活跃度奖励
     }
     if ($active_receive_info['active_value'] < $daily_active_reward_config[0]['active_value']) {
         $this->throw_error('10201');
         //活跃未达到奖励领取
     }
     $this->start_trans();
     $arr_reward = $this->get_format_achieve_reward($daily_active_reward_config[0]['reward']);
     $reward = array();
     foreach ($arr_reward as $prop) {
         $reward[] = array('item_id' => $prop[0], 'item_num' => $prop[1], 'type' => Cache_FbLoot::getInstance()->get_item_key($prop[0]));
     }
     $result = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '786', 'bind_flag' => 0));
     if ($result !== true) {
         $code = 10006;
         if ($result == '80001') {
             $code = "80001";
         }
         $this->throw_error($code);
     }
     $active_receive_info['receive_sid'][] = $sid;
     $ret_state = $objDailyActiveReceiveData->update_daily_active_receive($player_id, $active_receive_info);
     if (!$ret_state) {
         $this->throw_error($result);
     } else {
         $this->commit();
         $this->get_game('Reward')->add_reward_log();
     }
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1130);
     return array($sid, 1, $daily_active_reward_config[0]['reward']);
 }
Beispiel #7
0
 public function get_box_reward($player_id, $sid)
 {
     $res = array();
     $player_id = intval($player_id);
     $sid = intval($sid);
     $reward_log = $this->get_data('SevenReward')->get_data_list($player_id);
     $res['res'] = 0;
     $res['sid'] = $sid;
     $res['reward'] = array();
     // echo "<pre>";
     if (empty($reward_log) || !isset($reward_log['box_log'])) {
         $res['res'] = 0;
     } else {
         $fbloot_id = 0;
         foreach ($reward_log['box_log'] as &$val) {
             #测试用
             /*
             if($val['sid'] == $sid ){
                 $fbloot_id = $val['fbloot_id'];
                 $val['status']==2;
             }
             */
             if ($val['sid'] == $sid && $val['status'] == 1 && $val['star'] <= $reward_log['sum_star']) {
                 $fbloot_id = $val['fbloot_id'];
                 $val['status'] = 2;
             }
         }
         if ($fbloot_id > 0) {
             $rewards = Cache_FbLoot::getInstance()->get_loot($fbloot_id, $player_id);
             if (empty($rewards)) {
                 $this->throw_error(10222, 2010066);
             } else {
                 $this->start_trans();
                 $result = $this->get_game('Reward')->send_reward($player_id, $rewards, array('cmd_id' => '2006', 'bind_flag' => 0), 1);
                 if (true === $result) {
                     $this->get_game('Reward')->add_reward_log(true);
                     //记录日志,发宝箱843
                     if ($this->get_data('SevenReward')->update_data_info($player_id, array('box_log' => $reward_log['box_log']))) {
                         $res['res'] = 1;
                         $res['reward'] = $rewards;
                     } else {
                         $this->rollback();
                         $this->throw_error(10110, 2010067);
                     }
                     $this->commit();
                     #同步功能次数
                     $num = $this->get_reward_nums($player_id);
                     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1160, $num);
                 } else {
                     $res['res'] = 0;
                     $this->rollback();
                     $this->throw_error(10110, 2010068);
                 }
             }
             $res['res'] = 1;
         } else {
             $res['res'] = 0;
         }
     }
     return $res;
 }
Beispiel #8
0
 /**
  * @Purpose:
  * 获得抽奖道具
  * @param $fb_id 副本ID
  * @param $draw_data 抽奖数据
  * @param $out_data 输出道具数据
  * @return  返回结果
  */
 private function get_draw_item($fb_id, $draw_data, &$out_data, $player_id = null)
 {
     $data = Cache_FbLoot::getInstance()->get_loot($draw_data['loot_lib_id'], $player_id);
     if (!$data) {
         return FALSE;
     }
     //一次抽卡只能获得一种道具
     $out_data[] = reset($data);
     return TRUE;
 }
Beispiel #9
0
 /**
  * 获取道具增加的经验值
  * @param $prop_id 道具ID
  */
 private function get_prop_exp_id_by_prop_id($prop_id, $player_id = null)
 {
     //获取道具配置表
     $prop_table = $this->get_prop_table($prop_id);
     if (!$prop_table) {
         $this->throw_error('10109');
         //配置表读取错误
     }
     if (!$prop_table['loot_id']) {
         $this->throw_error('10111');
         //配置表配置错误
     }
     //获取道具信息
     $loot_data = Cache_FbLoot::getInstance()->get_loot($prop_table['loot_id'], $player_id);
     return $loot_data[0]['item_num'];
 }
Beispiel #10
0
 public function get_auth_reward($player_id, $vip_type, $auth_code)
 {
     $res = array();
     $player_id = intval($player_id);
     $vip_type = intval($vip_type);
     $auth_code = trim($auth_code);
     if (!$player_id || !$vip_type || !$auth_code) {
         $this->throw_error(10107, 20120161);
         #参数错误
     }
     $vip_auth = $this->get_data('VipReward')->get_vip_auth_reward($player_id);
     if (!empty($vip_auth) && isset($vip_auth[$vip_type])) {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('vip'));
         if ($player_info['vip'] < $vip_type) {
             #功能未开启
             $this->throw_error(10114);
         }
         $reward_log = json_decode($vip_auth[$vip_type], true);
         if (!empty($reward_log) && $reward_log['status'] == 1) {
             if ($reward_log['code'] == $auth_code) {
                 $reward_list = Cache_VipReward::getInstance()->get_vip_auth_list($vip_type);
                 if (!empty($reward_list)) {
                     $rewards = array();
                     foreach ($reward_list as $val) {
                         $temp = array();
                         $temp['type'] = Cache_FbLoot::getInstance()->get_item_key($val['item_id']);
                         $temp['item_id'] = $val['item_id'];
                         $temp['item_num'] = $val['item_num'];
                         $rewards[] = $temp;
                     }
                     if (empty($rewards)) {
                         $this->throw_error(10222, 20120164);
                     }
                     #奖励列表为空
                     $result = $this->get_game('Reward')->send_reward($player_id, $rewards, array('cmd_id' => '2017', 'bind_flag' => 0), 1);
                     if (true === $result) {
                         $reward_log['status'] = 2;
                         $update_reward = array();
                         $update_reward[$vip_type] = json_encode($reward_log);
                         $this->get_data('VipReward')->update_vip_auth_reward($player_id, $update_reward);
                         if ($vip_type == 6) {
                             $func_id = 1290;
                         } elseif ($vip_type == 10) {
                             $func_id = 1291;
                         }
                         $this->get_game('Reward')->add_reward_log(true);
                         //记录日志
                         $func_data = array();
                         $func_data[0][$func_id] = array('operate' => 2, 'func_id' => $func_id, 'open' => 0, 'guide' => 0, 'cd' => 0, 'tip' => 0);
                         Protocol::input($player_id, 8, 7, 741, $func_data);
                     } else {
                         $this->throw_error(10110, 20120173);
                     }
                 } else {
                     $this->throw_error(10222, 20120175);
                 }
             } else {
                 #验证码错误
                 $this->throw_error(2017002);
             }
         } elseif (!empty($reward_log) && $reward_log['status'] == 2) {
             #已领取奖励
             $this->throw_error(2017001, $vip_type);
         } else {
             #不可领取奖励
             $this->throw_error(2010002);
         }
     } else {
         #功能未开启
         $this->throw_error(10114);
     }
     return $res;
 }
Beispiel #11
0
 public function get_reward($player_id)
 {
     $player_id = intval($player_id);
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'cz_status'));
     $used_time = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'cz_reward_count');
     $res = array();
     if ($player_info['cz_status'] > 0 && $player_info['cz_status'] < 3 && $used_time == 0) {
         $reward_list = $this->get_list_for_time($player_info['cz_status'], $player_info['career_type']);
         if (!empty($reward_list)) {
             $reward_item = array();
             foreach ($reward_list as $val) {
                 if ($val['item_type'] == 1) {
                     $reward = array('type' => Cache_FbLoot::getInstance()->get_item_key($val['item_id']), 'item_id' => $val['item_id'], 'item_num' => $val['item_num']);
                     $reward_item[] = $reward;
                 } elseif ($val['item_type'] == 2) {
                     #翅膀
                     $this->get_game('PlayerWing')->update_wing_activation_condition($player_id, 1);
                 } elseif ($val['item_type'] == 3) {
                     #时装
                     $this->get_game('PlayerFashion')->send_fashion($player_id, $val['item_id']);
                 }
             }
             $result = $this->get_game('Reward')->send_reward($player_id, $reward_item, array('cmd_id' => '1906', 'bind_flag' => 0), 1);
             if ($result === true) {
                 $this->get_game('Reward')->add_reward_log();
                 //记录日志
                 $res['res'] = 1;
                 $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'cz_reward_count');
                 $this->get_data('Player')->update_player_info($player_id, array('cz_status' => $player_info['cz_status'] + 1));
                 if ($player_info['cz_status'] == 2) {
                     $func_data = array();
                     $func_data[0][1140] = array('operate' => 2, 'func_id' => 1140, 'open' => 0, 'guide' => 0, 'cd' => 0, 'tip' => 0);
                     Protocol::input($player_id, 8, 7, 741, $func_data);
                 } else {
                     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1140);
                 }
             } else {
                 $res['res'] = 0;
             }
         } else {
             $this->throw_error(10222, 2010023);
         }
     } else {
         $this->throw_error(17888, 2010024);
         #数据错误非法操作
     }
     return $res;
 }
Beispiel #12
0
 public function base_reward($player_id, $sid, $loot_id, $is_online = 1)
 {
     $result = array();
     $this->get_data('PlayerDailyTime')->set_used_time($player_id, 'world_boss_box_count', 0);
     $loot_id = intval($loot_id);
     $result['rewardlist'] = Cache_FbLoot::getInstance()->get_loot($loot_id, $player_id);
     if (empty($result['rewardlist'])) {
         $result['res'] = 0;
         //参数错误
         Protocol::input($player_id, 8, 11, 1122, $result);
         //$this->throw_error('10222');
         return;
     }
     $isfull = $this->get_game('Prop')->get_empty_pos($player_id);
     if (false == $isfull) {
         $result['res'] = 1;
         //包裹已满
         $this->send_mail($player_id, $result['rewardlist']);
         Protocol::input($player_id, 8, 11, 1122, $result);
         return;
     }
     if (1 == $is_online) {
         $results = $this->get_game('Reward')->send_reward($player_id, $result['rewardlist'], array('cmd_id' => '1779', 'bind_flag' => 0), 1);
         if ($results === true) {
             $this->get_game('Reward')->add_reward_log();
             //记录日志
             $result['res'] = 2;
             Protocol::input($player_id, 8, 11, 1122, $result);
             return;
         } else {
             $result['res'] = 3;
             Protocol::input($player_id, 8, 11, 1122, $result);
         }
     } else {
         $this->send_mail($player_id, $result['rewardlist']);
     }
 }
Beispiel #13
0
 private function return_rewards($str_reward)
 {
     if (empty($str_reward)) {
         $this->throw_error(10222, 2010036);
     }
     $rewards = array();
     foreach ($str_reward as $val) {
         $temp = explode(':', $val);
         $reward = array('type' => Cache_FbLoot::getInstance()->get_item_key($temp[0]), 'item_id' => $temp[0], 'item_num' => $temp[1]);
         array_push($rewards, $reward);
     }
     return $rewards;
 }
Beispiel #14
0
 /**
  * 发送奖励接口  此接口可以发游戏里所有的资源
  * @param $player_id    人物ID
  * @param $arr_reward   奖励 格式 二维数组
  * type exp:经验  silver:银币 gold:金币 prop:道具 drop:掉落库ID array('type'=>'exp','item_id'=>'','item_num'=>1)
  * @param array $arr_params 额外参数 参数包括了日常数据 至少里面有一个cmd_id  array('cmd_id'=>xx)
  * @param null $send_mail 0包裹满不发邮件 1 包裹满发邮件
  */
 public function send_reward($player_id, $arr_reward, $arr_params = array(), $send_mail = 0)
 {
     if (empty($arr_reward)) {
         return false;
     }
     $this->init_reward($player_id, $arr_params);
     if (!isset($arr_params['privilege_level']) || !isset($arr_params['name']) || !isset($arr_params['vip']) || !isset($arr_params['union_id']) || !isset($arr_params['fame_level_exp']) || !isset($arr_params['fame_level']) || !isset($arr_params['fame']) || !isset($arr_params['crystal']) || !isset($arr_params['kf_coin']) || !isset($arr_params['kf_score']) || !isset($arr_params['honor']) || !isset($arr_params['chips']) || !isset($arr_params['ticket']) || !isset($arr_params['gold']) || !isset($arr_params['silver']) || !isset($arr_params['level']) || !isset($arr_params['career_type']) || !isset($arr_params['exp'])) {
         $arrPlayer = $this->get_player_info();
         $this->arrParams['level'] = $arrPlayer['level'];
         $this->arrParams['name'] = $arrPlayer['name'];
         $this->arrParams['level_exp'] = $arrPlayer['level_exp'];
         $this->arrParams['career_type'] = $arrPlayer['career_type'];
         $this->arrParams['exp'] = $arrPlayer['exp'];
         $this->arrParams['silver'] = $arrPlayer['silver'];
         $this->arrParams['gold'] = $arrPlayer['gold'];
         $this->arrParams['ticket'] = $arrPlayer['ticket'];
         $this->arrParams['chips'] = $arrPlayer['chips'];
         $this->arrParams['honor'] = $arrPlayer['honor'];
         $this->arrParams['kf_coin'] = $arrPlayer['kf_coin'];
         $this->arrParams['crystal'] = $arrPlayer['crystal'];
         $this->arrParams['feather_unicorn'] = $arrPlayer['feather_unicorn'];
         $this->arrParams['battle_score'] = $arrPlayer['battle_score'];
         $this->arrParams['kf_score'] = $arrPlayer['kf_score'];
         $this->arrParams['fame'] = $arrPlayer['fame'];
         $this->arrParams['fame_level'] = intval($arrPlayer['fame_level']);
         $this->arrParams['fame_level_exp'] = intval($arrPlayer['fame_level_exp']);
         $this->arrParams['kf_score'] = intval($arrPlayer['kf_score']);
         $this->arrParams['vip'] = $arrPlayer['vip'];
         $this->arrParams['after_hero_hole'] = $arrPlayer['after_hero_hole'];
         $this->arrParams['privilege_level'] = intval($arrPlayer['privilege_level']);
         $this->arrParams['bag_num'] = intval($arrPlayer['bag_num']);
         $this->arrParams['union_id'] = intval($arrPlayer['union_id']);
     }
     if (isset($arr_params['cmd_id'])) {
         $this->arrParams['cmd_id'] = $arr_params['cmd_id'];
     }
     if (isset($arr_params['bind_flag'])) {
         $this->arrParams['bind_flag'] = $arr_params['bind_flag'];
     } else {
         $this->arrParams['bind_flag'] = null;
     }
     # 对奖励按倍率活动倍率进行修正
     $this->get_game('Event')->handle_resource_revise_for_event($player_id, $arr_reward, $this->arrParams['cmd_id'], $this->arrParams['vip'], 1);
     if (is_array($arr_reward)) {
         foreach ($arr_reward as $val) {
             if ($val['type'] == 'drop') {
                 $list = Cache_FbLoot::getInstance()->get_loot($val['item_id'], $this->player_id, array('career_type' => $this->arrParams['career_type'], 'level' => $this->arrParams['level']));
                 if (!empty($list)) {
                     foreach ($list as $lp) {
                         $this->set_reward($lp);
                     }
                 } else {
                     return false;
                 }
             } else {
                 $this->set_reward($val);
             }
         }
     }
     $bDealCheck = true;
     $start_trans = $this->is_trans();
     if (!$this->is_trans()) {
         $this->start_trans();
     }
     //发送道具
     if (!empty($this->arrPropReward) && $bDealCheck) {
         $arrPropLogs = array();
         $objPropGame = $this->get_game('Prop');
         foreach ($this->arrPropReward as $reward) {
             try {
                 #在增加满的时候 发送的邮件里的装备会有这个属性  因为在发邮件的时候要把
                 if (isset($reward['config'])) {
                     $prop_config = $reward['config'];
                 } else {
                     if (isset($reward['prop_config'])) {
                         $prop_config = $reward['prop_config'];
                     } else {
                         $prop_config = null;
                     }
                 }
                 $bDealCheck = $objPropGame->send_prop_auto_overlay($player_id, $reward['item_id'], $reward['item_num'], $arrPropLogs, $this->arrParams['cmd_id'], $this->arrParams['bind_flag'], $send_mail, $prop_config, $this->arrParams);
             } catch (Exception $e) {
                 if ($this->is_trans()) {
                     $this->rollback();
                 }
                 $msg = json_decode($e->getMessage(), true);
                 return $msg['error']['code'];
             }
             if ($bDealCheck !== true) {
                 $bDealCheck = false;
                 break;
             }
             Game_GainMsg::add($this->player_id, 1, $reward['item_id'], $reward['item_num']);
         }
         $this->arrPropLogs = $arrPropLogs;
     }
     //人物资源奖励
     if (!empty($this->arrPlayerReward) && $bDealCheck) {
         $updateItem = array();
         foreach ($this->arrPlayerReward as $field => $value) {
             //                if($field == 'exp') continue;//经验再升级的文件加
             if ($field == 'silver') {
                 $num = $this->arrParams['silver'] + $value;
                 if ($num > 1500000000) {
                     $value = 1500000000 - $this->arrParams['silver'];
                 }
             }
             if ($value) {
                 $updateItem[$field] = '+' . $value;
             }
         }
         if (!empty($updateItem)) {
             $bDealCheck = $this->get_data('Player')->update_player_info($player_id, $updateItem);
         }
     }
     //公会贡献
     if (!empty($this->arrUnionReward) && $bDealCheck) {
         foreach ($this->arrUnionReward as $field => $value) {
             if ($field == 'gh_con') {
                 $cmd_id = $arr_params['cmd_id'] ? $arr_params['cmd_id'] : 0;
                 $bDealCheck = $this->get_game('UnionPlayer')->add_player_dedicate($player_id, $value);
             }
             /* else if($field=='union_exp'){
                	$cmd_id = $arr_params['cmd_id']?$arr_params['cmd_id']:0;
                	$bDealCheck = $this->get_game('UnionBase')->union_add_exp($player_id,$value,$cmd_id);
                } */
             if (!$bDealCheck) {
                 break;
             }
         }
     }
     #发英雄
     if ($bDealCheck && !empty($this->arrHeroReward)) {
         foreach ($this->arrHeroReward as $value) {
             $bDealCheck = $this->get_game("Hero")->add_hero($player_id, $value);
             if (!$bDealCheck) {
                 break;
             }
         }
     }
     //赠送玩法
     if ($bDealCheck && !empty($this->arrPlayReward)) {
         $item_id = $arr_reward[0]['item_id'];
         switch ($item_id) {
             case 0:
                 $field = "main_map_present_num";
                 break;
             case 1:
                 $field = "map_pve_present_num";
                 break;
             case 2:
                 $field = "challenge_battle_buy_num";
                 break;
             case 3:
                 $field = "kf_arena_add_times";
                 break;
         }
         foreach ($this->arrPlayReward as $key => $value) {
             $bDealCheck = $this->get_data("PlayerDailyTime")->present_time($player_id, $field, $value);
             if (!$bDealCheck) {
                 break;
             }
         }
     }
     if ($bDealCheck) {
         if (!$start_trans) {
             $this->commit();
         }
         return true;
     } else {
         if (!$start_trans) {
             $this->rollback();
         }
         return false;
     }
 }
Beispiel #15
0
 private function send_box_to_player($union_id, $box_id, $role_id, $box)
 {
     $box_ids = explode(',', $box_id);
     $role_ids = explode(',', $role_id);
     if (!empty($box_ids) && !empty($role_ids)) {
         for ($i = 0; $i < count($role_ids); $i++) {
             #$num = $box['box_list'][$i]['num'];
             #根据宝箱id获取数量
             foreach ($box['box_list'] as $box_val) {
                 if (intval($box_val['box_id']) == intval($box_ids[$i])) {
                     $num = $box_val['num'];
                 }
             }
             $reward = array('type' => Cache_FbLoot::getInstance()->get_item_key($box_ids[$i]), "item_id" => $box_ids[$i], 'item_num' => $num);
             $this->send_mail($role_ids[$i], array($reward));
         }
         $box['status'] = 0;
         $this->get_data('UnionBoss')->save_box_log($union_id, $box);
         $this->get_data('UnionBoss')->save_send_box_log($union_id, $role_id, $box_id);
     }
 }
Beispiel #16
0
 /**
  * 挂机领取奖励
  * @param unknown $add_exp
  * @param unknown $arr_item_id
  * @param unknown $arr_item_num
  */
 public function auto_pve_add_reward($player_id, $add_exp, $arr_item_id, $arr_item_num)
 {
     $reward = array();
     if (Com_Array::is_good_arr($arr_item_id)) {
         foreach ($arr_item_id as $key => $item_id) {
             $item_num = $arr_item_num[$key];
             if ($item_num > 0) {
                 $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key($item_id), 'item_id' => $item_id, 'item_num' => $item_num);
             }
         }
     }
     if ($add_exp) {
         $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key(1), 'item_id' => 1, 'item_num' => $add_exp);
     }
     if (!empty($reward)) {
         $result = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '771'));
         if ($result !== true) {
             $attachment = array();
             foreach ($reward as $prop) {
                 $attachment[] = array("prop_id" => $prop['item_id'], "prop_num" => $prop['item_num']);
             }
             $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(11);
             $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 771);
             Com_Log::debug_write('auto_pve_add_reward', "player_id={$player_id},fail=" . json_encode($reward));
             $this->throw_error(80034);
             return false;
         }
         Com_Log::debug_write('auto_pve_add_reward', "player_id={$player_id},sucess=" . json_encode($reward));
         $this->get_game('Reward')->add_reward_log(true);
     }
 }
Beispiel #17
0
 /**
  * 篝火加料
  * @param unknown $player_id
  * @param unknown $union_id
  * @param unknown $type 1加草 2加炭 3加薪
  */
 public function bonfire_control($player_id, $type)
 {
     $type = intval($type);
     $objPlayerData = $this->get_data('Player');
     $playerInfo = $objPlayerData->get_player_info($player_id, array("privilege_level", "ticket", "level", "exp", "union_id", "silver", "gold", "exp", "union_name", "name"));
     $union_id = intval($playerInfo['union_id']);
     //$this->get_data('UnionBonfire')->del_union_bonfire($union_id);
     if ($union_id == 0) {
         $this->throw_error('171001');
     }
     $bonfireConfig = Cache_BonfireControl::getInstance()->get_bonfire_control($type);
     if (empty($bonfireConfig)) {
         $this->throw_error('10109');
     }
     $objUnionBonfireData = $this->get_data('UnionBonfire');
     $unionBonfireInfo = $objUnionBonfireData->get_union_bonfire($union_id);
     $is_init_bonfire_info = 0;
     if (empty($unionBonfireInfo)) {
         $is_init_bonfire_info = 1;
     }
     #限制时间是否开启
     $nowtime = time();
     $activities_info = Cache_UnionActivities::getInstance()->get_union_activities_info(array("activities_id" => 1));
     if ($activities_info['open_time']) {
         $begin_time = strtotime(date("Y-m-d {$activities_info['open_time']}"));
         $end_time = $begin_time + $activities_info["activities_time"];
         if (isset($unionBonfireInfo['second_extended'])) {
             $end_time += intval($unionBonfireInfo['second_extended']);
         }
         if ($nowtime < $begin_time || $nowtime > $end_time) {
             $this->throw_error("1752001");
         }
     }
     //操作职位权限
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $unionPlayerInfo = $objUnionPlayerData->get_union_player_info($union_id, $player_id);
     if ($unionPlayerInfo['job_id'] > $bonfireConfig['guild_job']) {
         if ($type == 2) {
             $this->throw_error('174508');
             //无权操作
         } else {
             if ($type == 3) {
                 $this->throw_error('174509');
                 //无权操作
             } else {
                 $this->throw_error('170701');
                 //无权操作
             }
         }
     }
     //可操作次数
     if ($bonfireConfig['max_frequency'] > 0) {
         if (isset($unionBonfireInfo['used_times'][$type])) {
             if ($unionBonfireInfo['used_times'][$type] >= $bonfireConfig['max_frequency']) {
                 $this->throw_error('174501');
                 //可操作次数已用完
             }
             $unionBonfireInfo['used_times'][$type] += 1;
         } else {
             $unionBonfireInfo['used_times'][$type] = 1;
         }
     }
     $item_key = Cache_FbLoot::getInstance()->get_item_key($bonfireConfig['add_cost_type']);
     //消耗货币类型是否满足
     $arr_consume = array();
     if ($item_key == "gold") {
         $ticket = 0;
         $price = $bonfireConfig['add_cost_num'];
         if ($playerInfo['ticket'] > 0) {
             if ($playerInfo['ticket'] >= $bonfireConfig['add_cost_num']) {
                 $ticket = $bonfireConfig['add_cost_num'];
                 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $bonfireConfig['add_cost_num']);
                 $bonfireConfig['add_cost_num'] = 0;
             } else {
                 $ticket = $playerInfo['ticket'];
                 $bonfireConfig['add_cost_num'] = $bonfireConfig['add_cost_num'] - $playerInfo['ticket'];
                 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $playerInfo['ticket']);
             }
         }
         $arr_consume = array('price' => $price, 'gold' => $bonfireConfig['add_cost_num'], 'ticket' => $ticket, 'count' => 1);
         #数据中心推送
     }
     $this->get_data('Player')->check_player_resource($player_id, $playerInfo, "-", $item_key, $bonfireConfig['add_cost_num']);
     //添加热度
     if ($bonfireConfig['add_heat'] > 0) {
         if (isset($unionBonfireInfo['heat'])) {
             if ($unionBonfireInfo['heat'] >= $bonfireConfig['max_heat']) {
                 $this->throw_error('174502');
                 //热度已到最大上限
             }
             if ($unionBonfireInfo['heat'] + $bonfireConfig['add_heat'] > $bonfireConfig['max_heat']) {
                 $bonfireConfig['add_heat'] = $bonfireConfig['max_heat'] - $bonfireConfig['heat'];
                 $unionBonfireInfo['heat'] = $bonfireConfig['max_heat'];
             } else {
                 $unionBonfireInfo['heat'] += $bonfireConfig['add_heat'];
             }
         } else {
             $unionBonfireInfo['heat'] = 100 + $bonfireConfig['add_heat'];
         }
     }
     //cd时间
     if ($bonfireConfig['cooldown'] > 0) {
         $cd_time = $objUnionBonfireData->get_bonfire_cd($player_id, $type);
         if ($cd_time) {
             $this->throw_error('174503');
             //cd中
         }
         $objUnionBonfireData->add_bonfire_cd($player_id, $type, $bonfireConfig['cooldown']);
     }
     //延长篝火时间
     if ($bonfireConfig['add_time'] > 0) {
         $unionBonfireInfo['second_extended'] += $bonfireConfig['add_time'];
     }
     $second_extended_used_times = 0;
     $second_extended_max_times = 0;
     if ($type == 3) {
         $second_extended_used_times = intval($unionBonfireInfo['used_times'][$type]);
         $second_extended_max_times = intval($bonfireConfig['max_frequency']);
     }
     $retBonfire = $objUnionBonfireData->update_union_bonfire($union_id, $unionBonfireInfo);
     $retPlayer = $this->get_data('Player')->update_player_resource($player_id, $playerInfo, 1745, array(), $arr_consume);
     if ($type < 3 && intval($unionBonfireInfo['heat']) >= intval($bonfireConfig['max_heat'])) {
         $use_times = -1;
     } else {
         if ($bonfireConfig['max_frequency'] == 0) {
             $use_times = 0;
         } else {
             $use_times = $bonfireConfig['max_frequency'] - intval($unionBonfireInfo["used_times"][$type]) > 0 ? $bonfireConfig['max_frequency'] - intval($unionBonfireInfo["used_times"][$type]) : -1;
         }
     }
     if ($retBonfire && $retPlayer) {
         #活动延长时间控制面板进入时间
         if ($bonfireConfig['add_time']) {
             $this->get_game('UnionActivities')->add_activities_time_interface($union_id, 4, $bonfireConfig['add_time']);
         }
         $this->commit();
         //			Protocol_Player::p2c_part_update($player_id,array('gold'=>'','silver'=>'','exp'=>''));
         $minutes_extended = $bonfireConfig['add_time'] ? $bonfireConfig['add_time'] / 60 : 0;
         if ($minutes_extended) {
             $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 19, $minutes_extended);
         }
         Protocol::input($player_id, 7, 4, 505, array($union_id, intval($bonfireConfig['add_heat']), $minutes_extended, $second_extended_used_times, $second_extended_max_times));
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     if ($is_init_bonfire_info) {
         $activities_info = Cache_UnionActivities::getInstance()->get_union_activities_info(array("activities_id" => 1));
         $minutes_extended = $activities_info["activities_time"] ? $activities_info["activities_time"] / 60 : 0;
         $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 19, $minutes_extended);
     }
     if (in_array($type, array(2, 3))) {
         if ($type == 2) {
             $code = 174510;
             #公会【%guild name%】公会的 %player_name% 增加了公会篝火的经验倍数10%!土豪有你真幸福!
         } else {
             $code = 174506;
             #公告【%guild name%】公会的管理 %player_name% 延长了篝火的持续时间!好领导,你们公会还要人嘛?
         }
         $arr_replace = array();
         $arr_replace[] = array('rep_type' => 7, 'txt' => $playerInfo['union_name'], 'rep_color' => "e8ac44");
         $arr_replace[] = array('rep_type' => 0, 'txt' => $playerInfo['name'], 'rep_val' => $player_id, 'underLine' => 1, 'rep_color' => "fff100");
         $msg = Language_Message::make_message($code, $arr_replace);
         if ($type == 2) {
             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
         } else {
             $this->get_game('SystemNotice')->send_system_msg(0, $msg, 1, 1);
         }
     }
     if ($use_times == -1) {
         $data = $this->get_bonfire_control($player_id, $union_id);
         if ($data) {
             Protocol::input($player_id, 8, 17, 1746, $data);
         }
     } else {
         return array(1, $type, $use_times);
     }
 }
Beispiel #18
0
 /**
  * 提取全部附件
  * @param $player_id
  * @param $mail_id
  * @deprecated  state 1有可领取附件0无
  */
 public function extract_all_attachment($player_id, $mail_id)
 {
     $player_id = intval($player_id);
     $mail_id = intval($mail_id);
     $data = $this->get_mail_detail_info($player_id, $mail_id);
     $this->start_trans();
     $arrLogs = array();
     if (empty($data) || empty($data['attachment'])) {
         $this->throw_error('10101');
     }
     if ($data['expiretime'] <= time()) {
         $this->throw_error('70013');
     }
     $ret_key = array();
     $reward = array();
     if ($data['cmd_id']) {
         $cmd_id = $data['cmd_id'];
     } else {
         $cmd_id = 703;
         if ($data['type'] == 3) {
             $cmd_id = 704;
         }
     }
     foreach ($data['attachment'] as $key => $attch) {
         //			$arrPropConfig = Cache_Prop::getInstance()->get_prop_info($attch['prop_id']);
         //			if(!Com_Array::is_good_arr($arrPropConfig)){
         //				$this->throw_error('80003'); //道具配置出错,请联系客服!
         //			}
         if (isset($attch['config'])) {
             $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key($attch['prop_id']), 'item_id' => $attch['prop_id'], 'item_num' => $attch['prop_num'], 'config' => $attch['config']);
         } else {
             $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key($attch['prop_id']), 'item_id' => $attch['prop_id'], 'item_num' => $attch['prop_num']);
         }
         $ret_key[] = $key;
     }
     $result = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => $cmd_id, 'bind_flag' => intval($data['bind_flag'])), 2);
     if ($result !== true) {
         $error_msg = $result;
     }
     if ($error_msg) {
         $this->throw_error($error_msg);
     }
     $data['attachment'] = array();
     $data['state'] = 0;
     #全部领取过的邮件设置为1天过期
     if (empty($data['attachment'])) {
         $expiretime = time() + 86400 - 1;
         if ($data['expiretime'] > $expiretime) {
             $data['expiretime'] = $expiretime;
         }
     }
     $countdown = $data['expiretime'] - time();
     $countdown = $countdown < 0 ? 0 : $countdown;
     $ret = $this->get_data('PlayerMail')->update_player_mail($player_id, $mail_id, $data);
     if ($ret) {
         $this->commit();
         $this->get_game('Reward')->add_reward_log();
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     return array($mail_id, $ret_key, $countdown);
 }
Beispiel #19
0
 /**
  * 转化奖励格式
  * @param unknown
  */
 public function get_format_reward($str_reward)
 {
     $reward = array();
     $arr_reward = explode("|", $str_reward);
     foreach ($arr_reward as $val) {
         if ($val) {
             list($item_id, $item_num) = explode(":", $val);
             $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key($item_id), 'item_id' => $item_id, 'item_num' => $item_num);
         }
     }
     return $reward;
 }
Beispiel #20
0
 public function get_item($player_id, $sid, $num)
 {
     $player_id = intval($player_id);
     $sid = intval($sid);
     $num = abs($num);
     $num = intval($num);
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level', 'name', 'vip', 'player_id', 'silver', 'kf_coin', 'honor', 'privilege_level', 'kf_score', 'battle_score'));
     $set_list = Cache_GloryShop::getInstance()->get_gloryshop_set(0, $player_info['career_type'], $player_info['level']);
     $set_info = $this->get_item_id($set_list, $sid);
     if (empty($set_info)) {
         $this->throw_error(10222, 20120201);
     }
     #判断资源是否足够
     $my_coin = 0 + $this->get_my_coin($player_id, $set_info['cost_type'], $player_info);
     if ($my_coin < $num * $set_info['cost_num']) {
         if ($set_info['cost_type'] > 30) {
             $this->throw_error(130006);
             #消耗资源不足
         }
     }
     $log_list = $this->get_data('GloryShop')->get_player_log($player_id, $set_info['func_type']);
     #判断数量是否符合
     $log_val = $this->get_log_val($log_list, $sid);
     $used = 0;
     empty($log_val) ? $used = 0 : ($used = $log_val['item_num']);
     if ($set_info['max_num'] >= $num + $used || $set_info['max_num'] == 0) {
         $this->start_trans();
         #发奖励
         $reward = array(array('type' => Cache_FbLoot::getInstance()->get_item_key($set_info['item_id']), 'item_id' => $set_info['item_id'], 'item_num' => $num));
         $cmd_id = 1305;
         if (1 == $set_info['func_type']) {
             //竞技场
             $cmd_id = 435;
         } elseif (4 == $set_info['func_type']) {
             $cmd_id = 13051;
         } elseif (6 == $set_info['func_type']) {
             $cmd_id = 13052;
         } elseif (7 == $set_info['func_type']) {
             $cmd_id = 10132;
         }
         $result = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => $cmd_id), 1);
         if (true === $result) {
             $log_res = $this->get_update_log($log_list, $num, $sid, $set_info['item_id']);
             if ($this->get_data('GloryShop')->update_player_log($player_id, array($set_info['func_type'] => $log_res))) {
                 $res = array();
                 $res['res'] = 1;
                 $res['item_id'] = $set_info['item_id'];
                 $res['item_num'] = $num;
                 $res['left_coin'] = $my_coin - $num * $set_info['cost_num'];
                 if ($this->update_coin($player_id, $set_info['cost_type'], $num * $set_info['cost_num'], $player_info, $cmd_id)) {
                     $this->commit();
                     $prop_logs = $this->get_game('Reward')->get_prop_log();
                     $this->get_game('Reward')->add_reward_log();
                     if ($set_info['func_type'] == 8) {
                         if ($prop_logs) {
                             foreach ($prop_logs as $val) {
                                 if (isset($val['overlay_num'])) {
                                     $val['item_num'] = $val['overlay_num'];
                                 }
                                 $this->get_game('TaskTrigger')->async_trigger_task($player_id, 20, $val['prop_id'], $val['item_num']);
                             }
                         }
                     }
                     #----发公告----(一波)需要还原
                     $this->send_system_notice($player_id, $player_info, $set_info['func_type'], $set_info['item_id'], $set_info['func_id']);
                     #Protocol_Player::p2c_part_update($player_id,array('silver'=>0,'kf_coin'=>0,'honor'=>0,'privilege_level'=>0,'kf_score'=>0,'battle_score'=>0));
                     return $res;
                 } else {
                     $this->rollback();
                     $this->throw_error(10110);
                 }
             } else {
                 #数据错误
                 $this->rollback();
                 $this->throw_error(10110);
             }
         } else {
             #数据错误
             #$this->rollback();
             $this->throw_error(10110);
         }
     } else {
         #超过最大购买数量
         #$this->rollback();
         $this->throw_error(130007);
     }
 }
Beispiel #21
0
 public function strenglen_action($player_id, $id)
 {
     $player_id = intval($player_id);
     $id = intval($id);
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('union_id', 'name', 'silver', 'ticket', 'gold', 'player_id', 'level', 'vip', 'fame', 'privilege_level'));
     $level_info = $this->get_union_by_id($id);
     if ($player_info['union_id'] == 0) {
         $this->throw_error(171101);
     }
     if (empty($level_info)) {
         $this->throw_error('10222', 2010069);
     }
     if ($level_info['type_id'] == 2) {
         $vip_limit = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10040);
         if (!empty($vip_limit)) {
             if ($player_info['vip'] < $vip_limit['vip_level']) {
                 $this->throw_error('11089');
             }
         }
     } elseif ($level_info['type_id'] == 3) {
         $vip_limit = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10041);
         if (!empty($vip_limit)) {
             if ($player_info['vip'] < $vip_limit['vip_level']) {
                 $this->throw_error('11089');
             }
         }
     }
     #判断消耗
     $res = array();
     $res['res'] = 1;
     #1强化成功 2金币不足  3次数用完
     $old = 0;
     $arr_consume = array();
     if ($level_info['cost_type'] == 3) {
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', abs($level_info['cost_num']));
     } elseif ($level_info['cost_type'] == 2 || $level_info['cost_type'] == 20) {
         #先扣除彩钻
         $cost = abs($level_info['cost_num']);
         $ticket = 0;
         $gold = $cost;
         if ($player_info['ticket'] > 0) {
             if ($player_info['ticket'] >= $cost) {
                 $ticket = $cost;
                 $gold = 0;
             } else {
                 $ticket = $player_info['ticket'];
                 $gold = $cost - $player_info['ticket'];
             }
         }
         $arr_consume = array('price' => $cost, 'gold' => $gold, 'ticket' => $ticket, 'count' => 1);
         #数据中心推送
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $cost, 1, 1);
     } else {
         $this->throw_error('10222', 2010070);
     }
     #判断今日次数
     $union_conf = Cache_UnionBase::getInstance()->get_union_conf();
     if (empty($union_conf)) {
         $this->throw_error(10222, 2010071);
     } else {
         if (isset($union_conf['max_bomb_time'])) {
             $used = 0 + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_bomb_count');
             if ($used >= $union_conf['max_bomb_time']) {
                 $this->throw_error(174401);
             }
         } else {
             $this->throw_error(10222, 2010072);
         }
     }
     $res['res'] = 1;
     $union_info = $this->get_data('UnionInfo')->get_union_info($player_info['union_id']);
     $res['bomb_exp'] = isset($union_info['bomb_exp']) ? $union_info['bomb_exp'] : 0;
     $res['max_exp'] = $level_info['max_exp'];
     $res['bomb_level'] = $level_info['level'];
     if ($res['res'] == 1) {
         #扣消耗
         #$this->start_trans();
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1723, array(), $arr_consume);
         if (false !== $result) {
             #保存记录
             $this->save_strength_log($player_info['union_id'], $player_id, $player_info['name'], $level_info);
             #福利大厅任务接口
             if ($level_info['type_id'] == 3) {
                 $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9040_2');
             }
             $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9040_1');
             $update = array();
             $update['fund'] = (isset($union_info['fund']) ? $union_info['fund'] : 0) + $level_info['union_fund'];
             $update['bomb_exp'] = (isset($union_info['bomb_exp']) ? $union_info['bomb_exp'] : 0) + $level_info['bomb_exp'];
             $update['bomb_up_exp'] = (isset($union_info['bomb_up_exp']) ? $union_info['bomb_up_exp'] : 0) + $level_info['bomb_exp'];
             $update['bomb_level'] = isset($union_info['bomb_level']) ? $union_info['bomb_level'] : 1;
             #判断是否升级
             $up = false;
             if ($update['bomb_up_exp'] >= $level_info['max_exp']) {
                 $nowLvl = isset($union_info['bomb_level']) ? $union_info['bomb_level'] : 1;
                 if ($union_info['union_level'] > $nowLvl) {
                     $update['bomb_level'] = $nowLvl + 1;
                     $update['bomb_up_exp'] -= $level_info['max_exp'];
                     $level_info['max_exp'] = $this->get_max_exp($update['bomb_level']);
                     $up = true;
                 } else {
                     $update['bomb_up_exp'] = $level_info['max_exp'];
                     $update['bomb_level'] = $nowLvl;
                 }
             }
             if ($up) {
                 //添加日志
                 $arr_replace = array();
                 $objUnionBaseGame = $this->get_game('UnionBase');
                 $objUnionBaseGame->sys_add_union_log($player_id, $player_info['union_id'], 173902, $arr_replace);
                 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 23, $update['bomb_level'], 2);
             }
             //添加日志
             $arr_replace = array();
             $type_name = '';
             if ($level_info['type_id'] == 1) {
                 $type_name = '初级强化';
             } elseif ($level_info['type_id'] == 2) {
                 $type_name = '中级强化';
             } elseif ($level_info['type_id'] == 3) {
                 $type_name = '高级强化';
                 $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 16, 1, 1);
             }
             $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
             $arr_replace[] = array('rep_type' => 7, 'rep_val' => $type_name);
             #强化类型
             $arr_replace[] = array('rep_type' => 7, 'rep_val' => $level_info['player_dedicate']);
             #公会贡献
             $arr_replace[] = array('rep_type' => 7, 'rep_val' => $level_info['union_fund']);
             #公会资金
             $objUnionBaseGame = $this->get_game('UnionBase');
             $objUnionBaseGame->sys_add_union_log($player_id, $player_info['union_id'], 173901, $arr_replace);
             #贡献玩家贡献-声望
             $this->get_game('Reward')->send_reward($player_id, array(array('type' => Cache_FbLoot::getInstance()->get_item_key(14), 'item_id' => 14, 'item_num' => $level_info['fame'])), array('cmd_id' => '1723'));
             $myinfo = $this->get_data("UnionPlayer")->get_union_player_info($player_info['union_id'], $player_id);
             $myold = isset($myinfo['total_dedicate']) ? $myinfo['total_dedicate'] : 0;
             $myinfo['total_dedicate'] = $myold + $level_info['player_dedicate'];
             $this->get_game("UnionPlayer")->add_player_dedicate($player_id, $level_info['player_dedicate']);
             $this->get_data("UnionInfo")->update_union_info($player_info['union_id'], $update);
             $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'union_bomb_count');
             $this->get_game('UnionGuide')->async_trigger_union_guide($player_id, $used + 1, $union_conf['max_bomb_time'], 3, 3);
             $res['bomb_exp'] = $update['bomb_up_exp'];
             $res['max_exp'] = $level_info['max_exp'];
             $res['bomb_level'] = $update['bomb_level'];
             $res['id'] = $id;
             $res['total_dedicate'] = $myold + $level_info['player_dedicate'];
             $res['fund'] = $update['fund'];
             $res['fame'] = $player_info['fame'] + $level_info['fame'];
             #变形金刚让加一个声望字段
             $this->get_game('Reward')->add_reward_log();
             #$this->commit();
             #任务埋点
             $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 12, 1, 1);
             //公会贡献-流水日志
             $log_data = array('player_id' => $player_id, 'channel' => 16, 'type' => 1, 'item_id' => 11, 'item_num' => $level_info['player_dedicate'], 'amount' => $myold, 'after_amount' => $myinfo['total_dedicate'], 'cmd_id' => 1723);
             Log_Common::getInstance()->add_log($log_data);
             $this->get_game('Union')->Sync_Union_msg($player_info['union_id']);
         } else {
             #$this->rollback();
             $this->throw_error('10110', 2010073);
         }
     }
     return $res;
 }
Beispiel #22
0
 /**
  * 赞好友动态
  * 单条与一键
  */
 public function like_friend_news($player_id, $news_ids, $is_key = 0, $page = 1)
 {
     $is_key = intval($is_key);
     $page = intval($page) < 1 ? 1 : intval($page);
     if (empty($player_id) || empty($news_ids)) {
         $this->throw_error('10101');
         //参数不全
     }
     //加锁
     if (!Com_Lock::lock('lock|like_friend_news|player_id=' . $player_id)) {
         //系统繁忙
         $this->throw_error('170501');
     }
     $player_id = intval($player_id);
     $arr_news_ids = array(intval($news_ids));
     $objplayer = $this->get_data('Player');
     $player_basic_info = $objplayer->get_player_info($player_id, array("privilege_level", 'ticket', 'level', 'gold', 'vip', 'level_exp', 'name'));
     $like_max_times = $this->like_default_times;
     if (intval($player_basic_info['vip']) > 0) {
         $vip_set = Cache_VipLevelLimit::getInstance()->get_limit_info($player_basic_info['vip'], 10069);
         $like_max_times = $this->like_default_times + $vip_set['max_times'];
     }
     //一键点赞扣2钻石
     $ticket = 0;
     $arr_consume = array();
     $price = $cost_gold = 10;
     if ($is_key) {
         if ($player_basic_info['ticket'] > 0) {
             if ($player_basic_info['ticket'] >= $cost_gold) {
                 $this->get_data('Player')->check_player_resource($player_id, $player_basic_info, '-', 'ticket', $cost_gold);
                 $ticket = $cost_gold;
                 $cost_gold = 0;
             } else {
                 $ticket = $player_basic_info['ticket'];
                 $cost_gold = $cost_gold - $player_basic_info['ticket'];
                 $this->get_data('Player')->check_player_resource($player_id, $player_basic_info, '-', 'ticket', $player_basic_info['ticket']);
             }
         }
         $this->get_data('Player')->check_player_resource($player_id, $player_basic_info, "-", "gold", $cost_gold);
         $arr_consume = array('price' => $price, 'gold' => $cost_gold, 'ticket' => $ticket, 'count' => 1);
         #数据中心推送
         $arr_news_ids = $this->get_no_like_newsid($player_id);
         if (!$arr_news_ids) {
             $this->throw_error('72201');
         }
         //不存在未赞过
     }
     $objfrined = $this->get_data('PlayerFriend');
     $ret_news_ids = array();
     //成功点赞动态ID
     $ret_error_msg = '';
     $error_msg = '';
     $sum_add_exp = 0;
     $sum_add_silver = 0;
     $add_exp = 0;
     $player_data = $objfrined->get_player_friend($player_id, array('follow', 'like_news', 'like_times'));
     if ($player_data['like_times']['today_like_friend_times'] + $player_data['like_times']['today_times'] >= $like_max_times) {
         $error_msg = '70120';
         //今日点赞已达到上线
     } else {
         //一次性获取动态信息
         $news_data = $objfrined->get_news_info(implode(",", $arr_news_ids));
         if (empty($news_data)) {
             $this->throw_error('10104');
         }
         //不存在这条动态
         foreach ($news_data as $key => $val) {
             $news_info[$val['news_id']] = $val;
         }
         foreach ($arr_news_ids as $news_id) {
             if ($error_msg) {
                 $ret_error_msg = $error_msg;
             }
             //这条动态信息
             $error_msg = '';
             $friend_id = intval($news_info[$news_id]['player_id']);
             if ($player_data['like_times']['today_like_friend_times'] + $player_data['like_times']['today_times'] >= $like_max_times) {
                 $error_msg = '70120';
                 //今日点赞已达到上线
                 break;
             }
             if (!isset($player_data['follow']['info'][$friend_id])) {
                 $error_msg = '70107';
                 //未关注
                 continue;
             }
             #已赞过
             if (isset($player_data['like_news'][$news_id])) {
                 $error_msg = '71604';
                 continue;
             }
             if (count($player_data['like_news']) > 200) {
                 //删除老数据避免存储太多
                 asort($player_data['like_news']);
                 foreach ($player_data['like_news'] as $like_id => $news_time) {
                     if ($news_time > time() - 86400 * 2) {
                         break;
                     }
                     unset($player_data['like_news'][$like_id]);
                 }
             }
             //异步更新好友数据
             $sys_ret = $this->sys_update_like_friend_data($player_id, $friend_id, $news_id, $player_basic_info['name']);
             if ($sys_ret) {
                 $player_data['like_news'][$news_id] = $news_info[$news_id]['create_time'];
                 $player_data['like_times']['upts'] = time();
                 $player_data['like_times']['today_like_friend_times'] += 1;
                 $player_add_exp = $this->add_default_exp;
                 $ret_news_ids[] = $news_id;
                 $sum_add_exp += $player_add_exp;
                 $sum_add_silver += $this->add_default_silver;
             } else {
                 $error_msg = '10104';
             }
         }
     }
     $out_msg = "";
     if (empty($ret_news_ids)) {
         if ($ret_error_msg) {
             $code = $ret_error_msg;
         } else {
             if ($error_msg) {
                 $code = $error_msg;
             } else {
                 $code = '10101';
             }
         }
         $language_config = Cache_Language::getInstance()->get_language_info($code);
         $out_msg = $language_config['content'];
     } else {
         $this->start_trans();
         //我赞的奖励
         if ($is_key) {
             //一键点赞扣钻石
             $this->get_data('Player')->update_player_resource($player_id, $player_basic_info, 716, array(), $arr_consume);
         }
         unset($player_data['follow']);
         //不参与更新,以上判断$news_id合法性
         $player_ret = $objfrined->update_player_friend($player_id, $player_data);
         $reward = array();
         $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key(1), 'item_id' => 1, 'item_num' => $sum_add_exp);
         #$reward[] = array('type'=>Cache_FbLoot::getInstance()->get_item_key(3),'item_id'=>3,'item_num'=>$sum_add_silver);
         $ret_reward = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '102'));
         unset($player_basic_info['gold']);
         unset($player_basic_info['ticket']);
         $ret_player_basic = $this->get_data('Player')->update_player_info($player_id, $player_basic_info);
         if ($player_ret && $ret_player_basic) {
             $this->commit();
             $this->get_game('Reward')->add_reward_log();
             //				Protocol_Player::p2c_part_update($player_id,array('gold'=>'','ticket'=>''));
             #数据中心推送
             //                if($cost_gold > 0){
             //                    $params['act'] = 102;
             //                    $params['price'] = $cost_gold;
             //                    $params['gold'] = $cost_gold;
             //                    $params['black_gold'] = 0;
             //                    $params['count'] = 1;
             //                    $params['time'] = time();
             //                    Com_DataCenter::getInstance()->publish_data($player_id,'prop',$params);
             //                }
         } else {
             $this->rollback();
             $out_msg = '10104';
         }
     }
     $today_like_friend = intval($player_data['like_times']['today_like_friend_times']) + intval($player_data['like_times']['today_times']);
     $out = array();
     $out['player_id'] = $player_id;
     $out['page'] = $page;
     $out['is_key'] = $is_key;
     $out['today_like_player'] = $like_max_times;
     //被赞过
     $out['today_like_friend'] = $today_like_friend;
     //赞过+被赞过
     $out['news_ids'] = $ret_news_ids;
     $out['add_silver'] = $sum_add_silver;
     $out['add_exp'] = $sum_add_exp;
     $out['like_max_times'] = $like_max_times;
     $out['error_msg'] = $out_msg;
     return $out;
 }
Beispiel #23
0
 /**
  * 检查是否满足创建公会
  * @param unknown $player_id
  * @param unknown $name
  * @param unknown $introduce
  * @return string
  */
 protected function check_create_union($player_id, $name, $introduce, &$playerInfo, &$unionCreatConfig, &$arr_consume = array())
 {
     //已有公会
     if ($playerInfo['union_id']) {
         $this->throw_error('170101');
     }
     //level等级不足
     if ($playerInfo['level'] < $unionCreatConfig['level_need']) {
         $this->throw_error('170105');
     }
     $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10027);
     if ($vip_table['fun_type'] == 1) {
         $player_vip = $playerInfo['vip'];
     } elseif ($vip_table['fun_type'] == 2) {
         $left_time = $this->get_game('VipSpecial')->get_left_time($player_id);
         $player_vip = $left_time == 0 ? 0 : $playerInfo['privilege_level'];
     }
     #获取VIP配置表限制
     $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10027);
     if ($vip_table['vip_level'] < 1 || $player_vip < $vip_table['vip_level']) {
         $this->throw_error('170106');
         //vip等级不足
     }
     $field = Cache_FbLoot::getInstance()->get_item_key($unionCreatConfig['cost_type']);
     #先扣除彩钻
     $ticket = 0;
     $price = $unionCreatConfig['cost_num'];
     if ($field == "gold") {
         if ($playerInfo['ticket'] > 0) {
             if ($playerInfo['ticket'] >= $unionCreatConfig['cost_num']) {
                 $ticket = $unionCreatConfig['cost_num'];
                 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $unionCreatConfig['cost_num']);
                 $unionCreatConfig['cost_num'] = 0;
             } else {
                 $ticket = $playerInfo['ticket'];
                 $unionCreatConfig['cost_num'] = $unionCreatConfig['cost_num'] - $playerInfo['ticket'];
                 $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $playerInfo['ticket']);
             }
         }
         $arr_consume = array('price' => $price, 'gold' => $unionCreatConfig['cost_num'], 'ticket' => $ticket, 'count' => 1);
         #数据中心推送
     }
     $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', $field, $unionCreatConfig['cost_num']);
     //公会名称
     $name = trim($name);
     if (!$name) {
         //公会名称不能为空
         $this->throw_error('170102');
     }
     $nameCheck = Com_Filter::check_str($name, 3, 12);
     if ($nameCheck == -1) {
         //长度不符法
         $this->throw_error('170104');
     } else {
         if ($nameCheck < 0) {
             //名称不合法
             $this->throw_error('170103');
         } else {
             if (is_numeric($name)) {
                 //名称不为纯数字
                 $this->throw_error('170111');
             } else {
                 if (!Com_Filter::check_badWord($name)) {
                     ///名称不合法
                     $this->throw_error('170103');
                 }
             }
         }
     }
     //宣言
     $this->check_introduce($introduce);
     //公会名称唯一
     $info = $this->get_data('UnionInfo')->get_union_name($name);
     if (!empty($info)) {
         $this->throw_error('170107');
     }
 }
Beispiel #24
0
 /**
  * 领取奖励
  * @param unknown $player_id
  * @param unknown $achieve_id
  */
 public function receive_awards($player_id, $achieve_id)
 {
     $config = Cache_AchieveConfig::getInstance()->get_achieve_config($achieve_id);
     $title_id = $config['title_id'];
     $player_achieve_data = $this->get_data('PlayerAchieve')->get_player_achieve_info($player_id, $config['title_id']);
     //是否可领取
     if (!isset($player_achieve_data[$achieve_id])) {
         $this->throw_error('10101');
     }
     if (!$player_achieve_data[$achieve_id]['state']) {
         $this->throw_error('10101');
     }
     if (!$player_achieve_data[$achieve_id]['reward_state']) {
         $this->throw_error('10101');
     }
     $arr_reward = $this->get_format_achieve_reward($config['reward']);
     $reward = array();
     foreach ($arr_reward as $prop) {
         $prop_info = Cache_Prop::getInstance()->get_prop_info($prop[0]);
         if (empty($prop_info)) {
             $this->throw_error('80003', "5011007{$prop[0]}");
             //游戏配置出错,请联系客服!
         }
         if (isset($player_achieve_data[$achieve_id]['config'][$prop[0]])) {
             $config = $player_achieve_data[$achieve_id]['config'][$prop[0]];
             $reward[] = array('item_id' => $prop[0], 'item_num' => $prop[1], 'type' => Cache_FbLoot::getInstance()->get_item_key($prop[0]), 'config' => $config);
         } else {
             $reward[] = array('item_id' => $prop[0], 'item_num' => $prop[1], 'type' => Cache_FbLoot::getInstance()->get_item_key($prop[0]));
         }
     }
     $this->start_trans();
     $result = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '766', 'bind_flag' => 0));
     $code = 71609;
     if ($result == '80001') {
         $code = "10018";
     }
     if ($result !== true) {
         $this->rollback();
         $this->throw_error($code);
     }
     $player_achieve_data[$achieve_id]["reward_state"] = 0;
     $ret_state = $this->get_data('PlayerAchieve')->update_player_achieve($player_id, $title_id, $player_achieve_data, $achieve_id);
     if (!$ret_state) {
         $this->rollback();
         $this->throw_error($code);
     }
     $this->commit();
     $this->get_game('Reward')->add_reward_log(true);
     $out["arr_reward"] = $reward;
     $out["achieve_id"] = $achieve_id;
     return $out;
 }