From 154004ae6ac3747769648511cdc77e7171c684d8 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 14 Dec 2017 14:09:07 +0100 Subject: The gamelog, being reworking combat. --- src/game/game.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/game/game.hpp') diff --git a/src/game/game.hpp b/src/game/game.hpp index 107bfbf..55e3c45 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -59,6 +59,7 @@ namespace game { } type_t; type_t type; + std::string name; unit_t(game::state_t *game_, type_t type_); @@ -88,12 +89,13 @@ namespace game { bool dead = false; double death_time = -INFINITY; int health = 1, max_health = 1; - void damage(int points); + void damage(int points, unit_t *attacker); + void try_attack(unit_t *target); virtual void die() = 0; - const wchar_t *say_text; + std::string say_text; double say_time = -INFINITY; - void say(const wchar_t *wstr); + void say(std::string str); void render_to(render::state_t *render); @@ -124,4 +126,14 @@ namespace game { void think(void); void die(void); }; + + static inline size_t roll(size_t count, size_t sides) + { + size_t total = 0; + + for (size_t i = 0; i < count; i++) + total += rand() % sides + 1; + + return total; + } }; -- cgit