blob: ec903949f493e821d23f108067bf5e12c6837b57 (
plain)
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
|
// parser/fight_results.h
// utilities for parsing the fight results data
#include "parser/parser_defs.h"
#include "utils/tcp.h"
#ifndef FIGHT_RESULTS_H
#define FIGHT_RESULTS_H
// Payload structure:
// FIGHT_RESULTS_START EntityResults (SEPARATOR_ENTITY EntityResults)* FIGHT_RESULTS_END
#define FIGHT_RESULTS_START "3;19;"
#define FIGHT_RESULTS_END "[--];"
// items parsing info
#define INIT_ITEMS_CAPACITY 8
#define SINGLE_ITEM_BUFFER_LEN 128
#define SEPARATOR_ITEMS "[-]"
// Item struct - for keeping item string and type
typedef enum { NORMAL, DRIF, ORB, SYNG, SET, RARE, EPIC } ItemType;
typedef struct {
char *data;
ItemType type;
} Item;
// fight results data for friendly
typedef struct {
char *name;
int exp;
int gold;
Item *items;
size_t num_items;
int level;
int psycho;
int splinters;
const char *saturation_type;
int saturation;
} FriendlyResults;
// fight results data for enemy
typedef struct {
char *name;
int level;
} EnemyResults;
#define INIT_ENTITIES_PER_SIDE 6
// entire fight resutls
typedef struct {
size_t num_friendly;
FriendlyResults *friendly_results;
size_t num_enemy;
EnemyResults *enemy_results;
} FightResults;
extern find_function_t find_fight_results;
extern parse_function_t parse_fight_results;
#endif
|