added T-800 as playable character

This commit is contained in:
2024-07-15 19:33:32 -04:00
parent 1ebdd2d162
commit 991ab34ca2
8 changed files with 56 additions and 13 deletions

View File

@ -9,12 +9,12 @@ character::character(RNG *rng, const feature enabled_features,
rng{rng}, enabled_features{enabled_features}, rng{rng}, enabled_features{enabled_features},
race{nrace}, HP{STARTING_HP[race]}, pos{pos}, race{nrace}, HP{STARTING_HP[race]}, pos{pos},
ATK{STARTING_ATK[race]}, DEF{STARTING_DEF[race]}, ATK{STARTING_ATK[race]}, DEF{STARTING_DEF[race]},
base_hit_rate{1, 1}, base_hit_rate_reset{1, 1} {} base_hit_rate{STARTING_HR[race]} {}
void character::start_turn() { void character::start_turn() {
ATK = STARTING_ATK[race]; ATK = STARTING_ATK[race];
DEF = STARTING_DEF[race]; DEF = STARTING_DEF[race];
base_hit_rate = base_hit_rate_reset; base_hit_rate = STARTING_HR[race];
} }
enum race character::get_race() const { enum race character::get_race() const {

View File

@ -56,7 +56,6 @@ protected:
int ATK; int ATK;
int DEF; int DEF;
fraction base_hit_rate; fraction base_hit_rate;
fraction base_hit_rate_reset;
potion_list effects; potion_list effects;

View File

@ -4,6 +4,7 @@
#include <ncurses.h> #include <ncurses.h>
#include <string> #include <string>
#include "position.h" #include "position.h"
#include "fraction.h"
static const int INF = 0x3F3F3F3F; static const int INF = 0x3F3F3F3F;
@ -41,27 +42,33 @@ enum game_command : int {game_command_terminate = 0,
}; };
// Character generation related // Character generation related
static const int RACE_CNT = 12; static const int RACE_CNT = 13;
enum race : int {rshade = 0, rdrow, rvampire, rtroll, enum race : int {rshade = 0, rdrow, rvampire, rtroll,
rgoblin, rhuman, rdwarf, relf, rgoblin, rhuman, rdwarf, relf,
rorc, rmerchant, rdragon, rhalfling rorc, rmerchant, rdragon, rhalfling,
rt_800
}; };
static const char CHAR_REP[RACE_CNT] = { static const char CHAR_REP[RACE_CNT] = {
's', 'd', 'v', 't', 'g', 'H', 'W', 'E', 'O', 'M', 'D', 'L' 's', 'd', 'v', 't', 'g', 'H', 'W', 'E', 'O', 'M', 'D', 'L', 't'
}; };
static const int MAX_HP[RACE_CNT] = { static const int MAX_HP[RACE_CNT] = {
125, 150, INF, 120, 110, 140, 100, 140, 180, 30, 150, 100 125, 150, INF, 120, 110, 140, 100, 140, 180, 30, 150, 100, 500
}; };
static const int STARTING_HP[RACE_CNT] = { static const int STARTING_HP[RACE_CNT] = {
125, 150, 50, 120, 110, 140, 100, 140, 180, 30, 150, 100 125, 150, 50, 120, 110, 140, 100, 140, 180, 30, 150, 100, 500
}; };
static const int STARTING_ATK[RACE_CNT] = { static const int STARTING_ATK[RACE_CNT] = {
25, 25, 25, 25, 15, 20, 20, 30, 30, 70, 20, 15 25, 25, 25, 25, 15, 20, 20, 30, 30, 70, 20, 15, 40
}; };
static const int STARTING_DEF[RACE_CNT] = { static const int STARTING_DEF[RACE_CNT] = {
25, 15, 25, 15, 20, 20, 30, 10, 25, 5, 20, 20 25, 15, 25, 15, 20, 20, 30, 10, 25, 5, 20, 20, 50
};
static const fraction STARTING_HR[RACE_CNT] = {
{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},
{1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
{1, 1}
}; };

View File

@ -8,9 +8,7 @@ enemy_base::enemy_base(RNG *rng, const feature enabled_features,
const enum race &nrace, const position &pos, const enum race &nrace, const position &pos,
const int gen_room_num, std::string abbrev): const int gen_room_num, std::string abbrev):
character{rng, enabled_features, nrace, pos}, character{rng, enabled_features, nrace, pos},
room_num{gen_room_num}, abbrev{abbrev} { room_num{gen_room_num}, abbrev{abbrev} {}
base_hit_rate_reset = {1, 2};
}
int enemy_base::get_room_num() const { int enemy_base::get_room_num() const {
return room_num; return room_num;

View File

@ -6,6 +6,7 @@
#include "player/shade.h" #include "player/shade.h"
#include "player/troll.h" #include "player/troll.h"
#include "player/vampire.h" #include "player/vampire.h"
#include "player/t_800.h"
void init_player(RNG *rng, std::unique_ptr<player_base> &pc, void init_player(RNG *rng, std::unique_ptr<player_base> &pc,
const feature enabled_features, const enum race &r) { const feature enabled_features, const enum race &r) {
@ -34,6 +35,10 @@ void init_player(RNG *rng, std::unique_ptr<player_base> &pc,
pc = make_unique<vampire>(rng, enabled_features); pc = make_unique<vampire>(rng, enabled_features);
break; break;
case rt_800:
pc = make_unique<t_800>(rng, enabled_features);
break;
default: default:
break; break;
} }

View File

@ -39,6 +39,10 @@ long_result player_base::apply(potion *p) {
apply_effect(p); apply_effect(p);
if (race == rt_800)
return {result::applied,
"PC gets rusty joints (-5 HP). "};
return {result::applied, return {result::applied,
(std::string)"PC applied potion of " + p->get_name() + ". "}; (std::string)"PC applied potion of " + p->get_name() + ". "};
} }

15
src/player/t_800.cc Normal file
View File

@ -0,0 +1,15 @@
#include "t_800.h"
#include "../constants.h"
t_800::t_800(RNG *rng, const feature enabled_features):
player_base{rng, enabled_features, race::rt_800} {}
const char *t_800::get_race_name() const {
return "T-800";
}
void t_800::apply_effect(potion *p) {
HP -= RUSTY;
return;
}

15
src/player/t_800.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __T_800_H__
#define __T_800_H__
#include "../player.h"
class potion;
class t_800 final: public player_base {
static const int RUSTY = 5;
public:
t_800(RNG *rng, const feature enabled_features);
const char *get_race_name() const override;
void apply_effect(potion *p) override;
};
#endif