summaryrefslogtreecommitdiff
path: root/jouer.c
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-01-11 02:02:07 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-01-11 03:01:46 +0100
commit65364d2e2f40807fdd03ade25917f728adc0ef77 (patch)
treee2d2e5d0a7e329f50009a086959b4226fe27dde7 /jouer.c
parentd590bfdcdfa8799439cffa41fc74346e9923b6e7 (diff)
coding rules: stop at 78 colsrewrite
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'jouer.c')
-rw-r--r--jouer.c80
1 files changed, 47 insertions, 33 deletions
diff --git a/jouer.c b/jouer.c
index 22d123c..2d4a30f 100644
--- a/jouer.c
+++ b/jouer.c
@@ -11,29 +11,29 @@
static inline void highlight_current_character(struct team_t *team)
{
- struct character_t *chr = &team->chrs[team->chr_cur];
+ struct chr_t *chr = &team->chrs[team->chr_cur];
chr->surf = chr->red_surf;
}
static inline void unhighlight_prev_character(struct team_t *team)
{
- struct character_t *chr = &team->chrs[team->chr_cur];
+ struct chr_t *chr = &team->chrs[team->chr_cur];
chr->surf = chr->def_surf;
}
-static struct character_t *find_next_team_member(const struct character_t *current)
+static struct chr_t *find_next_team_member(const struct chr_t *current)
{
for (int i = current->idx + 1; i < current->team->chr_cnt; ++i) {
- struct character_t *chr = &current->team->chrs[i];
+ struct chr_t *chr = &current->team->chrs[i];
if (chr->alive)
return chr;
}
for (int i = 0; i <= current->idx; ++i) {
- struct character_t *chr = &current->team->chrs[i];
+ struct chr_t *chr = &current->team->chrs[i];
if (chr->alive)
return chr;
@@ -42,17 +42,17 @@ static struct character_t *find_next_team_member(const struct character_t *curre
return NULL;
}
-static struct character_t *find_prev_team_member(const struct character_t *current)
+static struct chr_t *find_prev_team_member(const struct chr_t *current)
{
for (int i = current->idx - 1; i >= 0; --i) {
- struct character_t *chr = &current->team->chrs[i];
+ struct chr_t *chr = &current->team->chrs[i];
if (chr->alive)
return chr;
}
for (int i = current->team->chr_cnt - 1; i >= current->idx; ++i) {
- struct character_t *chr = &current->team->chrs[i];
+ struct chr_t *chr = &current->team->chrs[i];
if (chr->alive)
return chr;
@@ -61,7 +61,7 @@ static struct character_t *find_prev_team_member(const struct character_t *curre
return NULL;
}
-static struct character_t *get_first_alive_character(const struct team_t *team)
+static struct chr_t *get_first_alive_character(const struct team_t *team)
{
for (int i = 0; i < team->chr_cnt; ++i) {
if (team->chrs[i].alive)
@@ -72,10 +72,11 @@ static struct character_t *get_first_alive_character(const struct team_t *team)
}
/* function called after an action has been performed */
-static void update_current_character(struct team_t *t1, struct team_t *t2, struct team_t **playing)
+static void update_current_character(struct team_t *t1, struct team_t *t2,
+ struct team_t **playing)
{
struct team_t *current;
- struct character_t *next;
+ struct chr_t *next;
unhighlight_prev_character(*playing);
@@ -119,8 +120,8 @@ static void update_current_character(struct team_t *t1, struct team_t *t2, struc
}
/* TODO the code of this function should be split in different functions */
-static
-struct target_t select_default_target(const struct action_params_t *params,
+ static struct target_t
+select_default_target(const struct action_params_t *params,
enum target_type_t type)
{
struct team_t *enemy_team;
@@ -159,14 +160,14 @@ struct target_t select_default_target(const struct action_params_t *params,
abort();
}
-static
-enum action_state_t select_target(struct action_params_t *params, const struct action_t *action)
+static enum action_state_t
+select_target(struct action_params_t *params, const struct action_t *action)
{
SURFACES *surfaces = params->surfaces;
POSITIONS *positions = params->positions;
/* select our own character because he exists no matter what */
struct target_t target = select_default_target(params, action->target);
- struct character_t *new_selection;
+ struct chr_t *new_selection;
struct team_t *team;
SDL_Event event;
@@ -288,7 +289,8 @@ enum action_state_t select_target(struct action_params_t *params, const struct a
case SDLK_f:
update_selected_target(surfaces, positions, NULL);
- (*action->f)(surfaces, positions, params->src, &target, action->data);
+ (*action->f)(surfaces, positions, params->src, &target,
+ action->data);
return ACTION_PERFORMED;
default:
@@ -297,14 +299,15 @@ enum action_state_t select_target(struct action_params_t *params, const struct a
}
}
-static
-enum action_state_t dig_entry(const struct entry_t *entries, int cnt_entries, struct action_params_t *params)
+static enum action_state_t dig_entry(const struct entry_t *entries,
+ int cnt_entries, struct action_params_t *params)
{
SDL_Event event;
const struct entry_t *target;
int selection = 0;
- update_list_entries(params->surfaces, params->positions, entries, cnt_entries, selection);
+ update_list_entries(params->surfaces, params->positions, entries,
+ cnt_entries, selection);
while (SDL_PollEvent(&event));
for (;;) {
@@ -320,12 +323,14 @@ enum action_state_t dig_entry(const struct entry_t *entries, int cnt_entries, st
case SDLK_k:
case SDLK_UP:
selection = (selection > 0) ? selection - 1 : cnt_entries - 1;
- update_list_entries(params->surfaces, params->positions, entries, cnt_entries, selection);
+ update_list_entries(params->surfaces, params->positions,
+ entries, cnt_entries, selection);
break;
case SDLK_j:
case SDLK_DOWN:
selection = (selection < cnt_entries - 1) ? selection + 1 : 0;
- update_list_entries(params->surfaces, params->positions, entries, cnt_entries, selection);
+ update_list_entries(params->surfaces, params->positions,
+ entries, cnt_entries, selection);
break;
case SDLK_f:
case SDLK_RETURN:
@@ -333,25 +338,31 @@ enum action_state_t dig_entry(const struct entry_t *entries, int cnt_entries, st
if (!target->children_cnt) {
enum action_state_t state;
- update_list_entries(params->surfaces, params->positions, entries, cnt_entries, -1);
+ update_list_entries(params->surfaces, params->positions,
+ entries, cnt_entries, -1);
state = select_target(params, &target->action);
if (state == ACTION_PERFORMED)
return ACTION_PERFORMED;
- } else {
- if (dig_entry(target->children, target->children_cnt, params) == ACTION_PERFORMED)
+ } else {
+ if (dig_entry(target->children, target->children_cnt,
+ params) == ACTION_PERFORMED)
+ {
return ACTION_PERFORMED;
+ }
}
- update_list_entries(params->surfaces, params->positions, entries, cnt_entries, selection);
+ update_list_entries(params->surfaces, params->positions,
+ entries, cnt_entries, selection);
default:
break;
}
}
}
-static enum action_state_t character_play_turn(struct action_params_t *params)
+static enum action_state_t
+character_play_turn(struct action_params_t *params)
{
params->src->defensive = false;
@@ -366,10 +377,12 @@ static enum action_state_t character_play_turn(struct action_params_t *params)
static void hook_post_action(struct action_params_t *params)
{
- struct character_t *chr = params->src;
+ struct chr_t *chr = params->src;
if (chr->alive && chr->poisoned) {
- damage_target_hp(params->surfaces, params->positions, chr, chr->max_hp / 4);
+ int damages = chr->max_hp / 4;
+
+ damage_target_hp(params->surfaces, params->positions, chr, damages);
SDL_Flip(params->surfaces->screen);
@@ -377,7 +390,8 @@ static void hook_post_action(struct action_params_t *params)
}
}
-int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct team_t *t2)
+int Fjouer(SURFACES *surfaces, POSITIONS *positions,
+ struct team_t *t1, struct team_t *t2)
{
struct team_t *playing_team;
unsigned int continuer=1;
@@ -419,7 +433,8 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct
SDL_Delay(1000);
- SDL_BlitSurface(surfaces->background, &positions->degats, surfaces->screen, &positions->degats);
+ SDL_BlitSurface(surfaces->background, &positions->degats,
+ surfaces->screen, &positions->degats);
SDL_Flip(surfaces->Pecran);
@@ -433,7 +448,7 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct
break;
}
- // on vérifie à présent si on a gagné ou si on a perdu !
+ /* TODO rewrite */
gagne=1;
perdu=1;
for (i = 0; i < t2->chr_cnt; i++) {
@@ -445,7 +460,6 @@ int Fjouer (SURFACES *surfaces, POSITIONS *positions, struct team_t *t1, struct
perdu=0;
}
- // la y'a des trucs a mettre pour si on gagne ou on perd parce que sa fait assez pitié :p
if(perdu)
{
SDL_Delay(2000);