-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathprocessor_visit.cpp
More file actions
33 lines (30 loc) · 890 Bytes
/
processor_visit.cpp
File metadata and controls
33 lines (30 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright (c) 2023-2025, Edoardo Lolletti (edo9300) <edoardo762@gmail.com>
*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include <variant> //std::visit
#include "field.h"
OCG_DuelStatus field::process() {
core.units.splice(core.units.begin(), core.subunits);
if(core.units.empty())
return OCG_DUEL_STATUS_END;
auto invoke = [this](auto& arg) -> OCG_DuelStatus {
if(process(arg)) {
core.units.pop_front();
return OCG_DUEL_STATUS_CONTINUE;
} else {
++arg.step;
return arg.needs_answer ? OCG_DUEL_STATUS_AWAITING : OCG_DUEL_STATUS_CONTINUE;
}
};
return std::visit([&](auto& arg) -> OCG_DuelStatus {
if constexpr(Processors::IsProcess<decltype(arg)>) {
return invoke(arg);
} else {
// handle the case where the processes are stored
// in variants of variants in debug mode
return std::visit(invoke, arg);
}
}, core.units.front());
}