bool Oper_Activity_Manager::item_is_open(const uint32_t act_id) {
	Time_Value now = Time_Value::gettimeofday();
	if(act_start.sec() <= now.sec() && now.sec() < act_end.sec()) {
		if(start_time[act_id].sec() <= now.sec() && now.sec() < end_time[act_id].sec()) {
			return true;
		}
	}
	return false;
}
Пример #2
0
uint32_t Vip::get_vip_days(void) {
	//求出VIP剩余天数
	Time_Value now = Time_Value::gettimeofday();
	int32_t sec = player_self()->base_detail().vip_over_time.sec() - now.sec();
	if(sec <= 0) {
		return 0;
	}
	//uint8_t mod = sec % (3600*24);
	uint32_t days = sec/(3600*24);// + ((mod == 0)?0:1);
	return days;
}
Пример #3
0
int Answer_Manager::is_open(Logic_Player *player) {
	if((uint32_t)player->level() < level_limit) {
		return ERROR_LEVEL_LIMIT;
	}
	Time_Value now = Time_Value::gettimeofday();
	if(now.sec() >= bef_start_time.sec() && now.sec() < end_time.sec() && !is_close) {
		MSG_DEBUG("req enter answer scene on logic role_id:%ld, endtime:%ld, thistime:%ld", player->role_id(), end_time.sec(), now.sec());
		return 0;
	}
	return ERROR_ANSWER_ACTIVE_NOT_OPEN;
}
Пример #4
0
void Logic_Arenaer::get_arena_match_remain_time(bool& match, int& remain_time){
	if(arenaer_detail_->match_time != Time_Value::zero){
		match = true;
		Time_Value now = Time_Value::gettimeofday();
		remain_time = arenaer_detail_->match_time.sec() - now.sec();
		if(remain_time < 0){
			remain_time = 0;
		}
	}else{
		match = false;
		remain_time = 0;
	}
}
Пример #5
0
void Date_Time::update(const Time_Value &timevalue) {
	time_t time = timevalue.sec();
	struct tm tm_time;
	::localtime_r(&time, &tm_time);
	this->day_ = tm_time.tm_mday;
	this->month_ = tm_time.tm_mon + 1; // localtime's months are 0-11
	this->year_ = tm_time.tm_year + 1900; // localtime reports years since 1900
	this->hour_ = tm_time.tm_hour;
	this->minute_ = tm_time.tm_min;
	this->second_ = tm_time.tm_sec;
	this->microsec_ = timevalue.usec();
	this->wday_ = tm_time.tm_wday;
	this->isdst_ = tm_time.tm_isdst;
}
Пример #6
0
bool Game_Manager::check_forbid_account_list(std::string &account) {
	//return forbid_account_list_.count(account);
	String_Time_Map::iterator find_it = forbid_account_list_.find(account);
	if (find_it != forbid_account_list_.end()) {
		Time_Value now = Time_Value::gettimeofday();//获取当前时间
		if(find_it->second.sec()<now.sec()){
			forbid_account_list_.erase(find_it);
			return false;
		}else{
			return true;
		}
	}
	return false;
}
Пример #7
0
int Map_Team::sync_info_logic(void) {
	MSG_20100304 inner_msg;
	Block_Buffer buf;
	Time_Value now;
	now = Time_Value::gettimeofday();
	buf.make_message(inner_msg.msg_id);
	buf.write_int64(team_id_);
	buf.write_int16(fail_times_);
	buf.write_int16(match_fail_);
	now.serialize(buf);
	buf.finish_message();
	this->info_all_online_player(inner_msg.msg_id, &buf);
	return 0;
}
Пример #8
0
bool Game_Manager::check_forbid_role_id_list(role_id_t role_id) {
	//return forbid_role_id_list_.count(role_id);
	Role_Id_Time_Map::iterator find_it = forbid_role_id_list_.find(role_id);
	if (find_it != forbid_role_id_list_.end()) {
		Time_Value now = Time_Value::gettimeofday();//获取当前时间
		if(find_it->second.sec()<now.sec()){
			forbid_role_id_list_.erase(find_it);
			return false;
		}else{
			return true;
		}
	}
	return false;

}
Пример #9
0
int Logic_Arenaer::get_arena_cd(void){
	if(arenaer_detail_){
		if(arenaer_detail_->cd == Time_Value::zero){
			return 0;
		}else{
			Time_Value now = Time_Value::gettimeofday();
			int remain_time = arenaer_detail_->cd.sec() - now.sec();
			if(remain_time < 0){
				remain_time = 0;
			}
			return remain_time;
		}
	}
	return 0;
}
Пример #10
0
void Answer_Scene::check_make_question(const Time_Value &now) {
	//检测当前题目是否完成状态
	if(q.status != QUESTION_STATUS_OK && q.id != 0) {
		return;
	}
	//检测当前时间处于第几题
	int sl_sec = now.sec() - start_time.sec();
	if(sl_sec < 0) {
		return;
	}
	uint32_t ones_sec = get_ones_time_sec();
	uint16_t this_qno = sl_sec/ones_sec + 1;
	//检测当前是否正处于哪一题
	if(this_qno <= answer_info.question_id_list.size()) {
		return;
	}
	//随机生成题目
	uint32_t qid = rand_make_question();
	if(qid == 0)  {
		return;
	}
	//更新题目信息
	if(make_active_question(qid)){
		return;
	}
	answer_info.cur_qno = this_qno;
	 answer_info.question_id_list.insert(qid);
	send_to_logic_save_data();
}
Пример #11
0
int Answer_Scene::tick(const Time_Value &now){

	if(now.sec() >= start_time.sec()
			&& now.sec() < (start_time.sec()  + get_ones_time_sec() * CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_QUESTION_NUM))) {
		//检测生成题目
		check_make_question(now);
		//检测当前题目所处于时间的应该触发状态
		update_question_status(now);
	}

	if(end_time.sec() && now.sec() >= end_time.sec()) {
		send_to_logic_get_rank_reward();
		kick_all_palyer();
		this->set_scene_status(Move_Scene::SCENE_RECOVER_STATUS);
	}

	return 0;
}
Пример #12
0
std::string Logic_Public::get_name(int gender) {
	String_Set &set = (gender == 1) ? male_name_set : female_name_set;
	int size = set.size();
	if (size < 200) {
		rand_role_name();
	}

	size = set.size();
	if (size <= 0) {
		Time_Value now = Time_Value::gettimeofday();
		int num = now.sec() % 1000000;
		std::ostringstream ost;
		ost << num;
		return ost.str();
	}
	size = (size > 10000) ? 10000 : size;
	int rand = random() % size;
	String_Set::iterator it = set.begin();
	std::advance(it, rand);
	return *it;
}
Пример #13
0
void Vip::get_grow(const Time_Value &start_time, const Time_Value &end_time) {
	if(start_time == Time_Value::zero) { //出现0时间的情况只会出现在未开通过VIP
		return;
	}
	MSG_DEBUG("get grow on six role_id:%ld, start:%ld, end:%ld", player_self()->role_id(), start_time.sec(), end_time.sec());
	const Grow_Get_Config *conf =  CONFIG_CACHE_VIP->get_grow_get_config(player_self()->base_detail().vip);
	if(!conf) {
		return;
	}
	if(end_time.sec() > start_time.sec()) {
		long int slip_sec = end_time.sec() - start_time.sec(); //时间间隔的秒数
		uint32_t slip_days = slip_sec/(3600*24); //间隔天数
		tm tm_end,tm_start; //求开始和结束的TM
		{
			time_t t_end = end_time.sec();
			localtime_r(&t_end, &tm_end);
			time_t t_start = start_time.sec();
			localtime_r(&t_start, &tm_start);
		}
		if(tm_end.tm_hour >= 6 && tm_start.tm_hour < 6) { //如果开始在六点前,结束在6点后; 加一天
			++slip_days;
		}
		vip_detail_->grow_val += conf->get_val * slip_days; //补全所缺天数成长值
		vip_detail_->last_settle_grow = end_time;
		vip_detail_->detail_change();
		MSG_DEBUG("get grow on six role_id:%ld, slip_days:%d, oldval:%d, newval:%d", player_self()->role_id(), slip_days, conf->get_val, vip_detail_->grow_val);
		send_vip_info_client(VIP_ACTIVE_GROW_CHANGE);
	}
}
Пример #14
0
void Vip::lost_grow(const Time_Value &start_time, const Time_Value &end_time) {
	if(start_time == Time_Value::zero) { //出现0时间的情况只会出现在未开通过VIP
		return;
	}
	const Grow_Get_Config *conf =  CONFIG_CACHE_VIP->get_grow_get_config(player_self()->base_detail().vip);
	if(!conf) {
		return;
	}
	if(end_time.sec() > start_time.sec()) {
		long int slip_sec = end_time.sec() - start_time.sec(); //时间间隔的秒数
		uint32_t slip_days = slip_sec/(3600*24); //间隔天数
		tm tm_end,tm_start; //求开始和结束的TM
		{
			time_t t_end = end_time.sec();
			localtime_r(&t_end, &tm_end);
			time_t t_start = start_time.sec();
			localtime_r(&t_start, &tm_start);
		}
		if(tm_end.tm_hour >= 6 && tm_start.tm_hour < 6) { //如果开始在六点前,结束在6点后; 加一天
			++slip_days;
		}
		int32_t lost_to_val = vip_detail_->grow_val - conf->lost_val * slip_days;
		if(lost_to_val >= 0) {
			vip_detail_->grow_val = lost_to_val;
		} else {
			vip_detail_->grow_val = 0;
		}
		vip_detail_->last_settle_grow = end_time;
		vip_detail_->detail_change();
		send_vip_info_client(VIP_ACTIVE_GROW_CHANGE);
	}
}
Пример #15
0
void Answer_Scene::update_question_status(const Time_Value &now) {
	int this_start_sec = get_ones_time_sec() * (answer_info.cur_qno-1);
	if(this_start_sec < 0) {
		return;
	}
	uint32_t this_start_time = start_time.sec() + this_start_sec;
	int slep_sec = now.sec() - this_start_time;//当前题目开始时间与当前时间间隔的秒数
	if(slep_sec < 0) {
		return;
	}
	//计算当前时间该题目应该处于神马状态
	uint32_t read_sec = CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_READ_TIME);
	uint32_t answer_sec = CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_ANSWER_TIME);
	uint32_t ann_sec = CONFIG_CACHE_ANSWER->get_common_cfg_by_key(ANSWER_COMMON_CFG_KEY_ANN_TIME);
	if((uint32_t)slep_sec <= read_sec) {
		//阅题
		if(q.status == QUESTION_STATUS_READ) {
			return;
		} else {
			q.status = QUESTION_STATUS_READ;
			q.over_time = this_start_time + read_sec;
			send_client_question_info();
		}
	} else if((uint32_t)slep_sec <= (answer_sec+read_sec)) {
		//答题
		if(q.status == QUESTION_STATUS_ANSWER) {
			return;
		} else {
			q.status = QUESTION_STATUS_ANSWER;
			q.over_time = this_start_time + read_sec + answer_sec;
			send_client_question_info();
		}
	} else if((uint32_t)slep_sec <= (ann_sec+answer_sec+read_sec)) {
		//公布
		if(q.status == QUESTION_STATUS_ANN) {
			return;
		} else {
			q.status = QUESTION_STATUS_ANN;
			q.over_time = this_start_time + read_sec + answer_sec + ann_sec;
			//计算动态答案
			make_active_question_on_fulfil(q.id);
			send_client_question_info();
			fulfil_active_question();
		}
	} else {
		if(q.status == QUESTION_STATUS_OK) {
				return;
		} else {
			  q.status = QUESTION_STATUS_OK;
		}
	}
}
int Expedition_Global_Manager_Data::deserialize(Block_Buffer &r) {
	uint16_t len = 0;
	int64_t uuid = 0;
	Time_Value tv = Time_Value::zero;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(uuid);
		tv.deserialize(r);
		opened_uuid_opentime_map_.insert(std::make_pair(uuid, tv));
	}

	int inter = 0;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(uuid);
		r.read_int32(inter);
		uuid_inter_map_.insert(std::make_pair(uuid, inter));
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int32(inter);
		tv.deserialize(r);
		opentime_.insert(std::make_pair(inter, tv));
	}

	mmuid_.deserialize(r);

//	uint32_t inter_u = 0;
//	Expedition_Manager_Data emd;
//	r.read_uint16(len);
//	for (uint16_t i = 0; i < len; ++i) {
//		emd.reset();
//		r.read_uint32(inter_u);
//		emd.deserialize(r);
//		inter_manager_data_map_.insert(std::make_pair(inter_u, emd));
//	}
	return 0;
}
Пример #17
0
void Honor_Arena_Manager::check_fight_teams(const Time_Value& now){
	int now_sec = now.sec();
	std::vector<Honor_Arena_Match_Team>::iterator it;
	for(it = fight_teams_.begin(); it != fight_teams_.end();){
		if(now_sec > it->fight_time){
			if(start_fight(it->role_id_1, it->role_id_2) == 0){

			}else{

			}
			it = fight_teams_.erase(it);
		}else{
			++it;
		}
	}
}
Пример #18
0
int Operating::offline_invite_player(role_id_t role_id, const Time_Value &time) {
	if (!role_id) {
		MSG_USER("error role id");
		return -1;
	}

	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	uint32_t op_type = OPERATING_OFFLINE_INVITE_PLAYER;
	buf.write_uint32(op_type);
	buf.write_int64(role_id);
	buf.write_int64(time.sec());
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Пример #19
0
void Logic_Public::save_access_count(const Time_Value &now) {
	if(now.sec() - access_count_record_time.sec() > Time_Value::ONE_MINUTE_IN_SECS) {
		if(access_count.size() == 0) {
			access_count_record_time = now;
		}
		Block_Buffer buf;
		buf.make_message(MONGO_SACE_ACCESS_DATA_COUNT);
		buf.write_uint8(access_count.size());
		for(UInt_UInt_Map::iterator ait = access_count.begin(); ait != access_count.end(); ++ait) {
			buf.write_uint32(ait->first);
			buf.write_uint32(ait->second);
		}
		buf.finish_message();
		DB_MANAGER->push_data_block(buf, 0);
		access_count.clear();
	}
}
Пример #20
0
int Operating::offline_firend_add(role_id_t role_id, role_id_t other_role_id, Time_Value time) {
	if (!role_id) {
		MSG_USER("error role id");
		return -1;
	}

	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	int type = OPERATING_OFFLINE_FIREND_ADD;
	buf.write_int32(type);
	buf.write_int64(role_id);
	buf.write_int64(other_role_id);
	buf.write_int64(time.sec());
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);

	return 0;
}
Пример #21
0
void Answer_Scene::scene_close_note(const Time_Value &etime) {
	end_time.sec(etime.sec() + 10);
	MSG_82330002 msg;
	msg.time = end_time.sec();
	Block_Buffer buf__;
	buf__.make_message(msg.msg_id);
	msg.serialize(buf__);
	buf__.finish_message();
	Scene_Layer *layer = scene_layer(0);
	if (layer) {
		for (Mover_Map::iterator it = layer->mover_map_.begin();
				it != layer->mover_map_.end(); ++it) {
			if (it->second && it->second->player_self()) {
					it->second->send_to_client(buf__);
			}
		}
	}

}
Пример #22
0
void Vip::set_vip_exp_overtime(const Time_Value &time) {
	if(vip_detail_->exp_over_time.sec() > time.sec()) {
		vip_detail_->exp_over_time.sec(time.sec());
		vip_detail_->detail_change();
	}
}
int Expedition_Manager_Data::deserialize(Block_Buffer &r) {
	r.read_uint32(inter_);

	uint16_t len = 0;
	int64_t i_64 = 0;
	Time_Value tv = Time_Value::zero;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		tv.deserialize(r);
		opened_uuid_opentime_map_.insert(std::make_pair(i_64, tv));
	}

	int64_t i_64_2 = 0;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		r.read_int64(i_64_2);
		gang_id_uuid_map_.insert(std::make_pair(i_64, i_64_2));
	}

	last_reset_time_.deserialize(r);

	uint32_t ui_32 = 0;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		r.read_uint32(ui_32);
		first_gang_rank_.insert(std::make_pair(i_64, ui_32));
	}

	r.read_bool(has_init_);
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		bool hi = false;
		r.read_int64(i_64);
		r.read_bool(hi);
		uuid_has_init_[i_64] = hi;
	}

	r.read_uint16(len);
	Expedition_Gang_Rank_Info egri;
	for (uint16_t i = 0; i < len; ++i) {
		egri.reset();
		r.read_int64(i_64);
		egri.deserialize(r);
		gang_rank_map_.insert(std::make_pair(i_64, egri));
	}

	int64_t i_64_t = 0;
	r.read_uint16(len);
	uint16_t len_t = 0;
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64_t);
		r.read_uint16(len_t);
		for (uint16_t j = 0; j < len_t; ++j) {
			r.read_int64(i_64);
			egri.deserialize(r);
			uuid_gang_rank_map_[i_64_t].insert(std::make_pair(i_64, egri));
		}
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		gang_rank_sync_success_.insert(i_64);
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		gang_rank_sync_new_vec_.push_back(i_64);
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		r.read_uint32(ui_32);
		gang_id_point_id_.insert(std::make_pair(i_64, ui_32));
	}

	int i_32 = 0;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		r.read_int32(i_32);
		gang_id_cur_line_.insert(std::make_pair(i_64, i_32));
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64_t);
		r.read_uint16(len_t);
		for (uint16_t j = 0; j < len_t; ++j) {
			r.read_int64(i_64);
			r.read_uint32(ui_32);
			uuid_gang_id_point_id_[i_64_t].insert(std::make_pair(i_64, ui_32));
		}
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64_t);
		r.read_uint16(len_t);
		for (uint16_t j = 0; j < len_t; ++j) {
			r.read_int64(i_64);
			r.read_int32(i_32);
			uuid_gang_id_cur_line_[i_64_t].insert(std::make_pair(i_64, i_32));
		}
	}

	Expedition_Scene_Data esd;
	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		esd.reset();
		r.read_uint32(ui_32);
		esd.deserialize(r);
		line_scene_map_.insert(std::make_pair(ui_32, esd));
	}

	r.read_uint16(len);
	for (uint16_t i = 0; i < len; ++i) {
		r.read_int64(i_64);
		r.read_uint16(len_t);
		for (uint16_t j = 0; j < len_t; ++j) {
			esd.reset();
			r.read_uint32(ui_32);
			esd.deserialize(r);
			uuid_line_scene_map_[i_64].insert(std::make_pair(ui_32, esd));
		}
	}
	return 0;
}
Пример #24
0
int Login_Timer_Handler::handle_timeout(const Time_Value &tv) {
	return LOGIN_MANAGER->push_tick(tv.sec());
}
Пример #25
0
void Battle_AI_Object::handle_ai_foreshow(void){
	if(!owner_){
		return;
	}
	if(owner_->battle_scene() == NULL){
		return;
	}
	std::vector<AI_Foreshow_Info> foreshow_vec;
	AI_Foreshow_Info info;
	AI_MAP::iterator it;
	int value;
	int type;
	int skill_id;
	int buffer_id;
	for(it = running_ai_data_.begin(); it != running_ai_data_.end(); ++it){
		if(it->second.is_recover == false && it->second.config->foreshow == 1){
			if(it->second.config->c_type == MONSTER_AI_C_AI){// type 0
				if(it->second.is_valid == false){
					continue;
				}
				skill_id = 0;
				buffer_id = 0;
				if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_DL){//
					continue;
				}
				else if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_BB ||
						it->second.config->a_type == MONSTER_AI_A_ONE_SKILL){
					skill_id = it->second.config->a_val1;
				}else if(it->second.config->a_type == MONSTER_AI_A_ADD_BUF){
					buffer_id = it->second.config->buf_argv.status_id;
				}else{
					continue;
				}

				//type
				type = 0;
				// value
				value = 0;

			}else if(it->second.config->c_type == MONSTER_AI_C_TIMES){// type 1
				skill_id = 0;
				buffer_id = 0;
				if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_DL){//
					continue;
				}
				else if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_BB ||
						it->second.config->a_type == MONSTER_AI_A_ONE_SKILL){
					skill_id = it->second.config->a_val1;
				}else if(it->second.config->a_type == MONSTER_AI_A_ADD_BUF){
					buffer_id = it->second.config->buf_argv.status_id;
				}else{
					continue;
				}

				//type
				type = 1;
				// value
				int cur_value = this->fight_round_;

				if(it->second.config->c_val1 != 0){
					cur_value = cur_value%it->second.config->c_val1;
					int cam_value = it->second.config->c_val2%it->second.config->c_val1;
					if(cur_value > cam_value){
						cam_value += it->second.config->c_val1;
					}
					value = cam_value - cur_value;
				}else{
					value = it->second.config->c_val2 - cur_value;
				}
				if(value < 0){
					value = 0;
				}
				// 被中断技下回继续使用的技能
				if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_BB){
					if(it->second.is_valid ||
							(break_use_skill_ && break_use_skill_id_ != 0 && skill_id == break_use_skill_id_)){
						value = 0;
					}
				}


			}else if(it->second.config->c_type == MONSTER_AI_C_TIME){// type 2
				skill_id = 0;
				buffer_id = 0;
				if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_DL){//
					continue;
				}
				else if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_BB ||
						it->second.config->a_type == MONSTER_AI_A_ONE_SKILL){
					skill_id = it->second.config->a_val1;
				}else if(it->second.config->a_type == MONSTER_AI_A_ADD_BUF){
					buffer_id = it->second.config->buf_argv.status_id;
				}else{
					continue;
				}

				//type
				type = 2;
				// value
				int cur_val;
				int cmp_val;
				Time_Value last_time;
				cmp_val = it->second.config->c_val2;
				if(it->second.last_time == Time_Value::zero){// 第一次触发
					last_time = Time_Value::gettimeofday() - begin_time_;
				}else{//
					if(it->second.has_trigger){
						it->second.has_trigger = false;
						it->second.last_time = Time_Value::gettimeofday();
						last_time = Time_Value::zero;
					}else{
						last_time = Time_Value::gettimeofday() - it->second.last_time;
					}

					if(it->second.config->c_val1 != 0){
						cmp_val = it->second.config->c_val1;
					}
				}
				cur_val = last_time.sec();
				value = cmp_val - cur_val;
				if(value <= 0){
					value = 1;
				}
			}else if(it->second.config->c_type == MONSTER_AI_C_HP){// type 3
				skill_id = 0;
				buffer_id = 0;
				if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_DL){//
					continue;
				}
				else if(it->second.config->a_type == MONSTER_AI_A_ONE_SKILL_BB ||
						it->second.config->a_type == MONSTER_AI_A_ONE_SKILL){
					skill_id = it->second.config->a_val1;
				}else if(it->second.config->a_type == MONSTER_AI_A_ADD_BUF){
					buffer_id = it->second.config->buf_argv.status_id;
				}else{
					continue;
				}

				// 条件检测
				bool hp_valid = false;
				{
					double cur_val = owner_->blood_current();
					double max_val = owner_->blood_max();
					int cmp_val;
					if(it->second.config->c_val2 == 0){
						cmp_val = cur_val;
					}else{
						if(max_val > 0){
							cmp_val = 1000*(cur_val/max_val);
						}else{
							cmp_val = 1000;
						}
					}
					if(it->second.config->c_val1 == 0){
						if(cmp_val >= it->second.config->c_val3){
							hp_valid = true;
						}
					}else{
						if(cmp_val <= it->second.config->c_val3){
							hp_valid = true;
						}
					}
				}

				if(hp_valid){// 满足条件 cd中
					type = 2;
					Time_Value now = Time_Value::gettimeofday();
					value = it->second.config->cd + it->second.last_time.sec() - now.sec();
					if(value <= 0){
						value = 1;
					}
				}else{// 不满足条件
					// value
					int cur_value = it->second.config->c_val3;

					if(it->second.config->c_val2 == 0){// abs
						if(it->second.config->c_val1 == 0){//  > abs
							type = 6;
						}else{
							type = 5;
						}
					}else{// %
						if(it->second.config->c_val1 == 0){ // > %
							type = 4;
							cur_value = cur_value/10;
						}else{
							type = 3;
							cur_value = cur_value/10;
						}
					}

					if(cur_value < 0){
						cur_value = 0;
					}
					value = cur_value;
				}

			}else{
				continue;
			}

			info.reset();
			info.monster_role_id = owner_->role_id();
			info.ai_id = it->second.config->id;
			info.type = type;
			info.value = value;
			info.skill_id = skill_id;
			info.buffer_id = buffer_id;
			foreshow_vec.push_back(info);
		}
	}
	owner_->battle_scene()->add_ai_foreshow_info(owner_->role_id(), foreshow_vec);
}
Пример #26
0
void Vip::test_set_last_settle_grow(uint32_t days) { //todo delete
	Time_Value now = Time_Value::gettimeofday();
	vip_detail_->last_settle_grow.sec(now.sec() - days*3600*24);
}
Пример #27
0
int Gate_Timer_Handler::handle_timeout(const Time_Value &tv) {
	return GATE_MANAGER->push_tick(tv.sec());
}
Пример #28
0
int Logic_Arenaer::email_three_day_reward(int rank, const Time_Value& now){
	Arena_Award_Config* award_config;
	award_config = CONFIG_CACHE_ARENA->get_arena_award_conifg(rank);
	if(award_config){
		Mail_Send_Info send_info;
		send_info.sender_id = 0;
		send_info.receiver_id = this->role_id();
		send_info.send_type = MAIL_TYPE_SYS;
		send_info.show_send_time = now;

		double level_fix = CONFIG_CACHE_ARENA->get_arena_levelfix(level());
		int copper = award_config->rank_award_gold;
		int soul = award_config->rank_award_soul;
		int exploit = award_config->rank_award_exploit;

		for(std::vector<Int_Int>::iterator item_iter  = award_config->rank_award_item_vec.begin();
					item_iter != award_config->rank_award_item_vec.end(); item_iter++) {
			if(item_iter->val_2 <= 0){
				continue;
			}
			if(item_iter->val_1 == COPPER ){
				copper += item_iter->val_2;
			}else if(item_iter->val_1 == SOULS){
				soul += item_iter->val_2;
			}else if(item_iter->val_1 == DRAGON_SOUL){
				//m_a_list.push_back(Money_Add_Info(DRAGON_SOUL, it->val_2, Money_DM_Info(MONEY_ADD_ARENA_RANK)));
			}else if(item_iter->val_1 == FRIENDSHIP){
				//m_a_list.push_back(Money_Add_Info(FRIENDSHIP, it->val_2, Money_DM_Info(MONEY_ADD_ARENA_RANK)));
			}else if(item_iter->val_1 == BIND_GOLD){
				//m_a_list.push_back(Money_Add_Info(BIND_GOLD, it->val_2, Money_DM_Info(MONEY_ADD_ARENA_RANK)));
			}else if(item_iter->val_1 == EXPLOIT_SOURCE_ID){
				exploit += item_iter->val_2;
			}else{
				send_info.item_vector.push_back(Item_Detail(item_iter->val_1, item_iter->val_2, Item_Detail::BIND));
			}
		}
		copper = copper*level_fix;
		int copper_item_count = copper/COPPER_PROP_COUNT;
		if(copper >0){
			if(copper_item_count == 0){
				copper_item_count = 1;
			}
			send_info.item_vector.push_back(Item_Detail(COPPER_PROP_ID, copper_item_count, Item_Detail::BIND));
		}
		soul = soul*level_fix;
		int soul_item_count = soul/SOULS_PROP_COUNT;
		if(soul > 0){
			if(soul_item_count == 0){
				soul_item_count = 1;
			}
			send_info.item_vector.push_back(Item_Detail(SOULS_PROP_ID, soul_item_count, Item_Detail::BIND));
		}
		exploit = exploit*level_fix;
		int exploit_item_count = exploit/EXPLOIT_PROP_COUNT;
		if(exploit > 0){
			if(exploit_item_count == 0){
				exploit_item_count = 1;
			}
			send_info.item_vector.push_back(Item_Detail(EXPLOIT_PROP_ID, exploit_item_count, Item_Detail::BIND));
		}
		time_t time_v = now.sec();
		struct tm tm_v;
		localtime_r(&time_v, &tm_v);
		std::stringstream stream;
		std::string text_content = CONFIG_CACHE_ARENA->get_mail_content();
		char mail_content[256] = {'\0'};
		snprintf(mail_content, sizeof(mail_content), text_content.c_str(), rank);
		stream<<mail_content;

		for(std::vector<Int_Int>::iterator item_iter  = award_config->rank_award_item_vec.begin();
					item_iter != award_config->rank_award_item_vec.end(); item_iter++) {
			if(item_iter->val_2 <= 0){
				continue;
			}
			if(item_iter->val_1 == COPPER ){
				//
			}else if(item_iter->val_1 == SOULS){
				//
			}else if(item_iter->val_1 == DRAGON_SOUL){
				//
			}else if(item_iter->val_1 == FRIENDSHIP){
				//
			}else if(item_iter->val_1 == BIND_GOLD){
				//
			}else if(item_iter->val_1 == EXPLOIT_SOURCE_ID){
				//
			}else{
				const Item_Detail_Config *item_config = CONFIG_CACHE_ITEM->find_item(item_iter->val_1);
				if(item_config){
					stream << item_config->name<<" *"<< item_iter->val_2<< "\r";
				}
			}
		}

		if(copper > 0){
			std::string text_gold = CONFIG_CACHE_ARENA->get_text_copper();
			stream <<text_gold<< " *"<< copper_item_count*COPPER_PROP_COUNT<< "\r";
		}
		if(soul > 0){
			std::string text_souls = CONFIG_CACHE_ARENA->get_text_soul();
			stream <<text_souls<< " *"<< soul_item_count*SOULS_PROP_COUNT<< "\r";
		}
		if(exploit > 0){
			std::string text_exploit = CONFIG_CACHE_ARENA->get_text_exploit();
			stream <<text_exploit<< " *"<< exploit_item_count*EXPLOIT_PROP_COUNT<< "\r";
		}
		send_info.content = stream.str();
		std::string mail_title = CONFIG_CACHE_ARENA->get_mail_title();
		std::string mail_sender = CONFIG_CACHE_ARENA->get_mail_sender();
		send_info.sender_name = mail_sender;
		send_info.title = mail_title;
	   this->player_self()->send_mail_to_self(send_info);
	}
	return 0;
}