adg5/Destructible.h
2025-04-21 22:47:44 +10:00

45 lines
1.2 KiB
C++

#pragma once
#include <string>
#include "libtcod.hpp"
#include "Persistance.h"
class Actor;
class Destructible : public Persistent {
public:
float maxHp; // maximum health points
float hp; // current health points
float defense; // hit points deflected
std::string corpseName; // the actor's name once dead/destroyed
Destructible(float maxHp, float defense, std::string corpseName, int xp);
virtual ~Destructible() {};
inline bool isDead() { return hp <= 0; }
float takeDamage(Actor* owner, float damage);
virtual void die(Actor* owner);
float heal(float amount);
void load(TCODZip& zip);
void save(TCODZip& zip);
static Destructible* create(TCODZip& zip);
int xp; // XP gained when killing this monster (or player xp)
protected:
enum DestructibleType {
MONSTER, PLAYER
};
};
class MonsterDestructible : public Destructible {
public:
MonsterDestructible(float maxHp, float defense, std::string corpseName, int xp);
void save(TCODZip& zip);
void die(Actor* owner);
};
class PlayerDestructible : public Destructible {
public:
PlayerDestructible(float maxHp, float defense, std::string corpseName);
void save(TCODZip& zip);
void die(Actor* owner);
};