Merge branch 'AL/add-feat'
This commit is contained in:
@ -20,6 +20,7 @@ protected:
|
|||||||
potion_type type;
|
potion_type type;
|
||||||
int remaining_duration;
|
int remaining_duration;
|
||||||
position pos;
|
position pos;
|
||||||
|
constexpr static const float DROW_POTION_MUL = 1.5f;
|
||||||
public:
|
public:
|
||||||
potion(const potion &p);
|
potion(const potion &p);
|
||||||
potion(potion &&p);
|
potion(potion &&p);
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
const int BOOST_ATK = 5;
|
|
||||||
const int BOOST_ATK_DROW = 7;
|
|
||||||
|
|
||||||
boost_atk::boost_atk(const position &pos):
|
boost_atk::boost_atk(const position &pos):
|
||||||
potion{potion_type::boost_atk, -1, pos} {}
|
potion{potion_type::boost_atk, -1, pos} {}
|
||||||
@ -12,11 +11,9 @@ boost_atk::boost_atk(const position &pos):
|
|||||||
void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void boost_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
fraction &base_hit_rate) {
|
fraction &base_hit_rate) {
|
||||||
if (remaining_duration != 0) {
|
if (remaining_duration != 0) {
|
||||||
if (race == rdrow)
|
int tmp = BOOST_ATK;
|
||||||
ATK += BOOST_ATK_DROW;
|
if (race == rdrow) tmp *= DROW_POTION_MUL;
|
||||||
else
|
ATK += tmp;
|
||||||
ATK += BOOST_ATK;
|
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../potion.h"
|
#include "../potion.h"
|
||||||
|
|
||||||
class boost_atk final: public potion {
|
class boost_atk final: public potion {
|
||||||
|
static const int BOOST_ATK = 5;
|
||||||
public:
|
public:
|
||||||
boost_atk(const position &pos);
|
boost_atk(const position &pos);
|
||||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../constants.h"
|
#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):
|
boost_def::boost_def(const position &pos):
|
||||||
potion{potion_type::boost_def, -1, pos} {}
|
potion{potion_type::boost_def, -1, pos} {}
|
||||||
@ -13,11 +10,9 @@ boost_def::boost_def(const position &pos):
|
|||||||
void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void boost_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
fraction &base_hit_rate) {
|
fraction &base_hit_rate) {
|
||||||
if (remaining_duration != 0) {
|
if (remaining_duration != 0) {
|
||||||
if (race == rdrow)
|
int tmp = BOOST_DEF;
|
||||||
DEF += BOOST_DEF_DROW;
|
if (race == rdrow) tmp *= DROW_POTION_MUL;
|
||||||
else
|
DEF += tmp;
|
||||||
DEF += BOOST_DEF;
|
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../potion.h"
|
#include "../potion.h"
|
||||||
|
|
||||||
class boost_def final: public potion {
|
class boost_def final: public potion {
|
||||||
|
static const int BOOST_DEF = 5;
|
||||||
public:
|
public:
|
||||||
boost_def(const position &pos);
|
boost_def(const position &pos);
|
||||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
|
@ -9,11 +9,9 @@ poison_health::poison_health(const position &pos):
|
|||||||
void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void poison_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
fraction &base_hit_rate) {
|
fraction &base_hit_rate) {
|
||||||
if (remaining_duration != 0) {
|
if (remaining_duration != 0) {
|
||||||
if (race == rdrow)
|
int tmp = LOSE_HEALTH;
|
||||||
HP = std::max(HP - 7, 0);
|
if (race == rdrow) tmp *= DROW_POTION_MUL;
|
||||||
else
|
HP = std::max(HP - tmp, 0);
|
||||||
HP = std::max(HP - 5, 0);
|
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../potion.h"
|
#include "../potion.h"
|
||||||
|
|
||||||
class poison_health final: public potion {
|
class poison_health final: public potion {
|
||||||
|
static const int LOSE_HEALTH = 5;
|
||||||
public:
|
public:
|
||||||
poison_health(const position &pos);
|
poison_health(const position &pos);
|
||||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
|
@ -9,11 +9,9 @@ restore_health::restore_health(const position &pos):
|
|||||||
void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void restore_health::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
fraction &base_hit_rate) {
|
fraction &base_hit_rate) {
|
||||||
if (remaining_duration != 0) {
|
if (remaining_duration != 0) {
|
||||||
if (race == rdrow)
|
int tmp = GAIN_HEALTH;
|
||||||
HP = std::min(HP + 7, MAX_HP[race]);
|
if (race == rdrow) tmp *= DROW_POTION_MUL;
|
||||||
else
|
HP = std::min(HP + tmp, MAX_HP[race]);
|
||||||
HP = std::min(HP + 5, MAX_HP[race]);
|
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../potion.h"
|
#include "../potion.h"
|
||||||
|
|
||||||
class restore_health final: public potion {
|
class restore_health final: public potion {
|
||||||
|
static const int GAIN_HEALTH = 5;
|
||||||
public:
|
public:
|
||||||
restore_health(const position &pos);
|
restore_health(const position &pos);
|
||||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
|
@ -12,11 +12,9 @@ wound_atk::wound_atk(const position &pos):
|
|||||||
void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void wound_atk::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
fraction &base_hit_rate) {
|
fraction &base_hit_rate) {
|
||||||
if (remaining_duration != 0) {
|
if (remaining_duration != 0) {
|
||||||
if (race == rdrow)
|
int tmp = WOUND_ATK;
|
||||||
ATK = std::max(ATK - WOUND_ATK_DROW, 0);
|
if (race == rdrow) tmp *= DROW_POTION_MUL;
|
||||||
else
|
ATK = std::max(ATK - tmp, 0);
|
||||||
ATK = std::max(ATK - WOUND_ATK, 0);
|
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../potion.h"
|
#include "../potion.h"
|
||||||
|
|
||||||
class wound_atk final: public potion {
|
class wound_atk final: public potion {
|
||||||
|
static const int WOUND_ATK = 5;
|
||||||
public:
|
public:
|
||||||
wound_atk(const position &pos);
|
wound_atk(const position &pos);
|
||||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
|
|
||||||
const int WOUND_DEF = 5;
|
|
||||||
const int WOUND_DEF_DROW = 7;
|
|
||||||
|
|
||||||
wound_def::wound_def(const position &pos):
|
wound_def::wound_def(const position &pos):
|
||||||
potion{potion_type::wound_def, -1, pos} {}
|
potion{potion_type::wound_def, -1, pos} {}
|
||||||
@ -12,11 +10,9 @@ wound_def::wound_def(const position &pos):
|
|||||||
void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void wound_def::apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
fraction &base_hit_rate) {
|
fraction &base_hit_rate) {
|
||||||
if (remaining_duration != 0) {
|
if (remaining_duration != 0) {
|
||||||
if (race == rdrow)
|
int tmp = WOUND_DEF;
|
||||||
DEF = std::max(DEF - WOUND_DEF_DROW, 0);
|
if (race == rdrow) tmp *= DROW_POTION_MUL;
|
||||||
else
|
DEF = std::max(DEF - tmp, 0);
|
||||||
DEF = std::max(DEF - WOUND_DEF, 0);
|
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../potion.h"
|
#include "../potion.h"
|
||||||
|
|
||||||
class wound_def final: public potion {
|
class wound_def final: public potion {
|
||||||
|
static const int WOUND_DEF = 5;
|
||||||
public:
|
public:
|
||||||
wound_def(const position &pos);
|
wound_def(const position &pos);
|
||||||
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
void apply(const enum race &race, int &HP, int &ATK, int &DEF,
|
||||||
|
Reference in New Issue
Block a user