aboutsummaryrefslogtreecommitdiffstats
path: root/rps_game/src/rps_logger.cpp
blob: 638f11e96b2a8f204f0cbca549a20d82602f40c3 (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
#include "rps_logger.h"

namespace RPS {

	RPSLogger::RPSLogger() {
		clear();
	}

	void RPSLogger::clear() {
		logs.clear();

		p1_stats = {0, 0, 0};
		p2_stats = {0, 0, 0};

		p1_wins = 0;
		p2_wins = 0;
		duals = 0;
	}

	void RPSLogger::add_log(RPS::RPSLog log) {
		logs.push_back(log);
		update_rps_stat(&p1_stats, log.p1_choice);
		update_rps_stat(&p2_stats, log.p2_choice);

		RPS::OBJECT out_come = RPS::who_won(log);

		// Add to win count.  I saddly can't use a switch here ):
		if (out_come == RPS::NONE)
			return;
		if (out_come == RPS::DUAL)
			duals++;
		if (out_come == log.p1_choice)
			p1_wins++;
		if (out_come == log.p2_choice)
			p2_wins++;
	}
}