예제 #1
0
 /**
  * 更新公告
  * @param int $player_id
  * @param array $arr_notice_detail
  * @return int
  */
 public function update_system_notice($id, $arr_notice_detail)
 {
     $updateSql = "update system_notice set ";
     $update = array();
     foreach ($arr_notice_detail as $field => $value) {
         if ($field == 'id') {
             continue;
         }
         if (is_array($value)) {
             $arr_notice_detail[$field] = json_encode($value);
         }
         $update[] = "{$field} = '" . ($arr_notice_detail[$field] ? $arr_notice_detail[$field] : $value) . "'";
     }
     $updateSql = $updateSql . implode(",", $update) . " where id = {$id}";
     Com_Log::debug_write('crontab_system_notice', json_encode($updateSql));
     return $this->query($updateSql);
 }
예제 #2
0
 /**
  * 挂机领取奖励
  * @param unknown $add_exp
  * @param unknown $arr_item_id
  * @param unknown $arr_item_num
  */
 public function auto_pve_add_reward($player_id, $add_exp, $arr_item_id, $arr_item_num)
 {
     $reward = array();
     if (Com_Array::is_good_arr($arr_item_id)) {
         foreach ($arr_item_id as $key => $item_id) {
             $item_num = $arr_item_num[$key];
             if ($item_num > 0) {
                 $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key($item_id), 'item_id' => $item_id, 'item_num' => $item_num);
             }
         }
     }
     if ($add_exp) {
         $reward[] = array('type' => Cache_FbLoot::getInstance()->get_item_key(1), 'item_id' => 1, 'item_num' => $add_exp);
     }
     if (!empty($reward)) {
         $result = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '771'));
         if ($result !== true) {
             $attachment = array();
             foreach ($reward as $prop) {
                 $attachment[] = array("prop_id" => $prop['item_id'], "prop_num" => $prop['item_num']);
             }
             $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(11);
             $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 771);
             Com_Log::debug_write('auto_pve_add_reward', "player_id={$player_id},fail=" . json_encode($reward));
             $this->throw_error(80034);
             return false;
         }
         Com_Log::debug_write('auto_pve_add_reward', "player_id={$player_id},sucess=" . json_encode($reward));
         $this->get_game('Reward')->add_reward_log(true);
     }
 }
예제 #3
0
 /**
  * 红包领取历史数据添加
  * @param unknown $redEnvelopesInfo
  * @param unknown $redReceiveInfo
  */
 private function sys_add_red_envelopes_his($redEnvelopesInfo, $redReceiveInfo)
 {
     if (!Com_Array::is_good_arr($redEnvelopesInfo) || !Com_Array::is_good_arr($redReceiveInfo)) {
         return false;
     }
     $data = array();
     $data['union_id'] = $redEnvelopesInfo['union_id'];
     $data['send_player_id'] = $redEnvelopesInfo['player_id'];
     $data['player_name'] = $redEnvelopesInfo['name'];
     $data['send_gold'] = $redEnvelopesInfo['send_gold'];
     $data['send_packets'] = $redEnvelopesInfo['send_packets'];
     $data['grab_seconds'] = intval($redEnvelopesInfo['red_packet_living_seconds']);
     $data['message'] = $redEnvelopesInfo['message'];
     $data['career_type'] = $redEnvelopesInfo['career_type'];
     $data['add_time'] = $redEnvelopesInfo['add_time'];
     #红包时间接近属于异常
     $union_red_packet_upts = $this->get_data("PlayerDailyTime")->get_player_used_time($data['union_id'], "union_red_packet_upts");
     if ($union_red_packet_upts >= $data['add_time']) {
         return false;
     }
     $this->get_data("PlayerDailyTime")->set_used_time($data['union_id'], "union_red_packet_upts", $data['add_time']);
     $this->start_trans();
     $red_packets_id = $this->get_data('UnionRedPacketsHis')->add_red_packets($data);
     if (!$red_packets_id) {
         $this->rollback();
         return false;
     }
     $objPlayerData = $this->get_data('Player');
     $ret_player = $objPlayerData->update_player_info($data['send_player_id'], array("send_red_packets_num" => "+1", "send_red_packets_gold" => "+{$data['send_gold']}"));
     if (!$ret_player) {
         $this->rollback();
         return false;
     }
     $objUnionInfoData = $this->get_data('UnionInfo');
     $union_info = $objUnionInfoData->get_union_info($data['union_id'], array("red_packets_gold", "red_packets_num"));
     $union_info["red_packets_gold"] += $data['send_gold'];
     $union_info["red_packets_num"] += 1;
     Com_Log::debug_write('update_union_info', "sys_add_red_envelopes_his|unoin_id={$data['union_id']}" . json_encode($union_info));
     $ret_union_info = $objUnionInfoData->update_union_info($data['union_id'], $union_info);
     if (!$ret_union_info) {
         $this->rollback();
         return false;
     }
     $temp_gold = 0;
     foreach ($redReceiveInfo as $val) {
         $data = array();
         $data['red_packets_id'] = $red_packets_id;
         $data['receive_player_id'] = $val['player_id'];
         $data['receive_gold'] = $val['gold'];
         $data['send_name'] = $redEnvelopesInfo['name'];
         $data['receive_name'] = $val['name'];
         $data['message'] = $val['message'];
         $data['receive_time'] = $val['add_time'];
         $ret = $this->get_data('PlayerReceiveRedPackets')->add_receive_red_packets($data);
         if (!$ret_union_info) {
             $this->rollback();
             return false;
         }
         $ret = $objPlayerData->update_player_info($data['receive_player_id'], array("receive_red_packets_num" => "+1", "receive_red_packets_gold" => "+{$data['receive_gold']}"));
         if (!$ret) {
             $this->rollback();
             return false;
         }
         if ($data['receive_gold'] > $temp_gold) {
             $luck_player_id = $data['receive_player_id'];
             $temp_gold = $data['receive_gold'];
         }
     }
     if (count($redEnvelopesInfo["red_envelopes"]) == count($redReceiveInfo)) {
         $ret = $objPlayerData->update_player_info($luck_player_id, array("receive_luck_red_packets_num" => "+1"));
         if (!$ret) {
             $this->rollback();
             return false;
         }
     }
     $this->commit();
 }
예제 #4
0
파일: Event.php 프로젝트: bluefan/phpsource
 public function handle_mail_resource_revise_for_event($player_id, &$attachment, $cmd2_id, $vip_level, $ratio_type)
 {
     if (empty($player_id) || empty($resource_list) || empty($cmd2_id) || empty($ratio_type)) {
         return null;
     }
     Com_Log::debug_write('xgame.event', "event ratio revise {$player_id} {$cmd2_id}: " . json_encode($attachment));
     # 获取当前生效的活动倍率详细信息哈希 + 最终倍率
     list($event_ratio_hash, $final_ratio) = $this->get_valid_event_ratio_hash($cmd2_id, $vip_level, $ratio_type);
     if (empty($event_ratio_hash) || empty($final_ratio)) {
         return null;
     }
     # 按倍率修正受影响的资源数量
     $relate_item_id_list = explode(":", $event_ratio_hash[$cmd2_id]['relate_item_id']);
     $relate_item_id_hash = array_flip($relate_item_id_list);
     foreach ($attachment as $idx => $val) {
         if (isset($relate_item_id_hash[$val['prop_id']])) {
             $attachment[$idx]['prop_num'] = intval($attachment[$idx]['prop_num'] * ($final_ratio / 10000));
         }
     }
     Com_Log::debug_write('xgame.event', "event ratio revise {$player_id} {$cmd2_id}: " . json_encode($attachment));
     return true;
 }
예제 #5
0
 /**
  * 触发成就任务
  * @param unknown $player_id
  */
 public function trigger_achieve_target($data)
 {
     if (empty($data)) {
         return;
     }
     $data = json_decode($data, true);
     $player_id = $data["player_id"];
     $achieve_type = $data["achieve_type"];
     $trigger_val = $data["val"];
     $update_type = $data["update_type"];
     Com_Log::write('xgame.trigger_achieve_target', "{$player_id}---{$achieve_type}" . json_encode($data));
     $achieve_configs = Cache_AchieveConfig::getInstance()->get_achieve_config_by_type($achieve_type);
     $obj_player_counter = $this->get_data('PlayerAchieveCounter');
     $achieve_counter_type_progress = $obj_player_counter->get_player_achieve_counter_info($player_id, array("finish_title_ids", "task_type_progress"));
     $obj_player_only = $this->get_data('PlayerAchieveOnly');
     $objPlayerAchieve = $this->get_data('PlayerAchieve');
     $push_achieve_prompt1 = array();
     $push_achieve_prompt2 = array();
     $push_achieve_prompt3 = array();
     //2014-4-16是否添加过下一个要完成的值
     $is_added_next_target_val = 0;
     $push_prompt_title_id = 0;
     $push_prompt_achieve_id = 0;
     $finish_num = 0;
     $loot_times = 0;
     $achieve_counter_data = $obj_player_counter->get_player_achieve_counter_info($player_id, array("task_type_progress"));
     $player_achieve_data = $objPlayerAchieve->get_player_achieve_info($player_id);
     foreach ($achieve_configs as $achieve_config) {
         $loot_times++;
         $title_id = $achieve_config['title_id'];
         $achieve_id = $achieve_config['achieve_id'];
         #当前勋章下所有成就
         $player_achieve_info = $player_achieve_data[$title_id];
         if (isset($achieve_counter_data["task_type_progress"][$achieve_type]['val']) && !in_array($achieve_type, array(6, 28, 29, 24, 35, 36, 40, 48))) {
             $player_achieve_info[$achieve_config['achieve_id']]['val'] = $achieve_counter_data["task_type_progress"][$achieve_type]['val'];
         }
         $oldval = $player_achieve_info[$achieve_config['achieve_id']]['val'];
         #2014-4-14修改把配置表类型移到代码中
         $achieve_config["target_type"] = $update_type;
         //检查是否满足条件
         $check_finish = $this->check_achieve_finish($player_id, $trigger_val, $achieve_config, $player_achieve_info);
         $newval = $player_achieve_info[$achieve_config['achieve_id']]['val'];
         $prop_id = intval($achieve_config['reward']);
         if ($player_achieve_info[$achieve_id]['state'] == 1) {
             $finish_num++;
         }
         if ($is_added_next_target_val == 0) {
             $add_trigger_type_info = array();
             $add_trigger_type_info['type'] = $achieve_type;
             $add_trigger_type_info['update_type'] = $update_type;
             $add_trigger_type_info['val'] = $newval;
             $add_trigger_type_info['is_sys'] = 1;
         }
         //完成=>所有此类型
         if ($finish_num == count($achieve_configs) && $is_added_next_target_val == 0) {
             $add_trigger_type_info['next_target_val'] = 999999999;
             $is_added_next_target_val = 1;
         }
         //全服唯一
         if ($achieve_config['other_type'] == 1) {
             $achieve_only_info = $obj_player_only->get_player_achieve_only_info($achieve_id);
             if ($achieve_only_info) {
                 continue;
             }
         }
         Com_Log::write('xgame.trigger_achieve_medal_test', "{$player_id}--{$achieve_type}--{$oldval}--{$newval}--{$check_finish}");
         //未完成
         if ($oldval == $newval && $check_finish != 1) {
             if ($check_finish !== 2 && $is_added_next_target_val == 0) {
                 $add_trigger_type_info['next_target_val'] = $achieve_config['target_val'];
                 $is_added_next_target_val = 1;
             }
             continue;
             //无变化不更新
         }
         //未完成-变化
         if ($check_finish == 0 && $is_added_next_target_val == 0) {
             $add_trigger_type_info['next_target_val'] = $achieve_config['target_val'];
             $is_added_next_target_val = 1;
         }
         $this->start_trans();
         $ret_task = $objPlayerAchieve->update_player_achieve($player_id, $title_id, $player_achieve_info, $achieve_id);
         if (!$ret_task) {
             return false;
         }
         if ($check_finish == 0) {
             $this->commit();
             continue;
         }
         $ret_only = true;
         //更新全服唯一成就完成信息
         if ($achieve_config['other_type'] == 1) {
             $achieve_only_info = array("achieve_id" => $achieve_id, "player_id" => $player_id, "add_time" => time());
             $ret_only = $obj_player_only->update_player_achieve_only($achieve_config['achieve_id'], $achieve_only_info);
             if (!$ret_only) {
                 return false;
             }
         }
         $target_finish_num = 0;
         #获取配置表下当前勋章所有成就任务
         $achieve_title_data = Cache_AchieveConfig::getInstance()->get_achieve_config_by_titleid2($title_id);
         $target_total_num = count($achieve_title_data);
         //玩家完成的成就任务
         if ($player_achieve_info) {
             foreach ($player_achieve_info as $achieve_id => $val) {
                 if (isset($achieve_title_data[$achieve_id])) {
                     if ($val['state'] == 1) {
                         $target_finish_num++;
                     }
                 }
             }
         }
         //当前成就列任务是否全部完成
         if ($target_finish_num >= $target_total_num && $target_total_num > 0) {
             $field = "finish_title_ids";
             $ret_counter = true;
             if ($title_id < 100 || $prop_id < 1) {
                 $achieve_counter_data = $obj_player_counter->get_player_achieve_counter_info($player_id, $field);
                 $achieve_counter_data[$title_id] = time();
                 //激活新的勋章/称号
                 $set_counter_data[$field] = $achieve_counter_data;
                 $ret_counter = $obj_player_counter->update_player_achieve_counter($player_id, $set_counter_data);
                 if (!$ret_counter) {
                     return false;
                 }
             }
             $reward = array();
             //如果为勋章添加提升属性
             if ($title_id < 100) {
                 $finish_medal_id = array();
                 $finish_max_medal_id = 0;
                 if (Com_Array::is_good_arr($achieve_counter_type_progress["finish_title_ids"])) {
                     foreach ($achieve_counter_type_progress["finish_title_ids"] as $finish_title_id => $up_ts) {
                         if ($finish_title_id < 100) {
                             $finish_medal_id[] = $finish_title_id;
                         }
                     }
                 }
                 #防止后面勋章先完成
                 if (!empty($finish_medal_id)) {
                     $finish_max_medal_id = max($finish_medal_id);
                 }
                 if ($title_id > $finish_max_medal_id) {
                     $title_config = Cache_TitleConfig::getInstance()->get_title_config_by_id($title_id);
                     $achieve_attr_1 = $this->get_format_achieve_attr($title_config['reward']);
                     $update_player_detail_data['achieve_attr_1'] = $achieve_attr_1;
                     $ret_attr_1 = $this->get_data('PlayerDetail')->update_player_detail($player_id, $update_player_detail_data);
                     if (!$ret_attr_1) {
                         return false;
                     }
                     $ret_player = $this->get_data('Player')->update_player_info($player_id, array("medal_id" => $title_id));
                     if (!$ret_player) {
                         return false;
                     }
                     Com_Log::write('xgame.trigger_achieve_medal', "{$player_id}---{$achieve_type}---trigger_medal_id={$title_id}");
                 }
                 $push_achieve_prompt2 = array(2, $title_config['icon'], $title_config['font_icon'], "", 0, $title_id, 0);
             } else {
                 $title_config = Cache_TitleConfig::getInstance()->get_title_config_by_id($title_id);
                 #if($title_config['operator_id'] !=0 && OPERATOR_ID!=$title_config['operator_id']) return false;
                 if ($prop_id > 0) {
                     $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($achieve_config['title_id']);
                     $attachment = array();
                     $attachment[] = array("prop_id" => $prop_id, "prop_num" => 1);
                     $re = $this->get_game('Mail')->async_trigger_mail($player_id, $phrase_config['title'], $phrase_config['content'], $attachment, $phrase_config['sender'], 1, 766);
                 }
             }
             $this->commit();
             $push_prompt_achieve_id = $achieve_config['achieve_id'];
             $push_prompt_title_id = $title_id;
             Protocol_Player::p2c_part_update($player_id, array('attr' => array(), 'medal_id' => ''));
             if ($title_id < 100) {
                 #{玩家名}获得了{勋章名},功成名就,指日可待!
                 $replace_info = array();
                 $replace_info[] = array('rep_type' => 0, 'rep_val' => $player_id);
                 $replace_info[] = array('rep_type' => 7, 'txt' => $title_config['title_name']);
                 $this->get_game('SystemNotice')->push_sys_notice($player_id, 14, 0, $replace_info);
             }
         } else {
             if (!$ret_only) {
                 return false;
             }
             $this->commit();
             $push_prompt_achieve_id = $achieve_config['achieve_id'];
             $push_prompt_title_id = $title_id;
         }
         //任务完成添加成就点
         if ($achieve_config['achieve_point'] > 0) {
             $player_info = $this->get_data('Player')->get_player_info($player_id, array("achieve_point", "level", "vip"));
             $front_amount_achieve_point = intval($player_info["achieve_point"]);
             $player_info["achieve_point"] += $achieve_config['achieve_point'];
             $ret_player = $this->get_data('Player')->update_player_info($player_id, $player_info);
             if (!$ret_player) {
                 return false;
             }
             //主角成就日志
             $log_data = array('player_id' => $player_id, 'channel' => 29, 'type' => 1, 'item_id' => 12, 'item_num' => $achieve_config['achieve_point'], 'amount' => $front_amount_achieve_point, 'after_amount' => $player_info['achieve_point'], 'cmd_id' => 768, 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip']);
             Log_Common::getInstance()->add_log($log_data, 'day');
         }
     }
     #特殊类型不保留下一步记录
     if (!in_array($achieve_type, $this->special_task_type)) {
         if ($is_added_next_target_val == 1) {
             $add_trigger_type_info['upts'] = time();
             $task_type_progress = $obj_player_counter->get_player_achieve_counter_info($player_id, array("task_type_progress"));
             $task_type_progress["task_type_progress"][$achieve_type] = $add_trigger_type_info;
             $ret = $obj_player_counter->update_player_achieve_counter($player_id, $task_type_progress);
             if (!$ret) {
                 return false;
             }
         }
     }
     $func_open = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'func_open');
     if (isset($func_open[14])) {
         if ($push_prompt_title_id > 0) {
             if ($push_achieve_prompt2) {
                 Protocol::input($player_id, 8, 7, 768, array($push_achieve_prompt2));
                 Com_Log::debug_write('xgame.push_achieve_prompt', "{$player_id}---{$achieve_type}" . var_export($push_achieve_prompt2, true));
             } else {
                 if ($push_prompt_title_id < 100) {
                     $achieve_config = Cache_AchieveConfig::getInstance()->get_achieve_config($push_prompt_achieve_id);
                     $push_achieve_prompt = array(1, $achieve_config['icon'], $achieve_config['font_icon'], $achieve_config['target_info'], $achieve_config['achieve_point'], $push_prompt_title_id, $achieve_config['achieve_id']);
                 } else {
                     $title_config = Cache_TitleConfig::getInstance()->get_title_config_by_id($push_prompt_title_id);
                     $push_achieve_prompt = array(3, $title_config['icon'], $title_config['font_icon'], $achieve_config['target_info'], 0, $push_prompt_title_id, 0);
                 }
                 Com_Log::debug_write('xgame.push_achieve_prompt', "{$player_id}---{$achieve_type}" . var_export($push_achieve_prompt, true));
                 Protocol::input($player_id, 8, 7, 768, array($push_achieve_prompt));
             }
         }
     }
     if (!IS_FRONT) {
         Protocol::out();
     }
 }
예제 #6
0
 public function gain_free_reward($player_id, $plm_id)
 {
     $this->param_check_numeric(array($player_id, $plm_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, Com_Util::get_player_fields(array('currency', 'level', 'vip', 'privilege_level')));
     # 获取议会配置信息
     $plm_conf = Cache_MagicParliament::getInstance()->get_parliament_conf($plm_id);
     if (empty($plm_conf)) {
         $this->throw_error('100002');
         # 获取魔法议会配置失败
     }
     # 议会免费奖励领取上限
     $free_reward_gain_stint = $this->get_free_reward_gain_stint($plm_id, $plm_conf);
     # 获取玩家当日免费奖励领取次数
     $free_reward_num = $this->get_data('PlayerDailyTime')->get_player_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     # 判断上限
     if ($free_reward_num >= $free_reward_gain_stint) {
         $this->throw_error('100008');
         #  魔法议会免费领奖次数超过上限
     }
     $this->start_trans();
     # 更新免费奖励领取次数
     $re = $this->get_data('PlayerDailyTime')->add_used_time($player_id, $this->get_redis_key($this->daily_gain_free_reward_num_prefix, $plm_conf['plm_id']));
     $this->write_check($re, 3010223);
     # 发放免费奖励
     $reward = array();
     $reward_detail = $this->get_game('Reward')->get_reward_detail($plm_conf['free_reward']);
     $this->get_game('Reward')->gen_reward_array($reward_detail, $reward);
     if (!empty($reward)) {
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2506'), 1);
         $this->write_check_strict($re, 3010411);
     }
     # 记录行为日志
     $action_log = array('player_id' => $player_id, 'reg_time' => $this->current_time, 'plm_id' => $plm_id, 'action_type' => 3, 'reward_info' => json_encode($reward_detail));
     $re = $this->get_data('MagicParliament')->record_action_log($action_log);
     $this->write_check_strict($re, 3010445);
     $this->commit();
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $ret = $this->get_game('Reward')->add_reward_log(true);
     # 刷新议会信息
     $out_2503 = $this->init_magic_parliament_deatil($player_id, $plm_id);
     Protocol::input($player_id, 3, 25, 2503, $out_2503);
     # 记录行为
     Com_Log::debug_write('xgame.magic_parliament', "{$player_id}\t" . "gain_free_reward\t" . "{$plm_id}\t");
     $out_2506 = array();
     return $out_2506;
 }
예제 #7
0
 /**
  * 触发公会成就任务
  * @param unknown $player_id
  */
 public function trigger_union_achieve($data)
 {
     if (empty($data)) {
         return;
     }
     $data = json_decode($data, true);
     Com_Log::log($data, 'trigger_union_achieve.log', 1);
     $player_id = $data["player_id"];
     $task_type = $data["task_type"];
     $trigger_val = $data["num"];
     $update_type = $data["update_type"];
     $union_id = $data["union_id"];
     $objUnionAchieveData = $this->get_data('UnionAchieve');
     $achieve_list = Cache_UnionAchieve::getInstance()->get_union_achieve_info(array("type" => $task_type));
     foreach ($achieve_list as $val) {
         $achieve_id = $val['sid'];
         $unionAchieveInfo = $objUnionAchieveData->get_union_achieve_list($union_id, $achieve_id);
         if ($unionAchieveInfo['state'] == 1) {
             continue;
         }
         $content = explode('|', $val['content']);
         $total_num = count($content) > 1 ? $content[1] : $content[0];
         $player_num = count($content) > 1 ? $content[0] : 0;
         //不同玩家达成
         if ($player_num > 0) {
             if ($unionAchieveInfo['player_ids']) {
                 if (in_array($player_id, $unionAchieveInfo['player_ids'])) {
                     continue;
                 }
             }
             $unionAchieveInfo['player_ids'][] = $player_id;
         }
         $unionAchieveInfo['sid'] = $achieve_id;
         $unionAchieveInfo['state'] = 0;
         if ($update_type == 1) {
             //累加
             $unionAchieveInfo['num'] += $trigger_val;
             //成就完成
             if ($unionAchieveInfo['num'] >= $total_num) {
                 $unionAchieveInfo['state'] = 1;
             }
         } else {
             if ($update_type == 2) {
                 //赋值
                 $unionAchieveInfo['num'] = $trigger_val;
                 //成就完成
                 if ($unionAchieveInfo['num'] >= $total_num) {
                     $unionAchieveInfo['state'] = 1;
                 }
             } else {
                 if ($update_type == 3) {
                     //小于等于
                     $unionAchieveInfo['num'] = $trigger_val;
                     //成就完成
                     if ($unionAchieveInfo['num'] > 0 && $unionAchieveInfo['num'] <= $total_num) {
                         $unionAchieveInfo['state'] = 1;
                     }
                 } else {
                     continue;
                 }
             }
         }
         if ($player_num) {
             $unionAchieveInfo['state'] = 0;
             if (count($unionAchieveInfo['player_ids']) >= $player_num) {
                 $unionAchieveInfo['state'] = 1;
             }
             $unionAchieveInfo['num'] = count($unionAchieveInfo['player_ids']);
         }
         $progress_task_num = 0;
         $medal_achieve_list = Cache_UnionAchieve::getInstance()->get_union_achieve_info(array("medal_id" => $val["medal_id"]));
         $medal_total_task_num = count($medal_achieve_list);
         foreach ($medal_achieve_list as $medal_task_info) {
             if ($achieve_id == $medal_task_info["sid"]) {
                 if (!$unionAchieveInfo['state']) {
                     break;
                 }
                 $progress_task_num++;
             } else {
                 $achieve_info = $objUnionAchieveData->get_union_achieve_list($union_id, $medal_task_info["sid"]);
                 if (!$achieve_info) {
                     break;
                 }
                 if ($achieve_info['state'] == 1) {
                     $progress_task_num++;
                 }
             }
         }
         $this->start_trans();
         $unionAchieveInfo["rep_time"] = time();
         $retUnionAchieve = $objUnionAchieveData->update_union_achieve($union_id, $achieve_id, $unionAchieveInfo);
         //达成勋章
         $retUnionInfo = true;
         if ($progress_task_num == $medal_total_task_num) {
             $objUnionInfoData = $this->get_data('UnionInfo');
             $UnionInfo = $objUnionInfoData->get_union_info($union_id, array("union_medal"));
             $UnionInfo['union_medal'][] = $val['medal_id'];
             Com_Log::debug_write('update_union_info', "trigger_union_achieve|unoin_id={$union_id}" . json_encode($data));
             $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $UnionInfo);
             $medal_list = Cache_UnionMedal::getInstance()->get_union_medal_info(array("sid" => $val['medal_id']));
             $medal_info = $medal_list[0];
             $arr_replace = array();
             $arr_replace[] = array('rep_type' => 7, 'txt' => $medal_info['name'], 'rep_color' => "ffb901");
             $msg = Language_Message::make_message(174902, $arr_replace);
             $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
         }
         if ($retUnionAchieve && $retUnionInfo) {
             $this->commit();
             if ($unionAchieveInfo['state'] == 1) {
                 $arr_replace = array();
                 $arr_replace[] = array('rep_type' => 7, 'txt' => $val['name'], 'rep_color' => "ffb901");
                 $msg = Language_Message::make_message(174901, $arr_replace);
                 $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 7, 7);
             }
             if ($progress_task_num >= $medal_total_task_num) {
                 $this->union_player_add_attr($union_id, $val['medal_id']);
             }
         } else {
             $this->rollback();
         }
         if (!IS_FRONT) {
             Protocol::out();
         }
     }
 }
예제 #8
0
파일: Hero.php 프로젝트: bluefan/phpsource
 /**
  * 英雄公告
  * @param $player_id 玩家ID
  * @param $hero_code 英雄配置表ID
  * @param $hero_id 英雄ID
  * @param $get_way 获得途径(0:酒馆1:兑换)
  */
 public function hero_notice($player_id, $hero_code, $hero_id, $get_way)
 {
     $player_id = intval($player_id);
     $hero_id = strval($hero_id);
     $get_way = intval($get_way);
     $func_id = 1070;
     #酒馆
     if ($get_way == 1) {
         $func_id = 1071;
         #兑换
     }
     $sub_func_id = 0;
     $need_broadcas = 0;
     //获取英雄属性基础表
     $hero_attr_base = $this->get_hero_attr_table($hero_code);
     if ($hero_attr_base) {
         $need_broadcas = $hero_attr_base['need_broadcas'];
     }
     $replaceinfo = array();
     $replaceinfo[] = array('rep_type' => 0, 'rep_val' => $player_id);
     $replaceinfo[] = array('rep_type' => 1, 'rep_val' => $func_id, 'rep_pid' => $func_id);
     $replaceinfo[] = array('rep_type' => 3, 'rep_val' => $hero_code, 'rep_player_id' => $player_id, 'rep_pid' => $hero_id);
     Com_Log::debug_write('hero_notice', "player_id={$player_id}" . json_encode($need_broadcas));
     Com_Log::debug_write('hero_notice', "player_id={$player_id}" . json_encode($replaceinfo));
     $this->get_game('SystemNotice')->push_sys_notice($player_id, $func_id, $sub_func_id, $replaceinfo, 0, $need_broadcas);
 }
예제 #9
0
 public function start_time($params)
 {
     #公会boss,自动分配宝箱
     if ($params['type'] == 170001) {
         $res = $this->get_game('UnionBoss')->Auto_send_box($params['param1']);
         if ($res) {
             $params['timeout'] = 0;
         } else {
             $params['timeout'] = 10;
         }
         return $params;
     } else {
         if ($params['type'] == 170002) {
             //        	Com_Log::debug_write('add_system_notice',"start_time--".json_encode($params));
             $notice = $this->get_game('SystemNotice')->send_interval_system_notice($params['id']);
             if ($notice) {
                 if ($notice['state'] == 2) {
                     $params['timeout'] = 0;
                 } else {
                     $params['timeout'] = $notice['show_interval'];
                     Com_Log::debug_write('add_system_notice', "start_time" . json_encode($params));
                     Protocol::input(0, 7, 4, 516, $params);
                 }
             } else {
                 $params['timeout'] = 0;
             }
             return $params;
         } elseif ($params['type'] == 170003) {
             $this->get_game('ActivityQuestions')->delay_send_reward($params);
             $params['timeout'] = 0;
             return $params;
         } elseif ($params['type'] == 755) {
             #防沉迷
             $this->get_game('Adlut')->do_timer($params['id']);
             return $params;
         } elseif ($params['type'] == 170004) {
             #Com_Log::write('nut','--170004');
             #更新排行数据
             $this->get_data('RankList')->update_player_rank_list();
             $params['timeout'] = 180;
             return $params;
         } elseif ($params['type'] == 101838) {
             $this->get_game('PlayerFashion')->check_fashion_timer($params['id']);
             $params['timeout'] = 0;
             return $params;
         }
     }
 }
예제 #10
0
 public function save_kfarena_data($player_id)
 {
     $time = time();
     $data_value = $this->get_cross('KFArena')->get_cross_player_info($player_id);
     if (!empty($data_value)) {
         foreach ($data_value as $hash_key => $value) {
             if ($value) {
                 $data = array('hash_key' => $hash_key, 'player_id' => $player_id, 'data_value' => addslashes(json_encode($value)), 'is_cross' => 1, 'base_key' => "data|cache_key_arena_rank_user_list_cache", 'rep_time' => $time);
                 $table = $this->game_player_data . '_' . $player_id % $this->table_num;
                 $sql = $this->create_sql_value($table, $data);
                 if (!$this->query($sql)) {
                     Com_Log::debug_write('xgame.save_data_error', $sql);
                 }
             }
         }
     }
 }
예제 #11
0
 public function send_interval_system_notice($id)
 {
     $nowtime = time();
     $notice = $this->get_data('SystemNotice')->get_system_notice_by_id($id);
     if (in_array($notice['state'], array(0, 1))) {
         if ($notice['start_time'] > $nowtime) {
             $interval = $notice["start_time"] - $nowtime;
             $notice['show_interval'] = $interval;
             $notice['state'] = 0;
         } else {
             if ($nowtime > $notice['end_time']) {
                 //过期
                 $notice['state'] = 2;
             } else {
                 $notice['state'] = 1;
                 if ($notice['show_interval'] == 0) {
                     $notice['state'] = 2;
                 }
                 $notice['next_exec_time'] = $nowtime;
                 $this->send_gm_msg($notice['show_type'], $notice['location'], $notice['content']);
             }
             Com_Log::debug_write('add_system_notice', "send_interval_system_notice--" . json_encode($notice));
             if ($notice) {
                 $this->get_data('SystemNotice')->update_system_notice($notice['id'], $notice);
             }
         }
     }
     return $notice;
 }
예제 #12
0
 /**
  * 用途:获取结算奖励 + 484
  * @param $player_list和score_list已按降序排序过
  * @return array
  */
 public function get_reward($player_id, $map_id, $player_list, $score_list, $state_list, $looted_scores)
 {
     if (empty($map_id) || empty($player_list) || empty($score_list) || empty($state_list) || !is_array($player_list) || !is_array($score_list) || !is_array($state_list)) {
         $this->throw_error('10107');
         //参数错误!
     }
     # 获取排名奖励列表,已按排名排好序
     $rank_reward_list = Cache_GrabMine::getInstance()->get_rank_reward_list($map_id);
     if (empty($rank_reward_list)) {
         $this->throw_error('180003');
         # 抢矿副本排位奖励信息配置错误
     }
     $rank_reward_omit = $rank_reward_list[count($rank_reward_list) - 1];
     # 超过已配置最大排位的奖励,使用最大排位计算
     $involved_num = count($player_list);
     # 参与人数
     for ($i = 0; $i < $involved_num; $i++) {
         $rank_reward_info = empty($rank_reward_list[$i]) ? $rank_reward_omit : $rank_reward_list[$i];
         $player_info = $this->get_data('Player')->get_player_info($player_list[$i], array('player_id', 'level', 'vip', 'privilege_level'));
         if (empty($player_info['player_id'])) {
             # 可能是跨服造成的其它服玩家
             #Com_Log::debug_write('xgame.all.error', "Grabmine error: unvalid player: ".$player_list[$i]);
             #$this->throw_error('20002'); # 获取玩家信息失败
             continue;
         }
         # 获取vip对奖励的加成信息,只加成非道具奖励
         $vip_add_coeff = Com_Util::get_vip_special_reward_add_coeff(10036, $player_info['vip'], $player_info['privilege_level'], $player_info['player_id']);
         # 获取基础奖励信息
         $base_reward_info = Cache_GrabMine::getInstance()->get_base_reward_info($player_info['level']);
         if (empty($base_reward_info) || empty($base_reward_info['base_reward'])) {
             $this->throw_error('180005');
             # 抢矿副本基础奖励信息配置错误
         }
         if (!empty($state_list[$i])) {
             # 在线直接发奖
             $reward = array();
             $reward_detail_base = $this->get_game('Reward')->get_reward_detail_other_way($base_reward_info['base_reward'], $rank_reward_info['reward_add'], 1);
             $this->get_game('Reward')->gen_reward_array($reward_detail_base, $reward, 1 + $vip_add_coeff);
             $reward_detail_rank = $this->get_game('Reward')->get_reward_detail($rank_reward_info['reward_item'], 1);
             $this->get_game('Reward')->gen_reward_array($reward_detail_rank, $reward);
             $re = $this->get_game('Reward')->send_reward($player_list[$i], $reward, array('cmd_id' => '484'), 1);
             $this->write_check_strict($re, 3010303);
             # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
             $ret = $this->get_game('Reward')->add_reward_log();
             $reward_fmt = array();
             if (!empty($reward)) {
                 foreach ($reward as $r) {
                     if (empty($r['item_id'])) {
                         # 虚拟货币
                         $item_idx = Cache_Currency::getInstance()->get_index($r['type']);
                         $reward_fmt[] = array('type' => $item_idx, 'item_id' => $item_idx, 'item_num' => $r['item_num']);
                     } else {
                         $reward_fmt[] = array('type' => $r['item_id'], 'item_id' => $r['item_id'], 'item_num' => $r['item_num']);
                     }
                 }
             }
             # 告知Flash排位奖励
             Protocol::input($player_list[$i], 8, 11, 1126, array('rank' => $i + 1, 'rank_reward' => $reward_fmt));
             $final_reward_detail = $this->get_game('Reward')->get_reward_detail_by_reward($reward);
             Com_Log::debug_write('xgame.grabmine', $player_list[$i] . "\tget_reward directly\t" . $player_info['level'] . "\t" . $player_info['vip'] . "\t" . $vip_add_coeff . "\t" . json_encode($final_reward_detail));
         } else {
             # 不在线的发邮件
             # 生成奖励邮件附件信息
             $attachment = array();
             $reward_detail_base = $this->get_game('Reward')->get_reward_detail_other_way($base_reward_info['base_reward'], $rank_reward_info['reward_add'], 1);
             foreach ($reward_detail_base as $item_idx => $item_num) {
                 $item_num = ceil($item_num * (1 + $vip_add_coeff));
                 $attachment[] = array("prop_id" => $item_idx, "prop_num" => $item_num);
             }
             $reward_detail_rank = $this->get_game('Reward')->get_reward_detail($rank_reward_info['reward_item'], 1);
             foreach ($reward_detail_rank as $item_idx => $item_num) {
                 $item_num = ceil($item_num * (1 + $vip_add_coeff));
                 $attachment[] = array("prop_id" => $item_idx, "prop_num" => $item_num);
             }
             # 邮件发送
             $day = date("n.j", $this->current_time);
             $hour = date("G:i", $this->current_time);
             $phrase_config = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info(9);
             $content = sprintf($phrase_config['content'], $day, $hour, $rank_reward_info['rank_id']);
             $re = $this->get_game('Mail')->async_trigger_mail($player_list[$i], $phrase_config['title'], $content, $attachment, $phrase_config['sender'], 1, 484);
             $final_reward_detail = array();
             foreach ($attachment as $val) {
                 $final_reward_detail[$val['prop_id']] += $val['prop_num'];
             }
             Com_Log::debug_write('xgame.grabmine', $player_list[$i] . "\tget_reward mail\t" . $player_info['level'] . "\t" . $player_info['vip'] . "\t" . $vip_add_coeff . "\t" . json_encode($final_reward_detail));
         }
         # 更新水晶争夺参与次数[结算完算参与]
         $re = $this->get_data('PlayerDailyTime')->add_used_time($player_info['player_id'], 'grabmine_involved_num', 1);
         $left_num = $this->get_grabmine_remain_involved_num($player_info['player_id']);
         if ($left_num < 0) {
             $left_num = 0;
         }
         Protocol_Player::p2c_part_update($player_info['player_id'], array('mineral_remaining_count' => $left_num));
         $this->write_check($re, 3010363);
         //找回资源埋点
         $this->get_game('GetBackCurrency')->add_function_day_times($player_info['player_id'], 8);
         # --------------------------------------------------------------------
         # 维护一个全榜玩家积分累计值排名的有序集合[积分做score]
         # --------------------------------------------------------------------
         if (!empty($looted_scores[$i])) {
             $re = $this->redis()->zsets_incr($this->grabmine_score_acc_sorted_set, $looted_scores[$i], $player_info['player_id']);
             Com_Log::write('xgame.grabmine', $this->grabmine_score_acc_sorted_set . "|" . $looted_scores[$i] . "|" . $player_info['player_id']);
             $this->write_check($re, 3010417);
             # 成就相关埋点: 获取当前排名并埋点触发成就
             $current_rank = $this->get_rank($player_info['player_id']);
             if (!empty($current_rank)) {
                 $this->get_game('PlayerAchieve')->async_trigger_achieve_target($player_info['player_id'], 45, $current_rank, 3);
             }
         }
         # --------------------------------------------------------------------
         # 活动日志记录
         # --------------------------------------------------------------------
         $event_log_info = array('log_type' => 'grabmine', 'player_id' => $player_info['player_id'], 'reg_time' => $this->current_time, 'map_id' => $map_id, 'score' => $score_list[$i], 'rank' => $i + 1, 'state' => $state_list[$i]);
         $this->get_game('Event')->async_deal_event_log($event_log_info);
         # --------------------------------------------------------------------
         # 游戏日志记录
         # --------------------------------------------------------------------
         $log_info = array('player_id' => $player_info['player_id'], 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'map_id' => $map_id, 'score' => $score_list[$i], 'rank' => $i + 1, 'state' => $state_list[$i], 'reward' => json_encode($final_reward_detail));
         Log_Grabmine::getInstance()->add_log($log_info);
     }
     # 记录行为,TODO: 考虑更详细的日志信息记录
     $log_content = "{$player_id}\t" . "get_reward\t" . "{$map_id}\t" . json_encode($player_list) . "\t" . json_encode($score_list);
     Com_Log::debug_write('xgame.grabmine', $log_content);
 }
예제 #13
0
 /**
  *
  * $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_id, $task_type,$val,$update_type);
  * @param unknown $player_id
  * @param unknown $task_type
  * @param number $val
  * @param number $update_type 1累加 2赋值
  * @return unknown
  */
 public function async_trigger_daily_boon_task($player_id, $task_type, $val = 1, $update_type = 1, $is_async = 1)
 {
     $func_open = $this->get_data('PlayerDetail')->get_player_detail($player_id, 'func_open');
     if (!isset($func_open[1130])) {
         return false;
     }
     $player_id = intval($player_id);
     if (!$player_id) {
         return false;
     }
     $data["player_id"] = $player_id;
     $data["task_type"] = $task_type;
     $data["val"] = $val;
     $data["update_type"] = $update_type;
     Com_Log::debug_write('async_trigger_daily_boon_task', json_encode($data));
     if ($is_async) {
         return Com_Queued::send("daily_boon_task", json_encode($data));
     } else {
         return $this->trigger_daily_boon_task(json_encode($data));
     }
 }
예제 #14
0
 /**
  * @Purpose:
  * 开启公会活动
  * @Param $player_id 玩家ID
  * @Param $activities_id 活动ID
  */
 public function open_activities($player_id, $activities_id)
 {
     $player_id = intval($player_id);
     #获取玩家公会ID,验证公会信息
     $union_id = $this->get_data('Player')->get_player_info($player_id, 'union_id');
     if ($union_id < 1) {
         $this->throw_error('171101');
         #未加入公会
     }
     $activities_id = intval($activities_id);
     #获取公会活动配置表
     $activities_table = $this->get_cache_table_data('activities_table', array('activities_id' => $activities_id));
     if (!$activities_table) {
         $this->throw_error('10109');
         //配置表读取错误
     }
     #获取公会等级
     $union_level = $this->get_data('UnionInfo')->get_union_info($union_id, 'union_level');
     if (empty($union_level) || $union_level < $activities_table['union_level']) {
         $this->throw_error('1752007');
         #公会等级不足
     }
     #获取玩家公会职务
     $player_data = $this->get_data('UnionPlayer')->get_union_player_info($union_id, $player_id);
     $job = $player_data['job_id'];
     #获取公会活动天数据
     $uad_data = $this->get_data('UnionActivities')->get_union_activities_daily_info($union_id, 'uad', 'day');
     if ($uad_data['activities_info'] && !is_array($uad_data['activities_info'])) {
         $uad_data['activities_info'] = json_decode($uad_data['activities_info'], true);
     }
     if ($uad_data['open_times'] && !is_array($uad_data['open_times'])) {
         $uad_data['open_times'] = json_decode($uad_data['open_times'], true);
     }
     #获取公会资金
     $union_coin = $this->get_data('UnionInfo')->get_union_info($union_id, 'fund');
     if ($activities_table['expend_coin'] > $union_coin) {
         $this->throw_error('1752002');
         #公会资金不足
     }
     $activities_table['open_job'] = explode("|", $activities_table['open_job']);
     $is_open_job = false;
     if (Com_Array::is_good_arr($activities_table['open_job'])) {
         if (in_array($job, $activities_table['open_job'])) {
             $is_open_job = true;
         }
     }
     if (isset($uad_data['activities_info'][$activities_id]['state']) && $uad_data['activities_info'][$activities_id]['state'] != 0 || $activities_table['open_way'] != 1 || !$is_open_job || $uad_data['open_times'][$activities_id] >= $activities_table['open_times']) {
         $this->throw_error('1752001');
         #不能开启活动
     }
     #开启活动
     $time = time();
     $uad_data['activities_info'][$activities_id]['fb_id'] = $activities_table['fb_id'];
     $uad_data['activities_info'][$activities_id]['activities_type'] = $activities_table['activities_type'];
     $uad_data['activities_info'][$activities_id]['state'] = 1;
     $uad_data['activities_info'][$activities_id]['open_time'] = $time;
     $uad_data['activities_info'][$activities_id]['close_time'] = $time + $activities_table['activities_time'];
     $update_uad['activities_info'] = json_encode($uad_data['activities_info']);
     $uad_data['open_times'][$activities_id]++;
     $update_uad['open_times'] = json_encode($uad_data['open_times']);
     if ($activities_table['expend_coin']) {
         #$update_field['fund'] = $union_coin - $activities_table['expend_coin'];
         $update_field['fund'] = "-" . $activities_table['expend_coin'];
     }
     $this->start_trans();
     #更新活动天数据
     $this->get_data('UnionActivities')->update_union_activities_daily_data($union_id, 'uad', $update_uad);
     #更新公会资金
     if ($activities_table['expend_coin']) {
         Com_Log::debug_write('update_union_info', "UnionActivities|unoin_id={$union_id}" . json_encode($update_field));
         $update_res = $this->get_data('UnionInfo')->update_union_info($union_id, $update_field);
         if (!$update_res) {
             $this->throw_error('10104');
         }
     }
     $this->commit();
     #同步活动数据到C++
     $this->get_game('Union')->Sync_Union_msg($union_id, $activities_table['activities_type']);
     if ($uad_data['activities_info'][$activities_id]['activities_type'] == 1) {
         #公会任务触发
         $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, 9091);
         #更新公会成就任务
         $this->get_game('UnionAchieve')->async_trigger_union_achieve($player_id, 13, 1, 1);
     } else {
         if ($uad_data['activities_info'][$activities_id]['activities_type'] == 2) {
             #公会任务触发
             $this->get_game('UnionBoonHall')->async_trigger_union_task($player_id, 2, '9092_2');
         }
     }
     #公告发2遍
     for ($times = 0; $times < 2; $times++) {
         #通知c++在聊天窗口显示活动开启通知
         $player_info = $this->get_data('Player')->get_player_info($player_id, array('name', 'career_type'));
         $arr_replace = array();
         $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id, 'underLine' => 1, 'rep_color' => "fff100");
         $arr_replace[] = array('rep_type' => 9, 'txt' => '#1', 'rep_val' => 176, 'rep_param' => array(intval($uad_data['activities_info'][$activities_id]['activities_type'])), 'underLine' => 1, 'rep_color' => "cd4040");
         $msg = Language_Message::make_message($activities_table['code'], $arr_replace, 0, '', true);
         $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, '7,9', 7, 1, 0, 1, $player_info['career_type']);
     }
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 0, 'txt' => $player_info['name'], 'rep_val' => $player_id, 'underLine' => 1, 'rep_color' => "fff100");
     $arr_replace[] = array('rep_type' => 7, 'txt' => '');
     $msg = Language_Message::make_message($activities_table['code'], $arr_replace);
     $this->get_game('SystemNotice')->send_system_msg($player_id, $msg, 2, 7);
     #增加公会记录
     $arr_replace = array();
     $arr_replace[] = array('rep_type' => 0, 'rep_val' => $player_id);
     $arr_replace[] = array('rep_type' => 7, 'txt' => $activities_table['expend_coin'], 'rep_color' => "ffb901");
     $arr_replace[] = array('rep_type' => 7, 'txt' => $activities_table['activities_name'], 'rep_color' => "ffb901");
     $this->get_game('UnionBase')->sys_add_union_log($player_id, $union_id, 1752005, $arr_replace);
 }
예제 #15
0
 public function fund_income($player_id, $fund_id, $income_offset)
 {
     $this->param_check_numeric(array($player_id, $fund_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level'));
     # 获取基金配置信息
     $fund_conf = Cache_Finance::getInstance()->get_fund_conf($fund_id);
     if (empty($fund_conf)) {
         $this->throw_error(110001);
         # 获取基金信息失败
     }
     # 获取玩家某种类型基金的交易日志
     $deal_log = $this->get_data('Finance')->get_player_fund_deal_log($player_id, $fund_conf['fund_type']);
     if (empty($deal_log)) {
         $this->throw_error(110007);
         # 未购买此种类型基金,不能领取收益
     }
     # 获取玩家某种类型基金的收益情况
     list($income_log_hash_1, $income_log_hash_2, $income_acc) = $this->get_data('Finance')->get_player_fund_income_log_by_type($player_id, $fund_conf['fund_type']);
     # 获取基金收益配置信息
     switch ($fund_conf['fund_type']) {
         case 1:
             # 时间基金
             $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_time($fund_conf['fund_id']);
             $current_income_offset = $this->_cal_income_offset($deal_log['deal_time']);
             break;
         case 2:
             # 等级基金
             $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_level_2($fund_conf['fund_id'], $deal_log['invest_level']);
             $current_income_offset = $player_info['level'];
             break;
         default:
             $income_conf_list = array();
             break;
     }
     if (empty($income_conf_list)) {
         $this->throw_error(110008);
         # 获取基金收益配置信息失败
     }
     # 判断达成条件
     if ($current_income_offset < $income_offset) {
         $this->throw_error(110002);
         # 未达成该档基金收益领取条件
     }
     # 判断是否已领取过
     if (isset($income_log_hash_1[$fund_id][$income_offset])) {
         $this->throw_error(110003);
         # 已领取过该档基金收益
     }
     $this->start_trans();
     # 发放免费奖励
     $reward = array(array('type' => 'ticket', 'item_id' => $this->fund_income_cur_id, 'item_num' => $income_conf_list[$income_offset]['income']));
     if (!empty($reward)) {
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2704'), 1);
         $this->write_check_strict($re, 3010411);
     }
     # 记录收益领取日志
     $income_log = array('player_id' => $player_id, 'fund_id' => $fund_id, 'income_offset' => $income_offset, 'fund_type' => $fund_conf['fund_type'], 'income_time' => $this->current_time, 'income_num' => $income_conf_list[$income_offset]['income']);
     $re = $this->get_data('Finance')->insert_fund_income_log($income_log);
     $this->write_check($re, 3010277);
     $this->commit();
     # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
     $ret = $this->get_game('Reward')->add_reward_log(true);
     # 可领收益档次刷新埋点
     $this->get_game('PlayerFunc')->sync_func_tips($player_id, $this->func_id);
     # 刷新基金列表
     $out_2701 = $this->get_fund_list($player_id, $fund_conf['fund_type']);
     Protocol::input($player_id, 3, 27, 2701, $out_2701);
     # 记录行为
     Com_Log::debug_write('xgame.finance', "{$player_id}\t" . "fund_income\t" . "{$fund_id}\t" . "{$income_offset}\t");
     $out_2704 = array('fund_type' => $fund_conf['fund_type']);
     return $out_2704;
 }
예제 #16
0
파일: S2P_4.php 프로젝트: bluefan/phpsource
 /**
  * 挂机副本同步倒计时
  */
 public function CMD2_464()
 {
     $this->get_game('AutoPve')->data_sync_left_time($this->_authuser['player_id'], $this->_param[0], $this->_param[1], $this->_param[2], $this->_param[3], $this->_param[4], $this->_param[5], $this->_param[6]);
     Com_Log::debug_write('temp_auto_pve', "464-{$this->_authuser['player_id']}" . json_encode($this->_param));
 }
예제 #17
0
 public function fund_income($player_id, $fund_id, $income_offset)
 {
     $this->param_check_numeric(array($player_id, $fund_id));
     $player_info = $this->get_data('Player')->get_player_info($player_id, array('level', 'vip', 'privilege_level'));
     # 获取基金配置信息
     $fund_conf = Cache_Finance::getInstance()->get_fund_conf($fund_id);
     if (empty($fund_conf)) {
         $this->throw_error(110001);
         # 获取基金信息失败
     }
     # 获取玩家某种类型基金的投资情况
     list($invest_acc, $invest_lvl, $invest_time) = $this->get_data('Finance')->get_player_fund_invest_log_by_type($player_id, $fund_conf['fund_type']);
     # 获取玩家某种类型基金的收益情况
     list($income_log_hash_1, $income_log_hash_2) = $this->get_data('Finance')->get_player_fund_income_log_by_type($player_id, $fund_conf['fund_type']);
     # 获取基金收益配置信息
     switch ($fund_conf['fund_type']) {
         case 1:
             # 时间基金
             $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_time($fund_conf['fund_id']);
             $current_income_offset = $this->_cal_income_offset($invest_time);
             break;
         case 2:
             # 等级基金
             if (!empty($invest_lvl)) {
                 $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_level_2($fund_conf['fund_id'], $invest_lvl);
             } else {
                 $income_conf_list = Cache_Finance::getInstance()->get_fund_income_conf_list_level_2($fund_conf['fund_id'], $player_info['level']);
             }
             $current_income_offset = $player_info['level'];
             break;
         default:
             $income_conf_list = array();
             break;
     }
     # 判断达成条件
     if ($current_income_offset < $income_offset) {
         $this->throw_error(110002);
         # 未达成该档基金收益领取条件
     }
     # 判断是否已领取过
     if (isset($income_log_hash_1[$fund_id][$income_offset])) {
         $this->throw_error(110003);
         # 已领取过该档基金收益
     }
     # 判断是发直接收益,还是补差收益
     $income_type = 0;
     $income_num = 0;
     if (isset($income_log_hash_2[$income_offset])) {
         $income_type = 1;
         # 按价格由高到低排序
         Com_Array::multisort($income_log_hash_2[$income_offset], array('fund_price' => 'desc'));
         $income_log_info = reset($income_log_hash_2[$income_offset]);
         $income_num = $income_conf_list[$income_offset]['income'] - $income_log_info['income_num'];
     } else {
         $income_num = $income_conf_list[$income_offset]['income'];
     }
     $this->start_trans();
     # 发放免费奖励
     $reward = array(array('type' => 'ticket', 'item_id' => $this->fund_income_cur_id, 'item_num' => $income_num));
     if (!empty($reward)) {
         $re = $this->get_game('Reward')->send_reward($player_id, $reward, array('cmd_id' => '2704'), 1);
         $this->write_check_strict($re, 3010411);
     }
     # 记录收益领取日志
     $income_log = array('player_id' => $player_id, 'fund_id' => $fund_id, 'income_offset' => $income_offset, 'fund_type' => $fund_conf['fund_type'], 'fund_price' => $fund_conf['fund_price'], 'income_time' => $this->current_time, 'income_num' => $income_num, 'income_type' => $income_type);
     $re = $this->get_data('Finance')->insert_fund_income_log($income_log);
     $this->write_check($re, 3010277);
     $this->commit();
     # 刷新基金列表
     $out_2701 = $this->get_fund_list($player_id, $fund_conf['fund_type']);
     Protocol::input($player_id, 3, 27, 2701, $out_2701);
     # 记录行为
     Com_Log::debug_write('xgame.finance', "{$player_id}\t" . "fund_income\t" . "{$fund_id}\t" . "{$income_offset}\t");
     $out_2704 = array('fund_type' => $fund_conf['fund_type']);
     return $out_2704;
 }
예제 #18
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);
 }
예제 #19
0
 private function get_opponent_list_for_real($rank)
 {
     $my_rank = $rank;
     $monster_info = $this->get_challenge_monster_info();
     # 获取天梯榜怪物信息
     $i = 1;
     $need_player_num = $this->challenge_list_stint;
     $hold_monster_info = array();
     # 对手列表中拥有的怪物信息列表, array(offset => monster_id)
     $hold_player_rank_list = array();
     # 对手列表中拥有的玩家排名列表,存放排位列表
     while ($i <= $need_player_num) {
         $previous_rank = $this->get_previous_rank($rank);
         if ($previous_rank <= 0) {
             break;
         }
         $hold_player_rank_list[] = $rank = $previous_rank;
         # 若该位置之前有怪物,则少取一个玩家数据,补充一个怪物数据
         if (!empty($monster_info[$previous_rank]) && $i < $need_player_num) {
             # 当此处$i==$need_player_num时,表示玩家和怪物已经取满
             $need_player_num -= 1;
             $hold_monster_info[$previous_rank] = $monster_info[$previous_rank]['mon_id'];
         }
         $i++;
     }
     Com_Log::debug_write('xgame.challenge', "rank={$rank}:\thold_player_rank_list\t" . json_encode($hold_player_rank_list));
     Com_Log::debug_write('xgame.challenge', "rank={$rank}:\thold_monster_info\t" . json_encode($hold_monster_info));
     # 对于排名在第8名及之前的玩家,需要向后取排位的玩家信息补充满8个
     $hold_player_num = count($hold_player_rank_list);
     $hold_monster_num = count($hold_monster_info);
     $need_filling_num = $this->challenge_list_stint - ($hold_player_num + $hold_monster_num);
     if ($need_filling_num >= 0) {
         for ($i = 1; $i <= $need_filling_num; $i++) {
             $fill_rank = $my_rank + $i;
             array_unshift($hold_player_rank_list, $fill_rank);
             # 由于hold_player_rank_list是按照排位由大到小存入数组的,故填充时需要保持该顺序
         }
     }
     list($player_info_list, $player_pid_list) = $this->get_data('Challenge')->get_player_list_by_rank($hold_player_rank_list);
     Com_Log::debug_write('xgame.challenge', "rank={$rank}:\tplayer_pid_list\t" . json_encode($player_pid_list));
     $ladder_element_info = Cache_Ladder::getInstance()->get_element_info_by_type(2);
     if (empty($ladder_element_info)) {
         $this->throw_error('120108');
     }
     # 将怪物并入对手列表
     $opponent_list = array();
     foreach ($player_info_list as $rank => $rank_info) {
         if (!empty($rank_info)) {
             $sort_weight = intval($rank_info['rank'] * 2);
             $rank_info['is_mon'] = 0;
             $rank_info['sort_weight'] = $sort_weight;
             $rank_info['mon_offset'] = 0;
             $rank_info['mon_rtype'] = '0';
             $opponent_list[$sort_weight] = $rank_info;
         }
     }
     foreach ($hold_monster_info as $offset => $mon_id) {
         #$mon_rtype = $monster_info[$offset]['mon_rtype']; # 当修改过ladder_element表配置时,可能保存的rtype与配置表不一致
         $mon_rtype = $this->get_game('Reward')->get_reward_type($ladder_element_info[$mon_id]['reward']);
         $sort_weight = intval($offset * 2 - 1);
         $opponent_list[$sort_weight] = array('player_id' => $mon_id, 'rank' => 0, 'mod_date' => 0, 'is_mon' => 1, 'sort_weight' => $sort_weight, 'mon_offset' => $offset, 'mon_rtype' => $mon_rtype);
     }
     krsort($opponent_list);
     # 按sort_weight重新排序
     Com_Log::debug_write('xgame.challenge', "rank={$rank}:\topponent_list\t" . json_encode($opponent_list));
     Com_Log::debug_write('xgame.challenge', "----------------------------------------------------------");
     return array($opponent_list, $player_pid_list, $hold_monster_info);
 }
예제 #20
0
 /**
  * @Purpose:
  * 更新玩家英雄redis,sql字段
  * @Method Name: update_player_hero()
  * @Parameter: $player_id 玩家ID
  * @Parameter: $hero_id 英雄ID
  * @Parameter: $arr 更新字段
  * @Return: 是否成功
  */
 public function update_player_hero($player_id, $hero_id, $arr, $all_field, $cmd = 0)
 {
     if (!is_array($all_field)) {
         return FALSE;
     }
     list($hero_player, $value) = explode("|", $hero_id);
     if ($player_id != $hero_player) {
         Com_Log::debug_write('hero_update', 'cmd : ' . $cmd . ' ; player_id : ' . $player_id . ' ; hero_id : ' . $hero_id);
         return FALSE;
     }
     $player_Key = $this->getKeys($this->keyPrefix, array('player_id' => $player_id));
     $player_set_data = array();
     foreach ($all_field as $key => $value) {
         if (isset($this->arrField[$key])) {
             $player_set_data[$key] = $value;
         }
     }
     $player_set_data = json_encode($player_set_data);
     $res = 0;
     if ($this->is_trans()) {
         if ($player_set_data) {
             $res = $this->set_redis_pre_action(null, array($this->Redis, 'hash_set'), array($player_Key, array($hero_id => $player_set_data)));
         }
     } else {
         if ($player_set_data) {
             $res = $this->Redis->hash_set($player_Key, array($hero_id => $player_set_data));
         }
     }
     return $res > 0 ? TRUE : FALSE;
 }
예제 #21
0
파일: Mail.php 프로젝트: bluefan/phpsource
 /**
  *  把邮件处理放到预处理队列
  * @param unknown $player_id
  * @param unknown $title
  * @param unknown $content
  * @param unknown $attachment
  * @param number $channel
  * @param number $type 类型1系统 2公会 3GM工具
  * @param number $bind_flag null 为不绑定 0为绑定
  * @return unknown
  */
 public function async_trigger_mail($player_id, $title, $content, $attachment = array(), $sender = '', $type = 1, $cmd_id = 0, $bind_flag = null)
 {
     $expire_day = 3;
     if ($type == 1) {
         $expire_day = 7;
     }
     if ($type == 3) {
         $bind_flag = 0;
     }
     if (empty($title) || empty($content) || empty($sender)) {
         return false;
     }
     if (!$player_id) {
         return false;
     }
     Com_Log::debug_write('async_trigger_mail_test', "player_id={$player_id},{$title}=" . json_encode($attachment));
     if (!empty($attachment)) {
         $data = $this->add_extract_mail($player_id, $title, $content, $attachment, $sender, $expire_day, $type, $cmd_id, $bind_flag);
     } else {
         $data = $this->add_mail($player_id, $title, $content, $sender, $expire_day, $type);
     }
     if ($data) {
         Com_Log::debug_write('async_trigger_mail', json_encode($data));
         #$ret = $this->do_async_trigger_mail(json_encode($data));
         $ret = Com_Queued::send($this->_deal_mail_transfer_data, json_encode($data));
     }
     return $ret;
 }
예제 #22
0
 /**
  * 恢复公会
  * @param unknown $player_id
  * @param unknown $union_id
  */
 public function restore_union($player_id, $union_id)
 {
     $objPlayerData = $this->get_data('Player');
     $playerInfo = $objPlayerData->get_player_info($player_id, array("union_id", "name"));
     if (intval($playerInfo['union_id']) > 0) {
         $this->throw_error('170301');
         //已加入过公会
     }
     $objUnionInfoData = $this->get_data('UnionInfo');
     $unionInfo = $objUnionInfoData->get_union_info($union_id);
     if (!$unionInfo) {
         $this->throw_error('170303');
         //该公会未创建
     }
     //公会成员
     $unionPlayer = array();
     $unionPlayer['player_id'] = $player_id;
     $unionPlayer['job_id'] = 1;
     $unionPlayer['total_dedicate'] = 0;
     //总贡献
     $unionPlayer['rep_time'] = time();
     $unionPlayer['add_time'] = time();
     $unionPlayer['quit_time'] = 0;
     $objUnionPlayerData = $this->get_data('UnionPlayer');
     $retUnionPlayerInfo = $objUnionPlayerData->update_union_player_info($union_id, $player_id, $unionPlayer);
     //公会人数
     $unionInfo['create_player_id'] = $player_id;
     $unionInfo['create_player_name'] = $playerInfo["name"];
     $unionInfo['player_num'] = "+1";
     Com_Log::debug_write('update_union_info', "restore_union|unoin_id={$union_id}" . json_encode($unionInfo));
     $retUnionInfo = $objUnionInfoData->update_union_info($union_id, $unionInfo);
     $setPlayerInfo = array("union_id" => $union_id, "union_name" => $unionInfo['union_name'], "union_job" => $unionPlayer['job_id']);
     $retPlayerInfo = $this->get_data('Player')->update_player_info($player_id, $setPlayerInfo);
     if ($retUnionPlayerInfo && $retPlayerInfo && $retUnionInfo) {
         $this->commit();
         $this->get_game('Union')->Sync_Union_msg($union_id);
         Protocol_Player::p2c_part_update($player_id, array('union_id' => $union_id, 'union_name' => $unionInfo['union_name'], 'union_job' => $unionPlayer['job_id']));
     } else {
         $this->rollback();
         $this->throw_error('10101');
     }
     return array(1, $union_id);
 }
예제 #23
0
 public function get_reward($player_id, $map_id, $player_list, $score_list, $state_list)
 {
     if (empty($map_id) || empty($player_list) || empty($score_list) || empty($state_list) || !is_array($player_list) || !is_array($score_list)) {
         $this->throw_error('10107');
         //参数错误!
     }
     $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)) {
             Com_Log::debug_write('xgame.all.error', "Grabmine error: unvalid player: " . $player_list[$i]);
             #$this->throw_error('20002'); # 获取玩家信息失败
         }
         # 获取排名奖励信息
         $rank_reward_info = Cache_AthenaQuestion::getInstance()->get_rank_reward_info($i + 1, $player_info['level']);
         # 获取分值奖励信息
         $score_reward_info = Cache_AthenaQuestion::getInstance()->get_score_reward_info($player_info['level']);
         if (empty($score_reward_info) || empty($score_reward_info['loop_score']) || empty($score_reward_info['score_reward'])) {
             $this->throw_error('190006');
             # 雅典娜答题积分奖励信息配置错误
         }
         $reward_detail_score = array();
         $reward_detail_rank = array();
         if (!empty($state_list[$i])) {
             # 在线直接发奖
             $reward = array();
             # 积分奖励
             if (!empty($score_list[$i])) {
                 # 积分不为0
                 $loop_num = intval($score_list[$i] / $score_reward_info['loop_score']);
                 $reward_detail_score = $this->get_game('Reward')->get_reward_detail($score_reward_info['score_reward'], $loop_num);
                 $this->get_game('Reward')->gen_reward_array($reward_detail_score, $reward);
             }
             # 排位奖励
             if (!empty($rank_reward_info)) {
                 $reward_detail_rank = $this->get_game('Reward')->get_reward_detail($rank_reward_info['rank_reward'], 1);
                 $this->get_game('Reward')->gen_reward_array($reward_detail_rank, $reward);
             }
             $re = $this->get_game('Reward')->send_reward($player_list[$i], $reward, array('cmd_id' => '484'), 1);
             $this->write_check_strict($re, 3010303);
             # 该方法会自动推送843协议告知前端显示奖励信息,会调用prop_806协议通知道具变更,调用p2c_part_update通知人物信息变更
             $ret = $this->get_game('Reward')->add_reward_log();
             $reward_fmt = array();
             if (!empty($reward)) {
                 $reward_detail = $this->get_game('Reward')->get_reward_detail_by_reward($reward);
                 foreach ($reward_detail as $item_id => $item_num) {
                     $reward_fmt[] = array('type' => $item_id, 'item_id' => $item_id, 'item_num' => $item_num);
                 }
             }
             # 告知Flash排位与奖励,注意score有可能为0
             Protocol::input($player_list[$i], 8, 11, 1150, array('score' => $score_list[$i], 'rank' => $i + 1, 'rank_reward' => $reward_fmt));
         } else {
             # 不在线的发邮件
             # 邮件发送
             $day = date("n.j", $this->current_time);
             $attachment_score = array();
             $attachment_rank = array();
             # 积分奖励
             if (!empty($score_list[$i])) {
                 # 积分不为0
                 $loop_num = intval($score_list[$i] / $score_reward_info['loop_score']);
                 $reward_detail_score = $this->get_game('Reward')->get_reward_detail($score_reward_info['score_reward'], $loop_num);
                 foreach ($reward_detail_score as $item_idx => $item_num) {
                     $attachment_score[] = array("prop_id" => $item_idx, "prop_num" => $item_num);
                 }
                 $phrase_config_score = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($this->score_reward_mail_id);
                 $content_score = sprintf($phrase_config_score['content'], $day, $score_list[$i]);
                 $re = $this->get_game('Mail')->async_trigger_mail($player_list[$i], $phrase_config_score['title'], $content_score, $attachment_score, $phrase_config_score['sender'], 1, 552);
             }
             # 排位奖励
             if (!empty($rank_reward_info)) {
                 $reward_detail_rank = $this->get_game('Reward')->get_reward_detail($rank_reward_info['rank_reward'], 1);
                 foreach ($reward_detail_rank as $item_idx => $item_num) {
                     $attachment_rank[] = array("prop_id" => $item_idx, "prop_num" => $item_num);
                 }
                 $phrase_config_rank = Cache_FuncPhraseConfig::getInstance()->get_phrase_config_info($this->rank_reward_mail_id);
                 $content_rank = sprintf($phrase_config_rank['content'], $day, $i + 1);
                 $re = $this->get_game('Mail')->async_trigger_mail($player_list[$i], $phrase_config_rank['title'], $content_rank, $attachment_rank, $phrase_config_rank['sender'], 1, 552);
             }
         }
         # 更新雅典娜答题参与次数[结算完算参与]
         $re = $this->get_data('PlayerDailyTime')->add_used_time($player_info['player_id'], 'athena_question_involved_num', 1);
         $this->write_check($re, 3010355);
         # 找回资源埋点
         $this->get_game('GetBackCurrency')->add_function_day_times($player_info['player_id'], 9);
         # 引导任务埋点
         $this->get_game('TaskTrigger')->async_trigger_guide_task($player_info['player_id'], 36, 1);
         # 每日活跃度埋点
         $this->get_game('DailyBoon')->async_trigger_daily_boon_task($player_info['player_id'], 3013, 1);
         # --------------------------------------------------------------------
         # 游戏日志记录
         # --------------------------------------------------------------------
         $log_info = array('player_id' => $player_info['player_id'], 'player_level' => $player_info['level'], 'vip_level' => $player_info['vip'], 'vip_special_level' => $player_info['privilege_level'], 'add_time' => $this->current_time, 'map_id' => $map_id, 'score' => $score_list[$i], 'rank' => $i + 1, 'reward_score' => json_encode($reward_detail_score), 'reward_rank' => json_encode($reward_detail_rank));
         Log_AthenaQuestion::getInstance()->add_log($log_info);
     }
     return null;
 }