Files
Text-Adventure/Engine/headers/CommandParser.h
T
weirdbeardgame 45c365e317 Added copy operators for game's static instance
Player
CommandParser can be swapped but not copied.
2026-08-28 20:38:11 -05:00

35 lines
944 B
C++

#pragma once
#include <map>
#include <string>
#include <vector>
typedef int (*FUNCTION)(const std::string &s);
static std::vector<std::string> Verbs{"Quit", "Exit", "Go", "Move", "Look"};
static std::vector<std::string> Nouns{"Object", "Door", "North", "South", "East",
"West", "Up", "Down", "Left", "right"};
class CommandParser {
private:
std::map<std::string, FUNCTION> commands;
public:
CommandParser();
bool AddCommand(std::string c, FUNCTION f);
void RemoveCommand(std::string c);
std::vector<std::string> Verb(std::stringstream &sentences);
std::vector<std::string> Noun(std::stringstream &sentences);
inline friend void swap(CommandParser& lhs, CommandParser& rhs)
{
using std::swap;
swap(lhs.commands, rhs.commands);
}
static inline void CommandUnrecognized() { printf("I don't know how to do that.\n"); }
int Parse();
};