summaryrefslogtreecommitdiff
path: root/utils/tfstats/teamkillaward.cpp
blob: dbf23339f7e2e5cd1cfab0f0e9dd7ea4298890ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:  Implemenation of CTeamKillAward
//
// $Workfile:     $
// $Date:         $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "TeamKillAward.h"

//------------------------------------------------------------------------------------------------------
// Function:	CTeamKillAward::getWinner
// Purpose:	 generates the winner of the award
//------------------------------------------------------------------------------------------------------
void CTeamKillAward::getWinner()
{
	CEventListIterator it;
	
	for (it=g_pMatchInfo->eventList()->begin(); it != g_pMatchInfo->eventList()->end(); ++it)
	{
		if ((*it)->getType()==CLogEvent::TEAM_FRAG)
		{
			PID traitor=(*it)->getArgument(0)->asPlayerGetPID();
			numbetrayals[traitor]++;
			winnerID=traitor;
			fNoWinner=false;
		}
	}
	
	map<PID,int>::iterator traitoriter;

	for (traitoriter=numbetrayals.begin();traitoriter!=numbetrayals.end();++traitoriter)
	{
		int currID=(*traitoriter).first;
		if (numbetrayals[currID]>numbetrayals[winnerID])
			winnerID=currID;
	}
}

//------------------------------------------------------------------------------------------------------
// Function:	CTeamKillAward::noWinner
// Purpose:	 writes html to indicate that there was no winner of this award
// Input:	html - the html file to write to
//------------------------------------------------------------------------------------------------------
void CTeamKillAward::noWinner(CHTMLFile& html)
{
	html.write("No one killed any teammates! Good Work!");
}

//------------------------------------------------------------------------------------------------------
// Function:	CTeamKillAward::extendedinfo
// Purpose:	writes out how many teammates were killed by the traitor
// Input:	html - the html file to write to
//------------------------------------------------------------------------------------------------------
void CTeamKillAward::extendedinfo(CHTMLFile& html)
{
	html.write("The traitor %s murdered %li teammates.",winnerName.c_str(),numbetrayals[winnerID]);
}