-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguiplayer.cpp
More file actions
38 lines (34 loc) · 780 Bytes
/
guiplayer.cpp
File metadata and controls
38 lines (34 loc) · 780 Bytes
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
#include "guiplayer.h"
#include "player.h"
#include <iostream>
#include <string>
GUIPlayer::GUIPlayer( Player* p )
{
player = p;
if(nameLabel == NULL)
nameLabel = new QLabel( this );
nameLabel->setTextFormat(Qt::RichText);
updateStats();
}
QString GUIPlayer::convert(int num)
{
QString str = "";
while(num != 0)
{
str = static_cast<char>(num % 10 + '0') + str;
num /= 10;
}
return str;
}
void GUIPlayer::updateStats()
{
QString str = player->getToken();
QString money = convert(player->getMoney());
nameLabel->setText("<b><font color=\"blue\">" + str + "</font></b>: $" + money);
}
void GUIPlayer::setMoney(int money)
{
int total = money - player->getMoney();
player->addMoney(total);
updateStats();
}