示例#1
0
文件: game.cpp 项目: zemen/labyrinth
void finish_game(Labyrinth &map) {
	int winner = map.current_player;
	global_message("Player " + map.player[winner].name + " has won the game!");
	for (int i = 0; i < (int) map.player.size(); ++i) {
		global_message(map.player[i].name + " has been killed " + to_string(map.player[i].deaths) + " times");
		global_message(map.player[i].name + " has failed " + to_string(map.player[i].fails) + " times");
		global_message(map.player[i].name + " has made " + to_string(map.player[i].good_turns) + " good turns");
	}
	
	int worst = __INT_MAX__;
	for (int i = 0; i < (int) map.player.size(); ++i) {
		if (i == winner || is_developer(map.player[i]))
			continue;
		worst = min(worst, 5 * map.player[i].good_turns - map.player[i].fails);
	}
	vector <int> losers(0);
	for (int i = 0; i < (int) map.player.size(); ++i) {
		if (i == winner || is_developer(map.player[i]))
			continue;
		if (5 * map.player[i].good_turns - map.player[i].fails > worst)
			continue;
		losers.push_back(i);
	}
	
	if (!SERVER) {
		global_message("The current labyrinth state is:");
		print_labyrinth(map);
	}
	if (!losers.empty()) {
		int loser = losers[rand() % int(losers.size())];
		global_message(map.player[loser].name + " must give a big chocolate to " + map.player[winner].name);
	}
	this_thread::sleep_for(chrono::seconds(60));
	exit(0);
}
示例#2
0
std::string FSData::processRequestForInfo(LLUUID requester, std::string message, std::string name, LLUUID sessionid)
{
	std::string detectstring = "/reqsysinfo";
	if(!message.find(detectstring) == 0)
	{
		return message;
	}

	if(!(is_support(requester)||is_developer(requester)))
	{
		return message;
	}

	std::string outmessage("I am requesting information about your system setup.");
	std::string reason("");
	if(message.length() > detectstring.length())
	{
		reason = std::string(message.substr(detectstring.length()));
		//there is more to it!
		outmessage = std::string("I am requesting information about your system setup for this reason : " + reason);
		reason = "The reason provided was : " + reason;
	}
	
	LLSD args;
	args["REASON"] = reason;
	args["NAME"] = name;
	args["FROMUUID"] = requester;
	args["SESSIONID"] = sessionid;
	LLNotifications::instance().add("FireStormReqInfo", args, LLSD(), callbackReqInfo);

	return outmessage;
}
示例#3
0
std::string PhoenixViewerLink::processRequestForInfo(LLUUID requester, std::string message, std::string name, LLUUID sessionid)
{
	std::string detectstring = "/reqsysinfo";
	if(!message.find(detectstring)==0)
	{
		//llinfos << "sysinfo was not found in this message, it was at " << message.find("/sysinfo") << " pos." << llendl;
		return message;
	}
	if(!(is_support(requester)||is_developer(requester)))
	{
		return message;
	}
	std::string my_name;
	gAgent.buildFullname(my_name);

	//llinfos << "sysinfo was found in this message, it was at " << message.find("/sysinfo") << " pos." << llendl;
	std::string outmessage("I am requesting information about your system setup.");
	std::string reason("");
	if(message.length()>detectstring.length())
	{
		reason = std::string(message.substr(detectstring.length()));
		//there is more to it!
		outmessage = std::string("I am requesting information about your system setup for this reason : "+reason);
		reason = "The reason provided was : "+reason;
	}
	LLSD args;
	args["REASON"] =reason;
	args["NAME"] = name;
	args["FROMUUID"]=requester;
	args["SESSIONID"]=sessionid;
	LLNotifications::instance().add("PhoenixReqInfo",args,LLSD(), callbackPhoenixReqInfo);

	return outmessage;
}
示例#4
0
文件: game.cpp 项目: zemen/labyrinth
bool turn(Labyrinth &map) {
	take_objects_from_cell(map, map.player[map.current_player]);
	if (DEBUG)
		print_debug(map);
	user_message(map.player[map.current_player].name + ", it's your turn");
	string message = map.player[map.current_player].name + ", enter what you want (go, bomb, shoot, knife, suicide, stay, leave";
	if (SERVER)
		message += ")";
	else
		message += ", save)";
	user_message(message);
	
	if (SERVER)
		server.clear_user_messages(map.current_player);
	string s = read_user_command(map.current_player);
	
	if (s == "leave")
		return leave_game(map, map.player[map.current_player]);
	if (s == "suicide")
		return suicide(map, map.player[map.current_player]);
	if (s == "knife")
		return use_knife(map, map.player[map.current_player]);
	if (s == "bomb")
		return bomb(map, map.player[map.current_player]);
	if (s == "go")
		return go(map, map.player[map.current_player]);
	if (s == "shoot")
		return shoot(map, map.player[map.current_player]);
	if (s == "stay")
		return stay(map.player[map.current_player]);
	if (s == "save" && !SERVER) {
		save_game(map);
		return false;
	}
	if (s == "winthemall") {
		if (is_developer(map.player[map.current_player])) {
			user_message("Okay, master");
			finish_game(map);
			return true;
		}
	}
	
	user_message(map.player[map.current_player].name + ", you entered incorrect command! Try again, if you can!");
	return false;
}
示例#5
0
文件: game.cpp 项目: zemen/labyrinth
string get_idiot_phraze(Player &p) {
	if (is_developer(p))
		return p.name + ", sorry, but it's incorrect! You can enter correct information, if you want.";
	return p.name + ", " + idiot_string[rand() % int(idiot_string.size())];
}