-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnterGameResultsDialog.cpp
52 lines (40 loc) · 1.3 KB
/
EnterGameResultsDialog.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
#include "EnterGameResultsDialog.h"
#include "ui_EnterGameResultsDialog.h"
#include "Match.h"
#include "Game.h"
#include <QtDebug>
EnterGameResults::EnterGameResults(std::shared_ptr<Game> g, QWidget *parent) :
QDialog(parent),
ui(new Ui::EnterGameResults)
{
this->game = g;
ui->setupUi(this);
ui->label->setAlignment(Qt::AlignCenter);
}
EnterGameResults::~EnterGameResults()
{
delete ui;
}
void EnterGameResults::on_lineEdit_returnPressed()
{
//std::shared_ptr<Player> p = std::make_shared<Player>();
accept();
close();
}
void EnterGameResults::enterScores(){
std::shared_ptr<Player> p = std::make_shared<Player>();
for(int i = 0; i < this->game->getPlayers().size(); i++){
ui->label->setText("Enter " + this->game->getPlayers().at(i)->getQName() + "'s Score");
int gameScore = ui->lineEdit->text().toInt();
game->insertResult(std::pair<std::string, int>(game->getPlayers().at(i)->getName(), gameScore));
//int score = ui->lineEdit->text().toInt();
p->setScore(gameScore);
//this->game->addPlayerToGame(p);
}
}
int EnterGameResults::playerScore() const{
return ui->lineEdit->text().toInt();
};
void EnterGameResults::editLabel(QString str){
ui->label->setText(str);
}