-
Notifications
You must be signed in to change notification settings - Fork 1
/
moves.cpp
113 lines (107 loc) · 2.93 KB
/
moves.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// For determining if the moves are valid or not
#include <iostream>
#include <SFML/Graphics.hpp>
// Flow of calls
// 1. Declare a moves::move classes' object
// 2. Call the init function with specific arguments
// 3. Call display() function
namespace moves {
// For displaying a square around the valid moves' square
class sq {
public:
sf::RectangleShape square[64];
int max;
sq() {
for(int i = 0 ; i < 64 ; i++) {
square[i].setSize({spacing,spacing});
square[i].setFillColor(sf::Color::Transparent);
square[i].setOutlineColor(sf::Color::Green);
square[i].setOutlineThickness(1.0f);
}
this->max = 0;
}
void demo(sf::RenderWindow* window) {
for(int i = 0 ; i < 8 ; i++)
for(int j = 0 ; j < 8 ; j++)
square[i].setPosition({X+j*spacing,Y+i*spacing});
for(int i = 0 ; i < 64 ; i++)
window->draw(square[i]);
}
void clear() {
this->max = 0;
}
void display(sf::RenderWindow *window) {
for(int i = 0 ; i < max ; i++)
window->draw(square[i]);
}
};
class move {
// Signifies the type of piece
char name;
// Keys for name
// Q -> Queen
// K -> King
// P -> Pawn
// R -> Rook
// N -> Knight
// B -> Bishop
public:
int id;
std::string position;
void init(int,std::string);
};
namespace pawn {
void valid(move m) {
int col = m.position[0] - 'a';
int row = m.position[1] - '0';
}
}
namespace king {
void valid(move m) {
}
}
namespace queen {
void valid(move m) {
}
}
namespace bishop {
void valid(move m) {
}
}
namespace rook {
void valid(move m) {
}
}
namespace knight {
void valid(move m) {
}
}
void move::init(int id, std::string position) {
this->id = id;
this->position = position;
if((id >= 8 && id <= 15) || (id >= 24 && id <= 31)) {
this->name = 'P';
pawn::valid(*this);
}
else if(id == 0 || id == 7 || id == 16 || id == 23) {
this->name = 'R';
rook::valid(*this);
}
else if(id == 1 || id == 6 || id == 17 || id == 22) {
this->name = 'N';
knight::valid(*this);
}
else if(id == 2 || id == 5 || id == 18 || id == 21) {
this->name = 'B';
bishop::valid(*this);
}
else if(id == 3 || id == 19) {
this->name = 'Q';
queen::valid(*this);
}
else if(id == 4 || id == 20) {
this->name = 'K';
king::valid(*this);
}
}
}