-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChessHistory.h
76 lines (56 loc) · 1.7 KB
/
ChessHistory.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
/*
* ChessHistory.h
*
* Created on: Feb 25, 2018
* Author: krimolovsky
*/
#ifndef CHESSHISTORY_H_
#define CHESSHISTORY_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define HISTORY_SIZE 6
#define NUMBER_OF_DETAILS_FOR_UNDO 5
/*
* {x,y,i,j,symbol}
* <x,y> - first two chars for location before move
* <i,j> - next 2 chars for location after move,
* symbol - last char for what symbol was before move
*/
typedef struct chess_history_t {
char elements[HISTORY_SIZE][NUMBER_OF_DETAILS_FOR_UNDO];
int actualSize;
int maxSize;
} ChessHistory;
/*
* creates a history list of size HISTORY_SIZE, each element of size NUMBER_OF_DETAILS_FOR_UNDO.
*/
ChessHistory* createHistoryChess(void);
/*
* copies a history, if history is null then returns null.
*/
ChessHistory* copyHistoryChess(ChessHistory* history);
/*
* deletes history chess list, releasing resources
*/
void destoryHistoryChess(ChessHistory* history);
/*
* inserts info to the first elements, EVEN WHEN THE LIST IS FULL (by deleting the last element).
*/
void addFirstHistoryChess(ChessHistory* history, char* details);
/*
* deletes the first elements, inserts nulls to last element
*/
void deleteFirstHistoryChess(ChessHistory* history);
/*
* returns the first element (meaning a list of all 5 details).
* this is the last move details made in the game (from, to where, the symbol was before the move).
*/
void getFirstHistoryChess(ChessHistory* history, char* details);
/*
* checks if the list is empty, for further use if player want to do undo over 3 times in a row.
*/
bool isEmptyHistoryChess(ChessHistory* history);
void PrintHistoryElements(ChessHistory* history);
#endif /* CHESSHISTORY_H_ */