2024-01-08 20:46:41 +01:00
|
|
|
/*
|
2025-02-23 13:56:35 +01:00
|
|
|
* Copyright (c) 2023-2025, Edoardo Lolletti (edo9300) <edoardo762@gmail.com>
|
2024-01-08 20:46:41 +01:00
|
|
|
*
|
|
|
|
|
* 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;
|
2025-02-20 23:36:31 +01:00
|
|
|
|
|
|
|
|
auto invoke = [this](auto& arg) -> OCG_DuelStatus {
|
|
|
|
|
if(process(arg)) {
|
|
|
|
|
core.units.pop_front();
|
|
|
|
|
return OCG_DUEL_STATUS_CONTINUE;
|
|
|
|
|
} else {
|
|
|
|
|
++arg.step;
|
2025-06-23 22:31:23 +02:00
|
|
|
return arg.needs_answer ? OCG_DUEL_STATUS_AWAITING : OCG_DUEL_STATUS_CONTINUE;
|
2025-02-20 23:36:31 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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());
|
2024-01-08 20:46:41 +01:00
|
|
|
}
|