removed layer and objects design
fixed bug in restore_health
This commit is contained in:
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "layer.h"
|
|
||||||
#include "potion.h"
|
#include "potion.h"
|
||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
|
|
||||||
|
@ -31,9 +31,6 @@ enum game_command {game_command_terminate = 0,
|
|||||||
|
|
||||||
enum stat_name {HP, ATK, DEF, hostile};
|
enum stat_name {HP, ATK, DEF, hostile};
|
||||||
|
|
||||||
const int LAYER_CNT = 4; // TODO: update as you go
|
|
||||||
enum layer_num {map = 0, objects, characters, shop};
|
|
||||||
|
|
||||||
const int RACE_CNT = 4; // TODO: update as you go
|
const int RACE_CNT = 4; // TODO: update as you go
|
||||||
|
|
||||||
enum race {rshade = 0, rvampire, rgoblin, rdrow /* TODO: fill out the other races (including enemies) */};
|
enum race {rshade = 0, rvampire, rgoblin, rdrow /* TODO: fill out the other races (including enemies) */};
|
||||||
@ -109,5 +106,6 @@ const int COLOR_BLACK_ON_WHITE = 8;
|
|||||||
|
|
||||||
typedef std::vector<position> position_list;
|
typedef std::vector<position> position_list;
|
||||||
typedef std::vector<direction> direction_list;
|
typedef std::vector<direction> direction_list;
|
||||||
|
typedef std::vector<int> gold_list;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#ifndef __INVENTORY_H__
|
|
||||||
#define __INVENTORY_H__
|
|
||||||
|
|
||||||
class inventory final {
|
|
||||||
private:
|
|
||||||
object_list objects;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
22
src/layer.h
22
src/layer.h
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* CS 246 Final Project
|
|
||||||
* File: map.h
|
|
||||||
* Purpose: handles map functionality
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __LAYER_H__
|
|
||||||
#define __LAYER_H__
|
|
||||||
#include "constants.h"
|
|
||||||
#include "display.h"
|
|
||||||
|
|
||||||
class layer {
|
|
||||||
public:
|
|
||||||
const layer_num num;
|
|
||||||
|
|
||||||
layer(const layer_num ln): num{ln} {}
|
|
||||||
|
|
||||||
virtual void print() const = 0;
|
|
||||||
virtual void print(display &display) const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -6,12 +6,11 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "characters.h"
|
#include "characters.h"
|
||||||
#include "objects.h"
|
|
||||||
|
|
||||||
class logger final {
|
class logger final {
|
||||||
private:
|
private:
|
||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
std::vector<char> display;
|
std::vector<char> contents;
|
||||||
public:
|
public:
|
||||||
logger(std::ofstream &&new_out);
|
logger(std::ofstream &&new_out);
|
||||||
|
|
||||||
@ -22,6 +21,7 @@ public:
|
|||||||
void print_turn(const unsigned turn);
|
void print_turn(const unsigned turn);
|
||||||
void print_player(std::unique_ptr<character> &player);
|
void print_player(std::unique_ptr<character> &player);
|
||||||
void print_chlist(const character_list &chlist);
|
void print_chlist(const character_list &chlist);
|
||||||
|
void print_gold(const gold_list &gold_piles);
|
||||||
void print_potions(const potion_list &potions);
|
void print_potions(const potion_list &potions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,14 +5,12 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
game_map::game_map(int lvl):
|
game_map::game_map(int lvl) {
|
||||||
layer{layer_num::map} {
|
|
||||||
level = lvl;
|
level = lvl;
|
||||||
// TODO: randomly generate a map
|
// TODO: randomly generate a map
|
||||||
}
|
}
|
||||||
|
|
||||||
game_map::game_map(const std::string &map_data, int lvl):
|
game_map::game_map(const std::string &map_data, int lvl) {
|
||||||
layer{layer_num::map} {
|
|
||||||
level = lvl;
|
level = lvl;
|
||||||
std::istringstream iss{map_data};
|
std::istringstream iss{map_data};
|
||||||
|
|
||||||
|
@ -8,14 +8,12 @@
|
|||||||
#define __MAP_H__
|
#define __MAP_H__
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "objects.h"
|
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "layer.h"
|
|
||||||
#include "characters.h"
|
#include "characters.h"
|
||||||
|
|
||||||
class game_map final: public layer {
|
class game_map final {
|
||||||
public:
|
public:
|
||||||
game_map(int lvl = 0); // randomly generate one
|
game_map(int lvl = 0); // randomly generate one
|
||||||
// initialize using stored data
|
// initialize using stored data
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* CS 246 Final Project
|
|
||||||
* File: map.h
|
|
||||||
* Purpose: handles map functionality
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __OBJECTS_H__
|
|
||||||
#define __OBJECTS_H__
|
|
||||||
#include <vector>
|
|
||||||
#include <memory>
|
|
||||||
#include "layer.h"
|
|
||||||
#include "display.h"
|
|
||||||
|
|
||||||
class object {
|
|
||||||
// TODO: design the entire class
|
|
||||||
public:
|
|
||||||
void print() {} // use ncurses
|
|
||||||
void print(display &display) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class object_list final: public layer {
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: throw potion into another header
|
|
||||||
|
|
||||||
class potion final: public object {
|
|
||||||
// TODO: design the entire class
|
|
||||||
};
|
|
||||||
|
|
||||||
class potion_list final: public layer {
|
|
||||||
private:
|
|
||||||
std::vector<std::unique_ptr<potion>> potions;
|
|
||||||
// TODO: design the entire class
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -9,9 +9,9 @@ void restore_health::apply(enum race &race, int &HP, int &ATK, int &DEF,
|
|||||||
float &base_hit_rate) {
|
float &base_hit_rate) {
|
||||||
if (remaining_duration > 0) {
|
if (remaining_duration > 0) {
|
||||||
if (race == rdrow)
|
if (race == rdrow)
|
||||||
HP = std::max(HP + 7, MAX_HP[race]);
|
HP = std::min(HP + 7, MAX_HP[race]);
|
||||||
else
|
else
|
||||||
HP = std::max(HP + 5, MAX_HP[race]);
|
HP = std::min(HP + 5, MAX_HP[race]);
|
||||||
|
|
||||||
--remaining_duration;
|
--remaining_duration;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user