Skip to content

Commit 3a6b536

Browse files
committed
clean up warnings and formatting
1 parent d60ecbd commit 3a6b536

File tree

15 files changed

+144
-139
lines changed

15 files changed

+144
-139
lines changed

.idea/QtSettings.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/Interface/DisplayBoard.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
#include <vector>
1010
#include "GameComponents/Board.h"
1111

12-
class DisplayBoard : public QWidget {
13-
Q_OBJECT
12+
class DisplayBoard final : public QWidget {
13+
Q_OBJECT
1414

1515
public:
1616
explicit DisplayBoard(QWidget *parent = nullptr, int lines = 10, int columns = 10);
17-
void setBoard(const Board& board);
18-
void onDraw();
19-
void insertCard(const Card& card, const std::pair<int, int>& position, PlayerTurn turn);
17+
void SetBoard(const Board &board);
18+
void OnDraw();
19+
void InsertCard(const Card &card, const std::pair<int, int> &position, const PlayerTurn &turn);
2020

2121
public slots:
22-
void placeCard(const Card& card);
22+
void PlaceCard(const Card &card);
2323

2424
protected:
2525
void paintEvent(QPaintEvent *event) override;
2626
void mousePressEvent(QMouseEvent *event) override;
2727

2828
private:
2929
Board m_Board;
30-
int m_Lines;
31-
int m_Columns;
32-
Card m_SelectedCard;
33-
bool m_CardSelected;
30+
int m_Lines;
31+
int m_Columns;
32+
Card m_SelectedCard;
33+
bool m_CardSelected;
3434
};
3535

36-
#endif // ETER_DISPLAYBOARD_H
36+
#endif // ETER_DISPLAYBOARD_H

include/Interface/DisplayHand.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
#include <vector>
1010
#include "GameComponents/Card.h"
1111

12-
class DisplayHand : public QWidget {
13-
Q_OBJECT
12+
class DisplayHand final : public QWidget {
13+
Q_OBJECT
1414

1515
public:
1616
explicit DisplayHand(QWidget *parent = nullptr);
17-
void setCards(const std::vector<Card>& cards);
18-
void onDraw();
19-
Card getSelectedCard() const;
17+
void SetCards(const std::vector<Card> &cards);
18+
void OnDraw();
19+
[[nodiscard]] Card GetSelectedCard() const;
2020

2121
signals:
22-
void cardSelected(const Card& card);
22+
void CardSelected(const Card &card);
2323

2424
protected:
2525
void paintEvent(QPaintEvent *event) override;
2626
void mousePressEvent(QMouseEvent *event) override;
2727

2828
private:
2929
std::vector<Card> m_Cards;
30-
int m_SelectedCardIndex;
30+
int m_SelectedCardIndex;
3131
};
3232

33-
#endif // ETER_DISPLAYHAND_H
33+
#endif // ETER_DISPLAYHAND_H

include/Interface/MainWindow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ private slots:
6363

6464
// Helper Functions
6565
static void CreateLabel(const QString &text, QWidget *parent);
66-
void CreateSlider(int &value, QWidget *parent);
67-
void CreateColorPicker(const QString &labelText, QColor &color, QWidget *parent);
66+
void CreateSlider(int &value, QWidget *parent);
67+
void CreateColorPicker(const QString &labelText, QColor &color, QWidget *parent);
6868
static QVBoxLayout *CreateLimitedLayout(QWidget *widget);
6969

7070
std::string m_CurrentGameMode;

include/Powers/ElementPower.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ enum class ElementIndexPower {
3636

3737
class ElementPower {
3838
static ElementIndexPower RandomPower();
39-
std::string GetElementPowerDescription(ElementIndexPower power);
39+
static std::string GetElementPowerDescription(ElementIndexPower power);
4040

4141
public:
4242
explicit ElementPower(ElementIndexPower power);

include/Powers/Explosion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Explosion {
88
enum class Effect { Nothing, Eliminate, Return, Hole };
99

1010
explicit Explosion(const std::vector<std::vector<Effect>> &effectMap);
11-
Explosion Generate(int size);
11+
static Explosion Generate(int size);
1212

1313
private:
1414
std::vector<std::vector<Effect>> m_Effects;

include/Powers/Wizard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Wizard {
3030
Wizard &operator=(const Wizard &other) = default;
3131
Wizard &operator=(Wizard &&other) noexcept = default;
3232
Wizard();
33-
~Wizard();
33+
~Wizard() = default;
3434

3535
[[nodiscard]] std::string GetWizardPowerDescription() const;
3636

src/GameComponents/Card.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <stdexcept>
55

66
Card::Card(const int value) {
7+
// todo: initialise mplaced by here (?)
78
if (value > 4 || value < 1) {
89
throw std::invalid_argument("Invalid card value");
910
}

src/GameModes/Antrenament.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// meci: 2/3;
99

1010
// todo: move this to somewhere more permanent
11-
const auto createCards = [](const std::array<int, 7> &values, const PlayerTurn &player) {
11+
const auto CREATE_CARDS = [](const std::array<int, 7> &values, const PlayerTurn &player) {
1212
std::vector<Card> cards;
1313
for (int value : values) {
1414
cards.emplace_back(value, player);
@@ -17,8 +17,8 @@ const auto createCards = [](const std::array<int, 7> &values, const PlayerTurn &
1717
};
1818

1919
constexpr std::array CARD_VALUES{1, 1, 2, 2, 3, 3, 4};
20-
const std::vector<Card> CARDS_PLAYER1 = createCards(CARD_VALUES, PlayerTurn::Player1);
21-
const std::vector<Card> CARDS_PLAYER2 = createCards(CARD_VALUES, PlayerTurn::Player2);
20+
const std::vector<Card> CARDS_PLAYER1 = CREATE_CARDS(CARD_VALUES, PlayerTurn::Player1);
21+
const std::vector<Card> CARDS_PLAYER2 = CREATE_CARDS(CARD_VALUES, PlayerTurn::Player2);
2222

2323
Antrenament::Antrenament(const std::string &nameOne, const std::string &nameTwo) :
2424
Game(3, 2, nameOne, nameTwo) {

src/Interface/DisplayBoard.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,67 +3,69 @@
33
//
44

55
#include "Interface/DisplayBoard.h"
6-
#include "GameComponents/Board.h"
7-
#include <QPainter>
86
#include <QMouseEvent>
7+
#include <QPainter>
8+
#include "GameComponents/Board.h"
99

10-
DisplayBoard::DisplayBoard(QWidget *parent, int lines, int columns)
11-
: QWidget(parent), m_Board(10), m_Lines(lines), m_Columns(columns), m_SelectedCard(1), m_CardSelected(false) {}
10+
DisplayBoard::DisplayBoard(QWidget *parent, const int lines, const int columns) :
11+
QWidget(parent), m_Board(10), m_Lines(lines), m_Columns(columns), m_SelectedCard(1),
12+
m_CardSelected(false) {}
1213

13-
void DisplayBoard::setBoard(const Board& board) {
14+
void DisplayBoard::SetBoard(const Board &board) {
1415
m_Board = board;
1516
update();
1617
}
1718

18-
void DisplayBoard::onDraw() {
19-
update();
20-
}
19+
void DisplayBoard::OnDraw() { update(); }
2120

22-
void DisplayBoard::insertCard(const Card& card, const std::pair<int, int>& position, PlayerTurn turn) {
21+
void DisplayBoard::InsertCard(const Card &card, const std::pair<int, int> &position,
22+
const PlayerTurn &turn) {
2323
m_Board.InsertCard(card, position, turn);
2424
update();
2525
}
2626

27-
void DisplayBoard::placeCard(const Card& card) {
27+
void DisplayBoard::PlaceCard(const Card &card) {
2828
m_SelectedCard = card;
2929
m_CardSelected = true;
3030
}
3131

3232
void DisplayBoard::paintEvent(QPaintEvent *event) {
3333
Q_UNUSED(event);
3434

35-
QPainter painter(this);
36-
int cellSize = 50;
37-
int xOffset = 10;
38-
int yOffset = 10;
35+
QPainter painter(this);
36+
constexpr int cellSize = 50;
37+
constexpr int xOffset = 10;
38+
constexpr int yOffset = 10;
3939

4040
for (int row = 0; row < m_Lines; ++row) {
4141
for (int col = 0; col < m_Columns; ++col) {
42-
int x = xOffset + col * cellSize;
43-
int y = yOffset + row * cellSize;
42+
const int x = xOffset + col * cellSize;
43+
const int y = yOffset + row * cellSize;
4444

4545
painter.drawRect(x, y, cellSize, cellSize);
4646

4747
Position pos{col, row};
48-
if (m_Board.GetGameBoard().count(pos) && !m_Board.GetGameBoard().at(pos).empty()) {
49-
painter.drawText(x + 10, y + 20, QString::number(m_Board.GetGameBoard().at(pos).top().GetValue()));
48+
if (m_Board.GetGameBoard().contains(pos) && !m_Board.GetGameBoard().at(pos).empty()) {
49+
painter.drawText(x + 10, y + 20,
50+
QString::number(m_Board.GetGameBoard().at(pos).top().GetValue()));
5051
}
5152
}
5253
}
5354
}
5455

5556
void DisplayBoard::mousePressEvent(QMouseEvent *event) {
5657
if (m_CardSelected) {
57-
int cellSize = 50;
58-
int xOffset = 10;
59-
int yOffset = 10;
58+
constexpr int cellSize = 50;
59+
constexpr int xOffset = 10;
60+
constexpr int yOffset = 10;
6061

61-
int col = (event->x() - xOffset) / cellSize;
62-
int row = (event->y() - yOffset) / cellSize;
62+
const int col = (event->position().x() - xOffset) / cellSize;
63+
const int row = (event->position().y() - yOffset) / cellSize;
6364

6465
if (col >= 0 && col < m_Columns && row >= 0 && row < m_Lines) {
65-
insertCard(m_SelectedCard, {col, row}, PlayerTurn::Player1); // Assuming Player1 for simplicity
66+
InsertCard(m_SelectedCard, {col, row},
67+
PlayerTurn::Player1); // Assuming Player1 for simplicity
6668
m_CardSelected = false;
6769
}
6870
}
69-
}
71+
}

0 commit comments

Comments
 (0)