-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameflow.cpp
More file actions
65 lines (44 loc) · 1.38 KB
/
Copy pathgameflow.cpp
File metadata and controls
65 lines (44 loc) · 1.38 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
#include "headers/gameflow.h"
#include "headers/display.h"
#include "headers/pieceslogic.h"
extern Display display;
extern Pieces pieces;
Game::Game(){
unordered_map <int,char> pieces_map = pieces.pieces_map;
}
void Game::init(
vector<vector<int>> &board,
vector<int> &p1_collec,
vector<int> &p2_collec
){
display.init(board,p1_collec,p2_collec);
}
vector<vector<int>> Game::update(vector<vector<int>> &board){
}
vector<vector<int>> Game::move_decoder(string move){ //2d4d
cout<<"====>> "<<move<<endl;
string spot_start=string(1,move[0])+string(1,move[1]);//2d
string spot_end=string(1,move[2])+string(1,move[3]);//4d
unordered_map <char,int> x_positions_map={
{'a',0},
{'b',1},
{'c',2},
{'d',3},
{'e',4},
{'f',5},
{'g',6},
{'h',7}
};
char x_start_enc = spot_start[0];
int x_start_dec = 8-(x_start_enc-'0');
char y_start_enc = spot_start[1];
int y_start_dec = x_positions_map[y_start_enc];
char x_end_enc = spot_end[0];
int x_end_dec = 8-(x_end_enc-'0');
char y_end_enc = spot_end[1];
int y_end_dec = x_positions_map[y_end_enc];
vector<int> start_pos ={ x_start_dec, y_start_dec };
vector<int> end_pos ={ x_end_dec, y_end_dec };
vector<vector<int>> positions_arr = { start_pos, end_pos };
return positions_arr;
}