-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiece.cpp
More file actions
72 lines (60 loc) · 1.39 KB
/
Copy pathpiece.cpp
File metadata and controls
72 lines (60 loc) · 1.39 KB
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
#include "piece.h"
#include <ctime>
#include <cmath>
#include <iostream>
#include <QtWidgets>
#include <QColor>
#include <QGraphicsItem>
#include <QString>
#include "pawn.h"
#include "bishop.h"
#include "knight.h"
#include "queen.h"
#include "king.h"
#include "rook.h"
Piece::Piece(QString color, int x, int y, int w, int h){
this->color_ = color;
this->x_ = x;
this->y_ = y;
this->width_ = w;
this->height_ = h;
}
Piece::Piece(){}
//Emit the signal that our MainWindow can grab for selecting a piece
void Piece::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event);
emit(PieceSelected(this));
}
int Piece::getX() {
return x_;
}
int Piece::getY() {
return y_;
}
QString Piece::getType() {
return "";
}
QString Piece::getColor() {
return color_;
}
Piece * Piece::PieceFactory(QString type, QString color){
if (type == "pawn"){
return new Pawn(color, 0, 0, 95, 95);
}
if (type == "bishop"){
return new Bishop(color, 0, 0, 95, 95);
}
if (type == "knight"){
return new Knight(color, 0, 0, 95, 95);
}
if (type == "queen"){
return new Queen(color, 0, 0, 95, 95);
}
if (type == "rook"){
return new Rook(color, 0, 0, 95, 95);
}
if (type == "king"){
return new King(color, 0, 0, 95, 95);
}
}