/** * 检查是否满足创建公会 * @param unknown $player_id * @param unknown $name * @param unknown $introduce * @return string */ protected function check_create_union($player_id, $name, $introduce, &$playerInfo, &$unionCreatConfig, &$arr_consume = array()) { //已有公会 if ($playerInfo['union_id']) { $this->throw_error('170101'); } //level等级不足 if ($playerInfo['level'] < $unionCreatConfig['level_need']) { $this->throw_error('170105'); } $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10027); if ($vip_table['fun_type'] == 1) { $player_vip = $playerInfo['vip']; } elseif ($vip_table['fun_type'] == 2) { $left_time = $this->get_game('VipSpecial')->get_left_time($player_id); $player_vip = $left_time == 0 ? 0 : $playerInfo['privilege_level']; } #获取VIP配置表限制 $vip_table = Cache_VipLevelLimit::getInstance()->get_limit_info_unrelated_to_vip_level(10027); if ($vip_table['vip_level'] < 1 || $player_vip < $vip_table['vip_level']) { $this->throw_error('170106'); //vip等级不足 } $field = Cache_FbLoot::getInstance()->get_item_key($unionCreatConfig['cost_type']); #先扣除彩钻 $ticket = 0; $price = $unionCreatConfig['cost_num']; if ($field == "gold") { if ($playerInfo['ticket'] > 0) { if ($playerInfo['ticket'] >= $unionCreatConfig['cost_num']) { $ticket = $unionCreatConfig['cost_num']; $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $unionCreatConfig['cost_num']); $unionCreatConfig['cost_num'] = 0; } else { $ticket = $playerInfo['ticket']; $unionCreatConfig['cost_num'] = $unionCreatConfig['cost_num'] - $playerInfo['ticket']; $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', 'ticket', $playerInfo['ticket']); } } $arr_consume = array('price' => $price, 'gold' => $unionCreatConfig['cost_num'], 'ticket' => $ticket, 'count' => 1); #数据中心推送 } $this->get_data('Player')->check_player_resource($player_id, $playerInfo, '-', $field, $unionCreatConfig['cost_num']); //公会名称 $name = trim($name); if (!$name) { //公会名称不能为空 $this->throw_error('170102'); } $nameCheck = Com_Filter::check_str($name, 3, 12); if ($nameCheck == -1) { //长度不符法 $this->throw_error('170104'); } else { if ($nameCheck < 0) { //名称不合法 $this->throw_error('170103'); } else { if (is_numeric($name)) { //名称不为纯数字 $this->throw_error('170111'); } else { if (!Com_Filter::check_badWord($name)) { ///名称不合法 $this->throw_error('170103'); } } } } //宣言 $this->check_introduce($introduce); //公会名称唯一 $info = $this->get_data('UnionInfo')->get_union_name($name); if (!empty($info)) { $this->throw_error('170107'); } }
/** * @Purpose: * 更改精灵名称 * @param $player_id 玩家ID * @param $fairy_id 精灵ID * @param $fairy_name 新的精灵名称 */ public function set_fairy_name($player_id, $fairy_id, $fairy_name) { $player_id = intval($player_id); $fairy_name = strval($fairy_name); //获取指定类型精灵配置表数据 $fairy_list_table = $this->get_fairy_table_data_by_type(1); if (!$fairy_list_table[0]['change_name_expend']) { $this->throw_error('10109'); //配置表读取错误 } list($prop_id, $prop_num) = explode(":", $fairy_list_table[0]['change_name_expend']); $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'ticket', 'gold', 'silver', 'privilege_level')); $arr_consume = array(); if ($prop_id > 0 && $prop_num > 0) { if ($prop_id == 3) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'silver', $prop_num); } else { if ($prop_id == 2) { $deduct_coin = 0; if ($player_info['ticket'] > 0) { if ($player_info['ticket'] < $prop_num) { $deduct_coin = $player_info['ticket']; } else { $deduct_coin = $prop_num; } $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'ticket', $deduct_coin); } if ($deduct_coin < $prop_num) { $this->get_data('Player')->check_player_resource($player_id, $player_info, '-', 'gold', $prop_num - $deduct_coin); } $arr_consume = array('price' => $prop_num, 'gold' => $prop_num - $deduct_coin, 'ticket' => $deduct_coin, 'count' => 1); #数据中心推送 } else { //获取玩家背包道具 $player_prop_num = $this->get_game('Prop')->get_prop_num_by_prop_id($player_id, $prop_id); if ($player_prop_num < $prop_num) { $this->throw_error('80011'); #道具不足 } } } } else { $this->throw_error('10111'); #配置表配置错误 } #检测新名字合法性 if (empty($fairy_name) || Com_Filter::check_str($fairy_name, 3, 12) != 1 || is_numeric($fairy_name)) { $this->throw_error('10220'); #内容不合法 } //获取玩家精灵数据 $obj_player_fairy_data = $this->get_data('Fairy'); $data = $obj_player_fairy_data->get_player_fairy_info($fairy_id); if (!$data) { $this->throw_error('10112'); //获取精灵信息失败 } $update_data['name'] = $fairy_name; $this->start_trans(); if ($prop_id == 2 || $prop_id == 3) { if ($prop_num > 0) { $update_res = $this->get_data('Player')->update_player_resource($player_id, $player_info, 534, array(), $arr_consume); if (!$update_res) { $this->throw_error('10104'); } } } else { if ($prop_id > 0 && $prop_num > 0) { $log_param = array('cmd_id' => 534, 'level' => $player_info['level'], 'vip' => $player_info['vip']); $arr_log = array(); $this->get_game('Prop')->deduct_prop_by_prop_id($player_id, $prop_id, $prop_num, $arr_log, 1, $log_param); } } $update_res = $this->get_data('Fairy')->update_player_fairy($fairy_id, $update_data); if (!$update_res) { $this->throw_error('10104'); } $this->commit(); if ($data['type'] == 1) { Protocol_Player::p2c_part_update($player_id, array('light_fairy_name' => $fairy_name)); } else { if ($data['type'] == 2) { Protocol_Player::p2c_part_update($player_id, array('dark_fairy_name' => $fairy_name)); } } return array($fairy_name); }