<commit_before>/* bzflag
* Copyright (c) 1993 - 2005 <NAME>
*
* This package is free software;  you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

#include "common.h"

/* class interface header */
#include "bzfs.h"
#include "bzfsEvents.h"
#include "GameKeeper.h"

extern void sendMessage(int playerIndex, PlayerId dstPlayer, const char *message);

// ----------------- SpreeTracker-----------------

/*typedef struct 
{
	int playerID;
	std::string callsign;
	double		startTime;
	double		lastUpdateTime;
	int			spreeTotal;
}trPlayerHistoryRecord;

std::map<int, trPlayerHistoryRecord > playerList; */

PlayHistoryTracker::PlayHistoryTracker()
{

}

PlayHistoryTracker::~PlayHistoryTracker()
{

}

void PlayHistoryTracker::process ( BaseEventData *eventData )
{
	switch (eventData->eventType)
	{
		case eNullEvent:
		case eZoneEntryEvent:
		case eCaptureEvent:
		case eZoneExitEvent:
			// really WTF!!!!
			break;

		case ePlayerDieEvent:
			{
				PlayerDieEventData	*deathRecord = (PlayerDieEventData*)eventData;
				
				GameKeeper::Player *killerData = GameKeeper::Player::getPlayerByIndex(deathRecord->killerID);
				//GameKeeper::Player *victimData = GameKeeper::Player::getPlayerByIndex(deathRecord->playerID);

				// clear out the dude who got shot, since he won't be having any SPREEs
				if (playerList.find(deathRecord->playerID) != playerList.end())
				{
					trPlayerHistoryRecord	&record = playerList.find(deathRecord->playerID)->second;
					std::string message;
					if ( record.spreeTotal >= 5 && record.spreeTotal < 10 )
						message = record.callsign + std::string("'s rampage was stoped by ") + std::string(killerData->player.getCallSign());
					if ( record.spreeTotal >= 10 && record.spreeTotal < 20 )
						message = record.callsign + std::string("'s killing spree was halted by ") + std::string(killerData->player.getCallSign());
					if ( record.spreeTotal >= 20 )
						message = std::string("The unstopable reign of ") + record.callsign + std::string(" was ended by ") + std::string(killerData->player.getCallSign());

					if (message.size())
						sendMessage(ServerPlayer, AllPlayers, message.c_str());

					record.spreeTotal = 0;
					record.startTime = deathRecord->time;
					record.lastUpdateTime = deathRecord->time;

				}

				// chock up another win for our killer
				// if they weren't the same as the killer ( suicide ).
				if ( (deathRecord->playerID != deathRecord->killerID) && playerList.find(deathRecord->killerID) != playerList.end())
				{
					trPlayerHistoryRecord	&record = playerList.find(deathRecord->killerID)->second;
					record.spreeTotal++;
					record.lastUpdateTime = deathRecord->time;

					std::string message;
					
					if ( record.spreeTotal > 5 )
						message = record.callsign + std::string(" is on a Rampage!");
					if ( record.spreeTotal > 10 )
						message = record.callsign + std::string(" is on a Killing Spree!");
					if ( record.spreeTotal > 20 )
						message = record.callsign + std::string(" is Unstoppable!!");
					<commit_msg>make the play history messages come out on the right kill numbers.<commit_after>/* bzflag
* Copyright (c) 1993 - 2005 <NAME>
*
* This package is free software;  you can redistribute it and/or
* modify it under the terms of the license found in the file
* named COPYING that should have accompanied this file.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

#include "common.h"

/* class interface header */
#include "bzfs.h"
#include "bzfsEvents.h"
#include "GameKeeper.h"

extern void sendMessage(int playerIndex, PlayerId dstPlayer, const char *message);

// ----------------- SpreeTracker-----------------

/*typedef struct 
{
	int playerID;
	std::string callsign;
	double		startTime;
	double		lastUpdateTime;
	int			spreeTotal;
}trPlayerHistoryRecord;

std::map<int, trPlayerHistoryRecord > playerList; */

PlayHistoryTracker::PlayHistoryTracker()
{

}

PlayHistoryTracker::~PlayHistoryTracker()
{

}

void PlayHistoryTracker::process ( BaseEventData *eventData )
{
	switch (eventData->eventType)
	{
		case eNullEvent:
		case eZoneEntryEvent:
		case eCaptureEvent:
		case eZoneExitEvent:
			// really WTF!!!!
			break;

		case ePlayerDieEvent:
			{
				PlayerDieEventData	*deathRecord = (PlayerDieEventData*)eventData;
				
				GameKeeper::Player *killerData = GameKeeper::Player::getPlayerByIndex(deathRecord->killerID);
				//GameKeeper::Player *victimData = GameKeeper::Player::getPlayerByIndex(deathRecord->playerID);

				// clear out the dude who got shot, since he won't be having any SPREEs
				if (playerList.find(deathRecord->playerID) != playerList.end())
				{
					trPlayerHistoryRecord	&record = playerList.find(deathRecord->playerID)->second;
					std::string message;
					if ( record.spreeTotal >= 5 && record.spreeTotal < 10 )
						message = record.callsign + std::string("'s rampage was stoped by ") + std::string(killerData->player.getCallSign());
					if ( record.spreeTotal >= 10 && record.spreeTotal < 20 )
						message = record.callsign + std::string("'s killing spree was halted by ") + std::string(killerData->player.getCallSign());
					if ( record.spreeTotal >= 20 )
						message = std::string("The unstopable reign of ") + record.callsign + std::string(" was ended by ") + std::string(killerData->player.getCallSign());

					if (message.size())
						sendMessage(ServerPlayer, AllPlayers, message.c_str());

					record.spreeTotal = 0;
					record.startTime = deathRecord->time;
					record.lastUpdateTime = deathRecord->time;

				}

				// chock up another win for our killer
				// if they weren't the same as the killer ( suicide ).
				if ( (deathRecord->playerID != deathRecord->killerID) && playerList.find(deathRecord->killerID) != playerList.end())
				{
					trPlayerHistoryRecord	&record = playerList.find(deathRecord->killerID)->second;
					record.spreeTotal++;
					record.lastUpdateTime = deathRecord->time;

					std::string message;
					
					if ( record.spreeTotal == 5 )
						message = record.callsign + std::string(" is on a Rampage!");
					if ( record.spreeTotal == 10 )
						message = record.callsign + std::string(" is on a Killing Spree!");
					if ( record.spreeTotal == 20 )
						message = record.callsign + std::string(" is Unstoppable!!");
					if ( record.spreeTotal > 20 && record.spreeTotal%5 == 0 )
						message = record.callsign + std::string("'s continues rage");
					
{'fraction_non_alphanumeric': 0.13066432028156622, 'fraction_numerical': 0.007332453438920663, 'mean_word_length': 3.7559274755927476, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4976098', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2016, 'n_words': 547}