76 lines
1.8 KiB
C++
76 lines
1.8 KiB
C++
#ifndef __CHARACTERS_H__
|
|
#define __CHARACTERS_H__
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <math.h>
|
|
|
|
#include "display.h"
|
|
#include "fraction.h"
|
|
#include "position.h"
|
|
#include "potions.h"
|
|
#include "gold.h"
|
|
#include "rng.h"
|
|
|
|
class level;
|
|
typedef unsigned int feature;
|
|
struct long_result;
|
|
enum result : int;
|
|
|
|
class character {
|
|
public:
|
|
character(RNG *rng, const feature enabled_features,
|
|
const race &nrace, const position &pos); // fills out the starting stats
|
|
|
|
virtual long_result move(level *lvl, const position &p);
|
|
|
|
virtual long_result attack(character *ch) = 0;
|
|
virtual long_result get_hit(character *ch, const int tATK,
|
|
const fraction &hit_rate) = 0;
|
|
|
|
virtual void apply_effect(potion *effect);
|
|
|
|
// override for different types
|
|
virtual void print(display *out) = 0;
|
|
|
|
result calc_effects();
|
|
void discard_level_effects();
|
|
virtual void start_turn();
|
|
|
|
virtual const char *get_race_name() const = 0;
|
|
enum race get_race() const;
|
|
position get_pos() const;
|
|
virtual std::string get_abbrev() const = 0;
|
|
void set_pos(const position &npos);
|
|
|
|
bool is_dead() const;
|
|
|
|
protected:
|
|
RNG *rng;
|
|
|
|
const feature enabled_features;
|
|
const enum race race;
|
|
|
|
int HP;
|
|
position pos;
|
|
|
|
// IMPORTANT: keep track at turn time
|
|
int ATK;
|
|
int DEF;
|
|
fraction base_hit_rate;
|
|
fraction base_hit_rate_reset;
|
|
|
|
potion_list effects;
|
|
|
|
private:
|
|
void insert_effect(potion *effect);
|
|
};
|
|
|
|
int calc_dmg(const int ATK, const int DEF);
|
|
|
|
typedef std::vector<character *> character_list;
|
|
|
|
character *get_ch_at(const position &pos, const character_list &chlist);
|
|
|
|
#endif
|