finished the bulk of game
This commit is contained in:
@ -1,20 +1,85 @@
|
||||
#include "enemies.h"
|
||||
|
||||
// TODO: implement after characters
|
||||
void new_enemy(RNG *rng, std::unique_ptr<character> &pch, const position &pos,
|
||||
bool extras) {
|
||||
if (extras) {
|
||||
#include "constants.h"
|
||||
#include "enemies/dragon.h"
|
||||
#include "enemies/dwarf.h"
|
||||
#include "enemies/elf.h"
|
||||
#include "enemies/halfling.h"
|
||||
#include "enemies/human.h"
|
||||
#include "enemies/merchant.h"
|
||||
#include "enemies/orc.h"
|
||||
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
void new_dragon(RNG *rng, std::unique_ptr<character> &pch, const position &pos,
|
||||
const position &fallback) {
|
||||
void new_dragon(RNG *rng, std::unique_ptr<enemy_base> &p,
|
||||
const position &pos, const position &fallback,
|
||||
const feature enabled_features, int which_room) {
|
||||
const position nil{0, 0};
|
||||
|
||||
if (pos != nil)
|
||||
pch = std::make_unique<dragon>(rng, pos);
|
||||
p = std::make_unique<dragon>(rng, enabled_features,
|
||||
pos, which_room);
|
||||
else
|
||||
pch = std::make_unique<dragon>(rng, fallback);
|
||||
p = std::make_unique<dragon>(rng, enabled_features,
|
||||
fallback, which_room);
|
||||
}
|
||||
|
||||
const int EXCNT = 6;
|
||||
const race EXCHOICES[EXCNT] = {
|
||||
rhuman, rdwarf, rhalfling, relf, rorc, rmerchant
|
||||
};
|
||||
const int CNT = 18;
|
||||
const race CHOICES[CNT] = {
|
||||
rhuman, rhuman, rhuman, rhuman,
|
||||
rdwarf, rdwarf, rdwarf,
|
||||
rhalfling, rhalfling, rhalfling, rhalfling, rhalfling,
|
||||
relf, relf,
|
||||
rorc, rorc,
|
||||
rmerchant, rmerchant
|
||||
};
|
||||
|
||||
enum race get_extra_race(RNG *rng) {
|
||||
return EXCHOICES[rng->rand_under(EXCNT)];
|
||||
}
|
||||
|
||||
enum race get_normal_race(RNG *rng) {
|
||||
return CHOICES[rng->rand_under(CNT)];
|
||||
}
|
||||
|
||||
void new_enemy(RNG *rng, std::unique_ptr<enemy_base> &p,
|
||||
const position &pos, const feature enabled_features,
|
||||
int which_room) {
|
||||
using std::make_unique;
|
||||
|
||||
enum race r;
|
||||
|
||||
if (enabled_features & FEATURE_EXTRA_STUFF)
|
||||
r = get_extra_race(rng);
|
||||
else
|
||||
r = get_normal_race(rng);
|
||||
|
||||
p = nullptr;
|
||||
|
||||
switch (r) {
|
||||
case rdwarf:
|
||||
p = make_unique<dwarf>(rng, enabled_features, pos, which_room);
|
||||
break;
|
||||
|
||||
case rhuman:
|
||||
p = make_unique<human>(rng, enabled_features, pos, which_room);
|
||||
break;
|
||||
|
||||
case relf:
|
||||
p = make_unique<elf>(rng, enabled_features, pos, which_room);
|
||||
break;
|
||||
|
||||
case rorc:
|
||||
p = make_unique<orc>(rng, enabled_features, pos, which_room);
|
||||
break;
|
||||
|
||||
case rmerchant:
|
||||
p = make_unique<merchant>(rng, enabled_features, pos, which_room);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user