added item base class for gold and potions

This commit is contained in:
2024-07-18 12:54:41 -04:00
parent 8704fdb7aa
commit dfea74ed42
9 changed files with 51 additions and 65 deletions

View File

@ -3,7 +3,7 @@
#include "constants.h"
potion::potion(const potion_type type, const int duration, const position &pos):
type{type}, remaining_duration{duration}, pos{pos} {}
item{pos}, type{type}, remaining_duration{duration} {}
potion_type potion::get_type() const {
return type;
@ -13,37 +13,7 @@ int potion::get_duration() const {
return remaining_duration;
}
position potion::get_pos() const {
return pos;
}
void potion::set_pos(const position &npos) {
pos = npos;
}
potion::potion(const potion &p):
type(p.type), remaining_duration(p.remaining_duration),
pos{p.pos} {}
potion::potion(potion &&p):
type(p.type), remaining_duration(p.remaining_duration),
pos{p.pos} {}
potion &potion::operator=(const potion &p) {
type = p.type;
remaining_duration = p.remaining_duration;
pos = p.pos;
return *this;
}
potion &potion::operator=(potion &&p) {
type = p.type;
remaining_duration = p.remaining_duration;
pos = p.pos;
return *this;
}
void potion::print(output *out) {
void potion::print(output *out) const {
out->print_char(pos, 'P', COLOR_PAIR(COLOR_GREEN));
}