added potion and restore_health

This commit is contained in:
2024-07-11 21:32:23 -04:00
parent ae5cd1e0c6
commit 0312986dce
7 changed files with 102 additions and 33 deletions

30
src/potion.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef __POTIONS_H__
#define __POTIONS_H__
#include <vector>
#include "constants.h"
// IMPORTANT: pop all potions of duration == 0, and when entering a
// new level, pop all potions of duration == -1
class potion {
protected:
// Use -1 to denote that the effect will last until leaving the level
// Otherwise, use a positive number
// Single use potions have a starting duration of 1
const potion_type type;
int remaining_duration;
public:
potion(const potion_type type, const int duration);
// apply decrements remaining_duration if it's positive, and
// won't do anything if it's non-negative
virtual void apply(enum race &race, int &HP, int &ATK, int &DEF,
float &base_hit_rate) = 0;
virtual int get_priority() const = 0;
potion_type get_type() const;
int get_duration() const;
};
typedef std::vector<potion> potion_list;
#endif