-impl all potions, and race: drow
This commit is contained in:
28
src/boost_atk.cc
Normal file
28
src/boost_atk.cc
Normal file
@ -0,0 +1,28 @@
|
||||
#include "boost_atk.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const int BOOST_ATK = 5;
|
||||
const int BOOST_ATK_DROW = 7;
|
||||
|
||||
boost_atk::boost_atk():
|
||||
potion{potion_type::boost_atk, -1} {}
|
||||
|
||||
void boost_atk::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &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;
|
||||
}
|
||||
|
||||
|
||||
|
15
src/boost_atk.h
Normal file
15
src/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();
|
||||
void apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
26
src/boost_def.cc
Normal file
26
src/boost_def.cc
Normal file
@ -0,0 +1,26 @@
|
||||
#include "boost_def.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const int BOOST_DEF = 5;
|
||||
const int BOOST_DEF_DROW = 7;
|
||||
|
||||
|
||||
boost_def::boost_def():
|
||||
potion{potion_type::boost_def, -1} {}
|
||||
|
||||
void boost_def::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &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;
|
||||
}
|
14
src/boost_def.h
Normal file
14
src/boost_def.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __BOOST_DEF_H__
|
||||
#define __BOOST_DEF_H__
|
||||
|
||||
#include "potion.h"
|
||||
|
||||
class boost_def final: public potion {
|
||||
public:
|
||||
boost_def();
|
||||
void apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
};
|
||||
|
||||
#endif
|
32
src/drow.cc
Normal file
32
src/drow.cc
Normal file
@ -0,0 +1,32 @@
|
||||
#include "drow.h"
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
drow::drow(RNG &rng, const position_list &available_positions):
|
||||
character{rng, race::rdrow} {
|
||||
pos = available_positions[rng.rand_under(available_positions.size())];
|
||||
gold = 0;
|
||||
hostile = true;
|
||||
}
|
||||
|
||||
result drow::attack(const direction dir, character_list &chlist) {
|
||||
position tmp{pos + MOVE[dir]};
|
||||
|
||||
for (auto &ch : chlist)
|
||||
if (tmp == ch.get_position()) {
|
||||
return ch.get_hit(race, ATK, base_hit_rate);
|
||||
}
|
||||
|
||||
return result::fine;
|
||||
}
|
||||
|
||||
result drow::get_hit(const enum race &race, const int atk,
|
||||
const float hitrate) {
|
||||
if (rng.rand_num() <= hitrate * (float)RAND_MAX)
|
||||
HP = std::max(HP - calc_dmg(atk, DEF), 0);
|
||||
|
||||
if (HP == 0)
|
||||
return result::died;
|
||||
|
||||
return result::hit;
|
||||
}
|
15
src/drow.h
Normal file
15
src/drow.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __DROW_H__
|
||||
#define __DROW_H__
|
||||
#include "characters.h"
|
||||
|
||||
class drow final: public character {
|
||||
public:
|
||||
drow(RNG &rng,
|
||||
const position_list &available_positions);
|
||||
virtual result attack(const direction dir,
|
||||
character_list &chlist) override;
|
||||
virtual result get_hit(const enum race &race, const int atk,
|
||||
const float hit_rate) override;
|
||||
};
|
||||
|
||||
#endif
|
22
src/poison_health.cc
Normal file
22
src/poison_health.cc
Normal file
@ -0,0 +1,22 @@
|
||||
#include "poison_health.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
poison_health::poison_health():
|
||||
potion{potion_type::poison_health, 1} {}
|
||||
|
||||
void poison_health::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &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;
|
||||
}
|
14
src/poison_health.h
Normal file
14
src/poison_health.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __POISON_HEALTH_H__
|
||||
#define __POISON_HEALTH_H__
|
||||
|
||||
#include "potion.h"
|
||||
|
||||
class poison_health final: public potion {
|
||||
public:
|
||||
poison_health();
|
||||
void apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
};
|
||||
|
||||
#endif
|
@ -3,7 +3,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
restore_health::restore_health():
|
||||
potion{potion_type::restore_health, -1} {}
|
||||
potion{potion_type::restore_health, 1} {}
|
||||
|
||||
void restore_health::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &base_hit_rate) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <math.h>
|
||||
|
||||
vampire::vampire(RNG &rng, const position_list &available_positions):
|
||||
character{rng, race::rshade} {
|
||||
character{rng, race::rvampire} {
|
||||
pos = available_positions[rng.rand_under(available_positions.size())];
|
||||
gold = 0;
|
||||
hostile = true;
|
||||
|
26
src/wound_atk.cc
Normal file
26
src/wound_atk.cc
Normal file
@ -0,0 +1,26 @@
|
||||
#include "wound_atk.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const int WOUND_ATK = 5;
|
||||
const int WOUND_ATK_DROW = 7;
|
||||
|
||||
wound_atk::wound_atk():
|
||||
potion{potion_type::wound_atk, -1} {}
|
||||
|
||||
void wound_atk::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &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;
|
||||
}
|
||||
|
14
src/wound_atk.h
Normal file
14
src/wound_atk.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __WOUND_ATK_H__
|
||||
#define __WOUND_ATK_H__
|
||||
|
||||
#include "potion.h"
|
||||
|
||||
class wound_atk final: public potion {
|
||||
public:
|
||||
wound_atk();
|
||||
void apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
};
|
||||
|
||||
#endif
|
25
src/wound_def.cc
Normal file
25
src/wound_def.cc
Normal file
@ -0,0 +1,25 @@
|
||||
#include "wound_def.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
const int WOUND_DEF = 5;
|
||||
const int WOUND_DEF_DROW = 7;
|
||||
|
||||
wound_def::wound_def():
|
||||
potion{potion_type::wound_def, -1} {}
|
||||
|
||||
void wound_def::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &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;
|
||||
}
|
14
src/wound_def.h
Normal file
14
src/wound_def.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __WOUND_DEF_H__
|
||||
#define __WOUND_DEF_H__
|
||||
|
||||
#include "potion.h"
|
||||
|
||||
class wound_def final: public potion {
|
||||
public:
|
||||
wound_def();
|
||||
void apply(enum race &race, int &HP, int &ATK, int &DEF,
|
||||
float &base_hit_rate) override;
|
||||
int get_priority() const override;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user