Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy/ai |
4 |
|
|
** File description: |
5 |
|
|
** Action.hpp |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#ifndef ACTIONS_HPP_ |
9 |
|
|
#define ACTIONS_HPP_ |
10 |
|
|
|
11 |
|
|
#include <iostream> |
12 |
|
|
#include <map> |
13 |
|
|
|
14 |
|
|
enum Action |
15 |
|
|
{ |
16 |
|
|
DEFAULT, |
17 |
|
|
FORWARD, |
18 |
|
|
RIGHT, |
19 |
|
|
LEFT, |
20 |
|
|
LOOK, |
21 |
|
|
INVENTORY, |
22 |
|
|
BROADCAST, |
23 |
|
|
CONNECT_NBR, |
24 |
|
|
FORK, |
25 |
|
|
EJECT, |
26 |
|
|
TAKE, |
27 |
|
|
SET, |
28 |
|
|
INCANTATION, |
29 |
|
|
}; |
30 |
|
|
|
31 |
|
|
class ActionInfoException : public std::exception |
32 |
|
|
{ |
33 |
|
|
|
34 |
|
|
public: |
35 |
|
✗ |
ActionInfoException(const std::string &msg) : _msg(msg) {} |
36 |
|
✗ |
const char *what() const noexcept override { return _msg.c_str(); } |
37 |
|
|
|
38 |
|
|
private: |
39 |
|
|
std::string _msg; |
40 |
|
|
}; |
41 |
|
|
|
42 |
|
|
class ActionInfo |
43 |
|
|
{ |
44 |
|
|
public: |
45 |
|
|
ActionInfo(const std::string &name, unsigned int timeUnitCost); |
46 |
|
|
~ActionInfo(); |
47 |
|
|
|
48 |
|
|
Action action = DEFAULT; |
49 |
|
|
std::string getName() const; |
50 |
|
|
unsigned int getTimeUnitCost() const; |
51 |
|
|
|
52 |
|
|
std::string parameter; |
53 |
|
|
unsigned int count = 0; |
54 |
|
|
|
55 |
|
|
private: |
56 |
|
|
std::string _name; |
57 |
|
|
unsigned int _timeUnitCost; |
58 |
|
|
}; |
59 |
|
|
|
60 |
|
|
extern std::map<Action, ActionInfo> actionMap; |
61 |
|
|
|
62 |
|
|
ActionInfo getActionInfo(Action action); |
63 |
|
|
|
64 |
|
|
#endif // ACTIONS_HPP_ |
65 |
|
|
|