diff --git a/.gitignore b/.gitignore index 10d5414..86732f5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ !Makefile !README.md !*.py +!*.h diff --git a/object.h b/object.h new file mode 100644 index 0000000..65b5aca --- /dev/null +++ b/object.h @@ -0,0 +1,27 @@ +#ifndef _object_h +#define _object_h + +typedef enum { + NORTH, SOUTH, EAST, WEST +} Direction; + +typedef struct { + char *description; + int (*init)(void *self); + void (*describe)(void *self); + void (*destroy)(void *self); + void *(*move)(void *self, Direction direction); + int (*attack)(void *self, int damage); +} Object; + +int Object_init(void *self); +void Object_destroy(void *self); +void Object_describe(void *self); +void *Object_move(void *self, Direction direction); +int Object_attack(void *self, int damage); +void *Object_new(size_t size, Object proto, char *description); + +#define NEW(T, N) Object_new(sizeof(T), T##Proto, N) +#define _(N) proto.N + +#endif