Добавлена система NPC, а также боевая система.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "player.h"
|
||||
#include "location.h"
|
||||
#include "item.h"
|
||||
#include "npc.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -15,6 +16,7 @@ private:
|
||||
Player player;
|
||||
std::vector<Location> locations;
|
||||
std::vector<Item> itemDatabase;
|
||||
std::vector<NPC> npcs;
|
||||
|
||||
void showMainMenu();
|
||||
|
||||
@@ -25,6 +27,10 @@ private:
|
||||
|
||||
Location* getCurrentLocation();
|
||||
|
||||
void interactWithNPC(Location& location);
|
||||
void startCombat(NPC& npc);
|
||||
void applyDialogResult(NPC& npc, const DialogOption& option);
|
||||
|
||||
void render();
|
||||
void processCommand();
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct Point {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
#include "Point.h"
|
||||
#include "NPC.h"
|
||||
|
||||
struct Chest {
|
||||
Point pos;
|
||||
@@ -19,11 +17,6 @@ struct Enemy {
|
||||
int hp = 50;
|
||||
};
|
||||
|
||||
struct NPC {
|
||||
Point pos;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct Riddle {
|
||||
int type = 0;
|
||||
std::string text;
|
||||
|
||||
48
include/npc.h
Normal file
48
include/npc.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "point.h"
|
||||
|
||||
enum class NPCState {
|
||||
Friendly,
|
||||
Hostile
|
||||
};
|
||||
|
||||
enum class DialogResultType {
|
||||
GiveItem,
|
||||
BecomeHostile,
|
||||
OpenLocation,
|
||||
Fight,
|
||||
Nothing
|
||||
};
|
||||
|
||||
struct DialogOption {
|
||||
std::string text;
|
||||
DialogResultType result = DialogResultType::Nothing;
|
||||
int value = 0;
|
||||
std::string message;
|
||||
};
|
||||
|
||||
class NPC {
|
||||
public:
|
||||
int id = 0;
|
||||
std::string name;
|
||||
|
||||
NPCState state = NPCState::Friendly;
|
||||
|
||||
int hp = 100;
|
||||
int damage = 10;
|
||||
|
||||
Point position;
|
||||
|
||||
std::string dialogText;
|
||||
std::vector<DialogOption> options;
|
||||
|
||||
bool defeated = false;
|
||||
|
||||
bool loadFromFile(const std::string& path);
|
||||
|
||||
private:
|
||||
NPCState parseState(const std::string& value);
|
||||
DialogResultType parseDialogResult(const std::string& value);
|
||||
};
|
||||
6
include/point.h
Normal file
6
include/point.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
struct Point {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
};
|
||||
Reference in New Issue
Block a user