fixed issue with potion output, added extras menu for player race selection
This commit is contained in:
11
src/item.cc
Normal file
11
src/item.cc
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "item.h"
|
||||||
|
|
||||||
|
item::item(const position &pos): pos{pos} {}
|
||||||
|
|
||||||
|
position item::get_pos() const {
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void item::set_pos(const position &npos) {
|
||||||
|
pos = npos;
|
||||||
|
}
|
17
src/item.h
Normal file
17
src/item.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef __ITEM_H__
|
||||||
|
#define __ITEM_H__
|
||||||
|
|
||||||
|
#include "position.h"
|
||||||
|
#include "output.h"
|
||||||
|
|
||||||
|
class item {
|
||||||
|
protected:
|
||||||
|
position pos;
|
||||||
|
public:
|
||||||
|
item(const position &pos);
|
||||||
|
position get_pos() const;
|
||||||
|
void set_pos(const position &npos);
|
||||||
|
virtual void print(output *out) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
92
src/menu.cc
92
src/menu.cc
@ -3,30 +3,21 @@
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
|
|
||||||
const int NORMAL_CNT = 5;
|
const int NORMAL_CNT = 5;
|
||||||
const int EXTRA_CNT = 5;
|
const int EXTRA_CNT = 10;
|
||||||
|
|
||||||
const enum race RACES[EXTRA_CNT] = {
|
const enum race RACES[EXTRA_CNT] = {
|
||||||
rshade, rdrow, rgoblin, rvampire, rtroll
|
rshade, rdrow, rgoblin, rvampire, rtroll,
|
||||||
|
rmonk, rassassin, rmr_goose, rbrawler, rt_800
|
||||||
};
|
};
|
||||||
|
|
||||||
const position RACE_POS[EXTRA_CNT] = {
|
const position RACE_POS[EXTRA_CNT] = {
|
||||||
{4, 9}, {4, 11}, {4, 13}, {4, 15}, {4, 17}
|
{4, 9}, {4, 11}, {4, 13}, {4, 15}, {4, 17},
|
||||||
|
{41, 9}, {41, 11}, {41, 13}, {41, 15}, {41, 17}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu::menu(const feature enabled_features):
|
menu::menu(const feature enabled_features):
|
||||||
enabled_features{enabled_features},
|
enabled_features{enabled_features},
|
||||||
cur{RACE_POS[0]} {}
|
curr{0} {}
|
||||||
|
|
||||||
const int UP_LIMIT = 9;
|
|
||||||
const int DOWN_LIMIT = 17;
|
|
||||||
const int LEFT_LIMIT = 4;
|
|
||||||
const int RIGHT_LIMIT = 4;
|
|
||||||
const int EXTRA_UP_LIMIT = 9;
|
|
||||||
const int EXTRA_DOWN_LIMIT = 17;
|
|
||||||
const int EXTRA_LEFT_LIMIT = 4;
|
|
||||||
const int EXTRA_RIGHT_LIMIT = 4;
|
|
||||||
const int X_INCRE = 37;
|
|
||||||
const int Y_INCRE = 2;
|
|
||||||
|
|
||||||
const char *NORMAL_SCREEN =
|
const char *NORMAL_SCREEN =
|
||||||
"+-----------------------------------------------------------------------------+\
|
"+-----------------------------------------------------------------------------+\
|
||||||
@ -65,15 +56,15 @@ const char *EXTRA_SCREEN =
|
|||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| Choose your race: |\
|
| Choose your race: |\
|
||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| Shade | |\
|
| Shade | Monk |\
|
||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| Drow | |\
|
| Drow | Assassin |\
|
||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| Goblin | |\
|
| Goblin | Mr. Goose |\
|
||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| Vampire | |\
|
| Vampire | Tavern Brawler |\
|
||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| Troll | |\
|
| Troll | T-800 |\
|
||||||
+-----------------------------------------------------------------------------+\
|
+-----------------------------------------------------------------------------+\
|
||||||
| |\
|
| |\
|
||||||
| |\
|
| |\
|
||||||
@ -83,61 +74,25 @@ const char *EXTRA_SCREEN =
|
|||||||
+-----------------------------------------------------------------------------+";
|
+-----------------------------------------------------------------------------+";
|
||||||
|
|
||||||
int menu::run(input *in) {
|
int menu::run(input *in) {
|
||||||
|
size_t limit = enabled_features & FEATURE_EXTRA_STUFF ?
|
||||||
|
EXTRA_CNT : NORMAL_CNT;
|
||||||
|
|
||||||
auto cmd = in->get_command();
|
auto cmd = in->get_command();
|
||||||
|
|
||||||
int up_limit = UP_LIMIT;
|
|
||||||
int down_limit = DOWN_LIMIT;
|
|
||||||
int left_limit = LEFT_LIMIT;
|
|
||||||
int right_limit = RIGHT_LIMIT;
|
|
||||||
|
|
||||||
if (enabled_features & FEATURE_EXTRA_STUFF) {
|
|
||||||
up_limit = EXTRA_UP_LIMIT;
|
|
||||||
down_limit = EXTRA_DOWN_LIMIT;
|
|
||||||
left_limit = EXTRA_LEFT_LIMIT;
|
|
||||||
right_limit = EXTRA_RIGHT_LIMIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case game_command::enter: {
|
case game_command::enter:
|
||||||
if (enabled_features & FEATURE_EXTRA_STUFF) {
|
return RACES[curr];
|
||||||
for (int i = 0; i < EXTRA_CNT; ++i)
|
|
||||||
if (cur == RACE_POS[i])
|
|
||||||
return RACES[i];
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < NORMAL_CNT; ++i)
|
|
||||||
if (cur == RACE_POS[i])
|
|
||||||
return RACES[i];
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
case move_north: {
|
case move_north: {
|
||||||
if (cur.y != up_limit)
|
if (curr > 0)
|
||||||
cur.y -= Y_INCRE;
|
--curr;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case move_south: {
|
case move_south: {
|
||||||
if (cur.y != down_limit)
|
if (curr < limit - 1)
|
||||||
cur.y += Y_INCRE;
|
++curr;
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case move_east: {
|
|
||||||
if (cur.x != left_limit)
|
|
||||||
cur.x -= X_INCRE;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case move_west: {
|
|
||||||
if (cur.x != right_limit)
|
|
||||||
cur.x += X_INCRE;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -161,9 +116,9 @@ const position SEED_POS = {1, 25};
|
|||||||
|
|
||||||
void menu::print(output *out, const unsigned int seed) {
|
void menu::print(output *out, const unsigned int seed) {
|
||||||
if (enabled_features & FEATURE_EXTRA_STUFF)
|
if (enabled_features & FEATURE_EXTRA_STUFF)
|
||||||
out->print_str({0, 0}, NORMAL_SCREEN);
|
|
||||||
else
|
|
||||||
out->print_str({0, 0}, EXTRA_SCREEN);
|
out->print_str({0, 0}, EXTRA_SCREEN);
|
||||||
|
else
|
||||||
|
out->print_str({0, 0}, NORMAL_SCREEN);
|
||||||
|
|
||||||
if (enabled_features & FEATURE_NCURSES)
|
if (enabled_features & FEATURE_NCURSES)
|
||||||
out->print_str(MSG_POS, MSG_NCURSES, COLOR_PAIR(COLOR_YELLOW));
|
out->print_str(MSG_POS, MSG_NCURSES, COLOR_PAIR(COLOR_YELLOW));
|
||||||
@ -173,6 +128,7 @@ void menu::print(output *out, const unsigned int seed) {
|
|||||||
out->print_str(SEED_POS, "Seed: " + std::to_string(seed),
|
out->print_str(SEED_POS, "Seed: " + std::to_string(seed),
|
||||||
COLOR_PAIR(COLOR_BLUE));
|
COLOR_PAIR(COLOR_BLUE));
|
||||||
|
|
||||||
out->print_str(cur, "->", COLOR_PAIR(COLOR_GREEN));
|
out->print_str(RACE_POS[curr], "->",
|
||||||
|
COLOR_PAIR(COLOR_GREEN));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ enum race : int;
|
|||||||
class menu final {
|
class menu final {
|
||||||
private:
|
private:
|
||||||
const feature enabled_features;
|
const feature enabled_features;
|
||||||
position cur;
|
size_t curr;
|
||||||
public:
|
public:
|
||||||
menu(const feature enabled_features);
|
menu(const feature enabled_features);
|
||||||
int run(input *in);
|
int run(input *in);
|
||||||
|
22
src/pc.cc
22
src/pc.cc
@ -7,6 +7,10 @@
|
|||||||
#include "player/troll.h"
|
#include "player/troll.h"
|
||||||
#include "player/vampire.h"
|
#include "player/vampire.h"
|
||||||
#include "player/t_800.h"
|
#include "player/t_800.h"
|
||||||
|
#include "player/assassin.h"
|
||||||
|
#include "player/monk.h"
|
||||||
|
#include "player/brawler.h"
|
||||||
|
#include "player/mr_goose.h"
|
||||||
|
|
||||||
std::unique_ptr<player_base> init_player(RNG *rng,
|
std::unique_ptr<player_base> init_player(RNG *rng,
|
||||||
const feature enabled_features, const enum race &r) {
|
const feature enabled_features, const enum race &r) {
|
||||||
@ -15,27 +19,33 @@ std::unique_ptr<player_base> init_player(RNG *rng,
|
|||||||
switch (r) {
|
switch (r) {
|
||||||
case rgoblin:
|
case rgoblin:
|
||||||
return make_unique<goblin>(rng, enabled_features);
|
return make_unique<goblin>(rng, enabled_features);
|
||||||
break;
|
|
||||||
|
|
||||||
case rdrow:
|
case rdrow:
|
||||||
return make_unique<drow>(rng, enabled_features);
|
return make_unique<drow>(rng, enabled_features);
|
||||||
break;
|
|
||||||
|
|
||||||
case rshade:
|
case rshade:
|
||||||
return make_unique<shade>(rng, enabled_features);
|
return make_unique<shade>(rng, enabled_features);
|
||||||
break;
|
|
||||||
|
|
||||||
case rtroll:
|
case rtroll:
|
||||||
return make_unique<troll>(rng, enabled_features);
|
return make_unique<troll>(rng, enabled_features);
|
||||||
break;
|
|
||||||
|
|
||||||
case rvampire:
|
case rvampire:
|
||||||
return make_unique<vampire>(rng, enabled_features);
|
return make_unique<vampire>(rng, enabled_features);
|
||||||
break;
|
|
||||||
|
|
||||||
case rt_800:
|
case rt_800:
|
||||||
return make_unique<t_800>(rng, enabled_features);
|
return make_unique<t_800>(rng, enabled_features);
|
||||||
break;
|
|
||||||
|
case rassassin:
|
||||||
|
return make_unique<assassin>(rng, enabled_features);
|
||||||
|
|
||||||
|
case rmonk:
|
||||||
|
return make_unique<monk>(rng, enabled_features);
|
||||||
|
|
||||||
|
case rbrawler:
|
||||||
|
return make_unique<brawler>(rng, enabled_features);
|
||||||
|
|
||||||
|
case rmr_goose:
|
||||||
|
return make_unique<mr_goose>(rng, enabled_features);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -14,7 +14,7 @@ int potion::get_duration() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void potion::print(output *out) const {
|
void potion::print(output *out) const {
|
||||||
out->print_char(pos, 'P', COLOR_PAIR(COLOR_GREEN));
|
out->print_char(this->get_pos(), 'P', COLOR_PAIR(COLOR_GREEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_potion_at(const position &pos, const potion_list &plist) {
|
size_t get_potion_at(const position &pos, const potion_list &plist) {
|
||||||
|
Reference in New Issue
Block a user