comparison libmlk-rpg/mlk/rpg/battle-bar.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-bar.c@3f13dc6c0e37
children 773a082f0b91
comparison
equal deleted inserted replaced
433:862b15c3a3ae 434:4e78f045e8c0
1 /*
2 * battle-bar.c -- abstract battle bar
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-bar.h"
22
23 void
24 battle_bar_start(struct battle_bar *bar, struct battle *bt)
25 {
26 assert(bar);
27 assert(bt);
28
29 if (bar->start)
30 bar->start(bar, bt);
31 }
32
33 void
34 battle_bar_select(struct battle_bar *bar, struct battle *bt, const struct selection *sel)
35 {
36 assert(bar);
37 assert(bt);
38 assert(sel);
39
40 if (bar->select)
41 bar->select(bar, bt, sel);
42
43 }
44
45 void
46 battle_bar_handle(struct battle_bar *bar, struct battle *bt, const union event *ev)
47 {
48 assert(bar);
49 assert(bt);
50 assert(ev);
51
52 if (bar->handle)
53 bar->handle(bar, bt, ev);
54 }
55
56 void
57 battle_bar_update(struct battle_bar *bar, struct battle *bt, unsigned int ticks)
58 {
59 assert(bar);
60 assert(bt);
61
62 if (bar->update)
63 bar->update(bar, bt, ticks);
64 }
65
66 void
67 battle_bar_draw(const struct battle_bar *bar, const struct battle *bt)
68 {
69 assert(bar);
70 assert(bt);
71
72 if (bar->draw)
73 bar->draw(bar, bt);
74 }
75
76 void
77 battle_bar_finish(struct battle_bar *bar, struct battle *bt)
78 {
79 assert(bar);
80 assert(bt);
81
82 if (bar->finish)
83 bar->finish(bar, bt);
84 }