Ejemplo n.º 1
0
 public function del_buff_data($player_id, $buff_sids)
 {
     if (!empty($buff_sids)) {
         $msg_flag = 0;
         foreach ($buff_sids as $buff_sid) {
             $this->get_data('PlayerBuffData')->del_buff_data($player_id, $buff_sid);
             $buff_data = Cache_SkillBuff::getInstance()->get_buff_data($buff_sid);
             if ($buff_data['family_lv'] > 0) {
                 $msg_flag = 1;
             }
         }
         $this->buff_attr($player_id, false);
         #计算属性
         if ($msg_flag) {
             Protocol_Msg::msg($player_id, 12018);
             #buff药已过期
         }
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * 资源类道具使用
  * @param $player_id
  * @param $loot_id
  */
 protected function use_resource($player_id, $loot_id, $use_num, $career_type, $bind_flag = null)
 {
     $objReward = $this->get_game('Reward');
     for ($i = 0; $i < $use_num; $i++) {
         $reward[] = array('type' => 'drop', 'item_id' => $loot_id);
     }
     $result = $objReward->send_reward($player_id, $reward, array('career_type' => $career_type, 'cmd_id' => '409', 'bind_flag' => $bind_flag));
     if ($result === true) {
         return 0;
     } else {
         $this->rollback();
         Protocol_Msg::msg($player_id, $result);
         return 6;
     }
     return 0;
 }
Ejemplo n.º 3
0
 /**
  * 购买次数
  * @param $player_id
  * @return array
  */
 public function add_fight_times($player_id)
 {
     $p_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_duel_add_times');
     $p_num = $p_num ? $p_num : 0;
     //获取购买消耗信息
     $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info(10, 1);
     //获取购买次数上限
     $time_max = $this->get_kf_duel_battle_num_buy_stint($player_id, $buy_times_info);
     if ($p_num >= $time_max) {
         $this->throw_error('120119', 6010097);
         // 你不能再增加挑战次数了
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $purchase_times_cost = explode("|", $buy_times_info['cost_num']);
     $cost_currency_value = intval($purchase_times_cost[$p_num]);
     $cost_currency_type = $buy_times_info['cost_type'];
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->start_trans();
     $result = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'kf_duel_add_times');
     if ($result) {
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1234, array(), $arr_consume);
     }
     if ($result) {
         $this->commit();
         $this->get_game('PlayerFunc')->sync_func_tips($player_id, $this->_func_id);
         $max_time = $p_num + 1;
         $kf_duel_conf = Cache_CrossDuel::getInstance()->get_battle_conf(41001);
         $max_fight_times = $kf_duel_conf['times'];
         $cur_num = intval($this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_duel_use_times'));
         if ($max_time >= $time_max) {
             //到了最大次数 前端不弹提示框 这里约定传 null
             $next_cost = '';
         } else {
             $p_num = $p_num + 1;
             $next_cost = intval($purchase_times_cost[$p_num]);
             $next_cost = $cost_currency_type . ':' . $next_cost;
         }
         Protocol_Msg::msg($player_id, 12017);
         //给前端提示 购买成功
         $left_num = $max_time + $max_fight_times - $cur_num;
         Protocol_Player::p2c_part_update($player_id, array('kf_3vs3_remaining_count' => $left_num));
         return array('cur_num' => $cur_num, 'max_time' => $max_time + $max_fight_times, 'next_cost' => $next_cost);
     } else {
         $this->rollback();
         $this->throw_error('10110', 6010098);
     }
 }
Ejemplo n.º 4
0
 /**
  * 购买次数
  * @param $player_id
  * @return array
  */
 public function add_fight_times($player_id)
 {
     $p_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_grab_domain_add_times');
     $p_num = $p_num ? $p_num : 0;
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     $vip_level = $player_info['vip'] ? $player_info['vip'] : 0;
     //获取购买消耗信息
     $buy_times_info = Cache_UnionGrabDomain::getInstance()->get_buy_times_info($vip_level);
     //获取购买次数上限
     $times_limit = $this->get_buy_max_times($player_id, $buy_times_info);
     if ($p_num >= $times_limit) {
         // 你不能再增加进攻次数了
         if (10 > $vip_level) {
             $this->throw_error(6010121);
         } else {
             $this->throw_error(6010146);
         }
     }
     $purchase_times_cost = explode("|", $buy_times_info['cost_num']);
     $cost_currency_value = intval($purchase_times_cost[$p_num]);
     $cost_currency_type = $buy_times_info['cost_type'];
     $cost_currency_key = Cache_Currency::getInstance()->get_key($cost_currency_type);
     $arr_consume = Com_Util::get_consume_info_for_data_center($player_info, $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', $cost_currency_key, $cost_currency_value, 1, $cost_currency_type);
     $this->start_trans();
     $result = $this->get_data('PlayerDailyTime')->add_used_time($player_id, 'union_grab_domain_add_times');
     if ($result) {
         $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 2602, array(), $arr_consume);
     }
     if ($result) {
         $this->commit();
         $max_time = $p_num + 1;
         $grab_domain_conf = Cache_UnionGrabDomain::getInstance()->get_base_conf();
         $max_fight_times = $grab_domain_conf['times'];
         $cur_num = intval($this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'union_grab_domain_use_times'));
         if ($max_time >= $times_limit) {
             //到了最大次数 前端不弹提示框 这里约定传 null
             $next_cost = '';
         } else {
             $p_num = $p_num + 1;
             $next_cost = intval($purchase_times_cost[$p_num]);
             $next_cost = $cost_currency_type . ':' . $next_cost;
         }
         Protocol_Msg::msg($player_id, 12017);
         //给前端提示 购买成功
         return array('cur_num' => $cur_num, 'max_time' => $max_time + $max_fight_times, 'next_cost' => $next_cost);
     } else {
         $this->rollback();
         $this->throw_error('10110', 6010122);
     }
 }
Ejemplo n.º 5
0
 /**
  * 更换对手
  * @param $player_id
  * @return bool
  */
 public function change_opponent($player_id, $change_times)
 {
     if ($change_times < 0) {
         Protocol_Msg::msg($player_id, 10107, '101120002');
         return false;
     }
     if (!$this->get_start_time()) {
         Protocol_Msg::msg($player_id, 120123);
         //活动未开启,请在每天的14:00-15:00进行匹配
         return false;
     }
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('ticket', 'level', 'vip', 'gold', 'privilege_level'));
     $kf_arena_conf = Cache_CrossArenaConf::getInstance()->get_conf(array('change_player_cost'));
     $change_player_cost = explode('|', $kf_arena_conf['change_player_cost']['val']);
     $change_times = $change_times > 6 ? 6 : intval($change_times);
     $need_gold = $change_player_cost[$change_times];
     $ticket = 0;
     $price = $need_gold * $change_times;
     if ($player_info['ticket'] > 0) {
         if ($player_info['ticket'] >= $need_gold) {
             $ticket = $need_gold;
             $result = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $need_gold, 0);
             $need_gold = 0;
         } else {
             $need_gold = $need_gold - $player_info['ticket'];
             $ticket = $player_info['ticket'];
             $result = $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $ticket, 0);
         }
     }
     $arr_consume = array('price' => $price, 'gold' => $need_gold, 'ticket' => $ticket, 'count' => 1);
     #数据中心推送
     if ($need_gold > 0) {
         $result = $this->get_data('Player')->check_player_resource($player_id, $player_info, "-", 'gold', $need_gold, 0);
     }
     if ($result !== true) {
         Protocol_Msg::msg($player_id, $result);
         return false;
     }
     $result = $this->get_data('Player')->update_player_resource($player_id, $player_info, 1214, array(), $arr_consume);
     if ($result) {
         Protocol_Msg::msg($player_id, 12016);
         #更换对手成功
         return true;
     }
     return false;
 }