This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModeleCase.h
74 lines (53 loc) · 1.46 KB
/
ModeleCase.h
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
/*
* Classe implémentant la logique d'une Case.
* Structure pour encapsuler une liste de Cases
*
* Fichier : ModeleCase.h, ModeleCase.cpp
* Auteurs : Sebastian Espin, Julien Roux
* Date : 05/05/2022
* Crée : 28/04/2022
*/
#pragma once
#include <QObject>
#include <vector>
#include <memory>
#include "StructSpecial.h"
#include "ModelePieceEchec.h"
namespace Modele {
class ModelePieceEchec;
class ModeleCase : public QObject
{
Q_OBJECT
public:
ModeleCase(int ligne, int colonne);
~ModeleCase();
const MatricePosition& lirePosition() { return mPosition; }
const PixelPosition& lirePixelPos() { return pPosition; }
PixelPosition* accedeCasePixelPos() { return &pPosition; }
void mettrePiece(ModelePieceEchec* piece);
void enleverPiece();
ModelePieceEchec* getPiece() { return piece_; }
private:
ModelePieceEchec* piece_ = nullptr;
MatricePosition mPosition;
PixelPosition pPosition;
signals:
void mettreCouleur(QColor couleur);
void mettreCouleurBase();
};
struct ListeCases {
std::vector<std::unique_ptr<ModeleCase>> listeCases;
ModeleCase* operator[](int x) {
return listeCases[x].get();
}
ModeleCase* operator()(int x, int y) {
return listeCases[size_t(x * 8 + y)].get();
}
void push_back(std::unique_ptr<ModeleCase> box) {
listeCases.push_back(move(box));
}
const size_t size() const { return listeCases.size(); }
auto begin() { return listeCases.begin(); }
auto end() { return listeCases.end(); }
};
}