finished the bulk of game
This commit is contained in:
30
src/potions/boost_atk.cc
Normal file
30
src/potions/boost_atk.cc
Normal file
@ -0,0 +1,30 @@
|
||||
#include "boost_atk.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../constants.h"
|
||||
|
||||
const int BOOST_ATK = 5;
|
||||
const int BOOST_ATK_DROW = 7;
|
||||
|
||||
boost_atk::boost_atk(const position &pos):
|
||||
potion{potion_type::boost_atk, -1, pos} {}
|
||||
|
||||
void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) {
|
||||
if (remaining_duration > 0) {
|
||||
if (race == rdrow)
|
||||
ATK += BOOST_ATK_DROW;
|
||||
else
|
||||
ATK += BOOST_ATK;
|
||||
|
||||
--remaining_duration;
|
||||
}
|
||||
}
|
||||
|
||||
int boost_atk::get_priority() const {
|
||||
return CALC_ADD_BASE;
|
||||
}
|
||||
|
||||
const char *boost_atk::get_name() const {
|
||||
return "BA";
|
||||
}
|
15
src/potions/boost_atk.h
Normal file
15
src/potions/boost_atk.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __BOOST_ATK_H__
|
||||
#define __BOOST_ATK_H__
|
||||
|
||||
#include "../potion.h"
|
||||
|
||||
class boost_atk final: public potion {
|
||||
public:
|
||||
boost_atk(const position &pos);
|
||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
const char *get_name() const override;
|
||||
};
|
||||
|
||||
#endif
|
31
src/potions/boost_def.cc
Normal file
31
src/potions/boost_def.cc
Normal file
@ -0,0 +1,31 @@
|
||||
#include "boost_def.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../constants.h"
|
||||
|
||||
// TODO: move into class def as static constants
|
||||
const int BOOST_DEF = 5;
|
||||
const int BOOST_DEF_DROW = 7;
|
||||
|
||||
boost_def::boost_def(const position &pos):
|
||||
potion{potion_type::boost_def, -1, pos} {}
|
||||
|
||||
void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) {
|
||||
if (remaining_duration > 0) {
|
||||
if (race == rdrow)
|
||||
DEF += BOOST_DEF_DROW;
|
||||
else
|
||||
DEF += BOOST_DEF;
|
||||
|
||||
--remaining_duration;
|
||||
}
|
||||
}
|
||||
|
||||
int boost_def::get_priority() const {
|
||||
return CALC_ADD_BASE;
|
||||
}
|
||||
|
||||
const char *boost_def::get_name() const {
|
||||
return "BD";
|
||||
}
|
15
src/potions/boost_def.h
Normal file
15
src/potions/boost_def.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __BOOST_DEF_H__
|
||||
#define __BOOST_DEF_H__
|
||||
|
||||
#include "../potion.h"
|
||||
|
||||
class boost_def final: public potion {
|
||||
public:
|
||||
boost_def(const position &pos);
|
||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
const char *get_name() const override;
|
||||
};
|
||||
|
||||
#endif
|
27
src/potions/poison_health.cc
Normal file
27
src/potions/poison_health.cc
Normal file
@ -0,0 +1,27 @@
|
||||
#include "poison_health.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../constants.h"
|
||||
|
||||
poison_health::poison_health(const position &pos):
|
||||
potion{potion_type::poison_health, 1, pos} {}
|
||||
|
||||
void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) {
|
||||
if (remaining_duration > 0) {
|
||||
if (race == rdrow)
|
||||
HP = std::max(HP - 7, 0);
|
||||
else
|
||||
HP = std::max(HP - 5, 0);
|
||||
|
||||
--remaining_duration;
|
||||
}
|
||||
}
|
||||
|
||||
int poison_health::get_priority() const {
|
||||
return CALC_ADD_BASE;
|
||||
}
|
||||
|
||||
const char *poison_health::get_name() const {
|
||||
return "PH";
|
||||
}
|
15
src/potions/poison_health.h
Normal file
15
src/potions/poison_health.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __POISON_HEALTH_H__
|
||||
#define __POISON_HEALTH_H__
|
||||
|
||||
#include "../potion.h"
|
||||
|
||||
class poison_health final: public potion {
|
||||
public:
|
||||
poison_health(const position &pos);
|
||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
const char *get_name() const override;
|
||||
};
|
||||
|
||||
#endif
|
27
src/potions/restore_health.cc
Normal file
27
src/potions/restore_health.cc
Normal file
@ -0,0 +1,27 @@
|
||||
#include "restore_health.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../constants.h"
|
||||
|
||||
restore_health::restore_health(const position &pos):
|
||||
potion{potion_type::restore_health, -1, pos} {}
|
||||
|
||||
void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) {
|
||||
if (remaining_duration > 0) {
|
||||
if (race == rdrow)
|
||||
HP = std::min(HP + 7, MAX_HP[race]);
|
||||
else
|
||||
HP = std::min(HP + 5, MAX_HP[race]);
|
||||
|
||||
--remaining_duration;
|
||||
}
|
||||
}
|
||||
|
||||
int restore_health::get_priority() const {
|
||||
return CALC_ADD_BASE;
|
||||
}
|
||||
|
||||
const char *restore_health::get_name() const {
|
||||
return "RH";
|
||||
}
|
15
src/potions/restore_health.h
Normal file
15
src/potions/restore_health.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __RESTORE_HEALTH_H__
|
||||
#define __RESTORE_HEALTH_H__
|
||||
|
||||
#include "../potion.h"
|
||||
|
||||
class restore_health final: public potion {
|
||||
public:
|
||||
restore_health(const position &pos);
|
||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
const char *get_name() const override;
|
||||
};
|
||||
|
||||
#endif
|
30
src/potions/wound_atk.cc
Normal file
30
src/potions/wound_atk.cc
Normal file
@ -0,0 +1,30 @@
|
||||
#include "wound_atk.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../constants.h"
|
||||
|
||||
const int WOUND_ATK = 5;
|
||||
const int WOUND_ATK_DROW = 7;
|
||||
|
||||
wound_atk::wound_atk(const position &pos):
|
||||
potion{potion_type::wound_atk, -1, pos} {}
|
||||
|
||||
void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) {
|
||||
if (remaining_duration > 0) {
|
||||
if (race == rdrow)
|
||||
ATK = std::max(ATK - WOUND_ATK_DROW, 0);
|
||||
else
|
||||
ATK = std::max(ATK - WOUND_ATK, 0);
|
||||
|
||||
--remaining_duration;
|
||||
}
|
||||
}
|
||||
|
||||
int wound_atk::get_priority() const {
|
||||
return CALC_ADD_BASE;
|
||||
}
|
||||
|
||||
const char *wound_atk::get_name() const {
|
||||
return "WA";
|
||||
}
|
15
src/potions/wound_atk.h
Normal file
15
src/potions/wound_atk.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __WOUND_ATK_H__
|
||||
#define __WOUND_ATK_H__
|
||||
|
||||
#include "../potion.h"
|
||||
|
||||
class wound_atk final: public potion {
|
||||
public:
|
||||
wound_atk(const position &pos);
|
||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
const char *get_name() const override;
|
||||
};
|
||||
|
||||
#endif
|
30
src/potions/wound_def.cc
Normal file
30
src/potions/wound_def.cc
Normal file
@ -0,0 +1,30 @@
|
||||
#include "wound_def.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "../constants.h"
|
||||
|
||||
const int WOUND_DEF = 5;
|
||||
const int WOUND_DEF_DROW = 7;
|
||||
|
||||
wound_def::wound_def(const position &pos):
|
||||
potion{potion_type::wound_def, -1, pos} {}
|
||||
|
||||
void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) {
|
||||
if (remaining_duration > 0) {
|
||||
if (race == rdrow)
|
||||
DEF = std::max(DEF - WOUND_DEF_DROW, 0);
|
||||
else
|
||||
DEF = std::max(DEF - WOUND_DEF, 0);
|
||||
|
||||
--remaining_duration;
|
||||
}
|
||||
}
|
||||
|
||||
int wound_def::get_priority() const {
|
||||
return CALC_ADD_BASE;
|
||||
}
|
||||
|
||||
const char *wound_def::get_name() const {
|
||||
return "WD";
|
||||
}
|
15
src/potions/wound_def.h
Normal file
15
src/potions/wound_def.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __WOUND_DEF_H__
|
||||
#define __WOUND_DEF_H__
|
||||
|
||||
#include "../potion.h"
|
||||
|
||||
class wound_def final: public potion {
|
||||
public:
|
||||
wound_def(const position &pos);
|
||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||
fraction &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
const char *get_name() const override;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user