-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.h
89 lines (57 loc) · 1.96 KB
/
map.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
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef MAP_H
#define MAP_H
#define MAP_WIDTH 80
#define MAP_HEIGHT 24
#include <stdint.h>
#include "piece.h"
struct tile;
struct region;
struct grid;
typedef struct tile {
unsigned char walkable;
// uint16_t owner; /* 0 is no owner */
struct region *region;
uint16_t height;
uint16_t width;
piece_t *piece; /* should be a pointer to piece_t structure, NULL if empty */
} tile_t;
typedef struct region {
uint16_t id;
uint16_t size;
char name[17];
tile_t **tiles; /* pointer to an array of pointers to tiles */
character_t *owner;
struct region *prev;
struct region *next;
} region_t;
region_t *add_region(const char *name); //, const uint16_t height, const uint16_t width);
void change_tile_region(region_t *new_region, tile_t *tile);
void change_region_owner(character_t *new_character, region_t *region);
void change_region_name(char *new_name, region_t *region);
unsigned char claim_region(character_t *character, region_t *region);
region_t *get_region_by_id(const uint16_t id);
region_t *get_region_by_name(const char *name);
uint16_t get_region_order(region_t *region);
region_t *get_region_by_order(uint16_t order);
void clear_region(region_t *region);
void remove_region(region_t *region);
void sort_region_list();
void clear_region_list();
uint16_t count_tiles_by_owner(character_t *owner);
uint16_t count_regions_by_owner(character_t *owner);
uint16_t count_regions();
typedef struct grid {
uint16_t height;
uint16_t width;
tile_t ***tiles;
} grid_t;
grid_t *create_grid(uint16_t height, uint16_t width);
void remove_grid();
unsigned int is_legal_move(const uint16_t src_height, const uint16_t src_width,
const uint16_t dst_height, const uint16_t dst_width);
unsigned int move_piece(piece_t *piece, const uint16_t dst_heigh,
const uint16_t dst_width);
void toggle_walkable(const uint16_t height, const uint16_t width);
tile_t *region_center(region_t *region);
tile_t *get_empty_tile_in_region(region_t *region);
#endif /* MAP_H */