-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenums.h
77 lines (66 loc) · 2.24 KB
/
enums.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
75
76
77
#ifndef CHESS_ENUMS_H
#define CHESS_ENUMS_H
#include <iostream>
#include <map>
#include "SFML/Graphics/Texture.hpp"
namespace enums {
enum piece_type {
bishop,
horse,
king,
pawn,
queen,
tower
};
static inline std::map<piece_type, std::string> piece_type_map{
{piece_type::bishop, "bishop"},
{piece_type::horse, "horse"},
{piece_type::king, "king"},
{piece_type::pawn, "pawn"},
{piece_type::queen, "queen"},
{piece_type::tower, "tower"}
};
enum color {
white,
black,
possible
};
static void invert_color(color& col) {
col = col == enums::black ? enums::white : enums::black;
}
static inline std::map<color, std::string> color_map{
{white, "w"},
{black, "b"},
{possible, "p"}
};
}
class pieces {
class sub_pieces {
public:
std::map<enums::piece_type, sf::Texture> pieces{};
sf::Texture &operator[](enums::piece_type type){
return pieces[type];
}
};
std::map<enums::color, sub_pieces> pieces;
void loadPieces(){
pieces[enums::black][enums::pawn].loadFromFile("./pieces/b_pawn.png");
pieces[enums::white][enums::pawn].loadFromFile("./pieces/w_pawn.png");
pieces[enums::black][enums::bishop].loadFromFile("./pieces/b_bishop.png");
pieces[enums::white][enums::bishop].loadFromFile("./pieces/w_bishop.png");
pieces[enums::black][enums::tower].loadFromFile("./pieces/b_tower.png");
pieces[enums::white][enums::tower].loadFromFile("./pieces/w_tower.png");
pieces[enums::black][enums::king].loadFromFile("./pieces/b_king.png");
pieces[enums::white][enums::king].loadFromFile("./pieces/w_king.png");
pieces[enums::black][enums::horse].loadFromFile("./pieces/b_horse.png");
pieces[enums::white][enums::horse].loadFromFile("./pieces/w_horse.png");
pieces[enums::black][enums::queen].loadFromFile("./pieces/b_queen.png");
pieces[enums::white][enums::queen].loadFromFile("./pieces/w_queen.png");
}
friend int main();
public:
sub_pieces &operator[](enums::color color){
return pieces[color];
}
} tex_pieces;
#endif