summaryrefslogtreecommitdiff
path: root/character.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 /character.c
parentd590bfdcdfa8799439cffa41fc74346e9923b6e7 (diff)
coding rules: stop at 78 colsrewrite
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'character.c')
-rw-r--r--character.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/character.c b/character.c
index 4a3a260..2b4be4e 100644
--- a/character.c
+++ b/character.c
@@ -2,57 +2,65 @@
#include "players.h"
#include "blits.h"
-static void incr_hp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int incr)
+static void
+incr_hp(SURFACES *surfaces, POSITIONS *positions, struct chr_t *chr, int incr)
{
SDL_Color color;
- target->hp += incr;
+ chr->hp += incr;
- if (target->hp <= 0) {
- target->hp = 0;
- target->alive = false;
- } else if (target->hp > target->max_hp) {
- target->hp = target->max_hp;
+ if (chr->hp <= 0) {
+ chr->hp = 0;
+ chr->alive = false;
+ } else if (chr->hp > chr->max_hp) {
+ chr->hp = chr->max_hp;
}
- color = (incr < 0) ? (SDL_Color){0xe0, 0x00, 0x00, 0x00} : (SDL_Color){0x00, 0xe0, 0x00, 0x00};
+ if (incr < 0) {
+ color = (SDL_Color){0xe0, 0x00, 0x00, 0x00};
+ } else {
+ color = (SDL_Color){0x00, 0xe0, 0x00, 0x00};
+ }
- display_incr(surfaces, positions, target, (incr >= 0) ? incr : -incr, color);
+ display_incr(surfaces, positions, chr, (incr >= 0) ? incr : -incr, color);
}
-static void incr_mp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int incr)
+static void
+incr_mp(SURFACES *surfaces, POSITIONS *positions, struct chr_t *chr, int incr)
{
SDL_Color color;
- target->hp += incr;
+ chr->hp += incr;
- if (target->mp <= 0) {
- target->mp = 0;
- } else if (target->mp > target->max_mp) {
- target->mp = target->max_mp;
+ if (chr->mp <= 0) {
+ chr->mp = 0;
+ } else if (chr->mp > chr->max_mp) {
+ chr->mp = chr->max_mp;
}
- color = (incr < 0) ? (SDL_Color){0xe0, 0x00, 0x00, 0x00} : (SDL_Color){0x00, 0xe0, 0x00, 0x00};
-
- display_incr(surfaces, positions, target, (incr >= 0) ? incr : -incr, color);
+ display_incr(surfaces, positions, chr, (incr >= 0) ? incr : -incr, color);
}
-void damage_target_hp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int damages)
+void damage_target_hp(SURFACES *surfaces, POSITIONS *positions,
+ struct chr_t *target, int damages)
{
incr_hp(surfaces, positions, target, -damages);
}
-void cure_target_hp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int cure)
+void cure_target_hp(SURFACES *surfaces, POSITIONS *positions,
+ struct chr_t *target, int cure)
{
incr_hp(surfaces, positions, target, cure);
}
-void damage_target_mp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int damages)
+void damage_target_mp(SURFACES *surfaces, POSITIONS *positions,
+ struct chr_t *target, int damages)
{
incr_mp(surfaces, positions, target, -damages);
}
-void cure_target_mp(SURFACES *surfaces, POSITIONS *positions, struct character_t *target, int cure)
+void cure_target_mp(SURFACES *surfaces, POSITIONS *positions,
+ struct chr_t *target, int cure)
{
incr_mp(surfaces, positions, target, cure);
}