Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy/ai |
4 |
|
|
** File description: |
5 |
|
|
** Incantation.cpp |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "../../bots/ABotPattern.hpp" |
9 |
|
|
// Landmark: fix meeting_id_group_done |
10 |
|
✗ |
void ABotPattern::warnsWillIncant() |
11 |
|
|
{ |
12 |
|
✗ |
std::string willIncant = "warns_will_incant_" + _state.metadata["id_group"]; |
13 |
|
✗ |
addBroadcastAction(willIncant); |
14 |
|
✗ |
} |
15 |
|
|
|
16 |
|
✗ |
void ABotPattern::incantationLvl1() |
17 |
|
|
{ |
18 |
|
✗ |
queue.push_back({[&]() |
19 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
20 |
|
✗ |
_state.ressources.linemate--; |
21 |
|
✗ |
queue.push_back({[&]() |
22 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
23 |
|
✗ |
} |
24 |
|
|
|
25 |
|
✗ |
void ABotPattern::incantationLvl2() |
26 |
|
|
{ |
27 |
|
✗ |
queue.push_back({[&]() |
28 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
29 |
|
✗ |
_state.ressources.linemate--; |
30 |
|
✗ |
queue.push_back({[&]() |
31 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
32 |
|
✗ |
_state.ressources.deraumere--; |
33 |
|
✗ |
queue.push_back({[&]() |
34 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
35 |
|
✗ |
_state.ressources.sibur--; |
36 |
|
✗ |
warnsWillIncant(); |
37 |
|
✗ |
queue.push_back({[&]() |
38 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
39 |
|
✗ |
_state.metadata["should_incant"] = "false"; |
40 |
|
✗ |
} |
41 |
|
|
|
42 |
|
✗ |
void ABotPattern::incantationLvl3() |
43 |
|
|
{ |
44 |
|
✗ |
queue.push_back({[&]() |
45 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
46 |
|
✗ |
_state.ressources.linemate--; |
47 |
|
✗ |
queue.push_back({[&]() |
48 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
49 |
|
✗ |
_state.ressources.linemate--; |
50 |
|
✗ |
queue.push_back({[&]() |
51 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
52 |
|
✗ |
_state.ressources.sibur--; |
53 |
|
✗ |
queue.push_back({[&]() |
54 |
|
✗ |
{ doAction(SET, "phiras"); }, "SET"}); |
55 |
|
✗ |
_state.ressources.phiras--; |
56 |
|
✗ |
queue.push_back({[&]() |
57 |
|
✗ |
{ doAction(SET, "phiras"); }, "SET"}); |
58 |
|
✗ |
_state.ressources.phiras--; |
59 |
|
✗ |
warnsWillIncant(); |
60 |
|
✗ |
queue.push_back({[&]() |
61 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
62 |
|
✗ |
_state.metadata["should_incant"] = "false"; |
63 |
|
✗ |
} |
64 |
|
|
|
65 |
|
✗ |
void ABotPattern::incantationLvl4() |
66 |
|
|
{ |
67 |
|
✗ |
queue.push_back({[&]() |
68 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
69 |
|
✗ |
_state.ressources.linemate--; |
70 |
|
✗ |
queue.push_back({[&]() |
71 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
72 |
|
✗ |
_state.ressources.deraumere--; |
73 |
|
✗ |
queue.push_back({[&]() |
74 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
75 |
|
✗ |
_state.ressources.sibur--; |
76 |
|
✗ |
queue.push_back({[&]() |
77 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
78 |
|
✗ |
_state.ressources.sibur--; |
79 |
|
✗ |
queue.push_back({[&]() |
80 |
|
✗ |
{ doAction(SET, "phiras"); }, "SET"}); |
81 |
|
✗ |
_state.ressources.phiras--; |
82 |
|
✗ |
warnsWillIncant(); |
83 |
|
✗ |
queue.push_back({[&]() |
84 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
85 |
|
✗ |
_state.metadata["should_incant"] = "false"; |
86 |
|
✗ |
} |
87 |
|
|
|
88 |
|
✗ |
void ABotPattern::incantationLvl5() |
89 |
|
|
{ |
90 |
|
✗ |
queue.push_back({[&]() |
91 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
92 |
|
✗ |
_state.ressources.linemate--; |
93 |
|
✗ |
queue.push_back({[&]() |
94 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
95 |
|
✗ |
_state.ressources.deraumere--; |
96 |
|
✗ |
queue.push_back({[&]() |
97 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
98 |
|
✗ |
_state.ressources.deraumere--; |
99 |
|
✗ |
queue.push_back({[&]() |
100 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
101 |
|
✗ |
_state.ressources.sibur--; |
102 |
|
✗ |
queue.push_back({[&]() |
103 |
|
✗ |
{ doAction(SET, "mendiane"); }, "SET"}); |
104 |
|
✗ |
_state.ressources.mendiane--; |
105 |
|
✗ |
queue.push_back({[&]() |
106 |
|
✗ |
{ doAction(SET, "mendiane"); }, "SET"}); |
107 |
|
✗ |
_state.ressources.mendiane--; |
108 |
|
✗ |
queue.push_back({[&]() |
109 |
|
✗ |
{ doAction(SET, "mendiane"); }, "SET"}); |
110 |
|
✗ |
_state.ressources.mendiane--; |
111 |
|
✗ |
warnsWillIncant(); |
112 |
|
✗ |
queue.push_back({[&]() |
113 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
114 |
|
✗ |
_state.metadata["should_incant"] = "false"; |
115 |
|
✗ |
} |
116 |
|
|
|
117 |
|
✗ |
void ABotPattern::incantationLvl6() |
118 |
|
|
{ |
119 |
|
✗ |
queue.push_back({[&]() |
120 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
121 |
|
✗ |
_state.ressources.linemate--; |
122 |
|
✗ |
queue.push_back({[&]() |
123 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
124 |
|
✗ |
_state.ressources.deraumere--; |
125 |
|
✗ |
queue.push_back({[&]() |
126 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
127 |
|
✗ |
_state.ressources.deraumere--; |
128 |
|
✗ |
queue.push_back({[&]() |
129 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
130 |
|
✗ |
_state.ressources.sibur--; |
131 |
|
✗ |
queue.push_back({[&]() |
132 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
133 |
|
✗ |
_state.ressources.sibur--; |
134 |
|
✗ |
queue.push_back({[&]() |
135 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
136 |
|
✗ |
_state.ressources.sibur--; |
137 |
|
✗ |
queue.push_back({[&]() |
138 |
|
✗ |
{ doAction(SET, "phiras"); }, "SET"}); |
139 |
|
✗ |
_state.ressources.phiras--; |
140 |
|
✗ |
warnsWillIncant(); |
141 |
|
✗ |
queue.push_back({[&]() |
142 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
143 |
|
✗ |
_state.metadata["should_incant"] = "false"; |
144 |
|
✗ |
} |
145 |
|
|
|
146 |
|
✗ |
void ABotPattern::incantationLvl7() |
147 |
|
|
{ |
148 |
|
✗ |
queue.push_back({[&]() |
149 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
150 |
|
✗ |
_state.ressources.linemate--; |
151 |
|
✗ |
queue.push_back({[&]() |
152 |
|
✗ |
{ doAction(SET, "linemate"); }, "SET"}); |
153 |
|
✗ |
_state.ressources.linemate--; |
154 |
|
✗ |
queue.push_back({[&]() |
155 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
156 |
|
✗ |
_state.ressources.deraumere--; |
157 |
|
✗ |
queue.push_back({[&]() |
158 |
|
✗ |
{ doAction(SET, "deraumere"); }, "SET"}); |
159 |
|
✗ |
_state.ressources.deraumere--; |
160 |
|
✗ |
queue.push_back({[&]() |
161 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
162 |
|
✗ |
_state.ressources.sibur--; |
163 |
|
✗ |
queue.push_back({[&]() |
164 |
|
✗ |
{ doAction(SET, "sibur"); }, "SET"}); |
165 |
|
✗ |
_state.ressources.sibur--; |
166 |
|
✗ |
queue.push_back({[&]() |
167 |
|
✗ |
{ doAction(SET, "mendiane"); }, "SET"}); |
168 |
|
✗ |
_state.ressources.mendiane--; |
169 |
|
✗ |
queue.push_back({[&]() |
170 |
|
✗ |
{ doAction(SET, "mendiane"); }, "SET"}); |
171 |
|
✗ |
_state.ressources.mendiane--; |
172 |
|
✗ |
queue.push_back({[&]() |
173 |
|
✗ |
{ doAction(SET, "phiras"); }, "SET"}); |
174 |
|
✗ |
_state.ressources.phiras--; |
175 |
|
✗ |
queue.push_back({[&]() |
176 |
|
✗ |
{ doAction(SET, "phiras"); }, "SET"}); |
177 |
|
✗ |
_state.ressources.phiras--; |
178 |
|
✗ |
queue.push_back({[&]() |
179 |
|
✗ |
{ doAction(SET, "thystame"); }, "SET"}); |
180 |
|
✗ |
_state.ressources.thystame--; |
181 |
|
✗ |
warnsWillIncant(); |
182 |
|
✗ |
queue.push_back({[&]() |
183 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
184 |
|
✗ |
_state.metadata["should_incant"] = "false"; |
185 |
|
✗ |
} |
186 |
|
|
|
187 |
|
|
// TODO: Fix this i guess. objStr is empty |
188 |
|
✗ |
void ABotPattern::incantation(std::vector<std::string> objs) |
189 |
|
|
{ |
190 |
|
✗ |
for (auto &obj : objs) |
191 |
|
|
{ |
192 |
|
✗ |
std::string objStr = obj; |
193 |
|
|
|
194 |
|
✗ |
queue.push_back({[&]() |
195 |
|
✗ |
{ doAction(SET, objStr); }, "SET"}); |
196 |
|
✗ |
if (obj == "linemate") |
197 |
|
✗ |
_state.ressources.linemate--; |
198 |
|
|
} |
199 |
|
✗ |
warnsWillIncant(); |
200 |
|
✗ |
queue.push_back({[&]() |
201 |
|
✗ |
{ doAction(INCANTATION, ""); }, "INCANTATION"}); |
202 |
|
✗ |
} |
203 |
|
|
|