merged AL-races
This commit is contained in:
@ -7,7 +7,6 @@
|
||||
#include "input.h"
|
||||
#include "rng.h"
|
||||
|
||||
|
||||
#include "constants.h"
|
||||
|
||||
// IMPORTANT: Errors include the index that caused them (or'ed into them)
|
||||
|
25
src/boost_atk.cc
Normal file
25
src/boost_atk.cc
Normal file
@ -0,0 +1,25 @@
|
||||
#include "boost_atk.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
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;
|
||||
}
|
14
src/boost_atk.h
Normal file
14
src/boost_atk.h
Normal file
@ -0,0 +1,14 @@
|
||||
#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;
|
||||
};
|
||||
|
||||
#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>
|
||||
|
||||
// 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;
|
||||
}
|
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(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;
|
||||
};
|
||||
|
||||
#endif
|
@ -54,6 +54,13 @@ int character::get_room_num() const {
|
||||
return room_num;
|
||||
}
|
||||
|
||||
<<< <<< < HEAD
|
||||
== == == =
|
||||
bool character::is_hostile() const {
|
||||
return hostile;
|
||||
}
|
||||
|
||||
>>> >>> > AL - races
|
||||
void character::set_room_num(const int room) {
|
||||
room_num = room;
|
||||
}
|
||||
@ -82,6 +89,39 @@ void character::set_hitrate(const fraction nhitrate) {
|
||||
base_hit_rate = nhitrate;
|
||||
}
|
||||
|
||||
<<< <<< < HEAD
|
||||
== == == =
|
||||
void character::set_hostile(const bool is_hostile) {
|
||||
hostile = is_hostile;
|
||||
}
|
||||
|
||||
void character::apply_buff(const stat_name statn, const int amount) {
|
||||
// TODO: add checks for bounds
|
||||
switch (statn) {
|
||||
case stat_name::HP:
|
||||
HP += amount;
|
||||
break;
|
||||
|
||||
case stat_name::ATK:
|
||||
ATK += amount;
|
||||
break;
|
||||
|
||||
case stat_name::DEF:
|
||||
DEF += amount;
|
||||
break;
|
||||
|
||||
case stat_name::hostile: {
|
||||
if (amount > 0)
|
||||
hostile = true;
|
||||
else
|
||||
hostile = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
>>> >>> > AL - races
|
||||
direction_list character::moveable(const position_list &available_positions)
|
||||
const {
|
||||
direction_list result;
|
||||
@ -164,4 +204,3 @@ result character::move(const direction dir,
|
||||
int calc_dmg(const int ATK, const int DEF) {
|
||||
return ceil((100.0f / (100.0f + DEF)) * ATK);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <utility>
|
||||
#include <ncurses.h>
|
||||
|
||||
|
||||
console_output::console_output(std::ostream &cout): out{cout} {}
|
||||
|
||||
/* Attributes
|
||||
|
@ -67,8 +67,6 @@ const int CALC_ADD_LATER = 2;
|
||||
const int CALC_MUL_LATER = 3;
|
||||
const int CALC_ADD_FIXED = 4;
|
||||
|
||||
|
||||
|
||||
const int DIRECTION_CNT = 8;
|
||||
// IMPORTANT: east is positive for x and SOUTH is positive for y
|
||||
// initializes all directions to an int
|
||||
|
31
src/drow.cc
Normal file
31
src/drow.cc
Normal file
@ -0,0 +1,31 @@
|
||||
#include "drow.h"
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
drow::drow(RNG *rng, const position &pos):
|
||||
character{rng, race::rdrow, pos} {
|
||||
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 fraction hitrate) {
|
||||
if (rng->trial(hitrate))
|
||||
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 &pos);
|
||||
virtual result attack(const direction dir,
|
||||
character_list &chlist) override;
|
||||
virtual result get_hit(const enum race &race, const int atk,
|
||||
const fraction hit_rate) override;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,6 +1,5 @@
|
||||
#include "input.h"
|
||||
|
||||
|
||||
const char *COMMANDS[] = {
|
||||
"no", "so", "ea", "we", "ne", "nw", "se", "sw"
|
||||
};
|
||||
|
@ -10,7 +10,6 @@ int main(int argc, char **argv) {
|
||||
std::unique_ptr<logger> log;
|
||||
std::unique_ptr<RNG> rng;
|
||||
|
||||
|
||||
feature enabled_features = proc_args(argc, argv,
|
||||
curse, in, out, log, rng);
|
||||
|
||||
|
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(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;
|
||||
}
|
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(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;
|
||||
};
|
||||
|
||||
#endif
|
4
src/room.h
Normal file
4
src/room.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef __ROOM_H__
|
||||
#define __ROOM_H__
|
||||
|
||||
#endif
|
@ -6,7 +6,6 @@
|
||||
shade::shade(RNG *rng, const position &pos):
|
||||
character{rng, race::rshade, pos} {
|
||||
gold = 0;
|
||||
hostile = true;
|
||||
}
|
||||
|
||||
character::attack_result shade::attack(const direction dir,
|
||||
@ -51,4 +50,3 @@ character::hit_result shade::get_hit(const enum race &race, const int atk,
|
||||
|
||||
return {result::miss, 0, HP};
|
||||
}
|
||||
|
||||
|
25
src/wound_atk.cc
Normal file
25
src/wound_atk.cc
Normal file
@ -0,0 +1,25 @@
|
||||
#include "wound_atk.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
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;
|
||||
}
|
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(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;
|
||||
};
|
||||
|
||||
#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(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;
|
||||
}
|
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(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;
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user