summaryrefslogtreecommitdiff
path: root/utils/tfstats/sentryrebuildaward.cpp
blob: 8881ff3911ebb70c98215b9ed67428f68389114e (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
63
64
65
66
67
68
69
70
71
72
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Implementation of CSentryRebuildAward
//
// $Workfile:     $
// $Date:         $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "SentryRebuildAward.h"

//------------------------------------------------------------------------------------------------------
// Function:	CSentryRebuildAward::getWinner
// Purpose:	scans to find whose sentry guns were built the most often
//------------------------------------------------------------------------------------------------------
void CSentryRebuildAward::getWinner()
{
	CEventListIterator it;
	
	for (it=g_pMatchInfo->eventList()->begin(); it != g_pMatchInfo->eventList()->end(); ++it)
	{
		if ((*it)->getType()==CLogEvent::BUILD)
		{
			string built=(*it)->getArgument(1)->getStringValue();
			
			if (stricmp(built.c_str(),"sentry") == 0)
			{
				PID builder=(*it)->getArgument(0)->asPlayerGetPID();
				numbuilds[builder]++;
				winnerID=builder;
				fNoWinner=false;
			}
		}
	}
	
	map<PID,int>::iterator builditer;

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

//------------------------------------------------------------------------------------------------------
// Function:	CSentryRebuildAward::noWinner
// Purpose:	writes html indicating that no one built any sentries
// Input:	html - the html file to write to
//------------------------------------------------------------------------------------------------------
void CSentryRebuildAward::noWinner(CHTMLFile& html)
{
	html.write("No sentries were built during this match.");
}

//------------------------------------------------------------------------------------------------------
// Function:	CSentryRebuildAward::extendedinfo
// Purpose:	reports how many times the winner had to rebuild their sentry
// Input:	html - the html file to write to
//------------------------------------------------------------------------------------------------------
void CSentryRebuildAward::extendedinfo(CHTMLFile& html)
{
	
	if (numbuilds[winnerID] == 1)
		html.write("No one had to rebuild a sentry gun in this match.!",winnerName.c_str());
	else
		html.write("%s had to build a sentry gun %li times!",winnerName.c_str(),numbuilds[winnerID]);
}