-
Notifications
You must be signed in to change notification settings - Fork 0
/
thing.h
82 lines (67 loc) · 1.52 KB
/
thing.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
#ifndef THING_H_INCLUDED
#define THING_H_INCLUDED
#include "loc.h"
#include <stdbool.h>
#include <stdio.h>
#define NAME_SIZE 64
#define BEHAVIOR_MAX 16
typedef struct Thing Thing;
typedef bool (*BumpAction) (Thing * actor, Thing * target);
typedef void (*TurnAction) (Thing * actor);
typedef void (*UseAction) (Thing * item, Thing * user);
typedef enum
{
DEAD,
PLAYER,
GOBLIN,
ORC,
WOLF,
HALFLING,
ELF,
WEAPON,
ARMOR,
POTION,
SMALL_TREASURE,
MEDIUM_TREASURE,
LARGE_TREASURE
} Appearance;
typedef enum
{
INERT,
PLAYER_CONTROLLED,
ORC_MONSTER,
HALFLING_MONSTER,
ELF_MONSTER,
ANIMAL,
WEAPON_PICKUP,
ARMOR_PICKUP,
HEALING_POTION,
TREASURE
} ThingBehavior;
struct Thing
{
Appearance appearance;
char name[NAME_SIZE];
Loc loc;
int gold;
int hp;
int max_hp;
int xp;
int dmg;
int speed;
bool equipped;
int remaining_wait;
ThingBehavior behavior;
Thing *target, *ignored_target;
};
void define_thing_behavior (ThingBehavior behavior, BumpAction bump_action,
UseAction use_action, TurnAction turn_action);
BumpAction get_bump_action (Thing * thing);
UseAction get_use_action (Thing * thing);
TurnAction get_turn_action (Thing * thing);
Thing make_thing (Appearance appearance, char *name, int speed,
ThingBehavior behavior);
bool equal_things (Thing left, Thing right);
void write_thing (Thing * thing, FILE * stream);
Thing read_thing (FILE * stream);
#endif