96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
/*
|
|
* CS 246 Final Project
|
|
* File: map.h
|
|
* Purpose: handles all characters
|
|
*/
|
|
|
|
#ifndef __CHARACTERS_H__
|
|
#define __CHARACTERS_H__
|
|
#include <vector>
|
|
#include <string>
|
|
#include <memory>
|
|
#include <math.h>
|
|
|
|
#include "constants.h"
|
|
#include "position.h"
|
|
#include "potion.h"
|
|
#include "rng.h"
|
|
|
|
// #include "inventory.h" // Reserved for later
|
|
|
|
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 result apply(direction &dir,
|
|
const potion_list &potions);
|
|
virtual result get_hit(const enum race &race, const int atk,
|
|
const float hitrate) = 0;
|
|
|
|
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() 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 float 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;
|
|
|
|
position pos;
|
|
|
|
int gold; // characters spawn with gold
|
|
potion_list potions;// inventory inventory; // Reserved
|
|
|
|
float base_hit_rate; // requires: between [0,1]
|
|
|
|
bool hostile;
|
|
};
|
|
|
|
// requires: all elements of excluded are in sorted_positions
|
|
position_list remove_from_list(const position_list &sorted_positions,
|
|
position_list excluded);
|
|
|
|
|
|
int calc_dmg(const int ATK, const int DEF);
|
|
|
|
#endif
|