-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphaseobserver.cpp
63 lines (47 loc) · 1.23 KB
/
phaseobserver.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
#include "phaseobserver.h"
#include "ui_mainwindow.h"
#include "state.h"
#include "game.h"
// Default Construtoor
PhaseObserver::PhaseObserver()
{
}
// Attach UI
PhaseObserver::PhaseObserver(Ui::MainWindow *&_ui) {
ui = _ui;
}
// Updates happen here
void PhaseObserver::Update() {
// Update Player Turn UI
int playerNumber = Game::getInstance()->getTurn();
string playerName = Game::getInstance()->getPlayerName(playerNumber);
string message = "Player " + to_string(playerNumber+1) + ": " + playerName;
ui->playerTurnLabel->setText(QString(message.c_str()));
// Update Game Phase Message UI
State state = Game::getInstance()->getState();
string msg = "";
switch (state) {
case STARTUP_ROLL:
msg = "Startup Roll";
break;
case STARTUP_LOCATION:
msg = "Pick Startup Location";
break;
case ROLLING_DICE:
msg = "Roll Dice";
break;
case RESOLVING_DICE:
msg = "Resolving Dice";
break;
case MOVING:
msg = "Pick a moving location";
break;
case BUYING_CARDS:
msg = "Buy Cards";
break;
case FINISHING_TURN:
msg = "Finish Your Turn";
break;
}
ui->messageLabel->setText(QString(msg.c_str()));
}