Exemplo n.º 1
0
void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list)
{
	Database* db = Database::getInstance();
	War_t war;

	std::stringstream s;
	for(DeathList::const_iterator it = list.begin(); it != list.end(); )
	{
		if(it->isLast())
			war = it->getWar();

		Creature* creature = it->getKillerCreature();
		if(it != list.begin())
		{
			++it;
			if(it == list.end())
				s << " and ";
			else
				s << ", ";
		}
		else
			++it;

		s << creature->getName();
	}

	std::string killers = s.str();
	s.str("");

	ChatChannel* channel = NULL;
	if((channel = g_chat.getChannel(player, CHANNEL_GUILD)))
	{
		s << "Guild member " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[
			war.type == WAR_GUILD] << ":" << war.frags[war.type] << " frags (limit " << war.limit << ").";
		channel->talk("", SPEAK_CHANNEL_RA, s.str());
	}

	s.str("");
	if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD)))
	{
		s << "Opponent " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[
			war.type] << ":" << war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ").";
		channel->talk("", SPEAK_CHANNEL_RA, s.str());
	}

	DBQuery query;
	query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES (" << war.ids[war.type] << ", " << war.war << ", " << deathId << ");";
	db->query(query.str());
}
Exemplo n.º 2
0
void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list, bool score)
{
	War_t war;
	std::stringstream s;
	for(DeathList::const_iterator it = list.begin(); it != list.end(); )
	{
		if(score)
		{
			if(it->isLast())
				war = it->getWar();
		}
		else if(!war.war)
			war = it->getWar();

		Creature* creature = it->getKillerCreature();
		if(it != list.begin())
		{
			++it;
			if(it == list.end())
				s << " and ";
			else
				s << ", ";
		}
		else
			++it;

		s << creature->getName();
	}

	if(!war.ids[war.type])
	{
		#ifdef __DEBUG__
		std::clog << "[Notice - IOGuild::frag] Unable to attach war frag to player " << player->getName() << "." << std::endl;
		#endif
		return;
	}

	std::string killers = s.str();
	s.str("");

	ChatChannel* channel = NULL;
	if((channel = g_chat.getChannel(player, CHANNEL_GUILD)))
	{
		s << "Guild member " << player->getName() << " was killed by " << killers << ".";
		if(score)
			s << " The new score is " << war.frags[war.type == WAR_GUILD] << ":"
				<< war.frags[war.type] << " frags (limit " << war.limit << ").";

		channel->talk("", MSG_GAMEMASTER_CHANNEL, s.str());
	}

	s.str("");
	if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD)))
	{
		s << "Opponent " << player->getName() << " was killed by " << killers << ".";
		if(score)
			s << " The new score is " << war.frags[war.type] << ":"
				<< war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ").";

		channel->talk("", MSG_CHANNEL_HIGHLIGHT, s.str());
	}

	Database* db = Database::getInstance();
	DBQuery query;

	query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES ("
		<< war.ids[war.type] << ", " << war.war << ", " << deathId << ");";
	db->query(query.str());
}