Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
AiParser.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <string_view>
6#include <variant>
7
8#include "../core/data/Resources.hpp"
9
20namespace Ai {
21 struct Forward {};
22 struct Right {};
23 struct Left {};
24 struct Look {};
25 struct Inventory {};
26 struct Broadcast {
27 std::string message;
28 };
29 struct ConnectNbr {};
30 struct Fork {};
31 struct Eject {};
32 struct Take {
34 };
35 struct Set {
37 };
38 struct Incantation {};
39
42} // namespace Ai
43
52class AiParser {
53 public:
58 static std::optional<Ai::Command> parse(std::string_view line);
59};
ResourceType
Enumerate the different types of resources in the game.
Definition Resources.hpp:12
Parses a raw AI client line into a typed Ai::Command.
Definition AiParser.hpp:52
static std::optional< Ai::Command > parse(std::string_view line)
Parse one line from an AI client (no trailing newline).
Definition AiParser.cpp:3
Typed structs for the 12 AI client commands.
Definition AiParser.hpp:20
std::variant< Forward, Right, Left, Look, Inventory, Broadcast, ConnectNbr, Fork, Eject, Take, Set, Incantation > Command
Definition AiParser.hpp:41
std::string message
Definition AiParser.hpp:27
ResourceType resource
Definition AiParser.hpp:36
ResourceType resource
Definition AiParser.hpp:33