Mercurial > molko
comparison src/libmlk-rpg/rpg/battle.h @ 320:8f9937403749
misc: improve loading of data
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 01 Oct 2021 20:30:00 +0200 |
parents | libmlk-rpg/rpg/battle.h@d01e83210ca2 |
children | 19782ea1cf4a |
comparison
equal
deleted
inserted
replaced
319:b843eef4cc35 | 320:8f9937403749 |
---|---|
1 /* | |
2 * battle.h -- battles | |
3 * | |
4 * Copyright (c) 2020-2021 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 #ifndef MOLKO_RPG_BATTLE_H | |
20 #define MOLKO_RPG_BATTLE_H | |
21 | |
22 #include <core/action.h> | |
23 #include <core/core.h> | |
24 #include <core/drawable.h> | |
25 | |
26 #include <ui/frame.h> | |
27 #include <ui/gridmenu.h> | |
28 | |
29 #include "battle-bar.h" | |
30 #include "battle-entity.h" | |
31 #include "battle-state.h" | |
32 #include "selection.h" | |
33 #include "spell.h" | |
34 | |
35 union event; | |
36 | |
37 struct character; | |
38 struct inventory; | |
39 struct item; | |
40 struct music; | |
41 struct selection; | |
42 struct spell; | |
43 struct theme; | |
44 | |
45 #define BATTLE_TEAM_MAX (4) | |
46 #define BATTLE_ENEMY_MAX (8) | |
47 #define BATTLE_ENTITY_MAX (BATTLE_TEAM_MAX + BATTLE_ENEMY_MAX) | |
48 | |
49 #define BATTLE_TEAM_FOREACH(bt, iter) \ | |
50 for (size_t i = 0; i < BATTLE_TEAM_MAX && ((iter) = &(bt)->team[i]); ++i) | |
51 #define BATTLE_ENEMY_FOREACH(bt, iter) \ | |
52 for (size_t i = 0; i < BATTLE_ENEMY_MAX && ((iter) = &(bt)->enemies[i]); ++i) | |
53 | |
54 #define BATTLE_THEME(bt) ((bt)->theme ? (bt)->theme : theme_default()) | |
55 | |
56 enum battle_status { | |
57 BATTLE_STATUS_NONE, | |
58 BATTLE_STATUS_RUNNING, | |
59 BATTLE_STATUS_WON, | |
60 BATTLE_STATUS_LOST, | |
61 }; | |
62 | |
63 struct battle { | |
64 struct battle_state *state; | |
65 enum battle_status status; | |
66 struct battle_entity team[BATTLE_TEAM_MAX]; | |
67 struct battle_entity enemies[BATTLE_ENEMY_MAX]; | |
68 struct battle_entity *order[BATTLE_ENTITY_MAX]; | |
69 struct battle_entity *order_cur; | |
70 size_t order_curindex; | |
71 struct texture *background; | |
72 struct music *music[3]; | |
73 struct theme *theme; | |
74 struct drawable_stack effects; | |
75 struct action_stack actions[2]; | |
76 struct inventory *inventory; | |
77 struct battle_bar bar; | |
78 }; | |
79 | |
80 CORE_BEGIN_DECLS | |
81 | |
82 void | |
83 battle_start(struct battle *); | |
84 | |
85 void | |
86 battle_next(struct battle *); | |
87 | |
88 struct battle_entity * | |
89 battle_find(struct battle *, const struct character *); | |
90 | |
91 void | |
92 battle_switch(struct battle *, struct battle_state *); | |
93 | |
94 void | |
95 battle_order(struct battle *); | |
96 | |
97 void | |
98 battle_attack(struct battle *, struct character *, struct character *); | |
99 | |
100 void | |
101 battle_cast(struct battle *, struct character *, const struct spell *, const struct selection *); | |
102 | |
103 void | |
104 battle_use(struct battle *, const struct item *, struct character *, struct character *); | |
105 | |
106 void | |
107 battle_indicator_hp(struct battle *, const struct character *, long); | |
108 | |
109 void | |
110 battle_handle(struct battle *, const union event *); | |
111 | |
112 int | |
113 battle_update(struct battle *, unsigned int); | |
114 | |
115 void | |
116 battle_draw(struct battle *); | |
117 | |
118 void | |
119 battle_finish(struct battle *); | |
120 | |
121 CORE_END_DECLS | |
122 | |
123 #endif /* MOLKO_RPG_BATTLE_H */ |