summaryrefslogtreecommitdiff
path: root/utils/tfstats/customawardtriggers.h
blob: 6362846040c434ba0b67b9d9977df652855f3777 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:  Interfaces of the CustomAwardTrigger tree. Both types of
// Custom award triggers and their base class
//
// $Workfile:     $
// $Date:         $
//
//------------------------------------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#ifndef CUSTOMAWARDTRIGGERS_H
#define CUSTOMAWARDTRIGGERS_H
#ifdef WIN32
#pragma once
#endif
#pragma warning(disable :4786)
#include "TextFile.h"
#include "LogEvent.h"
#include <vector>
#include <list>
#include <map>

using std::map;
using std::list;
using std::vector;
using std::string;
//------------------------------------------------------------------------------------------------------
// Purpose: CCustomAwardTrigger is the base class for both types of award 
// triggers. An award trigger is an object that recognizes a certain type of event
// in the log file, and if it matches that event, then it "triggers" and the custom
// award which owns it increments the counter for the player who triggered the
// trigger.
//------------------------------------------------------------------------------------------------------
class CCustomAwardTrigger
{
public:
	static CCustomAwardTrigger* readTrigger(CTextFile& f);
	int plrValue;
	int teamValue;
	
	map<string,string> extraProps;	
	
	virtual bool matches(const CLogEvent* le)=0;

	virtual PID  plrIDFromEvent(const CLogEvent* ple){return -1;}
	virtual string getTrackString(const CLogEvent* ple){return "";}
	CCustomAwardTrigger(int value, int tmVal, map<string,string> extras){plrValue=value;teamValue=tmVal;extraProps=extras;}
};


//------------------------------------------------------------------------------------------------------
// Purpose: CBroadcastTrigger scans broadcast events for matching data
//------------------------------------------------------------------------------------------------------
class CBroadcastTrigger: public CCustomAwardTrigger
{
public:
	CBroadcastTrigger(int value, int teamValue, vector<string>& keys,map<string,string> extras);
	vector<string> broadcastStrings;
	virtual bool matches(const CLogEvent* le);
	virtual PID  plrIDFromEvent(const CLogEvent* ple){return ple->getArgument(1)->asPlayerGetPID();}
	
	//this class doesn't need this function
	//virtual string getTrackString(const CLogEvent* ple){return "";}
};


//------------------------------------------------------------------------------------------------------
// Purpose: CGoalTrigger scans goal activations for matching data
//------------------------------------------------------------------------------------------------------
class CGoalTrigger: public CCustomAwardTrigger
{
public:
	CGoalTrigger(int value, int teamValue, vector<string>& keys,map<string,string> extras);
	vector<string> goalNames;
	virtual bool matches(const CLogEvent* le);
	virtual PID  plrIDFromEvent(const CLogEvent* ple){return ple->getArgument(0)->asPlayerGetPID();}
	
	//this class doesn't need this function
	//virtual string getTrackString(const CLogEvent* ple){return "";}
};


//------------------------------------------------------------------------------------------------------
// Purpose: CFullSearchTrigger scans FullSearch activations for matching data
//------------------------------------------------------------------------------------------------------
class CFullSearchTrigger: public CCustomAwardTrigger
{
public:
	int regExpCompare(string exp,string cmp);

	map<string,string> varexpressions;
	
	CFullSearchTrigger(int value, int teamValue, vector<string>& ks,map<string,string> extras);
	
	vector<string> keys;
	
	string winnerVar;
	
	bool compare(string str_msg,string str_key,map<string,string>& varmatches);
	virtual bool matches(const CLogEvent* le);
	virtual PID  plrIDFromEvent(const CLogEvent* ple);

	//this class does
	virtual string getTrackString(const CLogEvent* ple);
};



#endif // CUSTOMAWARDTRIGGERS_H