Exemple #1
0
 public function compose($player_id, $target_id, $comp_type, $comp_sub_type, $auto_buy, $onekey)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id);
     # 参数校验,comp_sub_type允许为0
     $this->param_check_numeric(array($player_id, $target_id, $comp_type, $comp_sub_type), 0);
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'player_id', 'level', 'vip', 'privilege_level')));
     # 一键合成不允许自动购买
     if ($onekey) {
         $auto_buy = 0;
     }
     # 获取具体合成信息
     $comp_info = Cache_ItemCompose::getInstance()->get_item_compose_info_by_target_id($target_id);
     if (empty($comp_info)) {
         $this->throw_error('90002');
         # 没有配置该道具的合成信息
     }
     $comp_type = $comp_info['comp_type'];
     $comp_sub_type = $comp_info['comp_sub_type'];
     /** 由于前端问题,传参此处可能报异常,反正这两个参数不实用,故忽略
     		if ($comp_info['comp_type'] != $comp_type || $comp_info['comp_sub_type'] != $comp_sub_type) {
     			$this->throw_error('90003'); # 合成参数异常
     		}
     		**/
     # 检查消耗情况
     $cost_material_info_hash = array();
     # 消耗材料信息哈希,为了方便一次性查找所有消耗材料的持有数
     for ($i = 1; $i <= 5; $i++) {
         if (!empty($comp_info['m' . $i . '_id']) && !empty($comp_info['m' . $i . '_amount'])) {
             $cost_material_info_hash[$comp_info['m' . $i . '_id']] = $comp_info['m' . $i . '_amount'];
         }
     }
     # --------------------------------------------------------------------
     # 计算可一键合成的产物数量
     # --------------------------------------------------------------------
     $onekey_num_list = array();
     # 每项材料可以满足合成条件几次
     if (!empty($cost_material_info_hash)) {
         $material_hold_nums = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, array_keys($cost_material_info_hash));
         foreach ($cost_material_info_hash as $m_id => $m_amount) {
             $onekey_num_list[$m_id] = intval($material_hold_nums[$m_id] / $m_amount);
         }
     }
     $onekey_num = min($onekey_num_list);
     # 木桶原理,能一键合成的产物数由最少材料项决定
     if ($onekey) {
         if (empty($onekey_num)) {
             $this->throw_error('90004');
             # 合成所需材料不足
         }
         $onekey_num = min($onekey_num, intval($player_info['silver'] / $comp_info['cost']));
         # 木桶原理,能一键合成的产物数还由玩家持有货币决定
         if (empty($onekey_num)) {
             $this->throw_error('10113');
             # 金币不足
         }
     } else {
         if (empty($onekey_num) && empty($auto_buy)) {
             $this->throw_error('90004');
             # 合成所需材料不足
         }
         $onekey_num = 1;
         # 非一键合成一次只允许合成一件
     }
     $this->start_trans();
     # 消耗虚拟货币
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $comp_info['cost'] * $onekey_num, 1, 1);
     # 消耗材料
     $arr_logs = array();
     $log_param = array('level' => $player_info['level'], 'vip' => $player_info['vip'], 'privilege_level' => $player_info['privilege_level'], 'cmd_id' => 2202);
     foreach ($cost_material_info_hash as $m_id => $m_amount) {
         $hold_num = !empty($material_hold_nums[$m_id]) ? $material_hold_nums[$m_id] : 0;
         if (!empty($auto_buy) && $hold_num < $m_amount) {
             # 一定是单次合成
             # 获取正确的单价
             $price_info = $this->get_game('Shop')->shortcut_purchase_interface($m_id, 1);
             if (empty($price_info['item_price'])) {
                 $this->throw_error('130001');
                 # 商城没有出售该道具
             }
             # 策划价格配置多项时,选其中一项
             list($cur_idx, $cur_val) = each($price_info['item_price']);
             $price = $cur_val;
             $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx);
             $cost_currency_value = intval($cur_val * ($m_amount - $hold_num));
             $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cur_idx);
             if ($hold_num > 0) {
                 # 该方法在道具不足时会报错,无需外层再判断是否道具足够
                 $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $material_hold_nums[$m_id], $arr_logs, 0, $log_param);
                 $this->write_check($re, 3010156);
             }
             # 若有购买缺少材料,记录虚假商城购买日志
             if ($cost_currency_value > 0) {
                 $this->get_game('Shop')->add_dummy_shop_log($player_id, $player_info, $m_id, intval($m_amount - $hold_num), $cur_idx, $cost_currency_value, 2202);
             }
         } else {
             # 可能单次,可能一键
             # 该方法在道具不足时会报错,无需外层再判断是否道具足够
             $re = $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $m_id, $m_amount * $onekey_num, $arr_logs, 0, $log_param);
             $this->write_check($re, 3010161);
         }
     }
     # TODO: 数据中心推送
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '2202');
     $this->write_check($re, 3010167);
     #---------------------------------------------------------------------
     # 按概率计算成功次数
     #---------------------------------------------------------------------
     $success_num = 0;
     for ($i = 1; $i <= $onekey_num; $i++) {
         if (Com_Random::probability($comp_info['succ_rate'], 10000)) {
             # 成功
             $success_num += 1;
         }
     }
     if ($success_num) {
         # 成功
         # 发送道具
         $reward[] = array('type' => 'prop', 'item_id' => $target_id, 'item_num' => $success_num);
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => 2202));
         #send_reward失败时,会返回各种失败情况的错误码
         $this->write_check_strict($re, 3010173);
     }
     # 记录合成日志
     $this->commit();
     # --------------------------------------------------------------------
     # 通知道具变更,粘包806
     # --------------------------------------------------------------------
     $this->get_game('Reward')->add_reward_log();
     # 调用add_reward_log,触发806协议通知道具变更,并记录道具获取日志
     if (!empty($arr_logs) && is_array($arr_logs)) {
         $ndata = array();
         foreach ($arr_logs as $key => $val) {
             $ndata[] = $val;
         }
         Protocol_Prop::prop_806($player_id, $ndata);
     }
     # --------------------------------------------------------------------
     # 刷新2201协议
     # --------------------------------------------------------------------
     $data_2201 = $this->get_compose_info($player_id, $comp_type, $comp_sub_type);
     Protocol::input($player_id, 3, 22, 2201, $data_2201);
     # 记录行为
     Com_Log::write('xgame.compose', "{$player_id}\t" . "{$target_id}\t" . "{$auto_buy}\t" . "{$onekey}\t" . "{$onekey_num}\t" . "{$success_num}\t");
     # 日常任务埋点,宝石合成才触发,考虑宝石种类可能包含多种,不方便使用$arr_logs[0]['type'] == 3 && $arr_logs[0]['sub_type'] == 6类似条件
     #if ($comp_type == $this->comp_type_for_gem) { # 改为任意合成都算
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 109, 109, $onekey_num);
     #}
     #引导任务
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 12, $onekey_num);
     # --------------------------------------------------------------------
     # 公告
     # --------------------------------------------------------------------
     $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 1, 'rep_val' => 70), array('rep_type' => 2, 'rep_val' => $target_id));
     $prop_info = Cache_Prop::getInstance()->get_prop_info($target_id);
     $this->get_game('SystemNotice')->push_sys_notice($player_id, 70, 0, $replace_info, 0, $prop_info['need_broad_cast']);
     $out_2202 = array('result' => 1);
     return $out_2202;
 }
Exemple #2
0
 /**
  * @Purpose:
  * 提升英雄成长值
  * @Param $player_id 
  * @Param $hero_id
  * @Param $state 0普通提升 1批量提升
  * @Param $auto 为1时表示道具不足时从上次自动购买道具
  */
 public function player_hero_grow_upgrade($player_id, $hero_id, $state, $auto = 0)
 {
     $player_id = intval($player_id);
     $hero_id = strval($hero_id);
     $obj_player_hero_data = $this->get_data('PlayerHero');
     $hero_data = $obj_player_hero_data->get_player_hero_info($player_id, $hero_id);
     if (empty($hero_data)) {
         $this->throw_error('10102');
         #英雄不存在
     }
     $hero_conf = Cache_HeroAttr::getInstance()->get_hero_attr_info($hero_data['hero_code']);
     if (empty($hero_conf)) {
         $this->throw_error('50120');
         #英雄配置错误
     }
     if ($hero_data['grow_rate'] >= $hero_conf['grow_limit']) {
         $this->throw_error('50121');
         #成长值已达上限
     }
     $obj_hero_grow = $this->get_data('PlayerHeroGrow');
     $hero_grow_id = $obj_hero_grow->get_player_hero_grow_data($hero_id);
     $hero_grow_conf = array();
     $findFlag = false;
     if (!$hero_grow_id) {
         $findFlag = true;
     } else {
         $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id);
         if (empty($hero_grow_conf)) {
             $findFlag = true;
         } else {
             if ($hero_data['grow_rate'] < $hero_grow_conf['grow_left'] || $hero_data['grow_rate'] >= $hero_grow_conf['grow_right']) {
                 #区间错误
                 $findFlag = true;
             }
         }
     }
     if ($findFlag) {
         #启动自动纠错
         $hero_grow_id = $this->find_hero_grow_id($hero_data['grow_rate'], $hero_grow_conf);
         if (!$hero_grow_id) {
             $this->throw_error('10111');
             #配置错误
         }
     }
     if (empty($hero_grow_conf)) {
         $this->throw_error('10111');
     }
     $obj_prop_game = $this->get_game('Prop');
     $obj_shop_game = $this->get_game('Shop');
     $consume_props = $last_props = $arr_consume = $arr_shop_log = array();
     $last_props[$hero_grow_conf['item_id']] = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $hero_grow_conf['item_id']));
     if (empty($auto) && $last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) {
         $this->throw_error('50107');
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $crit_counter = 0;
     #暴击计数
     $counter = 10;
     #while执行计数
     $sum_rand_grow_val = 0;
     #总提升数量
     $new_hero_grow_val = 0;
     #新的成长值
     $upgrade_times = $counter;
     $error_code = 0;
     $update_gold = false;
     #是否更新彩钻或钻石资源
     do {
         $need_buy_prop_nums = 0;
         #每次执行所需要的材料需在商城购买的数量
         if ($last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) {
             $last_props[$hero_grow_conf['item_id']] = 0;
             $need_buy_prop_nums = $hero_grow_conf['item_nums'] - $last_props[$hero_grow_conf['item_id']];
             if ($last_props[$hero_grow_conf['item_id']] > 0) {
                 $consume_props[$hero_grow_conf['item_id']] += $last_props[$hero_grow_conf['item_id']];
             }
         } else {
             $last_props[$hero_grow_conf['item_id']] -= $hero_grow_conf['item_nums'];
             #剩余数量
             $consume_props[$hero_grow_conf['item_id']] += $hero_grow_conf['item_nums'];
             #消耗数量
         }
         if ($need_buy_prop_nums > 0) {
             #材料不足需要在商城购买
             $update_gold = true;
             $buy_prop_info = $obj_shop_game->shortcut_purchase_interface($hero_grow_conf['item_id'], 1);
             if (empty($buy_prop_info['item_price'])) {
                 $this->throw_error('130001');
                 #商城没有出售该道具
             }
             list($cost_currency_type, $cost_currency_value) = each($buy_prop_info['item_price']);
             $cost_currency_value *= $need_buy_prop_nums;
             $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
             $arr_tmp_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, $need_buy_prop_nums);
             if (!empty($arr_tmp_consume)) {
                 $arr_consume['price'] += $arr_tmp_consume['price'];
                 $arr_consume['gold'] += $arr_tmp_consume['gold'];
                 $arr_consume['ticket'] += $arr_tmp_consume['ticket'];
                 $arr_consume['count'] += $arr_tmp_consume['count'];
             }
             #虚拟商城记录日志
             if (!isset($arr_shop_log[$hero_grow_conf['item_id']])) {
                 $arr_shop_log[$hero_grow_conf['item_id']]['cost_resource_id'] = $cost_currency_type;
             }
             $arr_shop_log[$hero_grow_conf['item_id']]['item_num'] += $need_buy_prop_nums;
             $arr_shop_log[$hero_grow_conf['item_id']]['cost_resource_num'] += $cost_currency_value;
             $error_code = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 0, $cost_currency_type);
             if ($error_code !== true) {
                 if ($counter == 10) {
                     #首次执行如果资源不足则退出
                     $this->throw_error($error_code);
                 }
                 break;
             }
         }
         $counter--;
         $rand_val = 0;
         $is_crit = Com_Random::probability($hero_grow_conf['crit_rate']);
         if ($is_crit) {
             $crit_counter++;
             $rand_val = $this->parse_data($hero_grow_conf['val_crit']);
         } else {
             $rand_val = $this->parse_data($hero_grow_conf['val_nor']);
         }
         if (!$rand_val) {
             $this->throw_error('50122');
             #英雄成长配置表解析错误
         }
         #单次随机值
         $real_rand_val = Com_Random::get_probability_key($rand_val);
         #批量随机值之和
         $sum_rand_grow_val += $real_rand_val;
         #英雄的新成长值
         $new_hero_grow_val = $hero_data['grow_rate'] + $sum_rand_grow_val;
         if ($new_hero_grow_val >= $hero_conf['grow_limit']) {
             #超过英雄成长值上限
             $new_hero_grow_val = $hero_conf['grow_limit'];
             $sum_rand_grow_val = $hero_conf['grow_limit'] - $hero_data['grow_rate'];
             break;
         }
         #移动至下一个成长值区间
         if ($new_hero_grow_val > $hero_grow_conf['grow_right']) {
             $hero_grow_id++;
             $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id);
             if (empty($hero_grow_conf)) {
                 break;
             }
             if (!isset($last_props[$hero_grow_conf['item_id']])) {
                 $last_props[$hero_grow_conf['item_id']] = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $hero_grow_conf['item_id']));
             }
         }
         if (empty($auto) && $last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']) {
             #道具不足
             break;
         }
     } while ($counter > 0 && $state > 0);
     #控制循环数量防止进入死循环
     $this->start_trans();
     $result = true;
     if ($update_gold) {
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 557, array(), $arr_consume);
         $this->write_check($result, 3010476);
     }
     if (!empty($consume_props)) {
         $log_param = array('cmd_id' => 557, 'level' => $player_info['level'], 'vip' => $player_info['vip']);
         $logs = array();
         foreach ($consume_props as $prop_id => $prop_nums) {
             #批量扣除多个道具如果可能
             $result = $obj_prop_game->deduct_prop_by_prop_id($player_id, $prop_id, $prop_nums, $logs, 1, $log_param);
             if (!$result) {
                 $this->throw_error('10101');
             }
         }
     }
     if ($result) {
         $hero_data['grow_rate'] = $new_hero_grow_val;
         $hero_data['fight'] = $this->calc_fight($player_id, $hero_data, $hero_data['fit'], $hero_data['rune_hole_list'], $hero_data['star_add_attr_per'], $hero_data['skill_list']);
         $update_field['grow_rate'] = $hero_data['grow_rate'];
         $update_field['fight'] = $hero_data['fight'];
         $result = $this->update_db($player_id, $update_field, $hero_data, 557);
         $this->get_data('RankList')->update_hero_rank($hero_id, $hero_data['fight']);
     }
     if ($result) {
         $this->commit();
         $obj_hero_grow->set_player_hero_grow_data($hero_id, $hero_grow_id);
         $n_hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($hero_grow_id);
         #引导任务
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 26, $upgrade_times - $counter);
         $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 37, $hero_data['grow_rate'] + $hero_data['fit_grow'], 8);
         if (!empty($arr_shop_log)) {
             foreach ($arr_shop_log as $item_id => $item_info) {
                 $obj_shop_game->add_dummy_shop_log($player_id, $player_info, $item_id, $item_info['item_num'], $item_info['cost_resource_id'], $item_info['cost_resource_num'], 557);
             }
         }
         return array('res' => $crit_counter, 'rand_val' => $sum_rand_grow_val, 'cur_grow_val' => $new_hero_grow_val, 'effect' => 10000 * round($this->calc_grow_attar($new_hero_grow_val, $hero_conf['grow']), 4), 'prop_id' => $n_hero_grow_conf['item_id'], 'prop_nums' => $n_hero_grow_conf['item_nums'], 'nor_desc' => $n_hero_grow_conf['nor_desc'], 'crit_desc' => $n_hero_grow_conf['crit_desc']);
     } else {
         $this->throw_error('10101');
     }
 }
Exemple #3
0
 /**
  * 夺宝战斗结果
  * @param unknown $player_id
  * @param unknown $battle_seq
  * @param unknown $winner_player_id
  * @param unknown $loser_player_id
  */
 public function battle_result($player_id, $battle_seq, $winner_player_id, $loser_player_id)
 {
     $battle_seq = intval($battle_seq);
     $winner_player_id = intval($winner_player_id);
     $loser_player_id = intval($loser_player_id);
     $this->start_trans();
     $grab_fail_award = "";
     $get_piece_id = "";
     $battle_result = 0;
     $grab_result = 0;
     $opponent_player_id = $winner_player_id;
     $phrase_id = 0;
     $player_info = array();
     $opponent_player_info = array();
     if ($winner_player_id == 0 && $loser_player_id == 0) {
         $battle_id_info = $this->get_data("GrabTreasure")->get_battle_id_info($battle_seq);
         $player_id = $battle_id_info['player_id'];
         $opponent_player_id = $battle_id_info['opponent_player_id'];
         $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
         $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
         if (empty($opponent_player_info)) {
             $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
         }
         Com_Log::debug_write('async_trigger_battle_test', "player_id={$player_id},{$player_info['sum_fpower']}={$opponent_player_info['sum_fpower']}");
         if ($player_info['sum_fpower'] > $opponent_player_info['sum_fpower']) {
             $winner_player_id = $player_id;
             $loser_player_id = $opponent_player_id;
             $phrase_id = 16;
         } else {
             $winner_player_id = $opponent_player_id;
             $loser_player_id = $player_id;
             $phrase_id = 17;
         }
     }
     if ($player_id == $winner_player_id) {
         $battle_result = 1;
         $opponent_player_id = $loser_player_id;
         if (empty($opponent_player_info) || empty($player_info)) {
             $player_info = $this->get_data('Player')->get_player_info($player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
             $opponent_player_info = $this->get_cross("GrabTreasure")->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
             if (empty($opponent_player_info)) {
                 $opponent_player_info = $this->get_data('Player')->get_player_info($opponent_player_id, array("sum_fpower", "is_dummy", "name", "vip", "privilege_level", "level"));
             }
         }
         #抢碎片成功概率
         $rate_config = $this->get_battle_success_rate($player_info, $opponent_player_info);
         $random_get_piece_result = Com_Random::probability($rate_config['success_rate'], 100);
         #新手引导成功率100%
         $player_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($player_id, array("battle_log_id", "battle_need_piece_id", "battle_piece_quality", "quality_piece_ids", "is_guide"));
         if (intval($player_treasure_info["is_guide"]) == 1) {
             $random_get_piece_result = true;
         }
         $player_treasure_info["is_guide"] = 0;
         #抢碎片成功
         if ($random_get_piece_result) {
             $grab_result = 1;
             $quality = $player_treasure_info["battle_piece_quality"];
             $need_piece_id = $player_treasure_info["battle_need_piece_id"];
             #挑战成功加碎片
             $player_treasure_info["quality_piece_ids"][$quality][$need_piece_id] = $need_piece_id;
             #真实玩家
             if ($opponent_player_info['is_dummy'] == 0) {
                 $grab_piece_id = $need_piece_id;
                 $opponent_treasure_info = $this->get_cross("GrabTreasure")->get_grab_treasure($opponent_player_id, array("quality_piece_ids"));
                 #碎片存在
                 if (isset($opponent_treasure_info["quality_piece_ids"][$quality]) && !empty($opponent_treasure_info["quality_piece_ids"][$quality])) {
                     if (isset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id])) {
                         unset($opponent_treasure_info["quality_piece_ids"][$quality][$need_piece_id]);
                     } else {
                         $grab_piece_id = array_shift($opponent_treasure_info["quality_piece_ids"][$quality]);
                     }
                     #被抢者扣碎片
                     $re = $this->get_cross("GrabTreasure")->update_grab_treasure($opponent_player_id, $opponent_treasure_info);
                     $this->write_check($re, 5010859);
                     #抢者加碎片
                     $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info);
                     $this->write_check($re, 5010867);
                     #解除战斗中锁
                     $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id);
                     $this->write_check($re, 5010862);
                     #抢碎片日志
                     #{0}抢走了你的{1},简直不能忍!
                     $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($grab_piece_id);
                     $arr_replace = array(array('rep_type' => 0, 'rep_val' => $player_id, 'txt' => $player_info['name']), array('rep_type' => 7, 'txt' => $pieceConfig['name']));
                     $msg = Language_Message::make_message(123001, $arr_replace);
                     $add_log["player_id"] = $opponent_player_id;
                     $add_log["grab_player_id"] = $player_id;
                     $add_log["grab_piece_id"] = $grab_piece_id;
                     $add_log["quality"] = $quality;
                     $add_log["add_time"] = time();
                     $add_log['rep_content'] = $msg;
                     $add_log["is_allow_grab"] = 1;
                     $re = $this->get_cross("GrabTreasureLog")->add_grab_treasure_log($battle_seq, $add_log);
                     $this->write_check($re, 5010876);
                 } else {
                     $grab_result = 0;
                 }
             } else {
                 $re = $this->get_cross("GrabTreasure")->update_grab_treasure($player_id, $player_treasure_info);
                 $this->write_check($re, 5010992);
             }
             if (intval($player_treasure_info['battle_log_id']) > 0) {
                 $data = $this->get_cross('GrabTreasureLog')->get_grab_treasure_log($player_id, $player_treasure_info['battle_log_id']);
                 if (!empty($data)) {
                     $data['is_allow_grab'] = 0;
                     $re = $this->get_cross('GrabTreasureLog')->update_grab_treasure_info($player_id, $player_treasure_info['battle_log_id'], $data);
                     $this->write_check($re, 5010983);
                 }
             }
         }
         if ($grab_result == 0) {
             $need_piece_id = '';
             $grab_fail_award = $rate_config['fail_award'];
             $reward = $this->get_format_reward($grab_fail_award);
             if ($phrase_id > 0) {
                 $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($phrase_id);
                 $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 1230);
             } else {
                 $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '1230'), 1);
                 if ($re !== true) {
                     $this->write_check($re, 5011077);
                 }
             }
         }
     }
     $is_battle_lock = $this->get_cross("GrabTreasure")->get_battle_lock($opponent_player_id);
     if ($is_battle_lock) {
         $re = $this->get_cross("GrabTreasure")->clear_battle_lock($opponent_player_id);
         $this->write_check($re, 5010872);
     }
     $this->commit();
     if ($battle_result == 1 && $grab_result == 0 && $phrase_id == 0) {
         $this->get_game('Reward')->add_reward_log();
     }
     if ($battle_result == 0 && $phrase_id > 0) {
         $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($phrase_id);
         $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1);
     }
     #抢碎片增加日志
     if ($grab_result == 1) {
         if ($opponent_player_info['is_dummy'] == 0) {
             Log_Common::getInstance()->add_prop_log($opponent_player_id, $opponent_player_info['level'], $opponent_player_info['vip'], $opponent_player_info['privilege_level'], 1231, 11, 0, $grab_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0);
         }
         $pieceConfig = Cache_GrabTreasurePiece::getInstance()->get_grab_treasure_piece($need_piece_id);
         Log_Common::getInstance()->add_prop_log($player_id, $player_info['level'], $player_info['vip'], $player_info['privilege_level'], 1231, 10, 0, $need_piece_id, 1, $pieceConfig['name'], $quality, 1, 0, 1, '', 0);
         if ($phrase_id > 0) {
             $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(18);
             $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], array(), $phrase_config['sender'], 1);
         }
     }
     $out = array('battle_result' => $battle_result, 'grab_result' => $grab_result, 'get_piece_id' => $need_piece_id, 'grab_fail_award' => $grab_fail_award);
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, 1040);
     #日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 119, 119, 1);
     Protocol::input($player_id, 8, 12, 1230, $out);
 }
Exemple #4
0
 /**
  * 获取掉落数据
  * @param $loot_id
  * @return array
  */
 public function get_prop_loot($loot_id, $career_type = 0)
 {
     $prop_list = array();
     $condition = Cache_LootCondition::getInstance()->get_loot_condition($loot_id);
     if (intval($condition['prob_part_per_million']) > 0) {
         //0直接退出
         $flag = Com_Random::probability($condition['prob_part_per_million'], 1000000);
         if ($flag) {
             $loop_times = 0;
             //普通循环次数
             $arr_loop = array();
             $arr_critical_loop = array();
             for ($i = 0; $i < 5; $i++) {
                 //把循环次数权重取出
                 $lkey = 'count_weight' . $i;
                 $wkey = 'critical_weight' . $i;
                 $arr_loop[$i] = $condition[$lkey];
                 $arr_critical_loop[$i] = $condition[$wkey];
             }
             $crit_flag = Com_Random::probability($condition['critical_prob_part_per_million']);
             if ($crit_flag) {
                 //算暴击次数
                 $wkey = Com_Random::get_probability_key($arr_critical_loop);
                 $wkey = 'critical_times' . $wkey;
                 $loop_times += $condition[$wkey];
             }
             $lkey = Com_Random::get_probability_key($arr_loop);
             $lkey = 'count' . $lkey;
             $loop_times += $condition[$lkey];
             $loot_info = Cache_Loot::getInstance()->get_Loot_info($condition['loot_id']);
             if (!empty($loot_info)) {
                 $arr_loot_lib = array();
                 foreach ($loot_info as $loot) {
                     $arr_loot_lib[$loot['loot_lib_id']] = $loot['weight'];
                 }
                 $loot_lib = array();
                 for ($i = 0; $i < $loop_times; $i++) {
                     //获取掉落库的随机次数
                     $key = Com_Random::get_probability_key($arr_loot_lib);
                     $loot_lib[$key] += 1;
                 }
                 if (!empty($loot_lib)) {
                     foreach ($loot_lib as $key => $times) {
                         $arr_loot_lib = Cache_LootLib::getInstance()->get_loot_lib_info($key);
                         if (!empty($arr_loot_lib)) {
                             $arr_item = array();
                             $arr_item_limit = array();
                             $arr_item_num = array();
                             foreach ($arr_loot_lib as $loot_lib_info) {
                                 if ($loot_lib_info['class_filter'] > 0 && $loot_lib_info['class_filter'] != $career_type) {
                                     continue;
                                 }
                                 $arr_item[$loot_lib_info['item_sid']] = $loot_lib_info['weight'];
                                 $arr_item_num[$loot_lib_info['item_sid']] = $loot_lib_info['count'] <= 0 ? 1 : $loot_lib_info['count'];
                                 if ($loot_lib_info['loop_limit'] > 0) {
                                     if ($loot_lib_info['loop_limit'] > 0) {
                                         $arr_item_limit[$loot_lib_info['item_sid']] = $loot_lib_info['loop_limit'];
                                     }
                                 }
                             }
                             if (!empty($arr_item)) {
                                 for ($i = 0; $i < $times; $i++) {
                                     if (empty($arr_item)) {
                                         break;
                                     }
                                     $key = Com_Random::get_probability_key($arr_item);
                                     if (!isset($prop_list[$key])) {
                                         $type = $this->get_item_key($key);
                                         if ($type == 'prop') {
                                             $prop_list[$key] = array('type' => $type, 'item_id' => $key, 'item_num' => $arr_item_num[$key]);
                                         } else {
                                             $prop_list[$key] = array('type' => $type, 'item_id' => $key, 'item_num' => $arr_item_num[$key]);
                                         }
                                     } else {
                                         $prop_list[$key]['item_num'] += $arr_item_num[$key];
                                     }
                                     if (isset($arr_item_limit[$key])) {
                                         $arr_item_limit[$key] -= 1;
                                         if ($arr_item_limit[$key] <= 0) {
                                             unset($arr_item[$key]);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $flag = Com_Random::probability($condition['prob_silver_part_per_million'], 1000000);
     if ($flag) {
         $item_num = rand($condition['min_silver'], $condition['max_silver']);
         if ($item_num > 0) {
             if (isset($prop_list[3])) {
                 $item_num = $prop_list[3]['item_num'] + $item_num;
             }
             $prop_list[3] = array('type' => $this->get_item_key(3), 'item_id' => 3, 'item_num' => $item_num);
         }
     }
     $flag = Com_Random::probability($condition['prob_mojo_part_per_million'], 1000000);
     if ($flag) {
         $item_num = rand($condition['min_mojo'], $condition['max_mojo']);
         if ($item_num > 0) {
             if (isset($prop_list[13])) {
                 $item_num = $prop_list[13]['item_num'] + $item_num;
             }
             $prop_list[13] = array('type' => $this->get_item_key(13), 'item_id' => 13, 'item_num' => $item_num);
         }
     }
     if ($prop_list) {
         $now_time = time();
         foreach ($prop_list as $key => $item) {
             if ($item['item_id'] > 200) {
                 $arrPropConfig = Cache_Prop::getInstance()->get_prop_info($item['item_id']);
                 $prop_list[$key]['prop_config'] = $arrPropConfig;
                 if (!empty($arrPropConfig['generate_start_time']) && !empty($arrPropConfig['generate_end_time']) && ($now_time < strtotime($arrPropConfig['generate_start_time']) || $now_time > strtotime($arrPropConfig['generate_end_time']))) {
                     unset($prop_list[$key]);
                 }
             }
         }
     }
     return $prop_list;
 }
Exemple #5
0
 public function enhanced_refine($player_id, $player_prop_id, $refine_attr_seq, $add_success_rate)
 {
     #$this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_enhanced_refine);
     $this->param_check_numeric(array($player_id, $refine_attr_seq));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (!$player_equip_info) {
         $this->throw_error('80013');
         # 玩家没有该装备!
     }
     if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) {
         $this->throw_error('81105');
         # 首充装备不允许精练
     }
     $out_850 = array('player_prop_id' => $player_prop_id, 'result' => 0);
     # 洗练属性检查
     if (empty($player_equip_info['refine_info'])) {
         $this->throw_error('81008');
         # 洗练属性为空,不能精炼
     }
     # 获取洗练属性key
     /**
     		foreach ($player_equip_info['refine_info']['attr_info'] as $attr_seq => $attr_info) {
     			if ($attr_info['attr_seq'] == $refine_attr_seq) {
     				$en_refine_attr_key = $attr_info['attr_key'];
     				break;
     			}
     		}
     		**/
     if (!isset($player_equip_info['refine_info']['attr_info'][$refine_attr_seq])) {
         $this->throw_error('81009');
         # 精炼属性异常,选择的精炼属性不存在
     }
     $refine_info = $player_equip_info['refine_info'];
     $refine_attr = $player_equip_info['refine_attr'];
     $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']);
     if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] >= $player_equip_info['level'] && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) {
         $this->throw_error('81010');
         # 精炼属性已满
     }
     # 计算成功率 + 货币消耗
     $refine_info_mod = $this->get_en_refine_success_rate_and_cost_currency($refine_info);
     list($cost_currency_type, $cost_currency_value) = explode(":", $refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_cost_currency']);
     if ($add_success_rate) {
         $refine_info_mod['en_refine_success_rate'] += $this->add_success_rate;
     }
     $before_refine_attr = isset($player_equip_info['refine_attr']) ? $player_equip_info['refine_attr'] : array();
     $before_refine_info = isset($player_equip_info['refine_info']) ? $player_equip_info['refine_info'] : array();
     # 更新洗练属性 + 消耗货币
     $this->start_trans();
     $success_flag = false;
     if (Com_Random::probability($refine_info_mod['attr_info'][$refine_attr_seq]['en_refine_success_rate'], 10000)) {
         if ($refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']) {
             $delta = ceil($refine_info_mod['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info_mod['attr_info'][$refine_attr_seq]['attr_section']);
         } else {
             $delta = 0;
         }
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] += $delta;
         if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] > $refine_info['attr_info'][$refine_attr_seq]['attr_stint']) {
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['attr_stint'];
         }
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] += 1;
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] = 0;
         $refine_info['attr_info'][$refine_attr_seq]['attr_value'] = $refine_info['attr_info'][$refine_attr_seq]['refine_attr_value'] + $refine_info['attr_info'][$refine_attr_seq]['en_refine_attr_value'];
         # 升级
         $en_refine_lv_stint = $this->get_en_refine_lv_stint($player_equip_info['level']);
         $en_refine_attr_value_current_lv = $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] * ceil($refine_info['attr_info'][$refine_attr_seq]['attr_limit'] / $refine_info['attr_info'][$refine_attr_seq]['attr_section']);
         if ($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] < $en_refine_lv_stint && $en_refine_attr_value_current_lv >= $refine_info['attr_info'][$refine_attr_seq]['attr_limit']) {
             # 获取精练属性基础值
             $attr_value_info_en_refine_old = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_lv'] += $this->en_refine_lv_delta;
             $attr_value_info_en_refine = Cache_Refine::getInstance()->get_attr_value_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             if (empty($attr_value_info_en_refine)) {
                 $this->throw_error('81011');
                 # 获取洗练属性值配置失败
             }
             $attr_key = $refine_info['attr_info'][$refine_attr_seq]['attr_key'];
             $attr_ratio = $refine_info['attr_info'][$refine_attr_seq]['attr_ratio'];
             $refine_info['attr_info'][$refine_attr_seq]['attr_limit'] = ceil(($attr_value_info_en_refine[$attr_key] - $attr_value_info_en_refine_old[$attr_key]) * ($attr_ratio / 10000));
             $en_refine_conf = Cache_Refine::getInstance()->get_equip_enhanced_refine_base_info($refine_info['attr_info'][$refine_attr_seq]['en_refine_lv']);
             $refine_info['attr_info'][$refine_attr_seq]['attr_section'] = $en_refine_conf['section'];
             $refine_info['attr_info'][$refine_attr_seq]['en_refine_success_num'] = 0;
         }
         $refine_attr[$refine_attr_seq] = array($refine_info['attr_info'][$refine_attr_seq]['attr_key'] => $refine_info['attr_info'][$refine_attr_seq]['attr_value']);
         $out_850['result'] = 1;
         $success_flag = true;
     } else {
         $refine_info['attr_info'][$refine_attr_seq]['en_refine_failed_cont'] += 1;
         # 连续失败精炼次数
     }
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, 1);
     if ($add_success_rate) {
         $cost_currency_key_other = Cache_Currency::getInstance()->get_key($this->add_success_rate_cost_cur_type);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key_other, $this->add_success_rate_cost_cur_value, 1, 0);
     }
     $re = $this->get_data('Player')->update_player_resource($player_id, $player_info, '850');
     $this->write_check($re, 3010132);
     $update_field = array('refine_attr' => $refine_attr, 'refine_info' => $refine_info);
     $re = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $update_field);
     $this->write_check($re, 3010414);
     $this->commit();
     # 提示购买成功消息
     if ($success_flag) {
         $message = array('texts' => array(array('code' => 81014, 'content' => array(), 'params' => array(array(array('txt' => '', 'type' => 6, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_key'], 'param' => '')), array(array('txt' => '', 'type' => 7, 'value' => $refine_info['attr_info'][$refine_attr_seq]['attr_value'] - $before_refine_info['attr_info'][$refine_attr_seq]['attr_value'], 'param' => ''))))), 'delay' => 0);
     } else {
         $message = array('texts' => array(array('code' => 81015, 'content' => array(), 'params' => array())), 'delay' => 0);
     }
     Protocol::input($player_id, 3, 7, 742, $message);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id_master' => $player_prop_id, 'item_id_master' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'item_position' => $player_equip_info['item_position'], 'action_type' => 2, 'before_refine_attr' => $before_refine_attr, 'after_refine_attr' => $player_equip_info['refine_attr'], 'before_refine_info' => $before_refine_info, 'after_refine_info' => $player_equip_info['refine_info']);
     Log_Forge::getInstance()->add_log($log_info, 'refine');
     # 刷新玩家属性
     if ($player_equip_info['item_position'] == 3) {
         $this->get_game('EquipAttr')->equip_attr($player_id);
     }
     # 粘806 + 通知道具变更信息
     $player_equip_info['refine_attr'] = $update_field['refine_attr'];
     $player_equip_info['refine_info'] = $update_field['refine_info'];
     $ndata = array($player_equip_info);
     Protocol_Prop::prop_806($player_id, $ndata);
     $out_849 = $this->get_enhanced_refine_info($player_id, $player_prop_id, $refine_attr_seq);
     Protocol::input($player_id, 3, 8, 849, $out_849);
     return $out_850;
 }
Exemple #6
0
 public function get_rand_attr_key_list($item_sub_type, $number, $lock_attr_key_hash)
 {
     if (empty($item_sub_type) || $number <= 0) {
         return false;
     }
     $sql = "select * from equip_refine_attr_key where item_sub_type = {$item_sub_type}";
     $attr_list = $this->select_all($sql, $this->get_cache_key(array('item_sub_type' => $item_sub_type), $this->prefix_equip_refine_attr_key));
     if (empty($attr_list)) {
         return false;
     }
     $attr_weight_hash = array();
     # 属性key权重哈希,随机确定属性key
     foreach ($attr_list as $index => $attr_info) {
         #if (!isset($lock_attr_key_hash[$attr_info['attr_key']])) { # 对锁定属性去重
         $attr_weight_hash[$attr_info['attr_key']] = $attr_info['rand_weight'];
         #}
     }
     if (empty($attr_weight_hash)) {
         return false;
     }
     # 防止一下随机函数返回false导致$rand_attr_list不为空
     # 不允许重复
     $rand_attr_key_list = array();
     for ($i = 1; $i <= $number; $i++) {
         $rand_attr_key = Com_Random::get_probability_key($attr_weight_hash);
         #unset($attr_weight_hash[$rand_attr_key]);
         $rand_attr_key_list[] = $rand_attr_key;
         if (empty($attr_weight_hash)) {
             break;
         }
     }
     return $rand_attr_key_list;
 }
Exemple #7
0
 /**
  * @Purpose:
  * 翅膀装备强化
  * @Param $player_id 玩家ID
  * @Param $player_prop_id 玩家装备ID
  * @Param $auto_buy 自动购买(0:不自动1:自动)
  */
 public function equip_intensify($player_id, $player_prop_id, $auto_buy)
 {
     $player_id = intval($player_id);
     $player_prop_id = strval($player_prop_id);
     $auto_buy = intval(0);
     #暂时没有自动购买功能
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'career_type', 'level', 'vip', 'privilege_level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (empty($player_equip_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     #根据翅膀等级获取翅膀装备当前最大的强化等级
     $player_detail = $this->get_data('PlayerDetail')->get_player_detail($player_id, Protocol_Player::get_player_attr_detail_key());
     if (empty($player_detail['wing_info'][$player_equip_info['vocation_limit']]) || $player_equip_info['sub_type'] == 7) {
         $this->throw_error('10110');
         #数据错误
     }
     $wing_level = $player_detail['wing_info'][$player_equip_info['vocation_limit']]['lvl'];
     $intensify_level_limit_table = Cache_WingEquipment::getInstance()->get_wing_equip_intensify_limit_info(array('wing_level' => $wing_level));
     if (empty($intensify_level_limit_table)) {
         $this->throw_error('10109');
         #配置表读取错误
     } else {
         if (empty($intensify_level_limit_table['intensify_level_limit'])) {
             $this->throw_error('150012');
             #wing_equip_intensify_limit配置表的intensify_level_limit字段配置错误
         }
     }
     $intensify_level_limit = $intensify_level_limit_table['intensify_level_limit'];
     if ($player_equip_info['intensive_level'] >= $intensify_level_limit) {
         $this->throw_error('80310');
         //已满级
     }
     $intensify_table = Cache_WingEquipment::getInstance()->get_wing_equip_intensify_info(array('level' => $player_equip_info['intensive_level'] + 1));
     if (empty($intensify_table)) {
         $this->throw_error('10109');
         #配置表读取错误
     }
     if (empty($intensify_table['expend_coin_list'])) {
         $this->throw_error('150014');
         #wing_equip_intensify配置表的expend_coin_list字段配置错误
     }
     $coin_list = $this->format_table_field($intensify_table['expend_coin_list']);
     if (!Com_Array::is_good_arr($coin_list)) {
         $this->throw_error('150014');
         #wing_equip_intensify配置表的expend_coin_list字段配置错误
     }
     #消耗货币检测
     foreach ($coin_list as $coin_type => $coin_num) {
         if (empty($coin_type) || empty($coin_num)) {
             $this->throw_error('150014');
             #wing_equip_intensify配置表的expend_coin_list字段配置错误
         }
         $cost_currency_key = Cache_Currency::getInstance()->get_key($coin_type);
         $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $coin_num, 1, $coin_type);
     }
     $prop_list = array();
     if (!empty($intensify_table['expend_prop_list'])) {
         #$this->throw_error('150015'); #wing_equip_intensify配置表的expend_prop_list字段配置错误
         $prop_list = $this->format_table_field($intensify_table['expend_prop_list']);
         if (!Com_Array::is_good_arr($prop_list)) {
             $this->throw_error('150015');
             #wing_equip_intensify配置表的expend_prop_list字段配置错误
         }
         #消耗道具检测
         $is_gold_num_res = false;
         $player_prop_list = array();
         foreach ($prop_list as $prop_id => $prop_num) {
             if (empty($prop_id) || empty($prop_num)) {
                 $this->throw_error('150015');
                 #wing_equip_intensify配置表的expend_prop_list字段配置错误
             }
             $player_prop_num = $this->get_prop_num_by_player_bag($player_id, $prop_id);
             $player_prop_list[$prop_id] = $player_prop_num;
             if ($player_prop_num < $prop_num) {
                 if ($auto_buy) {
                     #获取商城表道具元宝价格
                     $obj_shop_game = $this->get_game('Shop');
                     $drop_info = $obj_shop_game->shortcut_purchase_interface($prop_id, 1);
                     if (empty($drop_info['item_price'])) {
                         $this->throw_error('130001');
                         # 商城没有出售该道具
                     }
                     list($cur_idx, $cur_val) = each($drop_info['item_price']);
                     $cost_currency_key = Cache_Currency::getInstance()->get_key($cur_idx);
                     $deduct_gold_num = intval($cur_val * ($prop_num - $player_prop_num));
                     if ('gold' == $cost_currency_key) {
                         if (20 == $cur_idx) {
                             if ($player_info['ticket'] < $deduct_gold_num) {
                                 $ticket = $player_info['ticket'];
                                 $gold = $deduct_gold_num - $ticket;
                             } else {
                                 $ticket = $deduct_gold_num;
                                 $gold = 0;
                             }
                         } else {
                             $gold = $deduct_gold_num;
                             $ticket = 0;
                         }
                         $arr_consume = array('price' => $cur_val, 'gold' => $gold, 'ticket' => $ticket, 'count' => $prop_num - $player_prop_num);
                         #数据中心推送
                     }
                     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $deduct_gold_num, 1, $cur_idx);
                     $is_gold_num_res = true;
                 } else {
                     $this->throw_error('150016');
                     #道具不足
                 }
             }
         }
     }
     #强化是否成功
     $is_success = 1;
     if (!empty($intensify_table['fail_num']) && $player_equip_info['intensive_lose_times'] >= $intensify_table['fail_num']) {
         $is_success = 0;
     } else {
         $intensify_success_rate = $intensify_table['success_rate'];
         if (Com_Random::probability($intensify_success_rate, 10000)) {
             $is_success = 0;
         }
     }
     #生成强化后的装备
     $is_update_wing = false;
     $equip_update_field = array();
     if ($is_success == 0) {
         $wing_attr = $player_detail['wing_info'][$player_equip_info['vocation_limit']];
         #如果是装备中的装备,先减少强化前装备的战斗力
         if ($player_equip_info['item_position'] == $this->wing_pos) {
             $wing_attr['equipment'][$player_equip_info['sub_type']] = array();
             $arr_remove_prop_detail = $player_equip_info;
             Struct_Prop::get_item_additions($arr_remove_prop_detail);
             $arr_config = Cache_Prop::getInstance()->get_prop_info($arr_remove_prop_detail['prop_id']);
             $arr_remove_prop_detail['type'] = $arr_config['type'];
             $wing_attr['fight'] -= $arr_remove_prop_detail['fpower'];
             $wing_attr['fight'] = $wing_attr['fight'] > 0 ? $wing_attr['fight'] : 0;
             $wing_attr['equipment_fight'] -= $arr_remove_prop_detail['fpower'];
             $wing_attr['equipment_fight'] = $wing_attr['equipment_fight'] > 0 ? $wing_attr['equipment_fight'] : 0;
         }
         $player_equip_info['intensive_lose_times'] = 0;
         $player_equip_info['intensive_level'] += 1;
         $player_equip_info['intensive_desc'] = $this->get_latest_intensive_desc($player_equip_info, $intensify_table);
         $equip_update_field['intensive_lose_times'] = 0;
         $equip_update_field['intensive_level'] = $player_equip_info['intensive_level'];
         $equip_update_field['intensive_desc'] = $player_equip_info['intensive_desc'];
         #如果是装备中的装备,增加强化后装备的战斗力
         if ($player_equip_info['item_position'] == $this->wing_pos) {
             $wing_attr['equipment'][$player_equip_info['sub_type']] = $player_equip_info;
             $wing_attr['equip_attr'] = $this->get_wing_equip_attr($wing_attr['equipment']);
             $arr_prop_detail = $player_equip_info;
             Struct_Prop::get_item_additions($arr_prop_detail);
             $arr_config = Cache_Prop::getInstance()->get_prop_info($arr_prop_detail['prop_id']);
             $arr_prop_detail['type'] = $arr_config['type'];
             $wing_attr['fight'] += $arr_prop_detail['fpower'];
             $wing_attr['equipment_fight'] += $arr_prop_detail['fpower'];
             $player_detail['wing_info'][$player_equip_info['vocation_limit']] = $wing_attr;
             $is_update_wing = true;
         }
     } else {
         $player_equip_info['intensive_lose_times'] += 1;
         $equip_update_field['intensive_lose_times'] = $player_equip_info['intensive_lose_times'];
     }
     $this->start_trans();
     #更新道具属性
     if (!empty($equip_update_field)) {
         $update_res = $this->get_data('PlayerProp')->update_player_prop($player_equip_info, $equip_update_field);
         if (!$update_res) {
             $this->throw_error('10104');
         }
     }
     #更新翅膀战斗力
     if ($is_update_wing) {
         $update_res = $this->get_data('PlayerDetail')->update_player_detail($player_id, array('wing_info' => $player_detail['wing_info']));
         if (!$update_res) {
             $this->throw_error('10104');
         }
     }
     #扣道具
     if (Com_Array::is_good_arr($prop_list)) {
         if ($is_gold_num_res == true) {
             if (Com_Array::is_good_arr($player_prop_list)) {
                 foreach ($player_prop_list as $id => $num) {
                     if ($num > 0) {
                         $this->deduct_prop_num_by_prop_id($player_id, $id, $num, 1508, $player_info);
                     }
                 }
             }
         } else {
             foreach ($prop_list as $id => $num) {
                 $this->deduct_prop_num_by_prop_id($player_id, $id, $num, 1508, $player_info);
             }
         }
     }
     if (Com_Array::is_good_arr($coin_list)) {
         #扣货币
         $deduct_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1508, array(), $arr_consume);
         if (!$deduct_res) {
             $this->throw_error('10104');
         }
     }
     if ($is_update_wing && $player_detail['wing_info'][$player_equip_info['vocation_limit']]['fight'] > 0) {
         $wing_fight = $player_detail['wing_info'][$player_equip_info['vocation_limit']]['fight'];
         $this->get_data('RankList')->update_wing_rank($player_id, $player_equip_info['vocation_limit'], $wing_fight);
     }
     $this->commit();
     $upgrade_item = array();
     if ($is_success == 0) {
         if ($is_update_wing) {
             $upgrade_item = Struct_Prop::get_prop_struct($player_equip_info);
             #同步翅膀属性
             $str = $this->get_activation_wing_interface($player_id, $player_detail['wing_info']);
             Protocol_Player::p2c_part_update($player_id, array('had_on_swings' => $str, 'wing' => '', 'attr' => '', 'player_data' => array('player_detail' => $player_detail, 'player' => array('career_type' => $player_info['career_type'], 'level' => $player_info['level']))));
         } else {
             #806通知前端道具属性变更
             $ndata = array();
             $ndata[] = $player_equip_info;
             Protocol_Prop::prop_806($player_id, $ndata);
         }
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 34, 1);
         $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 34, $player_equip_info['intensive_level'], 8);
     }
     $rtn_data = array('result' => intval($is_success), 'upgrade_item' => empty($upgrade_item) ? array() : $upgrade_item);
     return $rtn_data;
 }
Exemple #8
0
 public function get_special_bounty_task($player_level, $star_type)
 {
     if ($star_type <= 0) {
         return false;
     }
     $sql = "select * from task_config where task_type = 3 and min_level <= {$player_level} and max_level >= {$player_level} and star_type = {$star_type}";
     $task_list = $this->select_all($sql, $this->get_cache_key(array('player_level' => $player_level, 'star_type' => $star_type)));
     # 列表结构转为哈希结构
     $task_hash = array();
     $task_weight_hash = array();
     # 任务权重哈希,随机取task_id用
     foreach ($task_list as $index => $task_info) {
         $task_hash[$task_info['task_id']] = $task_info;
         $task_weight_hash[$task_info['task_id']] = $task_info['weight'];
     }
     $rand_task_id = Com_Random::get_probability_key($task_weight_hash);
     return $task_hash[$rand_task_id];
 }
Exemple #9
0
 public function player_hero_grow_upgrade($player_id, $hero_id, $state)
 {
     $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');
     $consume_props = $last_props = 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($last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']){
     	$this->throw_error('50107');
     }
     */
     list($need_prop_id, $need_prop_nums) = explode(":", trim($hero_conf['grow_expend']));
     if (empty($need_prop_id) || empty($need_prop_nums)) {
         $this->throw_error('10111');
     }
     $obj_prop_game = $this->get_game('Prop');
     $last_props_nums = intval($obj_prop_game->get_prop_num_by_prop_id($player_id, $need_prop_id));
     if ($last_props_nums < $need_prop_nums) {
         $this->throw_error('50107');
     }
     $hero_grow_conf = Cache_HeroGrow::getInstance()->get_config_info($need_prop_id);
     if (empty($hero_grow_conf)) {
         $this->throw_error('10111');
         #配置错误
     }
     $consume_props_nums = 0;
     #消耗道具数量
     $crit_counter = 0;
     #暴击计数
     $counter = 10;
     #while执行计数
     $sum_rand_grow_val = 0;
     #总提升数量
     $new_hero_grow_val = 0;
     #新的成长值
     do {
         $counter--;
         // $last_props[$hero_grow_conf['item_id']] -= $hero_grow_conf['item_nums'];#剩余数量
         // $consume_props[$hero_grow_conf['item_id']] += $hero_grow_conf['item_nums'];#消耗数量
         $last_props_nums -= $need_prop_nums;
         $consume_props_nums += $need_prop_nums;
         $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($last_props[$hero_grow_conf['item_id']] < $hero_grow_conf['item_nums']){#道具不足
         	break;
         }
         */
         if ($last_props_nums < $need_prop_nums) {
             break;
         }
     } while ($counter > 0 && $state > 0);
     #控制循环数量防止进入死循环
     $result = true;
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip'));
     $log_param = array('cmd_id' => 557, 'level' => $player_info['level'], 'vip' => $player_info['vip']);
     $log = array();
     $this->start_trans();
     /*
     foreach($consume_props as $prop_id=>$prop_nums){#批量扣除多个道具如果可能
     	$result = $obj_prop_game->deduct_prop_by_prop_id($player_id, $prop_id, $prop_nums, $log, 1, $log_param);
     	if(!$result){
     		$this->throw_error('10101');
     	}
     }
     */
     $result = $obj_prop_game->deduct_prop_by_prop_id($player_id, $need_prop_id, $consume_props_nums, $log, 1, $log_param);
     if ($result) {
         $hero_data['grow_rate'] = $new_hero_grow_val;
         $result = $obj_player_hero_data->update_player_hero($player_id, $hero_id, array('grow_rate' => $new_hero_grow_val), $hero_data);
     }
     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);
         return array('res' => $crit_counter, 'rand_val' => $sum_rand_grow_val, 'cur_grow_val' => $new_hero_grow_val, 'effect' => 1000 * self::calc_grow_attar($new_hero_grow_val, $hero_conf['grow']), 'prop_id' => $need_prop_id, 'prop_nums' => $need_prop_nums, 'nor_desc' => $hero_grow_conf['nor_desc'], 'crit_desc' => $hero_grow_conf['crit_desc']);
     } else {
         $this->throw_error('10101');
     }
 }
Exemple #10
0
 private function daily_task_rule_apply($player_id, $task_info)
 {
     if ($task_info['task_step_type'] == 100 || $task_info['task_step_type'] == 101) {
         # [主线|挑战]副本类型日常任务
         $rule = Cache_TaskDaily::getInstance()->get_task_daily_rule($task_info['task_step_type']);
         if (empty($rule)) {
             $this->throw_error('10019');
             # 日常任务特殊规则未配置
         }
         # 随机副本权重列表
         $weight_list = explode(":", $rule['rule_param2']);
         if (empty($weight_list) || $rule['rule_param1'] != count($weight_list)) {
             $this->throw_error('10020');
             # 日常任务特殊规则配置错误
         }
         if ($task_info['task_step_type'] == 100) {
             $map_list = $this->get_game('PlayerFB')->get_pass_fb_last_interface($player_id, $rule['rule_param1']);
             Com_Log::write('xgame.dailytask', "player_id:{$player_id}:task_step_type:100" . json_encode($map_list));
             if (empty($map_list)) {
                 #$this->throw_error('10021'); # 特定类型的日常任务无法生成
                 $map_info = Cache_PlayerFB::getInstance()->get_player_fb_info($this->task_first_fb_map_id);
                 $map_list[] = array('map_id' => $this->task_first_fb_map_id, 'difficulty' => $map_info['difficulty']);
             }
             # 考虑map_list可能少于weight_list,先去除无效的索引
             for ($i = count($map_list); $i < $rule['rule_param1']; $i++) {
                 unset($weight_list[$i]);
             }
             $rand_idx = Com_Random::get_probability_key($weight_list);
             # 随机一个索引
             $task_info['dup_id'] = $map_list[$rand_idx]['map_id'];
             # 要求通关的副本ID
             # 处理难度加星
             if (!empty($rule['rule_param3'])) {
                 $star_add_info = explode("|", $rule['rule_param3']);
                 $star_add_hash = array();
                 foreach ($star_add_info as $key => $val) {
                     list($difficulty, $star_add) = explode(":", $val);
                     $star_add_hash[$difficulty] = $star_add;
                 }
                 $task_info['star'] += $star_add_hash[$map_list[$rand_idx]['difficulty']];
             }
             # 处理要求通关的水平以及通关水平加星
             if (!empty($rule['rule_param4'])) {
                 $clear_grade_info = explode("|", $rule['rule_param4']);
                 $weight_hash = array();
                 $star_add_hash = array();
                 foreach ($clear_grade_info as $key => $val) {
                     list($clear_grade, $weight, $star_add) = explode(":", $val);
                     $weight_hash[$clear_grade] = $weight;
                     $star_add_hash[$clear_grade] = $star_add;
                 }
                 $rand_clear_grade = Com_Random::get_probability_key($weight_hash);
                 # 随机一个通关水平
                 $task_info['star'] += $star_add_hash[$rand_clear_grade];
                 $task_info['dup_cle_grade'] = $rand_clear_grade;
             }
             # 星级边界值修正
             $task_info['star'] = min($task_info['star'], $this->task_star_stint);
         } elseif ($task_info['task_step_type'] == 101) {
             $map_list = $this->get_game('PlayerPVE')->get_last_three_chapter_id($player_id, $rule['rule_param1']);
             Com_Log::write('xgame.dailytask', "task_step_type:101" . json_encode($map_list));
             if (empty($map_list)) {
                 #$this->throw_error('10021'); # 特定类型的日常任务无法生成
                 $map_list[] = $this->task_first_pve_map_id;
             }
             $map_list = array_reverse($map_list);
             # 倒序
             # 考虑map_list可能少于weight_list,先去除无效的索引
             for ($i = count($map_list); $i < $rule['rule_param1']; $i++) {
                 unset($weight_list[$i]);
             }
             $rand_idx = Com_Random::get_probability_key($weight_list);
             # 随机一个索引
             $task_info['dup_id'] = $map_list[$rand_idx];
             # 要求通关的副本ID
         }
     } else {
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('level'));
         if ($task_info['task_step_type'] == 103) {
             # 守卫雅典娜副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 2);
         } elseif ($task_info['task_step_type'] == 104) {
             # 世界BOSS副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 1);
         } elseif ($task_info['task_step_type'] == 105) {
             # 抢矿副本ID
             $task_info['dup_id'] = Cache_ActivityHall::getInstance()->get_activity_map_id_by_category_and_level($player_info['level'], 4);
         } elseif ($task_info['task_step_type'] == 116) {
             # 通关副本ID
             #$task_info['dup_id'] = $task_info['city_id'];
         } elseif ($task_info['task_step_type'] == 117) {
             $task_info['dialog_task_id'] = Cache_TaskDaily::getInstance()->get_task_daily_dialog_id($player_info['level']);
         } elseif ($task_info['task_step_type'] == 10) {
             # 随机一个关联的采集主线任务ID
             $main_task_id = Cache_TaskDaily::getInstance()->get_task_daily_collection_id($player_info['level']);
             $main_task_step_config = Cache_TaskStepConfig::getInstance()->get_task_step_config($main_task_id, 1);
             if (empty($main_task_step_config) || !is_array($main_task_step_config)) {
                 Com_Log::write('xgame.dailytask', "task_step_type:10\t" . $main_task_id);
             } else {
                 $main_task_step_config['kill_npc_sid'] = $main_task_step_config['task_id'];
                 $task_info = array_merge($main_task_step_config, $task_info);
                 # 显示需要使用task_daily_base表的task_id,故而合并时,task_info靠后
             }
         }
     }
     return $task_info;
 }
Exemple #11
0
 /**
  *
  * @param $sid
  * @param $player_info
  * @return array
  */
 public function get_loot($sid, $player_id = null, $param = array())
 {
     $drop_list = $this->get_fb_loot_info($sid);
     if (empty($drop_list)) {
         return array();
     }
     $items = array();
     if (!empty($player_id) && empty($param)) {
         $param = $this->get_data('Player')->get_player_info($player_id, array('career_type', 'level'));
     }
     $arr_special = array();
     foreach ($drop_list as $key => $drop) {
         $arr_special[$drop['special']][$key] = $drop;
         # TODO: 郭鑫又改规则了
     }
     foreach ($arr_special as $list) {
         $condition = array();
         $conditions_by_role = array();
         #按职业随机掉的
         $conditions_by_99 = array();
         #必掉的
         foreach ($list as $key => $drop) {
             if ($drop['type'] > 0) {
                 if ($drop['type'] == $param['career_type']) {
                     $conditions_by_role[$key] = $drop['rate'];
                 }
                 if ($drop['type'] == 99) {
                     $conditions_by_99[] = $key;
                 }
                 continue;
             } else {
                 if ($drop['rate'] > 0) {
                     $condition[$key] = $drop['rate'];
                 }
             }
         }
         if ($conditions_by_role) {
             $key = Com_Random::get_probability_key($conditions_by_role, 1);
             $prop_param = explode(":", $drop_list[$key]['item_id']);
             if (count($prop_param) > 1) {
                 $prop = Cache_Prop::getInstance()->get_prop_by_param_and_career_type($param['level'], $param['career_type'], $prop_param[0], $prop_param[1], $prop_param[2], $prop_param[3]);
                 $items[] = array('type' => $this->get_item_key($prop['prop_id']), 'item_id' => $prop['prop_id'], 'item_num' => $drop_list[$key]['num']);
             } else {
                 $items[] = array('type' => $this->get_item_key($drop_list[$key]['item_id']), 'item_id' => $drop_list[$key]['item_id'], 'item_num' => $drop_list[$key]['num']);
             }
         }
         if ($conditions_by_99) {
             foreach ($conditions_by_99 as $key) {
                 $prop_param = explode(":", $drop_list[$key]['item_id']);
                 if (count($prop_param) > 1) {
                     $prop = Cache_Prop::getInstance()->get_prop_by_param($param['level'], $prop_param[0], $prop_param[1], $prop_param[2], $prop_param[3]);
                     $items[] = array('type' => $this->get_item_key($prop['prop_id']), 'item_id' => $prop['prop_id'], 'item_num' => $drop_list[$key]['num']);
                 } else {
                     $items[] = array('type' => $this->get_item_key($drop_list[$key]['item_id']), 'item_id' => $drop_list[$key]['item_id'], 'item_num' => $drop_list[$key]['num']);
                 }
             }
         }
         if ($condition) {
             $key = Com_Random::get_probability_key($condition, 1);
             $prop_param = explode(":", $list[$key]['item_id']);
             if (count($prop_param) > 1) {
                 $prop = Cache_Prop::getInstance()->get_prop_by_param($param['level'], $prop_param[0], $prop_param[1], $prop_param[2], $prop_param[3]);
                 //                    Com_Log::log($prop,'prop_use',1);
                 $items[] = array('type' => $this->get_item_key($prop['prop_id']), 'item_id' => $prop['prop_id'], 'item_num' => $drop_list[$key]['num']);
             } else {
                 $items[] = array('type' => $this->get_item_key($drop_list[$key]['item_id']), 'item_id' => $drop_list[$key]['item_id'], 'item_num' => $drop_list[$key]['num']);
             }
         }
     }
     if ($items) {
         $now_time = time();
         foreach ($items as $key => $item) {
             if ($item['item_id'] > 200) {
                 $arrPropConfig = Cache_Prop::getInstance()->get_prop_info($item['item_id']);
                 $items[$key]['prop_config'] = $arrPropConfig;
                 if (!empty($arrPropConfig['generate_start_time']) && !empty($arrPropConfig['generate_end_time']) && ($now_time < strtotime($arrPropConfig['generate_start_time']) || $now_time > strtotime($arrPropConfig['generate_end_time']))) {
                     unset($items[$key]);
                 }
             }
         }
     }
     return $items;
 }
 public function equip_intensify($player_id, $player_prop_id, $auto_buy, $bless_item_id)
 {
     $this->get_game('PlayerFunc')->get_func_is_open($player_id, $this->func_id_intensifier);
     # 参数检查
     $this->param_check_numeric(array($player_id, $auto_buy, $bless_item_id), 0);
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     $player_equip_info = $this->get_data('PlayerProp')->get_player_prop_detail($player_id, $player_prop_id);
     if (empty($player_equip_info)) {
         $this->throw_error('80013');
         //玩家没有该装备!
     }
     if (Com_Util::is_first_charge_item($player_equip_info['prop_id'])) {
         $this->throw_error('81101');
         # 首充装备不允许强化
     }
     # 获取强化等级上限
     $intensify_lv_limit = $this->get_intensify_lv_limit_by_item_level($player_equip_info['level']);
     if ($player_equip_info['intensive_level'] >= $intensify_lv_limit) {
         $this->throw_error('80310');
         //已满级
     }
     # 强化配置信息检查
     $intensify_config = Cache_Forge::getInstance()->get_intensify_info($player_equip_info['intensive_level'] + 1, 1);
     # 强化所需宝石检查
     $player_gems = 0;
     # 添加了自动购买强化宝石的逻辑,故没有该材料时不能报错
     $player_gems_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $intensify_config['item_id'], 1);
     if (!empty($player_gems_info)) {
         $gems = array_values($player_gems_info);
         foreach ($gems as $key => $val) {
             $player_gems += $val['item_num'];
         }
     }
     # 以下三种情况下的失败,前端要求仍然返回816协议下行,防止自动强化处理异常
     if ($player_info['silver'] < $intensify_config['silver_num']) {
         $extra_816 = array('is_failed' => 2, 'intensive_info' => array());
         Protocol::input($player_id, 3, 8, 816, $extra_816);
         $message = array('texts' => array(array('code' => 10113, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
         #$this->throw_error('10113'); # 银两不足
     }
     if (!$auto_buy && $player_gems < $intensify_config['item_num']) {
         $extra_816 = array('is_failed' => 3, 'intensive_info' => array());
         Protocol::input($player_id, 3, 8, 816, $extra_816);
         $message = array('texts' => array(array('code' => 80312, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
         #$this->throw_error('80312'); # 玩家强化的强化宝石不足!
     }
     if (!empty($bless_item_id)) {
         # 玩家强化的祝福石不足!
         # 强化所需祝福石检查
         $player_bless_item_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $bless_item_id, 1);
         if (empty($player_bless_item_info)) {
             $extra_816 = array('is_failed' => 4, 'intensive_info' => array());
             Protocol::input($player_id, 3, 8, 816, $extra_816);
             $message = array('texts' => array(array('code' => 80320, 'content' => array(), 'params' => array())), 'delay' => 0);
             Protocol::input($player_id, 3, 7, 742, $message);
             return;
         }
     }
     # 成功率判断
     $flag = false;
     if ($player_equip_info['intensive_lose_times'] >= $intensify_config['lose_num']) {
         $flag = true;
     } else {
         $intensify_success_rate = $intensify_config['chance'];
         if (!empty($bless_item_id)) {
             $intensify_bless_info = Cache_Forge::getInstance()->get_intensify_bless_info_by_item_id($bless_item_id, 1);
             $intensify_success_rate += $intensify_bless_info['add_success_rate'];
         }
         if (Com_Random::probability($intensify_success_rate, 10000)) {
             $flag = true;
         }
     }
     # 强化处理
     $before_intensive_desc = $player_equip_info['intensive_desc'];
     $after_intensive_desc = $this->equip_intensify_handle($flag, $player_id, $player_gems, $player_info, $player_equip_info, $intensify_config, $auto_buy, $bless_item_id);
     # 强化成功后,当前装备的强化等级加1
     if ($flag) {
         $player_equip_info['intensive_level'] += 1;
         # 添加好友动态消息
         $prop_info = Cache_Prop::getInstance()->get_prop_info($player_equip_info['prop_id']);
         $param = array(1 => "0|{$player_equip_info['intensive_level']}|1", 2 => "1|{$player_equip_info['prop_id']},{$prop_info['name']},{$player_equip_info['quality']}|2");
         //$this->get_game("PlayerFriend")->add_friend_news_by_type($player_id, 1, 3, 1, $param);
         # --------------------------------------------------------------------
         # 公告
         # --------------------------------------------------------------------
         $replace_info = array(array('rep_type' => 0, 'rep_val' => $player_id), array('rep_type' => 2, 'rep_val' => $player_equip_info['prop_id'], 'rep_player_id' => $player_id, 'rep_pid' => $player_equip_info['player_prop_id']), array('rep_type' => 7, 'txt' => $player_equip_info['intensive_level']));
         $this->get_game('SystemNotice')->push_sys_notice($player_id, 61, $player_equip_info['intensive_level'], $replace_info);
         # 强化公告
         if ($player_equip_info['type'] == 1) {
             $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 6, "1:" . $player_equip_info['quality'] . ":" . $player_equip_info['star_level'] . ":" . intval($player_equip_info['intensive_level']) . ":{$player_equip_info['player_prop_id']}", 4);
         } else {
             if ($player_equip_info['type'] == 6) {
                 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 35, "1:" . $player_equip_info['quality'] . ":" . $player_equip_info['star_level'] . ":" . intval($player_equip_info['level']) . ":{$player_equip_info['player_prop_id']}", 4);
             }
         }
     } else {
         # 失败时提示消息
         /**
         			$player_equip_info['intensive_lose_times'] += 1;
         			$sure_succeed = $intensify_config['lose_num'] - $player_equip_info['intensive_lose_times']; # 剩余必定成功次数
         			if ($sure_succeed < 0) $sure_secceed = 0;
         			$message = array(
         				'texts'	=> array(
         					array(
         						'code' 		=> 80906, 
         						'content' 	=> array(), 
         						'params' 	=> array(
         							array (
         								array('txt' => '', 'type' => 7, 'value' => $sure_succeed, 'param' => '')
         							),
         						),
         					),
         				),	
         				'delay'	=> 0,
         			);
         			**/
         $message = array('texts' => array(array('code' => 80919, 'content' => array(), 'params' => array())));
         Protocol::input($player_id, 3, 7, 742, $message);
     }
     $out_816 = array();
     $out_816['is_failed'] = $flag ? 0 : 1;
     # 强化成功后,获取下一级强化信息,若已满级,则可忽略满级标识以外信息内容,9->10级时,失败仍然会返回满级标识,进入下面if结构
     if ($player_equip_info['intensive_level'] >= $intensify_lv_limit) {
         $silver_index = Cache_Currency::getInstance()->get_index('silver');
         $out_816['intensive_info'] = array('result' => 1, 'item_pid' => $player_prop_id, 'upgrade_item' => array(), 'success_per' => 0, 'success_num' => 0, 'fail_num' => 0, 'expend_prop' => "{$intensify_config['item_id']}:{$intensify_config['item_num']}", 'expend_currency' => "{$silver_index}:{$intensify_config['silver_num']}", 'max_intensify_lv' => $intensify_lv_limit);
     } else {
         $ret = $this->get_equip_intensify_info($player_id, $player_prop_id);
         $out_816['intensive_info'] = $ret[0];
     }
     # 通知玩家信息变更[必须放在commit之后]
     # 日常活跃度处理
     $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, 2000);
     # 日常任务埋点
     $this->get_game('TaskTrigger')->async_trigger_task($player_id, 107, 107, 1);
     # 引导任务埋点
     $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 15, 1);
     # --------------------------------------------------------------------
     # 游戏日志记录
     # --------------------------------------------------------------------
     $log_info = array('player_id' => $player_id, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'player_prop_id' => $player_prop_id, 'item_id' => $player_equip_info['prop_id'], 'item_type' => $player_equip_info['type'], 'item_sub_type' => $player_equip_info['sub_type'], 'item_quality' => $player_equip_info['quality'], 'item_level' => $player_equip_info['level'], 'item_star_level' => $player_equip_info['star_level'], 'before_level' => $flag ? $player_equip_info['intensive_level'] - 1 : $player_equip_info['intensive_level'], 'after_level' => $player_equip_info['intensive_level'], 'before_attr_add' => $before_intensive_desc, 'after_attr_add' => $after_intensive_desc);
     Log_Forge::getInstance()->add_log($log_info, 'intensify');
     Protocol::input($player_id, 3, 8, 816, $out_816);
 }
Exemple #13
0
 protected function get_rand_addition_attr_key($vocation_limit, $attr_num_addition)
 {
     if (empty($vocation_limit) || empty($attr_num_addition)) {
         return array();
     }
     $sql = "select * from item_attr_key_rand_addi where item_vocation_limit = {$vocation_limit}";
     $records = $this->select_all($sql, $this->get_cache_key(array('item_vocation_limit' => $vocation_limit), $this->prefix_item_attr_key_rand_addi));
     if (empty($records)) {
         return array();
     }
     $attr_key_weight_hash = array();
     # 附加属性个数权重哈希,随机确定附加属性个数
     foreach ($records as $record) {
         $attr_key_weight_hash[$record['attr_key']] = $record['rand_weight'];
     }
     # 附加属性要求去重
     $addition_attr_key_list = array();
     $i = 1;
     while ($i++ <= $attr_num_addition && !empty($attr_key_weight_hash)) {
         $rand_attr_key = Com_Random::get_probability_key($attr_key_weight_hash);
         unset($attr_key_weight_hash[$rand_attr_key]);
         $addition_attr_key_list[] = $rand_attr_key;
     }
     return $addition_attr_key_list;
 }
Exemple #14
0
 /**
  * [train_upgrade 女神强化]
  * @param  [type] $player_id   [玩家ID]
  * @param  [type] $fairy_id    [女神ID]
  * @param  [type] $auto_buy    [是否自动购买]
  * @param  [type] $improve_per [是否提高成功率]
  * @return [type]              [0成功,1概率失败,2金币不足失败,3材料不足失败]
  */
 public function train_upgrade($player_id, $fairy_id, $auto_buy, $improve_flag)
 {
     # 参数检查
     $this->param_check_numeric(array($player_id, $auto_buy, $improve_flag), 0);
     # 获取玩家货币信息
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level')));
     if (empty($player_info)) {
         $this->throw_error('20002');
         //没有玩家信息!
     }
     # 获取玩家女神信息
     $fairy_info = $this->get_data('Fairy')->get_player_fairy_info($fairy_id);
     if (!$fairy_info) {
         $this->throw_error('10112');
         //获取女神信息失败
     }
     # 获取强化等级上限
     $max_train_lv = Cache_FairyTrain::getInstance()->get_max_train_lv();
     if (!empty($max_train_lv)) {
         $max_train_lv = $this->max_train_lv;
     }
     if ($fairy_info['train_level'] >= $max_train_lv) {
         $this->throw_error('80310');
         //已满级
     }
     # 获取升级到下一级的培养数据
     $trainConfigs = $this->get_cache_table_data('fairy_train_table', array("lvl" => $fairy_info['train_level']));
     if (!$trainConfigs[0] || empty($trainConfigs[0]['expend'])) {
         $this->throw_error('10109');
         //配置表读取错误
     }
     $train_config = $trainConfigs[0];
     // 消耗需求
     $cost_material = explode("|", $train_config['expend']);
     //升级下一级消耗
     $costItemInfo = explode(':', $cost_material[0]);
     //道具消耗
     $costGoldInfo = !empty($cost_material[1]) ? explode(':', $cost_material[1]) : 0;
     //金币消耗
     #当期女神品阶是否达到强化品阶
     if ($fairy_info['level'] < $train_config['fairy_lvl']) {
         $out_536 = array('result' => 5);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 536002, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         //536002 玩家的女神品阶没有达到当前强化需求
         return;
     }
     # 强化所需材料检查
     $cost_item_id = $costItemInfo[0];
     $cost_item_num = intval($costItemInfo[1]);
     # 获取包裹中资源数量
     $player_item_num = 0;
     # 添加了自动购买逻辑,故没有该材料时不能报错
     $player_item_info = $this->get_data('PlayerProp')->get_player_prop_by_prop_id($player_id, $cost_item_id, 1);
     if (!empty($player_item_info)) {
         $items = array_values($player_item_info);
         foreach ($items as $key => $val) {
             $player_item_num += $val['item_num'];
         }
     }
     # 强化所需金币
     $cost_silver_num = 0;
     $cost_silver_num = is_array($costGoldInfo) ? intval($costGoldInfo[1]) : 0;
     #勾选使用钻石提高成功率时钻石消耗
     $cost_gold_num = 0;
     if ($improve_flag) {
         $cost_gold_num = $train_config['success_buy_gold'];
     }
     # 金币不足
     if ($player_info['silver'] < $cost_silver_num) {
         $out_536 = array('result' => 2);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 10113, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
     }
     # 钻石不足
     if ($improve_flag && $player_info['gold'] < $cost_gold_num) {
         $out_536 = array('result' => 3);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 10108, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
     }
     # 材料不足 玩家升级的女神之泪不足
     if (!$auto_buy && $player_item_num < $cost_item_num) {
         $out_536 = array('result' => 4);
         Protocol::input($player_id, 3, 5, 536, $out_536);
         $message = array('texts' => array(array('code' => 536001, 'content' => array(), 'params' => array())), 'delay' => 0);
         Protocol::input($player_id, 3, 7, 742, $message);
         return;
     }
     # 成功率判断
     $flag = false;
     $current_success_rate = $train_config['success_rate'];
     # 如果勾选了金币购买成功率
     if ($improve_flag) {
         $current_success_rate += $train_config['success_buy_rate'];
     }
     # 成功率大于等于100%必定成功
     if ($current_success_rate >= 100) {
         $flag = true;
     } else {
         # 根据概率值返回是否成功
         if (Com_Random::probability($current_success_rate, 100)) {
             $flag = true;
         }
     }
     # 强化处理
     $old_fairy_info = $fairy_info;
     $this->_train_handle($flag, $player_id, $cost_item_id, $cost_item_num, $player_item_num, $cost_silver_num, $cost_gold_num, $player_info, $fairy_info, $auto_buy, $improve_flag);
     # 强化成功
     if ($flag) {
         #引导任务
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_id, 27, 1);
         $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_id, 38, $fairy_info['train_level'], 8);
     } else {
         # 失败时提示消息
         #失败返还一半消耗
         $call_back_silver = floor($cost_silver_num / 2);
         $this->_return_faile_silver($player_id, $call_back_silver);
         $message = array('texts' => array(array('code' => 80910, 'content' => array(), 'params' => array())));
         Protocol::input($player_id, 3, 7, 742, $message);
     }
     # 游戏日志记录
     $log_data = array('player_id' => $player_id, 'channel' => 536, 'server_id' => SERVER_ID, 'operator_id' => OPERATOR_ID, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'ad_info' => $player_info['ad_info'], 'cmd_id' => 536, 'player_fairy_id' => $fairy_id, 'fairy_code' => $fairy_info['fairy_code'], 'type' => $fairy_info['type'], 'old_train_level' => $old_fairy_info['train_level'], 'new_train_level' => $fairy_info['train_level'], 'old_train_attr' => json_encode($old_fairy_info['train_attr']), 'new_train_attr' => $flag ? $fairy_info['train_attr'] : json_encode($fairy_info['train_attr']), 'flag' => $flag ? 1 : 0);
     Log_Common::getInstance()->add_log_by_table($log_data, 'log_fairy_train');
     $out_536['result'] = $flag ? 0 : 1;
     Protocol::input($player_id, 3, 5, 536, $out_536);
 }
Exemple #15
0
 public function random_task($random_val, $all_random_task = null, $order)
 {
     if (is_null($all_random_task)) {
         $all_random_task = Cache_TaskRandom::getInstance()->get_task_random_info();
     }
     if ($random_val) {
         $has_keys = array_keys($random_val);
     } else {
         $has_keys = array();
     }
     $now_time = time();
     $rand_keys = array();
     foreach ($all_random_task as $key => $val) {
         if (!in_array($val['sid'], $has_keys)) {
             $rand_keys[$key] = $val['respawn_weight'];
         }
     }
     if ($rand_keys) {
         $key = Com_Random::get_probability_key($rand_keys);
         $quality_weight = array();
         for ($i = 1; $i <= 5; $i++) {
             $q_key = 'quality_weight' . $i;
             $quality_weight[$i] = $all_random_task[$key][$q_key];
         }
         $quality = Com_Random::get_probability_key($quality_weight);
         $due_time = $all_random_task[$key]['duration'] + $now_time;
         return $this->get_data('PlayerTask')->format_random_task_val($all_random_task[$key]['sid'], 1, $quality, $due_time, $order);
     }
     return array();
 }
Exemple #16
0
 private function get_challenge_monster_info()
 {
     # 获取天梯榜中已有monster信息
     $monster_info_all = $this->get_data('Challenge')->get_challenge_monster_info_all();
     # 获取天梯每日怪物刷新次数
     $monster_flush_seq = $this->get_data('PlayerDailyTime')->get_global_used_time('challenge_monster_flush_seq');
     if (empty($monster_flush_seq)) {
         $monster_flush_seq = 0;
     }
     $cur_flush_seq = 0;
     # 获取当前刷新后的刷新序号
     $flush_s2t = array_reverse($this->challenge_monster_flush_s2t);
     foreach ($flush_s2t as $s => $t) {
         if ($this->current_time >= $t) {
             $cur_flush_seq = $this->challenge_monster_flush_t2s[$t];
             break;
         }
     }
     # 若($cur_flush_seq == 0 || $monster_flush_seq >= $cur_flush_seq)标识没到刷新时间||已经刷新过该序号次数对应的刷新
     # 若该序号次数的刷新没有执行过,则刷新
     if ($monster_flush_seq < $cur_flush_seq) {
         # 获取monster的随机用权重哈希
         $ladder_element_info = Cache_Ladder::getInstance()->get_element_info_by_type(2);
         if (empty($ladder_element_info)) {
             $this->throw_error('120108');
         }
         $rand_monster_weight_hash = array();
         foreach ($ladder_element_info as $index => $element_info) {
             $rand_monster_weight_hash[$element_info['sub_type']] = $element_info['weight'];
         }
         # 构造一个随机monster_offset的集合数组,[2..100]分10段
         $rand_offset_weight_hash = array();
         for ($i = 1; $i <= $this->challenge_monster_section_num; $i++) {
             # 分10段填充,段位
             for ($j = ($i - 1) * $this->challenge_monster_flush_step + 1; $j <= $i * $this->challenge_monster_flush_step; $j++) {
                 # 该段位可用offset
                 if ($j != 1) {
                     $rand_offset_weight_hash[$i][$j] = 1;
                 }
                 # 怪物不能插入第1名之前,排除1,各偏移量的权重相等,都取1
             }
         }
         # 获取已有monster的offset集合,并将已有monster的offset从随机monster_offset的集合中去重
         $already_hold_monster_offset = array();
         if (!empty($monster_info_all)) {
             foreach ($monster_info_all as $offset => $mon_info) {
                 $section_idx = intval(($offset - 1) / $this->challenge_monster_flush_step) + 1;
                 # 获取段索引,1..10段
                 $already_hold_monster_offset[$section_idx][] = $offset;
                 unset($rand_offset_weight_hash[$section_idx][$offset]);
             }
         }
         # 刷新monster,每隔10名刷新3个怪物
         for ($i = 1; $i <= $this->challenge_monster_section_num; $i++) {
             # 分10段填充
             $hold_num = count($already_hold_monster_offset[$i]);
             if ($hold_num >= $this->challenge_monster_flush_num) {
                 # 该段怪物已满,不需填充
                 continue;
             } else {
                 $fill_num = $this->challenge_monster_flush_num - $hold_num;
                 # 该段需填充怪物个数
                 for ($j = 1; $j <= $fill_num; $j++) {
                     # 随机一个monster
                     $rand_mon_id = Com_Random::get_probability_key($rand_monster_weight_hash);
                     # 随机一个offset
                     $rand_offset = Com_Random::get_probability_key($rand_offset_weight_hash[$i]);
                     $mon_rtype = $this->get_game('Reward')->get_reward_type($ladder_element_info[$rand_mon_id]['reward']);
                     unset($rand_offset_weight_hash[$i][$rand_offset]);
                     # 去重
                     $monster_info_all[$rand_offset] = array('offset' => $rand_offset, 'mon_id' => $rand_mon_id, 'mon_rtype' => $mon_rtype, 'is_in_battle' => 0);
                 }
             }
         }
         $re = $this->get_data('Challenge')->update_challenge_monster_info_all($monster_info_all);
         $this->write_check($re, 3012082);
         $re = $this->get_data('PlayerDailyTime')->set_global_used_time('challenge_monster_flush_seq', $cur_flush_seq);
         $this->write_check($re, 3012084);
     }
     return $monster_info_all;
 }
Exemple #17
0
 public function get_task_daily_collection_id($player_level)
 {
     if (empty($player_level)) {
         return 0;
     }
     # 首先确定等级区间
     $level = 0;
     $sql = "select distinct level from task_daily_collection order by level desc";
     $records = $this->select_all($sql, $this->get_cache_key(array('task_daily_collection' => 1, 'sort' => 'desc'), $this->prefix_task_daily_collection));
     foreach ($records as $record) {
         if ($player_level >= $record['level']) {
             $level = $record['level'];
             break;
         }
     }
     $sql = "select * from task_daily_collection where level = {$level}";
     $coll_task_list = $this->select_all($sql, $this->get_cache_key(array('level' => $level), $this->prefix_task_daily_collection));
     $coll_task_weight_hash = array();
     # 地图权重哈希,随机取map_id用
     foreach ($coll_task_list as $index => $coll_task_info) {
         $coll_task_weight_hash[$coll_task_info['main_task_id']] = $coll_task_info['rand_weight'];
     }
     $rand_main_task_id = Com_Random::get_probability_key($coll_task_weight_hash);
     return intval($rand_main_task_id);
 }
Exemple #18
0
 public function get_answer_right_reward($player_id, $question_id, $map_id, $player_list)
 {
     if (empty($map_id) || empty($question_id) || empty($player_list)) {
         $this->throw_error('10107');
         //参数错误!
     }
     $athena_question_reward_id = Cache_Const::getInstance()->get_const('athena_question_reward_id', 0, 1);
     # 掉落道具ID
     $athena_question_reward_ratio = Cache_Const::getInstance()->get_const('athena_question_reward_ratio', 0, 1);
     # 掉落概率
     $athena_question_reward_stint = Cache_Const::getInstance()->get_const('athena_question_reward_stint', 0, 1);
     # 掉落获取次数上限
     $involved_num = count($player_list);
     # 参与人数
     for ($i = 0; $i < $involved_num; $i++) {
         $player_info = $this->get_data('Player')->get_player_info($player_list[$i], array('player_id', 'level', 'vip', 'privilege_level'));
         if (empty($player_info)) {
             continue;
             # 不阻挡别人发奖
         }
         if (Com_Random::probability($athena_question_reward_ratio, 10000)) {
             $gain_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_list[$i], $this->daily_answer_right_reward_gain_num);
             if ($gain_num >= $athena_question_reward_stint) {
                 continue;
             }
             $reward = array();
             $reward[] = array('type' => 'drop', 'item_id' => $athena_question_reward_id, 'item_num' => 1);
             $re = $this->get_game('Reward')->send_reward($player_list[$i], $reward, array('cmd_id' => '549'), 1);
             $this->write_check_strict($re, 3010334);
             # 更新奖励获取次数
             $re = $this->get_data('PlayerDailyTime')->add_used_time($player_list[$i], $this->daily_answer_right_reward_gain_num, 1);
             $this->write_check($re, 3010338);
             # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
             $ret = $this->get_game('Reward')->add_reward_log(true);
             /**
             				$reward_fmt = array();
             				$reward_fmt[] = array(
             					'type' 		=> $item_id,
             					'item_id'	=> $item_id,
             					'item_num'	=> $item_num,
             				);
             
             				# 告知Flash奖励
             				Protocol::input($player_list[$i], 8, 11, 1154, array('reward' => $reward_fmt));
             				**/
             Com_Log::debug_write('xgame.athena_question', "{$player_list[$i]} get answer right reward" . json_encode($reward));
         }
     }
     return null;
 }