91 lines
2.9 KiB
C++
91 lines
2.9 KiB
C++
#ifndef __CHARACTERS_H__
|
|
#define __CHARACTERS_H__
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <math.h>
|
|
|
|
#include "constants.h"
|
|
#include "fraction.h"
|
|
#include "position.h"
|
|
#include "potions.h"
|
|
#include "gold.h"
|
|
#include "rng.h"
|
|
|
|
class character; // forward declaration
|
|
|
|
// Note: player should not be in the character list
|
|
typedef std::vector<character> character_list;
|
|
|
|
class character {
|
|
public:
|
|
character(RNG *rng, const race &nrace); // fills out the starting stats
|
|
|
|
// usually I wouldn't do this but considering that the map has
|
|
// a super small size an O(n) solution is acceptable
|
|
// IMPORTANT: available_positions do NOT have characters in them
|
|
direction_list moveable(const position_list &available_positions) const;
|
|
virtual result move(const direction dir,
|
|
const position_list &available_positions);
|
|
virtual result attack(const direction dir,
|
|
character_list &chlist) = 0;
|
|
virtual result move_or_attack(const direction dir,
|
|
const position_list &available_positions,
|
|
character_list &chlist);
|
|
virtual void apply(direction &dir,
|
|
potion_list &potions);
|
|
virtual result get_hit(const enum race &race, const int atk,
|
|
const fraction hitrate) = 0;
|
|
result apply_effects();
|
|
void discard_level_effects();
|
|
void start_turn();
|
|
|
|
enum race get_race() const;
|
|
position get_position() const;
|
|
int get_HP() const;
|
|
int get_ATK() const;
|
|
int get_DEF() const;
|
|
int get_gold() const;
|
|
float get_hitrate_real() const;
|
|
fraction get_hitrate() const;
|
|
bool is_hostile() const;
|
|
|
|
void set_position(const position &npos);
|
|
void set_HP(const int nHP);
|
|
void set_ATK(const int nATK);
|
|
void set_DEF(const int nDEF);
|
|
void set_gold(const int ngold);
|
|
void set_hitrate(const fraction nhitrate);
|
|
void set_hostile(const bool is_hostile);
|
|
|
|
// if stat is hostile, positive to set it to hostile,
|
|
// negative to set it to peaceful
|
|
void apply_buff(const stat_name statn, const int amount);
|
|
// void apply_buff(const stat_name statn, const float mul);
|
|
// reserved for later
|
|
protected:
|
|
RNG *rng;
|
|
const enum race race;
|
|
|
|
int HP;
|
|
|
|
// IMPORTANT: keep track of ATK and DEF in game at turn time
|
|
int ATK;
|
|
int DEF;
|
|
fraction base_hit_rate;
|
|
|
|
position pos;
|
|
|
|
int gold; // characters spawn with gold
|
|
potion_list potions; // inventory
|
|
potion_list effects; // applied potions
|
|
|
|
bool hostile;
|
|
private:
|
|
void insert_potion(potion *p);
|
|
};
|
|
|
|
int calc_dmg(const int ATK, const int DEF);
|
|
|
|
#endif
|