-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhost_terminal.cpp
90 lines (72 loc) · 1.8 KB
/
host_terminal.cpp
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
/*
OOPoker
Copyright (c) 2010 Lode Vandevenne
All rights reserved.
This file is part of OOPoker.
OOPoker is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OOPoker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OOPoker. If not, see <http://www.gnu.org/licenses/>.
*/
#include "host_terminal.h"
#include "game.h"
#include "info.h"
#include "io_terminal.h"
#include "statistics.h"
#include "table.h"
HostTerminal::HostTerminal()
: quit(false)
, human_detected(false)
, dealCount(0)
{
}
void HostTerminal::onFrame()
{
if(getCharNonBlocking() == 'q') quit = true;
}
void HostTerminal::onDealDone(const Info& info)
{
dealCount++;
if(human_detected)
{
drawTable(info);
if(pressAnyKeyOrQuit()) quit = true;
}
else
{
/*if(dealCount % 10 == 0)*/ std::cout << std::endl << "Deal " << dealCount << " done." << std::endl << std::endl;
}
}
void HostTerminal::onGameBegin(const Info& info)
{
std::cout << std::endl;
drawTable(info);
}
void HostTerminal::onGameDone(const Info& info)
{
(void)info;
std::cout << std::endl << "Game finished. Press any key to show final events." << std::endl;
getChar();
}
bool HostTerminal::wantToQuit() const
{
return quit;
}
void HostTerminal::resetWantToQuit()
{
quit = false;
}
void HostTerminal::setQuitSignalFromHumanPlayer()
{
quit = true;
}
void HostTerminal::setHasHumanPlayer(bool has)
{
human_detected = has;
}