comparison libmlk-rpg/mlk/rpg/battle-state.c @ 434:4e78f045e8c0

rpg: cleanup hierarchy
author David Demelier <markand@malikania.fr>
date Sat, 15 Oct 2022 21:24:17 +0200
parents src/libmlk-rpg/rpg/battle-state.c@460c78706989
children 773a082f0b91
comparison
equal deleted inserted replaced
433:862b15c3a3ae 434:4e78f045e8c0
1 /*
2 * battle-state.c -- battle abstract state
3 *
4 * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <assert.h>
20
21 #include "battle-state.h"
22
23 void
24 battle_state_handle(struct battle_state *st, struct battle *bt, const union event *ev)
25 {
26 assert(st);
27 assert(bt);
28 assert(ev);
29
30 if (st->handle)
31 st->handle(st, bt, ev);
32 }
33
34 int
35 battle_state_update(struct battle_state *st, struct battle *bt, unsigned int ticks)
36 {
37 assert(st);
38 assert(bt);
39
40 if (st->update)
41 return st->update(st, bt, ticks);
42
43 return 0;
44 }
45
46 void
47 battle_state_draw(const struct battle_state *st, const struct battle *bt)
48 {
49 assert(st);
50 assert(bt);
51
52 if (st->draw)
53 st->draw(st, bt);
54 }
55
56 void
57 battle_state_finish(struct battle_state *st, struct battle *bt)
58 {
59 assert(st);
60 assert(bt);
61
62 if (st->finish)
63 st->finish(st, bt);
64 }