-
Notifications
You must be signed in to change notification settings - Fork 0
/
io.cpp
94 lines (69 loc) · 1.48 KB
/
io.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
91
92
93
94
#include "io.h"
//#include "basemessage.h"
#include "global.h"
#include "messages.h"
#include "toolkit.h"
IO::IO(list<BaseMessage*>* in_pQue, bool* tmp_quit)
: BaseSystem(GamePart::IO, in_pQue), quit(tmp_quit) {
}
IO::~IO() {
}
int IO::Init() {
START
STOP
}
int IO::Deinit() {
START
STOP
}
int IO::Update() {
START
int c = getch(); // refresh, accept single keystroke of input
//if (show) cout << c << endl;
switch (c) {
case 27: { // ESC
*quit = TRUE;
} break;
case 112: { // "p"
//show = !show;
//pMsgQue->push_back(new PrintMessage("Hej"));
} break;
case KEY_DOWN: {
/*
if (wmove(win[0], y + 1, x) != ERR) {
wmove(win[0], y, x);
waddch(win[0], '.');
y++;
wmove(win[0], y, x);
waddch(win[0], '@');
}
*/
} break;
case KEY_UP: {
} break;
case KEY_LEFT: {
//pMsgQue->push_back(new MoveMsg());
} break;
case KEY_RIGHT: {
} break;
}
STOP
}
int IO::UpdateMsgs() {
START
LOGF("Me: %d", me);
list<BaseMessage*>::iterator it;
for (it = pMsgQue->begin(); it != pMsgQue->end(); it++) {
LOGF("(*it)->GetReceiver(): %d", (*it)->GetReceiver());
LOGF("(*it)->GetType(): %d", (*it)->GetType());
if ((*it)->GetReceiver() != me) continue; // If this class is not the addressee, skip this msg
switch ((*it)->GetType()) {
case MessageType::PLAYERID: {
playerId = ((PlayerIdMsg*)(*it))->GetId();
LOGF("playerId: %d", playerId);
(*it)->SetValid(FALSE);
} break;
}
}
STOP
}