/** * 获取最大次数 * @param $player_id * @param $fun_id * @param $vip_level */ public function get_max_daily_time($player_id, $field, $vip_level = 0) { $max_num = 0; switch ($field) { case 'pub_left_num': #普通抽取总次数 $max_num = $this->get_game('PubHero')->get_max_free_time($vip_level, 1); break; case 'pub_left_ten_num': #十连抽 $max_num = $this->get_game('PubHero')->get_max_free_time($vip_level, 3); break; case 'daily_task_finish_count': # 日常任务每日完成轮数上限 $max_num = $this->get_game('TaskHandler')->get_daily_task_finish_stint($player_id); break; case 'challenge_battle_num': # 天梯战斗挑战次数上限 list($challenge_battle_num, $max_num) = $this->get_game('Challenge')->get_challenge_battle_num_info($player_id); break; case 'used_fight_num': #副本挑战总次数 $max_num = $this->get_game('PlayerPVE')->get_max_times($player_id, $vip_level); break; case 'coin_exchange_free_times_max': #炼金最大免费使用次数 $max_num = $this->get_game('PlayerCoinExchange')->get_free_times_max_interface($player_id, $vip_level); break; case 'daily_sign_free_times_max': #签到最大免费次数 $max_num = $this->get_game('DailySign')->get_free_times_max_interface($player_id, $vip_level); break; case 'union_wanted_times_max': #公会通缉任务最大完成次数 $max_num = $this->get_game('UnionWanted')->get_free_times_max_interface($player_id, $vip_level); break; case 'kf_arena_add_times_max': #竞技场最大的挑战次数 $kf_arena_conf = Cache_CrossArenaConf::getInstance()->get_conf(array('max_fight_times')); $max_fight_times = $kf_arena_conf['max_fight_times']; $max_num = $max_fight_times['val'] + $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'kf_arena_add_times'); break; case 'kf_duel_add_times_max': #组队最大的挑战次数 $kf_duel_conf = Cache_CrossDuel::getInstance()->get_battle_conf(41001); $max_fight_times = $kf_duel_conf['times']; $max_num = $max_fight_times + $this->get_player_used_time($player_id, 'kf_duel_add_times'); break; case 'union_bomb_count': #魔能巨炮强化最大次数 $union_conf = Cache_UnionBase::getInstance()->get_union_conf(); $max_num = $union_conf['max_bomb_time']; break; case 'grab_treasure_battle_times_max': $grab_treasure_battle_buy_type = $this->get_game('GrabTreasure')->get_grab_treasure_battle_buy_type(); $buy_times_info = Cache_BuyTimes::getInstance()->get_buy_times_info($grab_treasure_battle_buy_type, 1); # 获取: 每日已挑战次数 + 每日挑战购买次数 + 当天剩余可用挑战次数 $battle_buy_times = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, 'grab_treasure_battle_buy_times'); if (empty($battle_buy_times)) { $battle_buy_times = 0; } $max_num = $battle_buy_times * $buy_times_info['per_num'] + $this->get_game('GrabTreasure')->get_grab_treasure_max_times(); break; } return $max_num; }
/** * 设置战斗cd * @param $player_id * @return bool */ public function add_fight_cd($player_id) { $cacheKey = $this->cacheKeyFightCd . ":" . $player_id; $cd_time = Cache_CrossArenaConf::getInstance()->get_conf('clean_time'); $cd_time = $cd_time['val']; $this->redis()->set($cacheKey, 1); $this->redis()->expire($cacheKey, $cd_time); return true; }
/** * 更换对手 * @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; }