-
Notifications
You must be signed in to change notification settings - Fork 0
/
mill.h
64 lines (57 loc) · 3.17 KB
/
mill.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
#ifndef MILL_H
#define MILL_H
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <stdbool.h>
#include <unistd.h>
#include "fifo.h"
#define MAX_TEXT_LENGHT 20
// Wojciech Sniady, nr indeksu: 322993
typedef struct Board {
int** data;
int number_of_squares;
} Board;
typedef struct ButtonBoard {
GtkWidget*** data;
int number_of_squares;
} ButtonBoard;
extern PipesPtr potoki;
extern GtkWidget* CURRENT_BUTTON;
extern bool YOUR_TURN;
extern bool P_1_TURN;
extern ButtonBoard* BUTTON_BOARD;
extern Board *BOARD;
extern int MEN_NUMBER_P_1;
extern int MEN_NUMBER_P_2;
extern int SQUARE_NUMBER_TO_MOVE_FROM;
extern int FIELD_NUMBER_TO_MOVE_FROM;
extern int TOTALLY_PLACED_MEN_PLAYER_1;
extern int TOTALLY_PLACED_MEN_PLAYER_2;
extern GtkWidget *MAIN_WINDOW;
extern GtkWidget *MEN_NUMBER_P_1_LABEL;
extern GtkWidget *MEN_NUMBER_P_2_LABEL;
extern GtkWidget *WHOSE_TURN_LABEL;
extern int PLAYER_ID;
extern bool REMOVING;
extern int NUMBER_OF_SQUARES_ARG;
Board *generate_board(int n);
void free_board(Board* board);
void print_board(Board* board);
bool place_men(Board* board, ButtonBoard* button_board, bool players_1_turn, int *men_number_player_1, int *men_number_player_2, int square_number, int field_number);
bool mill_achieved(Board* board, int current_square, int current_field);
bool remove_opponents_men(Board* board, ButtonBoard* button_board, bool players_1_turn, int *men_number_player_1, int *men_number_player_2, int square_number, int field_number);
bool all_opponents_men_in_a_mill(Board* board, bool player_1_turn);
bool select_man_to_move(Board* board, ButtonBoard* button_board, bool players_1_turn, int *men_number_player_1, int *men_number_player_2, int current_square_number, int current_field_number);
bool select_field_to_move_on(Board* board, ButtonBoard* button_board, bool players_1_turn, int *men_number_player_1, int *men_number_player_2, int chosen_square_number, int chosen_field_number);
bool properly_selected_field_to_move_on(Board* board, bool players_1_turn, int current_square_number, int current_field_number, int chosen_square_number, int chosen_field_number, int men_number_player_1, int men_number_player_2);
bool properly_selected_man_to_move(Board* board, bool players_1_turn, int square_number, int field_number, int men_number_player_1, int men_number_player_2);
bool any_move_possible(Board* board, bool players_1_turn, int men_number_player_1, int men_number_player_2);
bool game_over(Board* board, bool players_1_turn, int men_number_player_1, int men_number_player_2);
void show_winner(bool players_1_turn, bool loss_message_received, GtkWidget* parent_window);
void place_men_received(Board* board, ButtonBoard* button_board, bool players_1_turn, int square_number, int field_number, int *men_number_player_1, int *men_number_player_2);
void remove_men_received(Board* board, ButtonBoard* button_board, bool players_1_turn, int square_number, int field_number, int *men_number_player_1, int *men_number_player_2);
void move_men_received(Board* board, ButtonBoard* button_board, bool players_1_turn, int current_square_number, int current_field_number, int chosen_square_number, int chosen_field_number);
void new_game();
void reset_all_global_variables();
#endif