-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathThreadContext.cpp
More file actions
54 lines (39 loc) · 1.14 KB
/
ThreadContext.cpp
File metadata and controls
54 lines (39 loc) · 1.14 KB
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
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <iostream>
#include "ThreadContext.h"
ThreadContext::ThreadContext()
{
std::cout << "ThreadContext ctor" << std::endl;
htWins = 0;
htRounds = 0;
}
ThreadContext::~ThreadContext() {
std::cout << "ThreadContext dtor" << std::endl;
}
void ThreadContext::incrementWins() { htWins++; }
void ThreadContext::incrementRounds() { htRounds++; }
void ThreadContext::incrementWinStreak(ServerStats &sStats) {
winStreak++; sStats.setHeadsTailsHS(winStreak);
}
void ThreadContext::resetWinStreak() { winStreak = 0; }
void ThreadContext::recordLastGuess(ServerStats &sStats, int lg) {
incrementRounds();
lastGuess = lg;
if (lg == 0) {
resetWinStreak();
}
else
{
incrementWins();
incrementWinStreak(sStats);
sStats.setHeadsTailsHS(winStreak);
}
}
int ThreadContext::getWins() { return htWins; }
int ThreadContext::getRounds() { return htRounds; }
int ThreadContext::getWinStreak() { return winStreak; }
int ThreadContext::getLastGuess() { return lastGuess; }