mirror of
https://github.com/edo9300/ygopro-core
synced 2026-08-25 16:23:07 -04:00
Restructure the processor handling to use a variant object (#149)
Rewrite the whole ``process`` function of the processor to use instead tag dispatching on variant objects. Each single processor message got rewritten as a struct, inheriting from a base templated Process struct, containing only the required data for that process, rather than using the generic structure that ended up needing to spam bitwise operations to pack as many arguments in a byte as possible. This makes things easier to follow and streamlines the addition of new processes: - Define its struct with the parameters it expects by also providing a constructor - If the process requires an answer, inherit it from ``Process<true>``, if it requires no answer, inherit it from ``Process<false>`` - Add such struct to the ``processors`` variant type - Declare and implement its corresponding ``bool process(Processors::NewProcess& arg);`` function
This commit is contained in:
parent
35f83fa12a
commit
e97a1c2f94
13 changed files with 2582 additions and 2334 deletions
|
|
@ -20,6 +20,7 @@ LOCAL_SRC_FILES := card.cpp \
|
|||
operations.cpp \
|
||||
playerop.cpp \
|
||||
processor.cpp \
|
||||
processor_visit.cpp \
|
||||
scriptlib.cpp
|
||||
|
||||
LOCAL_CFLAGS := -pedantic -Wextra -fvisibility=hidden -DOCGCORE_EXPORT_FUNCTIONS
|
||||
|
|
|
|||
|
|
@ -2079,7 +2079,7 @@ void field::adjust_self_destroy_set() {
|
|||
}
|
||||
std::sort(uniq_set.begin(), uniq_set.end(), [](card* lhs, card* rhs) { return lhs->fieldid < rhs->fieldid; });
|
||||
for(auto& pcard : uniq_set) {
|
||||
add_process(PROCESSOR_SELF_DESTROY, 0, 0, 0, p, 0, 0, 0, pcard);
|
||||
emplace_process<Processors::SelfDestroyUnique>(pcard, p);
|
||||
core.unique_destroy_set.insert(pcard);
|
||||
}
|
||||
p = 1 - p;
|
||||
|
|
@ -2110,9 +2110,9 @@ void field::adjust_self_destroy_set() {
|
|||
}
|
||||
}
|
||||
if(!core.self_destroy_set.empty())
|
||||
add_process(PROCESSOR_SELF_DESTROY, 10, 0, 0, 0, 0);
|
||||
emplace_process<Processors::SelfDestroy>();
|
||||
if(!core.self_tograve_set.empty())
|
||||
add_process(PROCESSOR_SELF_DESTROY, 20, 0, 0, 0, 0);
|
||||
emplace_process<Processors::SelfToGrave>();
|
||||
}
|
||||
void field::erase_grant_effect(effect* peffect) {
|
||||
auto eit = effects.grant_effect.find(peffect);
|
||||
|
|
|
|||
377
field.h
377
field.h
|
|
@ -10,6 +10,7 @@
|
|||
#include <array>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
|
@ -19,6 +20,7 @@
|
|||
#include "card.h"
|
||||
#include "common.h"
|
||||
#include "containers_fwd.h"
|
||||
#include "processor_unit.h"
|
||||
#include "progressivebuffer.h"
|
||||
|
||||
class duel;
|
||||
|
|
@ -176,18 +178,9 @@ struct lpcost {
|
|||
int32_t amount{ 0 };
|
||||
int32_t lpstack[8]{};
|
||||
};
|
||||
struct processor_unit {
|
||||
uint16_t type;
|
||||
int16_t step;
|
||||
effect* peffect;
|
||||
group* ptarget;
|
||||
int64_t arg1;
|
||||
int64_t arg2;
|
||||
int64_t arg3;
|
||||
int64_t arg4;
|
||||
void* ptr1;
|
||||
void* ptr2;
|
||||
};
|
||||
|
||||
using Processors::processor_unit;
|
||||
|
||||
template<typename T>
|
||||
class return_card_generic {
|
||||
public:
|
||||
|
|
@ -222,7 +215,7 @@ struct processor {
|
|||
|
||||
processor_list units;
|
||||
processor_list subunits;
|
||||
processor_unit reserved;
|
||||
std::optional<processor_unit> reserved;
|
||||
card_set just_sent_cards;
|
||||
card_vector select_cards;
|
||||
std::vector<std::pair<uint32_t, uint32_t>> select_cards_codes;
|
||||
|
|
@ -300,7 +293,6 @@ struct processor {
|
|||
std::unordered_map<uint32_t, uint32_t> spsummon_once_map[2];
|
||||
std::unordered_map<uint32_t, uint32_t> spsummon_once_map_rst[2];
|
||||
std::multimap<int32_t, card*, std::greater<int32_t>> xmaterial_lst;
|
||||
int64_t temp_var[4];
|
||||
uint32_t global_flag;
|
||||
uint32_t pre_field[2];
|
||||
std::set<uint32_t> opp_mzone;
|
||||
|
|
@ -404,6 +396,7 @@ struct processor {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
class field {
|
||||
public:
|
||||
duel* pduel;
|
||||
|
|
@ -501,7 +494,7 @@ public:
|
|||
void add_to_disable_check_list(card* pcard);
|
||||
void adjust_disable_check_list();
|
||||
void adjust_self_destroy_set();
|
||||
int32_t trap_monster_adjust(uint16_t step);
|
||||
bool process(Processors::TrapMonsterAdjust& arg);
|
||||
void erase_grant_effect(effect* peffect);
|
||||
int32_t adjust_grant_effect();
|
||||
void add_unique_card(card* pcard);
|
||||
|
|
@ -518,7 +511,7 @@ public:
|
|||
int32_t check_lp_cost(uint8_t playerid, uint32_t cost);
|
||||
void save_lp_cost() {}
|
||||
void restore_lp_cost() {}
|
||||
int32_t pay_lp_cost(uint32_t step, uint8_t playerid, uint32_t cost);
|
||||
bool process(Processors::PayLPCost& arg);
|
||||
|
||||
uint32_t get_field_counter(uint8_t playerid, uint8_t self, uint8_t oppo, uint16_t countertype);
|
||||
int32_t effect_replace_check(uint32_t code, const tevent& e);
|
||||
|
|
@ -565,43 +558,53 @@ public:
|
|||
int32_t check_spself_from_hand_trigger(const chain& ch) const;
|
||||
int32_t is_able_to_enter_bp();
|
||||
|
||||
void add_process(uint16_t type, uint16_t step, effect* peffect, group* target, int64_t arg1, int64_t arg2, int64_t arg3 = 0, int64_t arg4 = 0, void* ptr1 = nullptr, void* ptr2 = nullptr);
|
||||
int32_t process();
|
||||
int32_t execute_cost(uint16_t step, effect* peffect, uint8_t triggering_player);
|
||||
int32_t execute_operation(uint16_t step, effect* peffect, uint8_t triggering_player);
|
||||
int32_t execute_target(uint16_t step, effect* peffect, uint8_t triggering_player);
|
||||
struct Step { uint16_t step; };
|
||||
template<typename T, typename... Args>
|
||||
constexpr inline void emplace_process(Step step, Args&&... args) {
|
||||
core.subunits.emplace_back(std::in_place_type<T>, step.step, std::forward<Args>(args)...);
|
||||
}
|
||||
template<typename T, typename... Args>
|
||||
constexpr inline void emplace_process(Args&&... args) {
|
||||
emplace_process<T>(Step{ 0 }, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void raise_event(card* event_card, uint32_t event_code, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t event_player, uint32_t event_value);
|
||||
void raise_event(card_set* event_cards, uint32_t event_code, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t event_player, uint32_t event_value);
|
||||
void raise_single_event(card* trigger_card, card_set* event_cards, uint32_t event_code, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t event_player, uint32_t event_value);
|
||||
int32_t check_event(uint32_t code, tevent* pe = 0);
|
||||
int32_t check_event_c(effect* peffect, uint8_t playerid, int32_t neglect_con, int32_t neglect_cost, int32_t copy_info, tevent* pe = 0);
|
||||
int32_t check_hint_timing(effect* peffect);
|
||||
int32_t process_phase_event(int16_t step, int32_t phase_event);
|
||||
int32_t process_point_event(int16_t step, int32_t skip_trigger, int32_t skip_freechain, int32_t skip_new);
|
||||
int32_t process_quick_effect(int16_t step, int32_t skip_freechain, uint8_t priority);
|
||||
int32_t process_instant_event();
|
||||
int32_t process_single_event();
|
||||
int32_t process_single_event(effect* peffect, const tevent& e, chain_list& tp, chain_list& ntp);
|
||||
int32_t process_idle_command(uint16_t step);
|
||||
int32_t process_battle_command(uint16_t step);
|
||||
int32_t process_forced_battle(uint16_t step);
|
||||
int32_t process_damage_step(uint16_t step, uint32_t new_attack);
|
||||
void calculate_battle_damage(effect** pdamchange, card** preason_card, std::array<bool, 2>* battle_destroyed);
|
||||
int32_t process_turn(uint16_t step, uint8_t turn_player);
|
||||
|
||||
int32_t add_chain(uint16_t step);
|
||||
int32_t sort_chain(uint16_t step, uint8_t tp);
|
||||
void solve_continuous(uint8_t playerid, effect* peffect, const tevent& e);
|
||||
int32_t solve_continuous(uint16_t step);
|
||||
int32_t solve_chain(uint16_t step, uint32_t chainend_arg1, uint32_t chainend_arg2);
|
||||
int32_t break_effect(bool clear_sent = true);
|
||||
void adjust_instant();
|
||||
void adjust_all();
|
||||
void refresh_location_info_instant();
|
||||
int32_t refresh_location_info(uint16_t step);
|
||||
int32_t adjust_step(uint16_t step);
|
||||
int32_t startup(uint16_t step);
|
||||
int32_t refresh_relay(uint16_t step);
|
||||
void solve_continuous(uint8_t playerid, effect* peffect, const tevent& e);
|
||||
|
||||
OCG_DuelStatus process();
|
||||
bool process(Processors::ExecuteCost& arg);
|
||||
bool process(Processors::ExecuteOperation& arg);
|
||||
bool process(Processors::ExecuteTarget& arg);
|
||||
bool process(Processors::PhaseEvent& arg);
|
||||
bool process(Processors::PointEvent& arg);
|
||||
bool process(Processors::QuickEffect& arg);
|
||||
bool process(Processors::IdleCommand& arg);
|
||||
bool process(Processors::BattleCommand& arg);
|
||||
bool process(Processors::ForcedBattle& arg);
|
||||
bool process(Processors::DamageStep& arg);
|
||||
bool process(Processors::Turn& arg);
|
||||
|
||||
bool process(Processors::AddChain& arg);
|
||||
bool process(Processors::SortChain& arg);
|
||||
bool process(Processors::SolveContinuous& arg);
|
||||
bool process(Processors::SolveChain& arg);
|
||||
bool process(Processors::RefreshLoc& arg);
|
||||
bool process(Processors::Adjust& arg);
|
||||
bool process(Processors::Startup& arg);
|
||||
bool process(Processors::RefreshRelay& arg);
|
||||
|
||||
//operations
|
||||
int32_t negate_chain(uint8_t chaincount);
|
||||
|
|
@ -614,90 +617,109 @@ public:
|
|||
void remove_overlay_card(uint32_t reason, group* pgroup, uint32_t rplayer, uint8_t self, uint8_t oppo, uint16_t min, uint16_t max);
|
||||
void xyz_overlay(card* target, card_set materials, bool send_materials_to_grave);
|
||||
void xyz_overlay(card* target, card* material, bool send_materials_to_grave);
|
||||
void get_control(card_set targets, effect* reason_effect, uint32_t reason_player, uint32_t playerid, uint32_t reset_phase, uint32_t reset_count, uint32_t zone);
|
||||
void get_control(card* target, effect* reason_effect, uint32_t reason_player, uint32_t playerid, uint32_t reset_phase, uint32_t reset_count, uint32_t zone);
|
||||
void get_control(card_set targets, effect* reason_effect, uint8_t chose_player, uint8_t playerid, uint16_t reset_phase, uint8_t reset_count, uint32_t zone);
|
||||
void get_control(card* target, effect* reason_effect, uint8_t chose_player, uint8_t playerid, uint16_t reset_phase, uint8_t reset_count, uint32_t zone);
|
||||
void swap_control(effect* reason_effect, uint32_t reason_player, card_set targets1, card_set targets2, uint32_t reset_phase, uint32_t reset_count);
|
||||
void swap_control(effect* reason_effect, uint32_t reason_player, card* pcard1, card* pcard2, uint32_t reset_phase, uint32_t reset_count);
|
||||
void equip(uint32_t equip_player, card* equip_card, card* target, uint32_t up, uint32_t is_step);
|
||||
void draw(effect* reason_effect, uint32_t reason, uint32_t reason_player, uint32_t playerid, uint32_t count);
|
||||
void equip(uint8_t equip_player, card* equip_card, card* target, bool faceup, bool is_step);
|
||||
void draw(effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid, uint16_t count);
|
||||
void damage(effect* reason_effect, uint32_t reason, uint8_t reason_player, card* reason_card, uint8_t playerid, uint32_t amount, bool is_step = false);
|
||||
void recover(effect* reason_effect, uint32_t reason, uint32_t reason_player, uint32_t playerid, uint32_t amount, bool is_step = false);
|
||||
void summon(uint32_t sumplayer, card* target, effect* proc, uint32_t ignore_count, uint32_t min_tribute, uint32_t zone = 0x1f);
|
||||
void mset(uint32_t setplayer, card* target, effect* proc, uint32_t ignore_count, uint32_t min_tribute, uint32_t zone = 0x1f);
|
||||
void special_summon_rule(uint32_t sumplayer, card* target, uint32_t summon_type);
|
||||
void special_summon_rule_group(uint32_t sumplayer, uint32_t summon_type);
|
||||
void special_summon(card_set target, uint32_t sumtype, uint32_t sumplayer, uint32_t playerid, uint32_t nocheck, uint32_t nolimit, uint32_t positions, uint32_t zone);
|
||||
void special_summon_step(card* target, uint32_t sumtype, uint32_t sumplayer, uint32_t playerid, uint32_t nocheck, uint32_t nolimit, uint32_t positions, uint32_t zone);
|
||||
void summon(uint8_t sumplayer, card* target, effect* summon_procedure_effect, bool ignore_count, uint8_t min_tribute, uint32_t zone = 0x1f);
|
||||
void mset(uint8_t setplayer, card* target, effect* proc, bool ignore_count, uint8_t min_tribute, uint32_t zone = 0x1f);
|
||||
void special_summon_rule(uint8_t sumplayer, card* target, uint32_t summon_type);
|
||||
void special_summon_rule_group(uint8_t sumplayer, uint32_t summon_type);
|
||||
void special_summon(card_set target, uint32_t sumtype, uint8_t sumplayer, uint8_t playerid, bool nocheck, bool nolimit, uint8_t positions, uint32_t zone);
|
||||
void special_summon_step(card* target, uint32_t sumtype, uint8_t sumplayer, uint8_t playerid, bool nocheck, bool nolimit, uint8_t positions, uint32_t zone);
|
||||
void special_summon_complete(effect* reason_effect, uint8_t reason_player);
|
||||
void destroy(card_set targets, effect* reason_effect, uint32_t reason, uint32_t reason_player, uint32_t playerid = 2, uint32_t destination = 0, uint32_t sequence = 0);
|
||||
void destroy(card* target, effect* reason_effect, uint32_t reason, uint32_t reason_player, uint32_t playerid = 2, uint32_t destination = 0, uint32_t sequence = 0);
|
||||
void release(card_set targets, effect* reason_effect, uint32_t reason, uint32_t reason_player);
|
||||
void release(card* target, effect* reason_effect, uint32_t reason, uint32_t reason_player);
|
||||
void send_to(card_set targets, effect* reason_effect, uint32_t reason, uint32_t reason_player, uint32_t playerid, uint32_t destination, uint32_t sequence, uint32_t position, uint32_t ignore = false);
|
||||
void send_to(card* target, effect* reason_effect, uint32_t reason, uint32_t reason_player, uint32_t playerid, uint32_t destination, uint32_t sequence, uint32_t position, uint32_t ignore = false);
|
||||
void move_to_field(card* target, uint32_t move_player, uint32_t playerid, uint32_t destination, uint32_t positions, uint8_t enable = FALSE, uint8_t ret = 0, uint8_t zone = 0xff, uint8_t rule = FALSE, uint8_t reason = 0, uint8_t confirm = TRUE);
|
||||
void change_position(card_set targets, effect* reason_effect, uint32_t reason_player, uint32_t au, uint32_t ad, uint32_t du, uint32_t dd, uint32_t flag, uint32_t enable = FALSE);
|
||||
void change_position(card* target, effect* reason_effect, uint32_t reason_player, uint32_t npos, uint32_t flag, uint32_t enable = FALSE);
|
||||
void operation_replace(int32_t type, int32_t step, group* targets);
|
||||
void select_tribute_cards(card* target, uint8_t playerid, uint8_t cancelable, int32_t min, int32_t max, uint8_t toplayer, uint32_t zone);
|
||||
void destroy(card_set targets, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid = 2, uint16_t destination = 0, uint32_t sequence = 0);
|
||||
void destroy(card* target, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid = 2, uint16_t destination = 0, uint32_t sequence = 0);
|
||||
void release(card_set targets, effect* reason_effect, uint32_t reason, uint8_t reason_player);
|
||||
void release(card* target, effect* reason_effect, uint32_t reason, uint8_t reason_player);
|
||||
void send_to(card_set targets, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid, uint16_t destination, uint32_t sequence, uint8_t position, bool ignore = false);
|
||||
void send_to(card* target, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid, uint16_t destination, uint32_t sequence, uint8_t position, bool ignore = false);
|
||||
void move_to_field(card* target, uint8_t move_player, uint8_t playerid, uint16_t destination, uint8_t positions, bool enable = false, uint8_t ret = 0, uint8_t zone = 0xff, bool rule = false, uint8_t reason = 0, bool confirm = false);
|
||||
void change_position(card_set targets, effect* reason_effect, uint8_t reason_player, uint8_t au, uint8_t ad, uint8_t du, uint8_t dd, uint32_t flag, bool enable = false);
|
||||
void change_position(card* target, effect* reason_effect, uint8_t reason_player, uint8_t npos, uint32_t flag, bool enable = false);
|
||||
void operation_replace(uint32_t type, uint16_t step, group* targets);
|
||||
void select_tribute_cards(card* target, uint8_t playerid, bool cancelable, uint16_t min, uint16_t max, uint8_t toplayer, uint32_t zone);
|
||||
|
||||
int32_t remove_counter(uint16_t step, uint32_t reason, card* pcard, uint8_t rplayer, uint8_t s, uint8_t o, uint16_t countertype, uint16_t count);
|
||||
int32_t remove_overlay_card(uint16_t step, uint32_t reason, group* pgroup, uint8_t rplayer, uint8_t s, uint8_t o, uint16_t min, uint16_t max);
|
||||
int32_t xyz_overlay(uint16_t step, card* target, group* materials, bool send_materials_to_grave);
|
||||
int32_t get_control(uint16_t step, effect* reason_effect, uint8_t chose_player, group* targets, uint8_t playerid, uint16_t reset_phase, uint8_t reset_count, uint32_t zone);
|
||||
int32_t swap_control(uint16_t step, effect* reason_effect, uint8_t reason_player, group* targets1, group* targets2, uint16_t reset_phase, uint8_t reset_count);
|
||||
int32_t control_adjust(uint16_t step);
|
||||
int32_t self_destroy(uint16_t step, card* ucard, int32_t p);
|
||||
int32_t equip(uint16_t step, uint8_t equip_player, card* equip_card, card* target, uint32_t up, uint32_t is_step);
|
||||
int32_t draw(uint16_t step, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid, uint32_t count);
|
||||
int32_t damage(uint16_t step, effect* reason_effect, uint32_t reason, uint8_t reason_player, card* reason_card, uint8_t playerid, uint32_t amount, bool is_step);
|
||||
int32_t recover(uint16_t step, effect* reason_effect, uint32_t reason, uint8_t reason_player, uint8_t playerid, uint32_t amount, bool is_step);
|
||||
int32_t summon(uint16_t step, uint8_t sumplayer, card* target, effect* proc, uint8_t ignore_count, uint8_t min_tribute, uint32_t zone);
|
||||
int32_t flip_summon(uint16_t step, uint8_t sumplayer, card* target);
|
||||
int32_t mset(uint16_t step, uint8_t setplayer, card* ptarget, effect* proc, uint8_t ignore_count, uint8_t min_tribute, uint32_t zone);
|
||||
int32_t sset(uint16_t step, uint8_t setplayer, uint8_t toplayer, card* ptarget, effect* reason_effect);
|
||||
int32_t sset_g(uint16_t step, uint8_t setplayer, uint8_t toplayer, group* ptarget, uint8_t confirm, effect* reason_effect);
|
||||
int32_t special_summon_rule(uint16_t step, uint8_t sumplayer, card* target, uint32_t summon_type);
|
||||
int32_t special_summon_rule_group(uint16_t step, uint8_t sumplayer, uint32_t summon_type);
|
||||
int32_t special_summon_step(uint16_t step, group* targets, card* target, uint32_t zone);
|
||||
int32_t special_summon(uint16_t step, effect* reason_effect, uint8_t reason_player, group* targets, uint32_t zone);
|
||||
int32_t destroy_replace(uint16_t step, group* targets, card* target, uint8_t battle);
|
||||
int32_t destroy(uint16_t step, group* targets, effect* reason_effect, uint32_t reason, uint8_t reason_player);
|
||||
int32_t release_replace(uint16_t step, group* targets, card* target);
|
||||
int32_t release(uint16_t step, group* targets, effect* reason_effect, uint32_t reason, uint8_t reason_player);
|
||||
int32_t send_replace(uint16_t step, group* targets, card* target);
|
||||
int32_t send_to(uint16_t step, group* targets, effect* reason_effect, uint32_t reason, uint8_t reason_player);
|
||||
int32_t discard_deck(uint16_t step, uint8_t playerid, uint8_t count, uint32_t reason);
|
||||
int32_t move_to_field(uint16_t step, card* target, uint8_t enable, uint8_t ret, uint8_t pzone, uint8_t zone, uint8_t rule = FALSE, uint8_t reason = 0, uint8_t confirm = TRUE);
|
||||
int32_t change_position(uint16_t step, group* targets, effect* reason_effect, uint8_t reason_player, uint32_t enable);
|
||||
int32_t operation_replace(uint16_t step, effect* replace_effect, group* targets, card* target, int32_t is_destroy);
|
||||
int32_t activate_effect(uint16_t step, effect* peffect);
|
||||
int32_t select_release_cards(int16_t step, uint8_t playerid, uint8_t cancelable, int32_t min, int32_t max, uint8_t check_field, card* to_check, uint8_t toplayer, uint8_t zone);
|
||||
int32_t select_tribute_cards(int16_t step, card* target, uint8_t playerid, uint8_t cancelable, int32_t min, int32_t max, uint8_t toplayer, uint32_t zone);
|
||||
int32_t toss_coin(uint16_t step, effect* reason_effect, uint8_t reason_player, uint8_t playerid, uint8_t count);
|
||||
int32_t toss_dice(uint16_t step, effect* reason_effect, uint8_t reason_player, uint8_t playerid, uint8_t count1, uint8_t count2);
|
||||
int32_t rock_paper_scissors(uint16_t step, uint8_t repeat);
|
||||
|
||||
int32_t select_battle_command(uint16_t step, uint8_t playerid);
|
||||
int32_t select_idle_command(uint16_t step, uint8_t playerid);
|
||||
int32_t select_effect_yes_no(uint16_t step, uint8_t playerid, uint64_t description, card* pcard);
|
||||
int32_t select_yes_no(uint16_t step, uint8_t playerid, uint64_t description);
|
||||
int32_t select_option(uint16_t step, uint8_t playerid);
|
||||
bool parse_response_cards(bool cancelable);
|
||||
int32_t select_card(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max);
|
||||
int32_t select_card_codes(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max);
|
||||
int32_t select_unselect_card(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max, uint8_t finishable);
|
||||
int32_t select_chain(uint16_t step, uint8_t playerid, uint8_t spe_count, uint8_t forced);
|
||||
int32_t select_place(uint16_t step, uint8_t playerid, uint32_t flag, uint8_t count);
|
||||
int32_t select_position(uint16_t step, uint8_t playerid, uint32_t code, uint8_t positions);
|
||||
int32_t select_tribute(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max);
|
||||
int32_t select_counter(uint16_t step, uint8_t playerid, uint16_t countertype, uint16_t count, uint8_t s, uint8_t o);
|
||||
int32_t select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc, int32_t min, int32_t max);
|
||||
int32_t sort_card(int16_t step, uint8_t playerid, uint8_t is_chain);
|
||||
int32_t announce_race(int16_t step, uint8_t playerid, uint8_t count, uint64_t available);
|
||||
int32_t announce_attribute(int16_t step, uint8_t playerid, uint8_t count, uint32_t available);
|
||||
int32_t announce_card(int16_t step, uint8_t playerid);
|
||||
int32_t announce_number(int16_t step, uint8_t playerid);
|
||||
|
||||
bool process(Processors::RemoveCounter& arg);
|
||||
bool process(Processors::RemoveOverlay& arg);
|
||||
bool process(Processors::XyzOverlay& arg);
|
||||
bool process(Processors::GetControl& arg);
|
||||
bool process(Processors::SwapControl& arg);
|
||||
bool process(Processors::ControlAdjust& arg);
|
||||
bool process(Processors::SelfDestroyUnique& arg);
|
||||
bool process(Processors::SelfDestroy& arg);
|
||||
bool process(Processors::SelfToGrave& arg);
|
||||
bool process(Processors::Equip& arg);
|
||||
bool process(Processors::Draw& arg);
|
||||
bool process(Processors::Damage& arg);
|
||||
bool process(Processors::Recover& arg);
|
||||
bool process(Processors::SummonRule& arg);
|
||||
bool process(Processors::FlipSummon& arg);
|
||||
bool process(Processors::MonsterSet& arg);
|
||||
bool process(Processors::SpellSet& arg);
|
||||
bool process(Processors::SpellSetGroup& arg);
|
||||
bool process(Processors::SpSummonRule& arg);
|
||||
bool process(Processors::SpSummonRuleGroup& arg);
|
||||
bool process(Processors::SpSummonStep& arg);
|
||||
bool process(Processors::SpSummon& arg);
|
||||
bool process(Processors::DestroyReplace& arg);
|
||||
bool process(Processors::Destroy& arg);
|
||||
bool process(Processors::ReleaseReplace& arg);
|
||||
bool process(Processors::Release& arg);
|
||||
bool process(Processors::SendToReplace& arg);
|
||||
bool process(Processors::SendTo& arg);
|
||||
bool process(Processors::DiscardDeck& arg);
|
||||
bool process(Processors::SortDeck& arg);
|
||||
bool process(Processors::DiscardHand& arg);
|
||||
bool process(Processors::MoveToField& arg);
|
||||
bool process(Processors::ChangePos& arg);
|
||||
bool process(Processors::OperationReplace& arg);
|
||||
bool process(Processors::ActivateEffect& arg);
|
||||
bool process(Processors::SelectRelease& arg);
|
||||
bool process(Processors::SelectTribute& arg);
|
||||
bool process(Processors::SelectFusion& arg);
|
||||
bool process(Processors::TossCoin& arg);
|
||||
bool process(Processors::TossDice& arg);
|
||||
bool process(Processors::AttackDisable& arg);
|
||||
|
||||
bool process(Processors::SelectBattleCmd& arg);
|
||||
bool process(Processors::SelectIdleCmd& arg);
|
||||
bool process(Processors::SelectEffectYesNo& arg);
|
||||
bool process(Processors::SelectYesNo& arg);
|
||||
bool process(Processors::SelectOption& arg);
|
||||
bool process(Processors::SelectCard& arg);
|
||||
bool process(Processors::SelectCardCodes& arg);
|
||||
bool process(Processors::SelectUnselectCard& arg);
|
||||
bool process(Processors::SelectChain& arg);
|
||||
bool process(Processors::SelectPlace& arg);
|
||||
bool process(Processors::SelectPosition& arg);
|
||||
bool process(Processors::SelectTributeP& arg);
|
||||
bool process(Processors::SelectCounter& arg);
|
||||
bool process(Processors::SelectSum& arg);
|
||||
bool process(Processors::SortCard& arg);
|
||||
bool process(Processors::AnnounceRace& arg);
|
||||
bool process(Processors::AnnounceAttribute& arg);
|
||||
bool process(Processors::AnnounceCard& arg);
|
||||
bool process(Processors::AnnounceNumber& arg);
|
||||
bool process(Processors::RockPaperScissors& arg);
|
||||
|
||||
|
||||
template<typename T>
|
||||
OCG_DuelStatus operator()(T& arg) {
|
||||
if(process(arg)) {
|
||||
core.units.pop_front();
|
||||
return OCG_DUEL_STATUS_CONTINUE;
|
||||
} else {
|
||||
++arg.step;
|
||||
return Processors::NeedsAnswer<T> ? OCG_DUEL_STATUS_AWAITING : OCG_DUEL_STATUS_CONTINUE;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Location Use Reason
|
||||
|
|
@ -789,128 +811,5 @@ enum class CHAININFO {
|
|||
#define GLOBALFLAG_SPSUMMON_ONCE 0x200
|
||||
//#define GLOBALFLAG_TUNE_MAGICIAN 0x400
|
||||
//
|
||||
#define PROCESSOR_FLAG_END 0
|
||||
#define PROCESSOR_FLAG_WAITING 0x1
|
||||
#define PROCESSOR_FLAG_CONTINUE 0x2
|
||||
|
||||
#define PROCESSOR_ADJUST 1
|
||||
#define PROCESSOR_HINT 2
|
||||
#define PROCESSOR_TURN 3
|
||||
#define PROCESSOR_REFRESH_LOC 5
|
||||
#define PROCESSOR_STARTUP 6
|
||||
#define PROCESSOR_SELECT_IDLECMD 10
|
||||
#define PROCESSOR_SELECT_EFFECTYN 11
|
||||
#define PROCESSOR_SELECT_BATTLECMD 12
|
||||
#define PROCESSOR_SELECT_YESNO 13
|
||||
#define PROCESSOR_SELECT_OPTION 14
|
||||
#define PROCESSOR_SELECT_CARD 15
|
||||
#define PROCESSOR_SELECT_CHAIN 16
|
||||
#define PROCESSOR_SELECT_UNSELECT_CARD 17
|
||||
#define PROCESSOR_SELECT_PLACE 18
|
||||
#define PROCESSOR_SELECT_POSITION 19
|
||||
#define PROCESSOR_SELECT_TRIBUTE_P 20
|
||||
#define PROCESSOR_SORT_CHAIN 21
|
||||
#define PROCESSOR_SELECT_COUNTER 22
|
||||
#define PROCESSOR_SELECT_SUM 23
|
||||
#define PROCESSOR_SELECT_DISFIELD 24
|
||||
#define PROCESSOR_SORT_CARD 25
|
||||
#define PROCESSOR_SELECT_RELEASE 26
|
||||
#define PROCESSOR_SELECT_TRIBUTE 27
|
||||
#define PROCESSOR_SELECT_CARD_CODES 28
|
||||
#define PROCESSOR_POINT_EVENT 30
|
||||
#define PROCESSOR_QUICK_EFFECT 31
|
||||
#define PROCESSOR_IDLE_COMMAND 32
|
||||
#define PROCESSOR_PHASE_EVENT 33
|
||||
#define PROCESSOR_BATTLE_COMMAND 34
|
||||
#define PROCESSOR_DAMAGE_STEP 35
|
||||
#define PROCESSOR_FORCED_BATTLE 36
|
||||
#define PROCESSOR_ADD_CHAIN 40
|
||||
#define PROCESSOR_SOLVE_CHAIN 42
|
||||
#define PROCESSOR_SOLVE_CONTINUOUS 43
|
||||
#define PROCESSOR_EXECUTE_COST 44
|
||||
#define PROCESSOR_EXECUTE_OPERATION 45
|
||||
#define PROCESSOR_EXECUTE_TARGET 46
|
||||
#define PROCESSOR_DESTROY 50
|
||||
#define PROCESSOR_RELEASE 51
|
||||
#define PROCESSOR_SENDTO 52
|
||||
#define PROCESSOR_MOVETOFIELD 53
|
||||
#define PROCESSOR_CHANGEPOS 54
|
||||
#define PROCESSOR_OPERATION_REPLACE 55
|
||||
#define PROCESSOR_DESTROY_REPLACE 56
|
||||
#define PROCESSOR_RELEASE_REPLACE 57
|
||||
#define PROCESSOR_SENDTO_REPLACE 58
|
||||
#define PROCESSOR_SUMMON_RULE 60
|
||||
#define PROCESSOR_SPSUMMON_RULE 61
|
||||
#define PROCESSOR_SPSUMMON 62
|
||||
#define PROCESSOR_FLIP_SUMMON 63
|
||||
#define PROCESSOR_MSET 64
|
||||
#define PROCESSOR_SSET 65
|
||||
#define PROCESSOR_SPSUMMON_STEP 66
|
||||
#define PROCESSOR_SSET_G 67
|
||||
#define PROCESSOR_SPSUMMON_RULE_G 68
|
||||
#define PROCESSOR_DRAW 70
|
||||
#define PROCESSOR_DAMAGE 71
|
||||
#define PROCESSOR_RECOVER 72
|
||||
#define PROCESSOR_EQUIP 73
|
||||
#define PROCESSOR_GET_CONTROL 74
|
||||
#define PROCESSOR_SWAP_CONTROL 75
|
||||
#define PROCESSOR_CONTROL_ADJUST 76
|
||||
#define PROCESSOR_SELF_DESTROY 77
|
||||
#define PROCESSOR_TRAP_MONSTER_ADJUST 78
|
||||
#define PROCESSOR_PAY_LPCOST 80
|
||||
#define PROCESSOR_REMOVE_COUNTER 81
|
||||
#define PROCESSOR_ATTACK_DISABLE 82
|
||||
#define PROCESSOR_ACTIVATE_EFFECT 83
|
||||
|
||||
#define PROCESSOR_ANNOUNCE_RACE 110
|
||||
#define PROCESSOR_ANNOUNCE_ATTRIB 111
|
||||
#define PROCESSOR_ANNOUNCE_LEVEL 112
|
||||
#define PROCESSOR_ANNOUNCE_CARD 113
|
||||
#define PROCESSOR_ANNOUNCE_TYPE 114
|
||||
#define PROCESSOR_ANNOUNCE_NUMBER 115
|
||||
#define PROCESSOR_ANNOUNCE_COIN 116
|
||||
#define PROCESSOR_TOSS_DICE 117
|
||||
#define PROCESSOR_TOSS_COIN 118
|
||||
#define PROCESSOR_ROCK_PAPER_SCISSORS 119
|
||||
|
||||
#define PROCESSOR_SELECT_FUSION 131
|
||||
#define PROCESSOR_DISCARD_HAND 150
|
||||
#define PROCESSOR_DISCARD_DECK 151
|
||||
#define PROCESSOR_SORT_DECK 152
|
||||
#define PROCESSOR_REMOVE_OVERLAY 160
|
||||
#define PROCESSOR_XYZ_OVERLAY 161
|
||||
|
||||
#define PROCESSOR_REFRESH_RELAY 170
|
||||
|
||||
//#define PROCESSOR_DESTROY_S 100
|
||||
//#define PROCESSOR_RELEASE_S 101
|
||||
//#define PROCESSOR_SENDTO_S 102
|
||||
//#define PROCESSOR_CHANGEPOS_S 103
|
||||
//#define PROCESSOR_SELECT_YESNO_S 120
|
||||
//#define PROCESSOR_SELECT_OPTION_S 121
|
||||
//#define PROCESSOR_SELECT_CARD_S 122
|
||||
//#define PROCESSOR_SELECT_EFFECTYN_S 123
|
||||
//#define PROCESSOR_SELECT_UNSELECT_CARD_S 124
|
||||
//#define PROCESSOR_SELECT_PLACE_S 125
|
||||
//#define PROCESSOR_SELECT_POSITION_S 126
|
||||
//#define PROCESSOR_SELECT_TRIBUTE_S 127
|
||||
//#define PROCESSOR_SORT_CARDS_S 128
|
||||
//#define PROCESSOR_SELECT_RELEASE_S 129
|
||||
//#define PROCESSOR_SELECT_TARGET 130
|
||||
//#define PROCESSOR_SELECT_SYNCHRO 132
|
||||
//#define PROCESSOR_SELECT_XMATERIAL 139
|
||||
//#define PROCESSOR_SELECT_SUM_S 133
|
||||
//#define PROCESSOR_SELECT_DISFIELD_S 134
|
||||
//#define PROCESSOR_SPSUMMON_S 135
|
||||
//#define PROCESSOR_SPSUMMON_STEP_S 136
|
||||
//#define PROCESSOR_SPSUMMON_COMP_S 137
|
||||
//#define PROCESSOR_RANDOM_SELECT_S 138
|
||||
//#define PROCESSOR_DRAW_S 140
|
||||
//#define PROCESSOR_DAMAGE_S 141
|
||||
//#define PROCESSOR_RECOVER_S 142
|
||||
//#define PROCESSOR_EQUIP_S 143
|
||||
//#define PROCESSOR_GET_CONTROL_S 144
|
||||
//#define PROCESSOR_SWAP_CONTROL_S 145
|
||||
//#define PROCESSOR_MOVETOFIELD_S 161
|
||||
|
||||
#endif /* FIELD_H_ */
|
||||
|
|
|
|||
82
libduel.cpp
82
libduel.cpp
|
|
@ -239,7 +239,7 @@ LUA_STATIC_FUNCTION(Summon) {
|
|||
pduel->game_field->core.summon_cancelable = FALSE;
|
||||
pduel->game_field->summon(playerid, pcard, peffect, ignore_count, min_tribute, zone);
|
||||
if(pduel->game_field->core.current_chain.size()) {
|
||||
pduel->game_field->core.reserved = pduel->game_field->core.subunits.back();
|
||||
pduel->game_field->core.reserved = std::move(pduel->game_field->core.subunits.back());
|
||||
pduel->game_field->core.subunits.pop_back();
|
||||
pduel->game_field->core.summoning_card = pcard;
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ LUA_STATIC_FUNCTION(SpecialSummonRule) {
|
|||
pduel->game_field->core.summon_cancelable = FALSE;
|
||||
pduel->game_field->special_summon_rule(playerid, pcard, sumtype);
|
||||
if(pduel->game_field->core.current_chain.size()) {
|
||||
pduel->game_field->core.reserved = pduel->game_field->core.subunits.back();
|
||||
pduel->game_field->core.reserved = std::move(pduel->game_field->core.subunits.back());
|
||||
pduel->game_field->core.subunits.pop_back();
|
||||
pduel->game_field->core.summoning_card = pcard;
|
||||
}
|
||||
|
|
@ -299,7 +299,7 @@ inline int32_t spsummon_rule(lua_State* L, uint32_t summon_type, uint32_t offset
|
|||
pduel->game_field->core.summon_cancelable = FALSE;
|
||||
pduel->game_field->special_summon_rule(playerid, pcard, summon_type);
|
||||
if(pduel->game_field->core.current_chain.size()) {
|
||||
pduel->game_field->core.reserved = pduel->game_field->core.subunits.back();
|
||||
pduel->game_field->core.reserved = std::move(pduel->game_field->core.subunits.back());
|
||||
pduel->game_field->core.subunits.pop_back();
|
||||
pduel->game_field->core.summoning_card = pcard;
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ inline int32_t spsummon_rule_group(lua_State* L, uint32_t summon_type, [[maybe_u
|
|||
pduel->game_field->core.summon_cancelable = FALSE;
|
||||
pduel->game_field->special_summon_rule_group(playerid, summon_type);
|
||||
if(pduel->game_field->core.current_chain.size()) {
|
||||
pduel->game_field->core.reserved = pduel->game_field->core.subunits.back();
|
||||
pduel->game_field->core.reserved = std::move(pduel->game_field->core.subunits.back());
|
||||
pduel->game_field->core.subunits.pop_back();
|
||||
pduel->game_field->core.summoning_proc_group_type = summon_type;
|
||||
}
|
||||
|
|
@ -356,7 +356,7 @@ LUA_STATIC_FUNCTION(MSet) {
|
|||
pduel->game_field->core.summon_cancelable = FALSE;
|
||||
pduel->game_field->mset(playerid, pcard, peffect, ignore_count, min_tribute, zone);
|
||||
if(pduel->game_field->core.current_chain.size()) {
|
||||
pduel->game_field->core.reserved = pduel->game_field->core.subunits.back();
|
||||
pduel->game_field->core.reserved = std::move(pduel->game_field->core.subunits.back());
|
||||
pduel->game_field->core.subunits.pop_back();
|
||||
pduel->game_field->core.summoning_card = pcard;
|
||||
}
|
||||
|
|
@ -379,7 +379,7 @@ LUA_STATIC_FUNCTION(SSet) {
|
|||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
}
|
||||
pduel->game_field->add_process(PROCESSOR_SSET_G, 0, pduel->game_field->core.reason_effect, pgroup, playerid, toplayer, confirm);
|
||||
pduel->game_field->emplace_process<Processors::SpellSetGroup>(playerid, toplayer, pgroup, confirm, pduel->game_field->core.reason_effect);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -782,7 +782,7 @@ LUA_STATIC_FUNCTION(Activate) {
|
|||
check_action_permission(L);
|
||||
check_param_count(L, 1);
|
||||
auto peffect = lua_get<effect*, true>(L, 1);
|
||||
pduel->game_field->add_process(PROCESSOR_ACTIVATE_EFFECT, 0, peffect, 0, 0, 0);
|
||||
pduel->game_field->emplace_process<Processors::ActivateEffect>(peffect);
|
||||
return 0;
|
||||
}
|
||||
LUA_STATIC_FUNCTION(SetChainLimit) {
|
||||
|
|
@ -921,14 +921,14 @@ LUA_STATIC_FUNCTION(SortDecktop) {
|
|||
check_param_count(L, 3);
|
||||
auto sort_player = lua_get<uint8_t>(L, 1);
|
||||
auto target_player = lua_get<uint8_t>(L, 2);
|
||||
auto count = lua_get<uint32_t>(L, 3);
|
||||
auto count = lua_get<uint16_t>(L, 3);
|
||||
if(sort_player != 0 && sort_player != 1)
|
||||
return 0;
|
||||
if(target_player != 0 && target_player != 1)
|
||||
return 0;
|
||||
if(count < 1 || count > 64)
|
||||
return 0;
|
||||
pduel->game_field->add_process(PROCESSOR_SORT_DECK, 0, 0, 0, sort_player + (target_player << 16), count, FALSE);
|
||||
pduel->game_field->emplace_process<Processors::SortDeck>(sort_player, target_player, count, false);
|
||||
return yield();
|
||||
}
|
||||
LUA_STATIC_FUNCTION(SortDeckbottom) {
|
||||
|
|
@ -936,14 +936,14 @@ LUA_STATIC_FUNCTION(SortDeckbottom) {
|
|||
check_param_count(L, 3);
|
||||
auto sort_player = lua_get<uint8_t>(L, 1);
|
||||
auto target_player = lua_get<uint8_t>(L, 2);
|
||||
auto count = lua_get<uint32_t>(L, 3);
|
||||
auto count = lua_get<uint16_t>(L, 3);
|
||||
if(sort_player != 0 && sort_player != 1)
|
||||
return 0;
|
||||
if(target_player != 0 && target_player != 1)
|
||||
return 0;
|
||||
if(count < 1 || count > 64)
|
||||
return 0;
|
||||
pduel->game_field->add_process(PROCESSOR_SORT_DECK, 0, 0, 0, sort_player + (target_player << 16), count, TRUE);
|
||||
pduel->game_field->emplace_process<Processors::SortDeck>(sort_player, target_player, count, true);
|
||||
return yield();
|
||||
}
|
||||
LUA_STATIC_FUNCTION(CheckEvent) {
|
||||
|
|
@ -1280,7 +1280,7 @@ LUA_STATIC_FUNCTION(PayLPCost) {
|
|||
if(playerid != 0 && playerid != 1)
|
||||
return 0;
|
||||
auto cost = lua_get<uint32_t>(L, 2);
|
||||
pduel->game_field->add_process(PROCESSOR_PAY_LPCOST, 0, 0, 0, playerid, cost);
|
||||
pduel->game_field->emplace_process<Processors::PayLPCost>(playerid, cost);
|
||||
return yield();
|
||||
}
|
||||
LUA_STATIC_FUNCTION(DiscardDeck) {
|
||||
|
|
@ -1289,7 +1289,7 @@ LUA_STATIC_FUNCTION(DiscardDeck) {
|
|||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
auto count = lua_get<uint16_t>(L, 2);
|
||||
auto reason = lua_get<uint32_t>(L, 3);
|
||||
pduel->game_field->add_process(PROCESSOR_DISCARD_DECK, 0, 0, 0, playerid + (count << 16), reason);
|
||||
pduel->game_field->emplace_process<Processors::DiscardDeck>(playerid, count, reason);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -1318,7 +1318,7 @@ LUA_STATIC_FUNCTION(DiscardHand) {
|
|||
lua_pushinteger(L, 0);
|
||||
return 1;
|
||||
}
|
||||
pduel->game_field->add_process(PROCESSOR_DISCARD_HAND, 0, nullptr, nullptr, playerid, min + (max << 16), reason);
|
||||
pduel->game_field->emplace_process<Processors::DiscardHand>(playerid, min, max, reason);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -1512,7 +1512,7 @@ LUA_STATIC_FUNCTION(CalculateDamage) {
|
|||
auto new_attack = lua_get<bool, false>(L, 3);
|
||||
if(attacker == attack_target)
|
||||
return 0;
|
||||
pduel->game_field->add_process(PROCESSOR_DAMAGE_STEP, 0, (effect*)attacker, (group*)attack_target, 0, new_attack);
|
||||
pduel->game_field->emplace_process<Processors::DamageStep>(attacker, attack_target, new_attack);
|
||||
return yield();
|
||||
}
|
||||
LUA_STATIC_FUNCTION(GetBattleDamage) {
|
||||
|
|
@ -2119,7 +2119,7 @@ LUA_STATIC_FUNCTION(GetBattleMonster) {
|
|||
return 2;
|
||||
}
|
||||
LUA_STATIC_FUNCTION(NegateAttack) {
|
||||
pduel->game_field->add_process(PROCESSOR_ATTACK_DISABLE, 0, 0, 0, 0, 0);
|
||||
pduel->game_field->emplace_process<Processors::AttackDisable>();
|
||||
return yieldk({
|
||||
lua_pushboolean(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -2337,7 +2337,7 @@ LUA_STATIC_FUNCTION(SelectMatchingCard) {
|
|||
group* pgroup = pduel->new_group();
|
||||
pduel->game_field->filter_matching_card(findex, self, location1, location2, pgroup, pexception, pexgroup, extraargs);
|
||||
pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end());
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16));
|
||||
pduel->game_field->emplace_process<Processors::SelectCard>(playerid, cancelable, min, max);
|
||||
return push_return_cards(L, cancelable);
|
||||
}
|
||||
LUA_STATIC_FUNCTION(SelectCardsFromCodes) {
|
||||
|
|
@ -2354,7 +2354,7 @@ LUA_STATIC_FUNCTION(SelectCardsFromCodes) {
|
|||
lua_iterate_table_or_stack(L, 6, lua_gettop(L), [L, &select_codes = pduel->game_field->core.select_cards_codes]{
|
||||
select_codes.emplace_back(lua_get<uint32_t>(L, -1), static_cast<uint32_t>(select_codes.size() + 1));
|
||||
});
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_CARD_CODES, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16));
|
||||
pduel->game_field->emplace_process<Processors::SelectCardCodes>(playerid, cancelable, min, max);
|
||||
return yieldk({
|
||||
int ret = 1;
|
||||
const auto& ret_codes = pduel->game_field->return_card_codes;
|
||||
|
|
@ -2504,7 +2504,7 @@ static int32_t select_release_group(lua_State* L, uint8_t use_hand) {
|
|||
pduel->game_field->core.release_cards_ex.clear();
|
||||
pduel->game_field->core.release_cards_ex_oneof.clear();
|
||||
pduel->game_field->get_release_list(playerid, &pduel->game_field->core.release_cards, &pduel->game_field->core.release_cards_ex, &pduel->game_field->core.release_cards_ex_oneof, use_hand, findex, extraargs, pexception, pexgroup, use_oppo, REASON_EFFECT);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_RELEASE, 0, 0, (group*)to_check, playerid + (cancelable << 16), (max << 16) + min, check_field + (toplayer << 8) + (zone << 16));
|
||||
pduel->game_field->emplace_process<Processors::SelectRelease>(playerid, cancelable, min, max, check_field, to_check, toplayer, zone);
|
||||
return push_return_cards(L, cancelable);
|
||||
}
|
||||
LUA_STATIC_FUNCTION(SelectReleaseGroup) {
|
||||
|
|
@ -2656,7 +2656,7 @@ LUA_STATIC_FUNCTION(SelectTarget) {
|
|||
group* pgroup = pduel->new_group();
|
||||
pduel->game_field->filter_matching_card(findex, self, location1, location2, pgroup, pexception, pexgroup, extraargs, nullptr, 0, true);
|
||||
pduel->game_field->core.select_cards.assign(pgroup->container.begin(), pgroup->container.end());
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16));
|
||||
pduel->game_field->emplace_process<Processors::SelectCard>(playerid, cancelable, min, max);
|
||||
return yieldk({
|
||||
if(pduel->game_field->return_cards.canceled) {
|
||||
lua_pushnil(L);
|
||||
|
|
@ -2696,13 +2696,13 @@ LUA_STATIC_FUNCTION(SelectFusionMaterial) {
|
|||
return 0;
|
||||
auto pcard = lua_get<card*, true>(L, 2);
|
||||
auto pgroup = lua_get<group*, true>(L, 3);
|
||||
group* cg = 0;
|
||||
if(auto _pcard = lua_get<card*>(L, 4))
|
||||
cg = pduel->new_group(_pcard);
|
||||
group* forced_materials = nullptr;
|
||||
if(auto pcard_ = lua_get<card*>(L, 4))
|
||||
forced_materials = pduel->new_group(pcard_);
|
||||
else
|
||||
cg = lua_get<group*>(L, 4);
|
||||
forced_materials = lua_get<group*>(L, 4);
|
||||
auto chkf = lua_get<uint32_t, PLAYER_NONE>(L, 5);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_FUSION, 0, 0, (group*)pgroup, playerid + (chkf << 16), 0, 0, 0, cg, (card*)pcard);
|
||||
pduel->game_field->emplace_process<Processors::SelectFusion>(playerid, pgroup, chkf, forced_materials, pcard);
|
||||
return yieldk({
|
||||
group* pgroup = pduel->new_group(pduel->game_field->core.fusion_materials);
|
||||
interpreter::pushobject(L, pgroup);
|
||||
|
|
@ -3068,7 +3068,7 @@ LUA_STATIC_FUNCTION(SelectEffectYesNo) {
|
|||
if(playerid != 0 && playerid != 1)
|
||||
return 0;
|
||||
auto desc = lua_get<uint64_t, 95>(L, 3);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_EFFECTYN, 0, 0, (group*)pcard, playerid, desc);
|
||||
pduel->game_field->emplace_process<Processors::SelectEffectYesNo>(playerid, desc, pcard);
|
||||
return yieldk({
|
||||
lua_pushboolean(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -3081,7 +3081,7 @@ LUA_STATIC_FUNCTION(SelectYesNo) {
|
|||
if(playerid != 0 && playerid != 1)
|
||||
return 0;
|
||||
auto desc = lua_get<uint64_t>(L, 2);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, playerid, desc);
|
||||
pduel->game_field->emplace_process<Processors::SelectYesNo>(playerid, desc);
|
||||
return yieldk({
|
||||
lua_pushboolean(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -3097,7 +3097,7 @@ LUA_STATIC_FUNCTION(SelectOption) {
|
|||
lua_iterate_table_or_stack(L, 2 + lua_isboolean(L, 2), lua_gettop(L), [L, &select_options = pduel->game_field->core.select_options] {
|
||||
select_options.push_back(lua_get<uint64_t>(L, -1));
|
||||
});
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, playerid, 0);
|
||||
pduel->game_field->emplace_process<Processors::SelectOption>(playerid);
|
||||
return yieldk({
|
||||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
bool sel_hint = lua_get<bool, true>(L, 2);
|
||||
|
|
@ -3117,7 +3117,7 @@ LUA_STATIC_FUNCTION(SelectPosition) {
|
|||
auto pcard = lua_get<card*, true>(L, 2);
|
||||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
auto positions = lua_get<uint8_t>(L, 3);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_POSITION, 0, 0, 0, playerid + (positions << 16), pcard->data.code);
|
||||
pduel->game_field->emplace_process<Processors::SelectPosition>(playerid, pcard->data.code, positions);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -3213,7 +3213,7 @@ LUA_STATIC_FUNCTION(SelectDisableField) {
|
|||
count = ct1 + ct2 + ct3 + ct4;
|
||||
if(count == 0)
|
||||
return 0;
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_DISFIELD, 0, 0, 0, playerid, flag, count);
|
||||
pduel->game_field->emplace_process<Processors::SelectDisField>(playerid, flag, count);
|
||||
return yieldk({
|
||||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
auto count = lua_get<uint8_t>(L, 2);
|
||||
|
|
@ -3254,7 +3254,7 @@ LUA_STATIC_FUNCTION(SelectFieldZone) {
|
|||
flag |= filter;
|
||||
if (flag == 0xffffffff)
|
||||
return 0;
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_DISFIELD, 0, 0, 0, playerid, flag, count);
|
||||
pduel->game_field->emplace_process<Processors::SelectDisField>(playerid, flag, count);
|
||||
return yieldk({
|
||||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
auto count = lua_get<uint8_t>(L, 2);
|
||||
|
|
@ -3279,7 +3279,7 @@ LUA_STATIC_FUNCTION(AnnounceRace) {
|
|||
if(bit::has_invalid_bits(available, RACE_ALL))
|
||||
lua_error(L, "Passed an invalid race.");
|
||||
auto count = std::min(lua_get<uint8_t>(L, 2), bit::popcnt(available));
|
||||
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_RACE, 0, 0, 0, playerid + (count << 16), available);
|
||||
pduel->game_field->emplace_process<Processors::AnnounceRace>(playerid, count, available);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<uint64_t>(0));
|
||||
return 1;
|
||||
|
|
@ -3293,7 +3293,7 @@ LUA_STATIC_FUNCTION(AnnounceAttribute) {
|
|||
if(bit::has_invalid_bits(available, ATTRIBUTE_ALL))
|
||||
lua_error(L, "Passed an invalid attribute.");
|
||||
auto count = std::min(lua_get<uint8_t>(L, 2), bit::popcnt(available));
|
||||
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_ATTRIB, 0, 0, 0, playerid + (count << 16), available);
|
||||
pduel->game_field->emplace_process<Processors::AnnounceAttribute>(playerid, count, available);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -3338,7 +3338,7 @@ LUA_STATIC_FUNCTION(AnnounceNumberRange) {
|
|||
}
|
||||
if(select_options.empty())
|
||||
return 0;
|
||||
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_NUMBER, 0, 0, 0, playerid, 0);
|
||||
pduel->game_field->emplace_process<Processors::AnnounceNumber>(playerid);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->core.select_options[pduel->game_field->returns.at<int32_t>(0)]);
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
|
|
@ -3406,7 +3406,7 @@ LUA_STATIC_FUNCTION(AnnounceCard) {
|
|||
options.push_back(TYPE_MONSTER | TYPE_SPELL | TYPE_TRAP);
|
||||
options.push_back(OPCODE_ISTYPE);
|
||||
}
|
||||
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, 0);
|
||||
pduel->game_field->emplace_process<Processors::AnnounceCard>(playerid);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
@ -3420,7 +3420,7 @@ LUA_STATIC_FUNCTION(AnnounceType) {
|
|||
pduel->game_field->core.select_options.push_back(70);
|
||||
pduel->game_field->core.select_options.push_back(71);
|
||||
pduel->game_field->core.select_options.push_back(72);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, playerid, 0);
|
||||
pduel->game_field->emplace_process<Processors::SelectOption>(playerid);
|
||||
return yieldk({
|
||||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
auto message = pduel->new_message(MSG_HINT);
|
||||
|
|
@ -3439,7 +3439,7 @@ LUA_STATIC_FUNCTION(AnnounceNumber) {
|
|||
lua_iterate_table_or_stack(L, 2, lua_gettop(L), [L, &select_options = pduel->game_field->core.select_options] {
|
||||
select_options.push_back(lua_get<uint64_t>(L, -1));
|
||||
});
|
||||
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_NUMBER, 0, 0, 0, playerid, 0);
|
||||
pduel->game_field->emplace_process<Processors::AnnounceNumber>(playerid);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->core.select_options[pduel->game_field->returns.at<int32_t>(0)]);
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
|
|
@ -3458,7 +3458,7 @@ LUA_STATIC_FUNCTION(AnnounceCoin) {
|
|||
pduel->game_field->core.select_options.clear();
|
||||
pduel->game_field->core.select_options.push_back(60);
|
||||
pduel->game_field->core.select_options.push_back(61);
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, playerid, 0);
|
||||
pduel->game_field->emplace_process<Processors::SelectOption>(playerid);
|
||||
return yieldk({
|
||||
if(/*bool sel_hint = */lua_get<bool, true>(L, 2)) {
|
||||
auto playerid = lua_get<uint8_t>(L, 1);
|
||||
|
|
@ -3480,7 +3480,7 @@ LUA_STATIC_FUNCTION(TossCoin) {
|
|||
return 0;
|
||||
if(count > 5)
|
||||
count = 5;
|
||||
pduel->game_field->add_process(PROCESSOR_TOSS_COIN, 0, pduel->game_field->core.reason_effect, 0, (pduel->game_field->core.reason_player << 16) + playerid, count);
|
||||
pduel->game_field->emplace_process<Processors::TossCoin>(pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, playerid, count);
|
||||
return yieldk({
|
||||
const auto& coin_results = pduel->game_field->core.coin_results;
|
||||
luaL_checkstack(L, static_cast<int>(coin_results.size()), nullptr);
|
||||
|
|
@ -3497,7 +3497,7 @@ LUA_STATIC_FUNCTION(TossDice) {
|
|||
if(playerid != 0 && playerid != 1)
|
||||
return 0;
|
||||
auto count2 = lua_get<uint8_t, 0>(L, 3);
|
||||
pduel->game_field->add_process(PROCESSOR_TOSS_DICE, 0, pduel->game_field->core.reason_effect, 0, (pduel->game_field->core.reason_player << 16) + playerid, count1 + (count2 << 16));
|
||||
pduel->game_field->emplace_process<Processors::TossDice>(pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, playerid, count1, count2);
|
||||
return yieldk({
|
||||
const auto& dice_results = pduel->game_field->core.dice_results;
|
||||
luaL_checkstack(L, static_cast<int>(dice_results.size()), nullptr);
|
||||
|
|
@ -3508,7 +3508,7 @@ LUA_STATIC_FUNCTION(TossDice) {
|
|||
}
|
||||
LUA_STATIC_FUNCTION(RockPaperScissors) {
|
||||
uint8_t repeat = lua_get<bool, true>(L, 1);
|
||||
pduel->game_field->add_process(PROCESSOR_ROCK_PAPER_SCISSORS, 0, 0, 0, repeat, 0);
|
||||
pduel->game_field->emplace_process<Processors::RockPaperScissors>(repeat);
|
||||
return yieldk({
|
||||
lua_pushinteger(L, pduel->game_field->returns.at<int32_t>(0));
|
||||
return 1;
|
||||
|
|
|
|||
10
libgroup.cpp
10
libgroup.cpp
|
|
@ -245,7 +245,7 @@ LUA_FUNCTION(FilterSelect) {
|
|||
if(pduel->lua->check_matching(pcard, findex, extraargs))
|
||||
pduel->game_field->core.select_cards.push_back(pcard);
|
||||
}
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16));
|
||||
pduel->game_field->emplace_process<Processors::SelectCard>(playerid, cancelable, min, max);
|
||||
return push_return_cards(L, cancelable);
|
||||
}
|
||||
LUA_FUNCTION(Select) {
|
||||
|
|
@ -270,7 +270,7 @@ LUA_FUNCTION(Select) {
|
|||
auto min = lua_get<uint16_t>(L, 3);
|
||||
auto max = lua_get<uint16_t>(L, 4);
|
||||
pduel->game_field->core.select_cards.assign(cset.begin(), cset.end());
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16));
|
||||
pduel->game_field->emplace_process<Processors::SelectCard>(playerid, cancelable, min, max);
|
||||
return push_return_cards(L, cancelable);
|
||||
}
|
||||
LUA_FUNCTION(SelectUnselect) {
|
||||
|
|
@ -307,7 +307,7 @@ LUA_FUNCTION(SelectUnselect) {
|
|||
pduel->game_field->core.unselect_cards.assign(pgroup2->container.begin(), pgroup2->container.end());
|
||||
else
|
||||
pduel->game_field->core.unselect_cards.clear();
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_UNSELECT_CARD, 0, 0, 0, playerid + (cancelable << 16), min + (max << 16), finishable);
|
||||
pduel->game_field->emplace_process<Processors::SelectUnselectCard>(playerid, cancelable, min, max, finishable);
|
||||
return yieldk({
|
||||
if(pduel->game_field->return_cards.canceled)
|
||||
lua_pushnil(L);
|
||||
|
|
@ -427,7 +427,7 @@ LUA_FUNCTION(SelectWithSumEqual) {
|
|||
interpreter::pushobject(L, empty_group);
|
||||
return 1;
|
||||
}
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_SUM, 0, 0, 0, acc, playerid + (min << 16) + (max << 24));
|
||||
pduel->game_field->emplace_process<Processors::SelectSum>(playerid, acc, min, max);
|
||||
return yieldk({
|
||||
group* pgroup = pduel->new_group(pduel->game_field->return_cards.list);
|
||||
pduel->game_field->core.must_select_cards.clear();
|
||||
|
|
@ -481,7 +481,7 @@ LUA_FUNCTION(SelectWithSumGreater) {
|
|||
interpreter::pushobject(L, empty_group);
|
||||
return 1;
|
||||
}
|
||||
pduel->game_field->add_process(PROCESSOR_SELECT_SUM, 0, 0, 0, acc, playerid);
|
||||
pduel->game_field->emplace_process<Processors::SelectSum>(playerid, acc, 0, 0);
|
||||
return yieldk({
|
||||
group* pgroup = pduel->new_group(pduel->game_field->return_cards.list);
|
||||
pduel->game_field->core.must_select_cards.clear();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ ocgcore_src = files([
|
|||
'operations.cpp',
|
||||
'playerop.cpp',
|
||||
'processor.cpp',
|
||||
'processor_visit.cpp',
|
||||
'scriptlib.cpp',
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -93,17 +93,17 @@ OCGAPI void OCG_DuelNewCard(OCG_Duel ocg_duel, OCG_NewCardInfo info) {
|
|||
|
||||
OCGAPI void OCG_StartDuel(OCG_Duel ocg_duel) {
|
||||
auto* pduel = static_cast<duel*>(ocg_duel);
|
||||
pduel->game_field->add_process(PROCESSOR_STARTUP, 0, 0, 0, 0, 0);
|
||||
pduel->game_field->emplace_process<Processors::Startup>();
|
||||
}
|
||||
|
||||
OCGAPI int OCG_DuelProcess(OCG_Duel ocg_duel) {
|
||||
auto* pduel = static_cast<duel*>(ocg_duel);
|
||||
pduel->buff.clear();
|
||||
auto flag = 0;
|
||||
auto flag = OCG_DUEL_STATUS_END;
|
||||
do {
|
||||
flag = pduel->game_field->process();
|
||||
pduel->generate_buffer();
|
||||
} while(pduel->buff.size() == 0 && flag == PROCESSOR_FLAG_CONTINUE);
|
||||
} while(pduel->buff.size() == 0 && flag == OCG_DUEL_STATUS_CONTINUE);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
|
|
|||
1543
operations.cpp
1543
operations.cpp
File diff suppressed because it is too large
Load diff
166
playerop.cpp
166
playerop.cpp
|
|
@ -15,8 +15,9 @@
|
|||
#include "effect.h"
|
||||
#include "field.h"
|
||||
|
||||
int32_t field::select_battle_command(uint16_t step, uint8_t playerid) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectBattleCmd& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
if(arg.step == 0) {
|
||||
auto message = pduel->new_message(MSG_SELECT_BATTLECMD);
|
||||
message->write<uint8_t>(playerid);
|
||||
//Activatable
|
||||
|
|
@ -65,8 +66,9 @@ int32_t field::select_battle_command(uint16_t step, uint8_t playerid) {
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_idle_command(uint16_t step, uint8_t playerid) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectIdleCmd& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
if(arg.step == 0) {
|
||||
auto message = pduel->new_message(MSG_SELECT_IDLECMD);
|
||||
message->write<uint8_t>(playerid);
|
||||
//idle summon
|
||||
|
|
@ -155,9 +157,12 @@ int32_t field::select_idle_command(uint16_t step, uint8_t playerid) {
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_effect_yes_no(uint16_t step, uint8_t playerid, uint64_t description, card* pcard) {
|
||||
if(step == 0) {
|
||||
if((playerid == 1) && is_flag(DUEL_SIMPLE_AI)) {
|
||||
bool field::process(Processors::SelectEffectYesNo& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto pcard = arg.pcard;
|
||||
auto description = arg.description;
|
||||
if(arg.step == 0) {
|
||||
if((arg.playerid == 1) && is_flag(DUEL_SIMPLE_AI)) {
|
||||
returns.set<int32_t>(0, 1);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -176,8 +181,10 @@ int32_t field::select_effect_yes_no(uint16_t step, uint8_t playerid, uint64_t de
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_yes_no(uint16_t step, uint8_t playerid, uint64_t description) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectYesNo& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto description = arg.description;
|
||||
if(arg.step == 0) {
|
||||
if((playerid == 1) && is_flag(DUEL_SIMPLE_AI)) {
|
||||
returns.set<int32_t>(0, 1);
|
||||
return TRUE;
|
||||
|
|
@ -195,8 +202,9 @@ int32_t field::select_yes_no(uint16_t step, uint8_t playerid, uint64_t descripti
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_option(uint16_t step, uint8_t playerid) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectOption& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
if(arg.step == 0) {
|
||||
returns.set<int32_t>(0, -1);
|
||||
if(core.select_options.size() == 0) {
|
||||
auto message = pduel->new_message(MSG_HINT);
|
||||
|
|
@ -269,8 +277,12 @@ bool parse_response_cards(ProgressiveBuffer& returns, return_card_generic<Return
|
|||
bool inline field::parse_response_cards(bool cancelable) {
|
||||
return ::parse_response_cards(returns, return_cards, core.select_cards, cancelable);
|
||||
}
|
||||
int32_t field::select_card(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectCard& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto cancelable = arg.cancelable;
|
||||
auto min = arg.min;
|
||||
auto max = arg.max;
|
||||
if(arg.step == 0) {
|
||||
return_cards.clear();
|
||||
returns.clear();
|
||||
if(max == 0 || core.select_cards.empty()) {
|
||||
|
|
@ -290,7 +302,8 @@ int32_t field::select_card(uint16_t step, uint8_t playerid, uint8_t cancelable,
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
core.units.begin()->arg2 = ((uint32_t)min) + (((uint32_t)max) << 16);
|
||||
arg.min = min;
|
||||
arg.max = max;
|
||||
auto message = pduel->new_message(MSG_SELECT_CARD);
|
||||
message->write<uint8_t>(playerid);
|
||||
message->write<uint8_t>(cancelable || min == 0);
|
||||
|
|
@ -319,8 +332,12 @@ int32_t field::select_card(uint16_t step, uint8_t playerid, uint8_t cancelable,
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_card_codes(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectCardCodes& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto cancelable = arg.cancelable;
|
||||
auto min = arg.min;
|
||||
auto max = arg.max;
|
||||
if(arg.step == 0) {
|
||||
return_card_codes.clear();
|
||||
returns.clear();
|
||||
if(max == 0 || core.select_cards_codes.empty()) {
|
||||
|
|
@ -340,7 +357,8 @@ int32_t field::select_card_codes(uint16_t step, uint8_t playerid, uint8_t cancel
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
core.units.begin()->arg2 = ((uint32_t)min) + (((uint32_t)max) << 16);
|
||||
arg.min = min;
|
||||
arg.max = max;
|
||||
auto message = pduel->new_message(MSG_SELECT_CARD);
|
||||
message->write<uint8_t>(playerid);
|
||||
message->write<uint8_t>(cancelable || min == 0);
|
||||
|
|
@ -368,8 +386,13 @@ int32_t field::select_card_codes(uint16_t step, uint8_t playerid, uint8_t cancel
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_unselect_card(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max, uint8_t finishable) {
|
||||
if (step == 0) {
|
||||
bool field::process(Processors::SelectUnselectCard& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto cancelable = arg.cancelable;
|
||||
auto min = arg.min;
|
||||
auto max = arg.max;
|
||||
auto finishable = arg.finishable;
|
||||
if (arg.step == 0) {
|
||||
return_cards.clear();
|
||||
returns.clear();
|
||||
if (core.select_cards.empty() && core.unselect_cards.empty()) {
|
||||
|
|
@ -429,8 +452,11 @@ int32_t field::select_unselect_card(uint16_t step, uint8_t playerid, uint8_t can
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_chain(uint16_t step, uint8_t playerid, uint8_t spe_count, uint8_t forced) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectChain& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto spe_count = arg.spe_count;
|
||||
auto forced = arg.forced;
|
||||
if(arg.step == 0) {
|
||||
returns.set<int32_t>(0, -1);
|
||||
if((playerid == 1) && is_flag(DUEL_SIMPLE_AI)) {
|
||||
if(core.select_chains.size() == 0)
|
||||
|
|
@ -476,8 +502,12 @@ int32_t field::select_chain(uint16_t step, uint8_t playerid, uint8_t spe_count,
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_place(uint16_t step, uint8_t playerid, uint32_t flag, uint8_t count) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectPlace& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto flag = arg.flag;
|
||||
auto count = arg.count;
|
||||
auto disable_field = arg.disable_field;
|
||||
if(arg.step == 0) {
|
||||
if(count == 0) {
|
||||
auto message = pduel->new_message(MSG_HINT);
|
||||
message->write<uint8_t>(HINT_SELECTMSG);
|
||||
|
|
@ -530,7 +560,7 @@ int32_t field::select_place(uint16_t step, uint8_t playerid, uint32_t flag, uint
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
auto message = pduel->new_message((core.units.begin()->type == PROCESSOR_SELECT_PLACE) ? MSG_SELECT_PLACE : MSG_SELECT_DISFIELD);
|
||||
auto message = pduel->new_message(disable_field ? MSG_SELECT_DISFIELD : MSG_SELECT_PLACE);
|
||||
message->write<uint8_t>(playerid);
|
||||
message->write<uint8_t>(count);
|
||||
message->write<uint32_t>(flag);
|
||||
|
|
@ -567,8 +597,11 @@ int32_t field::select_place(uint16_t step, uint8_t playerid, uint32_t flag, uint
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_position(uint16_t step, uint8_t playerid, uint32_t code, uint8_t positions) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectPosition& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto code = arg.code;
|
||||
uint8_t positions = arg.positions;
|
||||
if(arg.step == 0) {
|
||||
if(positions == 0) {
|
||||
returns.set<int32_t>(0, POS_FACEUP_ATTACK);
|
||||
return TRUE;
|
||||
|
|
@ -604,8 +637,12 @@ int32_t field::select_position(uint16_t step, uint8_t playerid, uint32_t code, u
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_tribute(uint16_t step, uint8_t playerid, uint8_t cancelable, uint8_t min, uint8_t max) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectTributeP& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto cancelable = arg.cancelable;
|
||||
auto min = arg.min;
|
||||
auto max = arg.max;
|
||||
if(arg.step == 0) {
|
||||
returns.clear();
|
||||
return_cards.clear();
|
||||
if(max == 0 || core.select_cards.empty()) {
|
||||
|
|
@ -624,7 +661,8 @@ int32_t field::select_tribute(uint16_t step, uint8_t playerid, uint8_t cancelabl
|
|||
max = tm;
|
||||
if(min > max)
|
||||
min = max;
|
||||
core.units.begin()->arg2 = ((uint32_t)min) + (((uint32_t)max) << 16);
|
||||
arg.min = min;
|
||||
arg.max = max;
|
||||
auto message = pduel->new_message(MSG_SELECT_TRIBUTE);
|
||||
message->write<uint8_t>(playerid);
|
||||
message->write<uint8_t>(cancelable || min == 0);
|
||||
|
|
@ -664,11 +702,16 @@ int32_t field::select_tribute(uint16_t step, uint8_t playerid, uint8_t cancelabl
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::select_counter(uint16_t step, uint8_t playerid, uint16_t countertype, uint16_t count, uint8_t s, uint8_t o) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectCounter& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto countertype = arg.countertype;
|
||||
auto count = arg.count;
|
||||
auto self = arg.self;
|
||||
auto oppo = arg.oppo;
|
||||
if(arg.step == 0) {
|
||||
if(count == 0)
|
||||
return TRUE;
|
||||
uint8_t avail = s;
|
||||
uint8_t avail = self;
|
||||
uint8_t fp = playerid;
|
||||
uint32_t total = 0;
|
||||
core.select_cards.clear();
|
||||
|
|
@ -688,7 +731,7 @@ int32_t field::select_counter(uint16_t step, uint8_t playerid, uint16_t countert
|
|||
}
|
||||
}
|
||||
fp = 1 - fp;
|
||||
avail = o;
|
||||
avail = oppo;
|
||||
}
|
||||
if(count > total)
|
||||
count = total;
|
||||
|
|
@ -732,8 +775,12 @@ static int32_t select_sum_check1(const std::vector<int32_t>& oparam, int32_t siz
|
|||
return (acc > o1 && select_sum_check1(oparam, size, index + 1, acc - o1))
|
||||
|| (o2 > 0 && acc > o2 && select_sum_check1(oparam, size, index + 1, acc - o2));
|
||||
}
|
||||
int32_t field::select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc, int32_t min, int32_t max) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SelectSum& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto acc = arg.acc;
|
||||
auto min = arg.min;
|
||||
auto max = arg.max;
|
||||
if(arg.step == 0) {
|
||||
return_cards.clear();
|
||||
returns.clear();
|
||||
if(core.select_cards.empty()) {
|
||||
|
|
@ -818,8 +865,10 @@ int32_t field::select_with_sum_limit(int16_t step, uint8_t playerid, int32_t acc
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
int32_t field::sort_card(int16_t step, uint8_t playerid, uint8_t is_chain) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::SortCard& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto is_chain = arg.is_chain;
|
||||
if(arg.step == 0) {
|
||||
returns.clear();
|
||||
if((playerid == 1) && is_flag(DUEL_SIMPLE_AI)) {
|
||||
returns.set<int8_t>(0, -1);
|
||||
|
|
@ -859,8 +908,11 @@ int32_t field::sort_card(int16_t step, uint8_t playerid, uint8_t is_chain) {
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
int32_t field::announce_race(int16_t step, uint8_t playerid, uint8_t count, uint64_t available) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::AnnounceRace& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto count = arg.count;
|
||||
auto available = arg.available;
|
||||
if(arg.step == 0) {
|
||||
if(count == 0) {
|
||||
auto message = pduel->new_message(MSG_HINT);
|
||||
message->write<uint8_t>(HINT_SELECTMSG);
|
||||
|
|
@ -891,8 +943,11 @@ int32_t field::announce_race(int16_t step, uint8_t playerid, uint8_t count, uint
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
int32_t field::announce_attribute(int16_t step, uint8_t playerid, uint8_t count, uint32_t available) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::AnnounceAttribute& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
auto count = arg.count;
|
||||
auto available = arg.available;
|
||||
if(arg.step == 0) {
|
||||
if(count == 0) {
|
||||
auto message = pduel->new_message(MSG_HINT);
|
||||
message->write<uint8_t>(HINT_SELECTMSG);
|
||||
|
|
@ -1014,8 +1069,9 @@ static int32_t is_declarable(const card_data& cd, const std::vector<uint64_t>& o
|
|||
#undef UNARY_OP
|
||||
#undef UNARY_OP_OP
|
||||
#undef GET_OP
|
||||
int32_t field::announce_card(int16_t step, uint8_t playerid) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::AnnounceCard& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
if(arg.step == 0) {
|
||||
auto message = pduel->new_message(MSG_ANNOUNCE_CARD);
|
||||
message->write<uint8_t>(playerid);
|
||||
message->write<uint8_t>(static_cast<uint8_t>(core.select_options.size()));
|
||||
|
|
@ -1037,8 +1093,9 @@ int32_t field::announce_card(int16_t step, uint8_t playerid) {
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
int32_t field::announce_number(int16_t step, uint8_t playerid) {
|
||||
if(step == 0) {
|
||||
bool field::process(Processors::AnnounceNumber& arg) {
|
||||
auto playerid = arg.playerid;
|
||||
if(arg.step == 0) {
|
||||
auto message = pduel->new_message(MSG_ANNOUNCE_NUMBER);
|
||||
message->write<uint8_t>(playerid);
|
||||
message->write<uint8_t>(static_cast<uint8_t>(core.select_options.size()));
|
||||
|
|
@ -1058,17 +1115,18 @@ int32_t field::announce_number(int16_t step, uint8_t playerid) {
|
|||
return TRUE;
|
||||
}
|
||||
}
|
||||
int32_t field::rock_paper_scissors(uint16_t step, uint8_t repeat) {
|
||||
auto checkvalid = [this] {
|
||||
bool field::process(Processors::RockPaperScissors& arg) {
|
||||
auto checkvalid = [&] {
|
||||
const auto ret = returns.at<int32_t>(0);
|
||||
if(ret < 1 || ret>3) {
|
||||
if(ret < 1 || ret > 3) {
|
||||
pduel->new_message(MSG_RETRY);
|
||||
--core.units.begin()->step;
|
||||
--arg.step;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
switch(step) {
|
||||
auto repeat = arg.repeat;
|
||||
switch(arg.step) {
|
||||
case 0: {
|
||||
auto message = pduel->new_message(MSG_ROCK_PAPER_SCISSORS);
|
||||
message->write<uint8_t>(0);
|
||||
|
|
@ -1076,7 +1134,7 @@ int32_t field::rock_paper_scissors(uint16_t step, uint8_t repeat) {
|
|||
}
|
||||
case 1: {
|
||||
if(checkvalid()) {
|
||||
core.units.begin()->arg2 = returns.at<int32_t>(0);
|
||||
arg.hand0 = returns.at<int32_t>(0);
|
||||
auto message = pduel->new_message(MSG_ROCK_PAPER_SCISSORS);
|
||||
message->write<uint8_t>(1);
|
||||
}
|
||||
|
|
@ -1085,15 +1143,15 @@ int32_t field::rock_paper_scissors(uint16_t step, uint8_t repeat) {
|
|||
case 2: {
|
||||
if(!checkvalid())
|
||||
return FALSE;
|
||||
int32_t hand0 = core.units.begin()->arg2;
|
||||
int32_t hand1 = returns.at<int32_t>(0);
|
||||
auto hand0 = arg.hand0;
|
||||
auto hand1 = static_cast<uint8_t>(returns.at<int32_t>(0));
|
||||
auto message = pduel->new_message(MSG_HAND_RES);
|
||||
message->write<uint8_t>(hand0 + (hand1 << 2));
|
||||
if(hand0 == hand1) {
|
||||
if(repeat) {
|
||||
message = pduel->new_message(MSG_ROCK_PAPER_SCISSORS);
|
||||
message->write<uint8_t>(0);
|
||||
core.units.begin()->step = 0;
|
||||
arg.step = 0;
|
||||
return FALSE;
|
||||
} else
|
||||
returns.set<int32_t>(0, PLAYER_NONE);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ local ocgcore_config=function()
|
|||
|
||||
filter "action:not vs*"
|
||||
buildoptions { "-Wno-unused-parameter", "-pedantic" }
|
||||
if os.istarget("macosx") then
|
||||
filter { "files:processor_visit.cpp" }
|
||||
buildoptions { "-fno-exceptions" }
|
||||
end
|
||||
end
|
||||
|
||||
if not subproject then
|
||||
|
|
|
|||
1872
processor.cpp
1872
processor.cpp
File diff suppressed because it is too large
Load diff
834
processor_unit.h
Normal file
834
processor_unit.h
Normal file
|
|
@ -0,0 +1,834 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2024, Edoardo Lolletti (edo9300) <edoardo762@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
#ifndef PROCESSOR_UNIT_H_
|
||||
#define PROCESSOR_UNIT_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory> //std::unique_ptr
|
||||
#include <type_traits> //std::false_type, std::true_type
|
||||
#include <variant>
|
||||
#include "containers_fwd.h"
|
||||
|
||||
namespace P {
|
||||
template<bool NA>
|
||||
struct Process {
|
||||
static constexpr auto needs_answer = NA;
|
||||
Process(const Process&) = delete; // non construction-copyable
|
||||
Process& operator=(const Process&) = delete; // non copyable
|
||||
Process(Process&&) = default; // construction-movable
|
||||
Process& operator=(Process&&) = default; // movable
|
||||
int16_t step;
|
||||
protected:
|
||||
explicit Process(uint16_t step_) : step(step_) {}
|
||||
};
|
||||
struct Adjust : public Process<false> {
|
||||
Adjust(uint16_t step_) : Process(step_) {}
|
||||
};
|
||||
struct Turn : public Process<false> {
|
||||
uint8_t turn_player;
|
||||
bool has_performed_second_battle_phase;
|
||||
Turn(uint16_t step_, uint8_t turn_player_) : Process(step_), turn_player(turn_player_),
|
||||
has_performed_second_battle_phase(false) {}
|
||||
};
|
||||
struct RefreshLoc : public Process<false> {
|
||||
uint8_t dis_count;
|
||||
uint32_t previously_disabled_locations;
|
||||
effect* current_disable_field_effect;
|
||||
RefreshLoc(uint16_t step_) :
|
||||
Process(step_), dis_count(0), previously_disabled_locations(0),
|
||||
current_disable_field_effect(nullptr) {}
|
||||
};
|
||||
struct Startup : public Process<false> {
|
||||
Startup(uint16_t step_) : Process(step_) {}
|
||||
};
|
||||
struct SelectBattleCmd : public Process<true> {
|
||||
uint8_t playerid;
|
||||
SelectBattleCmd(uint16_t step_, uint8_t playerid_) : Process(step_), playerid(playerid_) {}
|
||||
};
|
||||
struct SelectIdleCmd : public Process<true> {
|
||||
uint8_t playerid;
|
||||
SelectIdleCmd(uint16_t step_, uint8_t playerid_) : Process(step_), playerid(playerid_) {}
|
||||
};
|
||||
struct SelectEffectYesNo : public Process<true> {
|
||||
uint8_t playerid;
|
||||
card* pcard;
|
||||
uint64_t description;
|
||||
SelectEffectYesNo(uint16_t step_, uint8_t playerid_, uint64_t description_, card* pcard_) :
|
||||
Process(step_), playerid(playerid_), pcard(pcard_), description(description_) {}
|
||||
};
|
||||
struct SelectYesNo : public Process<true> {
|
||||
uint8_t playerid;
|
||||
uint64_t description;
|
||||
SelectYesNo(uint16_t step_, uint8_t playerid_, uint64_t description_) :
|
||||
Process(step_), playerid(playerid_), description(description_) {}
|
||||
};
|
||||
struct SelectOption : public Process<true> {
|
||||
uint8_t playerid;
|
||||
SelectOption(uint16_t step_, uint8_t playerid_) : Process(step_), playerid(playerid_) {}
|
||||
};
|
||||
struct SelectCard : public Process<true> {
|
||||
uint8_t playerid;
|
||||
bool cancelable;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
SelectCard(uint16_t step_, uint8_t playerid_, bool cancelable_,
|
||||
uint8_t min_, uint8_t max_) :
|
||||
Process(step_), playerid(playerid_), cancelable(cancelable_), min(min_), max(max_) {}
|
||||
};
|
||||
struct SelectCardCodes : public Process<true> {
|
||||
uint8_t playerid;
|
||||
bool cancelable;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
SelectCardCodes(uint16_t step_, uint8_t playerid_, bool cancelable_,
|
||||
uint8_t min_, uint8_t max_) :
|
||||
Process(step_), playerid(playerid_), cancelable(cancelable_), min(min_), max(max_) {}
|
||||
};
|
||||
struct SelectUnselectCard : public Process<true> {
|
||||
uint8_t playerid;
|
||||
bool cancelable;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
bool finishable;
|
||||
SelectUnselectCard(uint16_t step_, uint8_t playerid_, bool cancelable_,
|
||||
uint8_t min_, uint8_t max_, bool finishable_) :
|
||||
Process(step_), playerid(playerid_), cancelable(cancelable_), min(min_), max(max_),
|
||||
finishable(finishable_) {}
|
||||
};
|
||||
struct SelectChain : public Process<true> {
|
||||
uint8_t playerid;
|
||||
uint8_t spe_count;
|
||||
bool forced;
|
||||
SelectChain(uint16_t step_, uint8_t playerid_, uint8_t spe_count_, bool forced_) :
|
||||
Process(step_), playerid(playerid_), spe_count(spe_count_), forced(forced_) {}
|
||||
};
|
||||
struct SelectPlace : public Process<true> {
|
||||
uint8_t playerid;
|
||||
uint8_t count;
|
||||
uint32_t flag;
|
||||
bool disable_field;
|
||||
SelectPlace(uint16_t step_, uint8_t playerid_, uint32_t flag_, uint8_t count_) :
|
||||
Process(step_), playerid(playerid_), count(count_), flag(flag_), disable_field(false) {}
|
||||
};
|
||||
struct SelectDisField : SelectPlace {
|
||||
SelectDisField(uint16_t step_, uint8_t playerid_, uint32_t flag_, uint8_t count_) :
|
||||
SelectPlace(step_, playerid_, flag_, count_) {
|
||||
disable_field = true;
|
||||
}
|
||||
};
|
||||
struct SelectPosition : public Process<true> {
|
||||
uint8_t playerid;
|
||||
uint8_t positions;
|
||||
uint32_t code;
|
||||
SelectPosition(uint16_t step_, uint8_t playerid_, uint32_t code_, uint8_t positions_) :
|
||||
Process(step_), playerid(playerid_), positions(positions_), code(code_) {}
|
||||
};
|
||||
struct SelectTributeP : public Process<true> {
|
||||
uint8_t playerid;
|
||||
bool cancelable;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
SelectTributeP(uint16_t step_, uint8_t playerid_, bool cancelable_, uint8_t min_, uint8_t max_) :
|
||||
Process(step_), playerid(playerid_), cancelable(cancelable_), min(min_), max(max_) {}
|
||||
};
|
||||
struct SortChain : public Process<false> {
|
||||
uint8_t playerid;
|
||||
SortChain(uint16_t step_, uint8_t playerid_) : Process(step_), playerid(playerid_) {}
|
||||
};
|
||||
struct SelectCounter : public Process<true> {
|
||||
uint16_t countertype;
|
||||
uint16_t count;
|
||||
uint8_t playerid;
|
||||
uint8_t self;
|
||||
uint8_t oppo;
|
||||
SelectCounter(uint16_t step_, uint8_t playerid_, uint16_t countertype_, uint16_t count_,
|
||||
uint8_t self_, uint8_t oppo_) :
|
||||
Process(step_), countertype(countertype_), count(count_), playerid(playerid_), self(self_),
|
||||
oppo(oppo_) {}
|
||||
};
|
||||
struct SelectSum : public Process<true> {
|
||||
uint8_t playerid;
|
||||
int32_t acc;
|
||||
int32_t min;
|
||||
int32_t max;
|
||||
SelectSum(uint16_t step_, uint8_t playerid_, int32_t acc_, int32_t min_, int32_t max_) :
|
||||
Process(step_), playerid(playerid_), acc(acc_), min(min_), max(max_) {}
|
||||
};
|
||||
struct SortCard : public Process<true> {
|
||||
uint8_t playerid;
|
||||
bool is_chain;
|
||||
SortCard(uint16_t step_, uint8_t playerid_, bool is_chain_) :
|
||||
Process(step_), playerid(playerid_), is_chain(is_chain_) {}
|
||||
};
|
||||
struct SelectRelease : public Process<false> {
|
||||
uint16_t min;
|
||||
uint16_t max;
|
||||
uint8_t playerid;
|
||||
bool cancelable;
|
||||
bool check_field;
|
||||
uint8_t toplayer;
|
||||
uint8_t zone;
|
||||
card* to_check;
|
||||
effect* extra_release_nonsum_effect;
|
||||
std::unique_ptr<card_set> must_choose_one;
|
||||
SelectRelease(uint16_t step_, uint8_t playerid_, bool cancelable_, uint16_t min_,
|
||||
uint16_t max_, bool check_field_, card* to_check_, uint8_t toplayer_,
|
||||
uint8_t zone_) :
|
||||
Process(step_), min(min_), max(max_), playerid(playerid_), cancelable(cancelable_),
|
||||
check_field(check_field_), toplayer(toplayer_), zone(zone_), to_check(to_check_),
|
||||
extra_release_nonsum_effect(nullptr), must_choose_one(nullptr) {}
|
||||
};
|
||||
struct SelectTribute : public Process<false> {
|
||||
uint16_t min;
|
||||
uint16_t max;
|
||||
uint8_t playerid;
|
||||
bool cancelable;
|
||||
uint8_t toplayer;
|
||||
uint8_t zone;
|
||||
card* target;
|
||||
effect* extra_release_effect;
|
||||
card_set must_choose_one;
|
||||
SelectTribute(uint16_t step_, card* target_, uint8_t playerid_, bool cancelable_, int32_t min_,
|
||||
int32_t max_, uint8_t toplayer_, uint8_t zone_) :
|
||||
Process(step_), min(min_), max(max_), playerid(playerid_), cancelable(cancelable_),
|
||||
toplayer(toplayer_), zone(zone_), target(target_), extra_release_effect(nullptr) {}
|
||||
};
|
||||
struct PointEvent : public Process<false> {
|
||||
bool skip_trigger;
|
||||
bool skip_freechain;
|
||||
bool skip_new;
|
||||
PointEvent(uint16_t step_, bool skip_trigger_, bool skip_freechain_, bool skip_new_) :
|
||||
Process(step_), skip_trigger(skip_trigger_), skip_freechain(skip_freechain_), skip_new(skip_new_) {}
|
||||
};
|
||||
struct QuickEffect : public Process<false> {
|
||||
bool skip_freechain;
|
||||
bool is_opponent;
|
||||
uint8_t priority_player;
|
||||
QuickEffect(uint16_t step_, bool skip_freechain_, uint8_t priority_player_) :
|
||||
Process(step_), skip_freechain(skip_freechain_), is_opponent(false), priority_player(priority_player_) {}
|
||||
};
|
||||
struct IdleCommand : public Process<false> {
|
||||
uint8_t phase_to_change_to;
|
||||
card* card_to_reposition;
|
||||
IdleCommand(uint16_t step_) :
|
||||
Process(step_), phase_to_change_to(0), card_to_reposition(nullptr) {}
|
||||
};
|
||||
struct PhaseEvent : public Process<false> {
|
||||
uint16_t phase;
|
||||
bool is_opponent;
|
||||
bool priority_passed;
|
||||
PhaseEvent(uint16_t step_, uint16_t phase_) :
|
||||
Process(step_), phase(phase_), is_opponent(false), priority_passed(false) {}
|
||||
};
|
||||
struct BattleCommand : public Process<false> {
|
||||
uint16_t phase_to_change_to;
|
||||
bool is_replaying_attack;
|
||||
bool attack_announce_failed;
|
||||
bool repeat_battle_phase;
|
||||
bool second_battle_phase_is_optional;
|
||||
bool previous_point_event_had_any_trigger_to_resolve;
|
||||
uint8_t reason_player;
|
||||
effect* damage_change_effect;
|
||||
group* cards_destroyed_by_battle;
|
||||
card* reason_card;
|
||||
BattleCommand(uint16_t step_, group* cards_destroyed_by_battle_ = nullptr) :
|
||||
Process(step_), phase_to_change_to(0), is_replaying_attack(false), attack_announce_failed(false),
|
||||
repeat_battle_phase(false), second_battle_phase_is_optional(false),
|
||||
previous_point_event_had_any_trigger_to_resolve(false), reason_player(PLAYER_NONE), damage_change_effect(nullptr),
|
||||
cards_destroyed_by_battle(cards_destroyed_by_battle_), reason_card(nullptr) {}
|
||||
};
|
||||
struct DamageStep : public Process<false> {
|
||||
uint16_t backup_phase;
|
||||
bool new_attack;
|
||||
card* attacker;
|
||||
card* attack_target;
|
||||
group* cards_destroyed_by_battle;
|
||||
DamageStep(uint16_t step_, card* attacker_, card* attack_target_, bool new_attack_) :
|
||||
Process(step_), backup_phase(0), new_attack(new_attack_), attacker(attacker_), attack_target(attack_target_), cards_destroyed_by_battle(nullptr) {}
|
||||
};
|
||||
struct ForcedBattle : public Process<false> {
|
||||
uint16_t backup_phase;
|
||||
ForcedBattle(uint16_t step_) :
|
||||
Process(step_), backup_phase(0) {}
|
||||
};
|
||||
struct AddChain : public Process<false> {
|
||||
bool is_activated_effect;
|
||||
AddChain(uint16_t step_) :
|
||||
Process(step_), is_activated_effect(false) {}
|
||||
};
|
||||
struct SolveChain : public Process<false> {
|
||||
bool skip_trigger;
|
||||
bool skip_freechain;
|
||||
bool skip_new;
|
||||
int32_t backed_up_operation;
|
||||
SolveChain(uint16_t step_, bool skip_trigger_, bool skip_freechain_, bool skip_new_) :
|
||||
Process(step_), skip_trigger(skip_trigger_), skip_freechain(skip_freechain_),
|
||||
skip_new(skip_new_), backed_up_operation(0) {}
|
||||
};
|
||||
struct SolveContinuous : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
effect* reason_effect;
|
||||
SolveContinuous(uint16_t step_) :
|
||||
Process(step_), reason_player(0), reason_effect(nullptr) {}
|
||||
};
|
||||
struct ExecuteCost : public Process<false> {
|
||||
uint8_t triggering_player;
|
||||
bool shuffle_check_was_disabled;
|
||||
effect* triggering_effect;
|
||||
ExecuteCost(uint16_t step_, effect* triggering_effect_, uint8_t triggering_player_) :
|
||||
Process(step_), triggering_player(triggering_player_), shuffle_check_was_disabled(false),
|
||||
triggering_effect(triggering_effect_) {}
|
||||
};
|
||||
struct ExecuteOperation : public Process<false> {
|
||||
uint8_t triggering_player;
|
||||
bool shuffle_check_was_disabled;
|
||||
effect* triggering_effect;
|
||||
ExecuteOperation(uint16_t step_, effect* triggering_effect_, uint8_t triggering_player_) :
|
||||
Process(step_), triggering_player(triggering_player_), shuffle_check_was_disabled(false),
|
||||
triggering_effect(triggering_effect_) {}
|
||||
};
|
||||
struct ExecuteTarget : public Process<false> {
|
||||
uint8_t triggering_player;
|
||||
bool shuffle_check_was_disabled;
|
||||
effect* triggering_effect;
|
||||
ExecuteTarget(uint16_t step_, effect* triggering_effect_, uint8_t triggering_player_) :
|
||||
Process(step_), triggering_player(triggering_player_), shuffle_check_was_disabled(false),
|
||||
triggering_effect(triggering_effect_) {}
|
||||
};
|
||||
struct Destroy : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
uint32_t reason;
|
||||
group* targets;
|
||||
effect* reason_effect;
|
||||
Destroy(uint16_t step_, group* targets_, effect* reason_effect_, uint32_t reason_,
|
||||
uint8_t reason_player_) :
|
||||
Process(step_), reason_player(reason_player_), reason(reason_), targets(targets_),
|
||||
reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct Release : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
uint32_t reason;
|
||||
group* targets;
|
||||
effect* reason_effect;
|
||||
Release(uint16_t step_, group* targets_, effect* reason_effect_, uint32_t reason_,
|
||||
uint8_t reason_player_) :
|
||||
Process(step_), reason_player(reason_player_), reason(reason_), targets(targets_),
|
||||
reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct SendTo : public Process<false> {
|
||||
struct exargs {
|
||||
card_set leave_field, leave_grave, detach;
|
||||
bool show_decktop[2];
|
||||
card_vector cv;
|
||||
card_vector::iterator cvit;
|
||||
effect* predirect;
|
||||
};
|
||||
uint8_t reason_player;
|
||||
uint32_t reason;
|
||||
group* targets;
|
||||
effect* reason_effect;
|
||||
std::unique_ptr<exargs> extra_args;
|
||||
SendTo(uint16_t step_, group* targets_, effect* reason_effect_, uint32_t reason_,
|
||||
uint8_t reason_player_) :
|
||||
Process(step_), reason_player(reason_player_), reason(reason_), targets(targets_),
|
||||
reason_effect(reason_effect_), extra_args(nullptr) {}
|
||||
};
|
||||
struct DestroyReplace : public Process<false> {
|
||||
bool battle;
|
||||
group* targets;
|
||||
card* target;
|
||||
DestroyReplace(uint16_t step_, group* targets_, card* target_, bool battle_) :
|
||||
Process(step_), battle(battle_), targets(targets_), target(target_) {}
|
||||
};
|
||||
struct ReleaseReplace : public Process<false> {
|
||||
group* targets;
|
||||
card* target;
|
||||
ReleaseReplace(uint16_t step_, group* targets_, card* target_) :
|
||||
Process(step_), targets(targets_), target(target_) {}
|
||||
};
|
||||
struct SendToReplace : public Process<false> {
|
||||
group* targets;
|
||||
card* target;
|
||||
SendToReplace(uint16_t step_, group* targets_, card* target_) :
|
||||
Process(step_), targets(targets_), target(target_) {}
|
||||
};
|
||||
struct MoveToField : public Process<false> {
|
||||
bool enable;
|
||||
uint8_t ret;
|
||||
bool pzone;
|
||||
uint8_t zone;
|
||||
bool rule;
|
||||
uint8_t location_reason;
|
||||
bool confirm;
|
||||
card* target;
|
||||
MoveToField(uint16_t step_, card* target_, bool enable_, uint8_t ret_, bool pzone_,
|
||||
uint8_t zone_, bool rule_, uint8_t location_reason_, bool confirm_) :
|
||||
Process(step_), enable(enable_), ret(ret_) , pzone(pzone_) , zone(zone_) , rule(rule_) ,
|
||||
location_reason(location_reason_) , confirm(confirm_), target(target_) {}
|
||||
};
|
||||
struct ChangePos : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
bool enable;
|
||||
bool oppo_selection;
|
||||
effect* reason_effect;
|
||||
group* targets;
|
||||
card_set to_grave_set;
|
||||
ChangePos(uint16_t step_, group* targets_, effect* reason_effect_,
|
||||
uint8_t reason_player_, bool enable_) :
|
||||
Process(step_), reason_player(reason_player_), enable(enable_), oppo_selection(false),
|
||||
reason_effect(reason_effect_), targets(targets_) {}
|
||||
};
|
||||
struct OperationReplace : public Process<false> {
|
||||
bool is_destroy;
|
||||
effect* replace_effect;
|
||||
group* targets;
|
||||
card* target;
|
||||
OperationReplace(uint16_t step_, effect* replace_effect_, group* targets_,
|
||||
card* target_, bool is_destroy_) :
|
||||
Process(step_), is_destroy(is_destroy_), replace_effect(replace_effect_),
|
||||
targets(targets_), target(target_) {}
|
||||
};
|
||||
struct ActivateEffect : public Process<false> {
|
||||
effect* peffect;
|
||||
ActivateEffect(uint16_t step_, effect* peffect_) :
|
||||
Process(step_), peffect(peffect_) {}
|
||||
};
|
||||
struct SummonRule : public Process<false> {
|
||||
uint8_t sumplayer;
|
||||
uint8_t min_tribute;
|
||||
uint8_t max_allowed_tributes;
|
||||
bool ignore_count;
|
||||
uint32_t zone;
|
||||
card* target;
|
||||
effect* summon_procedure_effect;
|
||||
effect* extra_summon_effect;
|
||||
card_set tributes;
|
||||
effect_set summon_cost_effects;
|
||||
SummonRule(uint16_t step_, uint8_t sumplayer_, card* target_, effect* proc_,
|
||||
bool ignore_count_, uint8_t min_tribute_, uint32_t zone_) :
|
||||
Process(step_), sumplayer(sumplayer_), min_tribute(min_tribute_), max_allowed_tributes(0),
|
||||
ignore_count(ignore_count_), zone(zone_), target(target_), summon_procedure_effect(proc_),
|
||||
extra_summon_effect(nullptr) {}
|
||||
};
|
||||
struct SpSummonRule : public Process<false> {
|
||||
uint8_t sumplayer;
|
||||
bool is_mid_chain;
|
||||
uint32_t summon_type;
|
||||
card* target;
|
||||
effect* summon_proc_effect;
|
||||
group* cards_to_summon_g;
|
||||
effect_set spsummon_cost_effects;
|
||||
SpSummonRule(uint16_t step_, uint8_t sumplayer_, card* target_, uint32_t summon_type_, bool is_mid_chain_ = false) :
|
||||
Process(step_), sumplayer(sumplayer_), is_mid_chain(is_mid_chain_), summon_type(summon_type_), target(target_),
|
||||
summon_proc_effect(nullptr), cards_to_summon_g(nullptr) {}
|
||||
};
|
||||
struct SpSummon : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
uint32_t zone;
|
||||
effect* reason_effect;
|
||||
group* targets;
|
||||
SpSummon(uint16_t step_, effect* reason_effect_, uint8_t reason_player_,
|
||||
group* targets_, uint32_t zone_) :
|
||||
Process(step_), reason_player(reason_player_), zone(zone_), reason_effect(reason_effect_),
|
||||
targets(targets_) {}
|
||||
};
|
||||
struct FlipSummon : public Process<false> {
|
||||
uint8_t sumplayer;
|
||||
card* target;
|
||||
effect_set flip_summon_cost_effects;
|
||||
FlipSummon(uint16_t step_, uint8_t sumplayer_, card* target_) :
|
||||
Process(step_), sumplayer(sumplayer_), target(target_) {}
|
||||
};
|
||||
struct MonsterSet : public Process<false> {
|
||||
uint8_t setplayer;
|
||||
uint8_t min_tribute;
|
||||
uint8_t max_allowed_tributes;
|
||||
bool ignore_count;
|
||||
uint32_t zone;
|
||||
card* target;
|
||||
effect* summon_procedure_effect;
|
||||
effect* extra_summon_effect;
|
||||
card_set tributes;
|
||||
MonsterSet(uint16_t step_, uint8_t setplayer_, card* target_, effect* proc_,
|
||||
bool ignore_count_, uint8_t min_tribute_, uint32_t zone_) :
|
||||
Process(step_), setplayer(setplayer_), min_tribute(min_tribute_), max_allowed_tributes(0), ignore_count(ignore_count_),
|
||||
zone(zone_), target(target_), summon_procedure_effect(proc_), extra_summon_effect(nullptr) {}
|
||||
};
|
||||
struct SpellSet : public Process<false> {
|
||||
uint8_t setplayer;
|
||||
uint8_t toplayer;
|
||||
card* target;
|
||||
effect* reason_effect;
|
||||
SpellSet(uint16_t step_, uint8_t setplayer_, uint8_t toplayer_, card* target_,
|
||||
effect* reason_effect_) :
|
||||
Process(step_), setplayer(setplayer_), toplayer(toplayer_), target(target_),
|
||||
reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct SpSummonStep : public Process<false> {
|
||||
uint32_t zone;
|
||||
group* targets;
|
||||
card* target;
|
||||
effect_set spsummon_cost_effects;
|
||||
SpSummonStep(uint16_t step_, group* targets_, card* target_, uint32_t zone_) :
|
||||
Process(step_), zone(zone_), targets(targets_), target(target_) {}
|
||||
};
|
||||
struct SpellSetGroup : public Process<false> {
|
||||
uint8_t setplayer;
|
||||
uint8_t toplayer;
|
||||
bool confirm;
|
||||
group* ptarget;
|
||||
effect* reason_effect;
|
||||
SpellSetGroup(uint16_t step_, uint8_t setplayer_, uint8_t toplayer_,
|
||||
group* ptarget_, bool confirm_, effect* reason_effect_) :
|
||||
Process(step_), setplayer(setplayer_), toplayer(toplayer_), confirm(confirm_),
|
||||
ptarget(ptarget_), reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct SpSummonRuleGroup : public Process<false> {
|
||||
uint8_t sumplayer;
|
||||
uint32_t summon_type;
|
||||
SpSummonRuleGroup(uint16_t step_, uint8_t sumplayer_, uint32_t summon_type_) :
|
||||
Process(step_), sumplayer(sumplayer_), summon_type(summon_type_) {}
|
||||
};
|
||||
struct Draw : public Process<false> {
|
||||
uint16_t count;
|
||||
uint8_t reason_player;
|
||||
uint8_t playerid;
|
||||
uint32_t reason;
|
||||
effect* reason_effect;
|
||||
card_set drawn_set;
|
||||
Draw(uint16_t step_, effect* reason_effect_, uint32_t reason_, uint8_t reason_player_,
|
||||
uint8_t playerid_, uint16_t count_) :
|
||||
Process(step_), count(count_), reason_player(reason_player_), playerid(playerid_),
|
||||
reason(reason_), reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct Damage : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
uint8_t playerid;
|
||||
bool is_step;
|
||||
bool is_reflected;
|
||||
uint32_t amount;
|
||||
uint32_t reason;
|
||||
card* reason_card;
|
||||
effect* reason_effect;
|
||||
Damage(uint16_t step_, effect* reason_effect_, uint32_t reason_, uint8_t reason_player_,
|
||||
card* reason_card_, uint8_t playerid_, uint32_t amount_, bool is_step_) :
|
||||
Process(step_), reason_player(reason_player_), playerid(playerid_), is_step(is_step_), is_reflected(false),
|
||||
amount(amount_), reason(reason_), reason_card(reason_card_), reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct Recover : public Process<false> {
|
||||
uint8_t reason_player;
|
||||
uint8_t playerid;
|
||||
bool is_step;
|
||||
uint32_t amount;
|
||||
uint32_t reason;
|
||||
effect* reason_effect;
|
||||
Recover(uint16_t step_, effect* reason_effect_, uint32_t reason_, uint8_t reason_player_,
|
||||
uint8_t playerid_, uint32_t amount_, bool is_step_) :
|
||||
Process(step_), reason_player(reason_player_), playerid(playerid_), is_step(is_step_), amount(amount_),
|
||||
reason(reason_), reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct Equip : public Process<false> {
|
||||
uint8_t equip_player;
|
||||
bool is_step;
|
||||
bool faceup;
|
||||
card* equip_card;
|
||||
card* target;
|
||||
Equip(uint16_t step_, uint8_t equip_player_, card* equip_card_, card* target_,
|
||||
bool faceup_, bool is_step_) :
|
||||
Process(step_), equip_player(equip_player_), is_step(is_step_), faceup(faceup_),
|
||||
equip_card(equip_card_), target(target_) {}
|
||||
};
|
||||
struct GetControl : public Process<false> {
|
||||
uint8_t chose_player;
|
||||
uint8_t playerid;
|
||||
uint8_t reset_count;
|
||||
uint16_t reset_phase;
|
||||
uint32_t zone;
|
||||
effect* reason_effect;
|
||||
group* targets;
|
||||
card_set destroy_set;
|
||||
GetControl(uint16_t step_, effect* reason_effect_, uint8_t chose_player_, group* targets_,
|
||||
uint8_t playerid_, uint16_t reset_phase_, uint8_t reset_count_, uint32_t zone_) :
|
||||
Process(step_), chose_player(chose_player_), playerid(playerid_), reset_count(reset_count_),
|
||||
reset_phase(reset_phase_), zone(zone_), reason_effect(reason_effect_), targets(targets_) {}
|
||||
};
|
||||
struct SwapControl : public Process<false> {
|
||||
uint8_t reset_count;
|
||||
uint8_t reason_player;
|
||||
uint8_t self_selected_sequence;
|
||||
uint16_t reset_phase;
|
||||
effect* reason_effect;
|
||||
group* targets1;
|
||||
group* targets2;
|
||||
SwapControl(uint16_t step_, effect* reason_effect_, uint8_t reason_player_,
|
||||
group* targets1_, group* targets2_, uint16_t reset_phase_, uint8_t reset_count_) :
|
||||
Process(step_), reset_count(reset_count_), reason_player(reason_player_), self_selected_sequence(0),
|
||||
reset_phase(reset_phase_), reason_effect(reason_effect_), targets1(targets1_), targets2(targets2_) {}
|
||||
};
|
||||
struct ControlAdjust : public Process<false> {
|
||||
uint8_t adjusting_player;
|
||||
card_set destroy_set;
|
||||
card_set adjust_set;
|
||||
ControlAdjust(uint16_t step_) :
|
||||
Process(step_), adjusting_player(0) {}
|
||||
};
|
||||
struct SelfDestroyUnique : public Process<false> {
|
||||
uint8_t playerid;
|
||||
card* unique_card;
|
||||
SelfDestroyUnique(uint16_t step_, card* unique_card_, uint8_t playerid_) :
|
||||
Process(step_), playerid(playerid_), unique_card(unique_card_) {}
|
||||
};
|
||||
struct SelfDestroy : public Process<false> {
|
||||
SelfDestroy(uint16_t step_) :
|
||||
Process(step_) {}
|
||||
};
|
||||
struct SelfToGrave : public Process<false> {
|
||||
SelfToGrave(uint16_t step_) :
|
||||
Process(step_) {}
|
||||
};
|
||||
struct TrapMonsterAdjust : public Process<false> {
|
||||
bool oppo_selection;
|
||||
card_set to_grave_set;
|
||||
TrapMonsterAdjust(uint16_t step_) :
|
||||
Process(step_), oppo_selection(false) {}
|
||||
};
|
||||
struct PayLPCost : public Process<false> {
|
||||
uint8_t playerid;
|
||||
uint32_t cost;
|
||||
PayLPCost(uint16_t step_, uint8_t playerid_, uint32_t cost_) :
|
||||
Process(step_), playerid(playerid_), cost(cost_) {}
|
||||
};
|
||||
struct RemoveCounter : public Process<false> {
|
||||
uint8_t rplayer;
|
||||
uint8_t self;
|
||||
uint8_t oppo;
|
||||
uint16_t countertype;
|
||||
uint16_t count;
|
||||
uint32_t reason;
|
||||
card* pcard;
|
||||
RemoveCounter(uint16_t step_, uint32_t reason_, card* pcard_, uint8_t rplayer_, uint8_t self_,
|
||||
uint8_t oppo_, uint16_t countertype_, uint16_t count_) :
|
||||
Process(step_), rplayer(rplayer_), self(self_), oppo(oppo_), countertype(countertype_), count(count_),
|
||||
reason(reason_), pcard(pcard_) {}
|
||||
};
|
||||
struct AttackDisable : public Process<false> {
|
||||
AttackDisable(uint16_t step_) :
|
||||
Process(step_) {}
|
||||
};
|
||||
struct AnnounceRace : public Process<true> {
|
||||
uint8_t playerid;
|
||||
uint8_t count;
|
||||
uint64_t available;
|
||||
AnnounceRace(uint16_t step_, uint8_t playerid_, uint8_t count_, uint64_t available_) :
|
||||
Process(step_), playerid(playerid_), count(count_), available(available_) {}
|
||||
};
|
||||
struct AnnounceAttribute : public Process<true> {
|
||||
uint8_t playerid;
|
||||
uint8_t count;
|
||||
uint32_t available;
|
||||
AnnounceAttribute(uint16_t step_, uint8_t playerid_, uint8_t count_, uint32_t available_) :
|
||||
Process(step_), playerid(playerid_), count(count_), available(available_) {}
|
||||
};
|
||||
struct AnnounceCard : public Process<true> {
|
||||
uint8_t playerid;
|
||||
AnnounceCard(uint16_t step_, uint8_t playerid_) :
|
||||
Process(step_), playerid(playerid_) {}
|
||||
};
|
||||
struct AnnounceNumber : public Process<true> {
|
||||
uint8_t playerid;
|
||||
AnnounceNumber(uint16_t step_, uint8_t playerid_) :
|
||||
Process(step_), playerid(playerid_) {}
|
||||
};
|
||||
struct TossCoin : public Process<false> {
|
||||
uint8_t playerid;
|
||||
uint8_t reason_player;
|
||||
uint8_t count;
|
||||
effect* reason_effect;
|
||||
TossCoin(uint16_t step_, effect* reason_effect_, uint8_t reason_player_, uint8_t playerid_,
|
||||
uint8_t count_) :
|
||||
Process(step_), playerid(playerid_), reason_player(reason_player_), count(count_),
|
||||
reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct TossDice : public Process<false> {
|
||||
uint8_t playerid;
|
||||
uint8_t reason_player;
|
||||
uint8_t count1;
|
||||
uint8_t count2;
|
||||
effect* reason_effect;
|
||||
TossDice(uint16_t step_, effect* reason_effect_, uint8_t reason_player_, uint8_t playerid_,
|
||||
uint8_t count1_, uint8_t count2_) :
|
||||
Process(step_), playerid(playerid_), reason_player(reason_player_), count1(count1_), count2(count2_),
|
||||
reason_effect(reason_effect_) {}
|
||||
};
|
||||
struct RockPaperScissors : public Process<true> {
|
||||
bool repeat;
|
||||
uint8_t hand0;
|
||||
RockPaperScissors(uint16_t step_, bool repeat_) :
|
||||
Process(step_), repeat(repeat_), hand0(0) {}
|
||||
};
|
||||
struct SelectFusion : public Process<false> {
|
||||
uint8_t playerid;
|
||||
uint32_t chkf;
|
||||
group* fusion_materials;
|
||||
group* forced_materials;
|
||||
card* pcard;
|
||||
SelectFusion(uint16_t step_, uint8_t playerid_, group* fusion_materials_, uint32_t chkf_,
|
||||
group* forced_materials_, card* pcard_) :
|
||||
Process(step_), playerid(playerid_), chkf(chkf_), fusion_materials(fusion_materials_),
|
||||
forced_materials(forced_materials_), pcard(pcard_) {}
|
||||
};
|
||||
struct DiscardHand : public Process<false> {
|
||||
uint8_t playerid;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
uint32_t reason;
|
||||
DiscardHand(uint16_t step_, uint8_t playerid_, uint8_t min_, uint8_t max_, uint32_t reason_) :
|
||||
Process(step_), playerid(playerid_), min(min_), max(max_), reason(reason_) {}
|
||||
};
|
||||
struct DiscardDeck : public Process<false> {
|
||||
uint16_t count;
|
||||
uint8_t playerid;
|
||||
uint32_t reason;
|
||||
DiscardDeck(uint16_t step_, uint8_t playerid_, uint16_t count_, uint32_t reason_) :
|
||||
Process(step_), count(count_), playerid(playerid_), reason(reason_) {}
|
||||
};
|
||||
struct SortDeck : public Process<false> {
|
||||
uint16_t count;
|
||||
uint8_t sort_player;
|
||||
uint8_t target_player;
|
||||
bool bottom;
|
||||
SortDeck(uint16_t step_, uint8_t sort_player_, uint8_t target_player_, uint16_t count_,
|
||||
bool bottom_) :
|
||||
Process(step_), count(count_), sort_player(sort_player_), target_player(target_player_),
|
||||
bottom(bottom_) {}
|
||||
};
|
||||
struct RemoveOverlay : public Process<false> {
|
||||
uint16_t min;
|
||||
uint16_t max;
|
||||
uint16_t replaced_amount;
|
||||
bool has_used_overlay_remove_replace_effect;
|
||||
uint8_t rplayer;
|
||||
uint8_t self;
|
||||
uint8_t oppo;
|
||||
uint32_t reason;
|
||||
group* pgroup;
|
||||
RemoveOverlay(uint16_t step_, uint32_t reason_, group* pgroup_, uint8_t rplayer_,
|
||||
uint8_t self_, uint8_t oppo_, uint16_t min_, uint16_t max_) :
|
||||
Process(step_), min(min_), max(max_), replaced_amount(0),
|
||||
has_used_overlay_remove_replace_effect(false), rplayer(rplayer_), self(self_),
|
||||
oppo(oppo_), reason(reason_), pgroup(pgroup_) {}
|
||||
};
|
||||
struct XyzOverlay : public Process<false> {
|
||||
bool send_materials_to_grave;
|
||||
card* target;
|
||||
group* materials;
|
||||
XyzOverlay(uint16_t step_, card* target_, group* materials_, bool send_materials_to_grave_) :
|
||||
Process(step_), send_materials_to_grave(send_materials_to_grave_), target(target_),
|
||||
materials(materials_) {}
|
||||
};
|
||||
struct RefreshRelay : public Process<false> {
|
||||
RefreshRelay(uint16_t step_) :
|
||||
Process(step_) {}
|
||||
};
|
||||
|
||||
using processors = std::variant<Adjust, Turn, RefreshLoc, Startup,
|
||||
SelectBattleCmd, SelectIdleCmd, SelectEffectYesNo, SelectYesNo,
|
||||
SelectOption, SelectCard, SelectCardCodes, SelectUnselectCard,
|
||||
SelectChain, SelectPlace, SelectDisField, SelectPosition,
|
||||
SelectTributeP, SortChain, SelectCounter, SelectSum, SortCard,
|
||||
SelectRelease, SelectTribute, QuickEffect, IdleCommand, PhaseEvent, PointEvent,
|
||||
BattleCommand, DamageStep, ForcedBattle, AddChain, SolveChain, SolveContinuous,
|
||||
ExecuteCost, ExecuteOperation, ExecuteTarget, Destroy, Release,
|
||||
SendTo, DestroyReplace, ReleaseReplace, SendToReplace, MoveToField,
|
||||
ChangePos, OperationReplace, ActivateEffect, SummonRule, SpSummonRule,
|
||||
SpSummon, FlipSummon, MonsterSet, SpellSet, SpSummonStep, SpellSetGroup,
|
||||
SpSummonRuleGroup, Draw, Damage, Recover, Equip, GetControl, SwapControl,
|
||||
ControlAdjust, SelfDestroyUnique, SelfDestroy, SelfToGrave, TrapMonsterAdjust,
|
||||
PayLPCost, RemoveCounter, AttackDisable, AnnounceRace, AnnounceAttribute,
|
||||
AnnounceCard, AnnounceNumber, TossCoin, TossDice, RockPaperScissors,
|
||||
SelectFusion, DiscardHand, DiscardDeck, SortDeck, RemoveOverlay, XyzOverlay,
|
||||
RefreshRelay>;
|
||||
|
||||
//Ugly hack only to ease debugging the core under visual studio it
|
||||
//splits the big variant into multiple variants of 30 types max so
|
||||
//that they can be properly displayed with the visual studio debugger
|
||||
#if (defined(_DEBUG) && defined(_MSC_VER)) || defined(PROCESSOR_VARIANT_CAP)
|
||||
#if !defined(PROCESSOR_VARIANT_CAP) || (PROCESSOR_VARIANT_CAP + 0) == 0
|
||||
static constexpr auto MAX_VARIANT_TYPES = 30;
|
||||
#else
|
||||
static constexpr auto MAX_VARIANT_TYPES = PROCESSOR_VARIANT_CAP;
|
||||
#endif
|
||||
|
||||
template <typename T, std::size_t offset, std::size_t amount, typename = std::make_index_sequence<amount>>
|
||||
struct variant_slice;
|
||||
|
||||
template <typename T, std::size_t offset, std::size_t amount, std::size_t... ints>
|
||||
struct variant_slice<T, offset, amount, std::index_sequence<ints...>> {
|
||||
using type = std::variant<std::variant_alternative_t<offset + ints, T>...>;
|
||||
};
|
||||
|
||||
template <typename T, std::size_t offset, std::size_t amount>
|
||||
using variant_slice_t = typename variant_slice<T, offset, amount>::type;
|
||||
|
||||
template <typename T, std::size_t max_variant_size, typename = std::make_index_sequence<std::variant_size_v<T> / max_variant_size>>
|
||||
struct split_to_subvariants;
|
||||
|
||||
template <typename T, std::size_t max_variant_size, std::size_t... ints>
|
||||
struct split_to_subvariants<T, max_variant_size, std::index_sequence<ints...>> {
|
||||
private:
|
||||
static constexpr auto total = std::variant_size_v<T>;
|
||||
static constexpr auto remaining_types = total % max_variant_size;
|
||||
public:
|
||||
using type = std::conditional_t<
|
||||
remaining_types != 0,
|
||||
std::variant<
|
||||
variant_slice_t<T, ints * max_variant_size, max_variant_size>...,
|
||||
variant_slice_t<T, total - remaining_types, remaining_types>
|
||||
>,
|
||||
std::variant<variant_slice_t<T, ints * max_variant_size, max_variant_size>...>
|
||||
>;
|
||||
};
|
||||
|
||||
using processor_unit = split_to_subvariants<processors, MAX_VARIANT_TYPES>::type;
|
||||
|
||||
template<typename T>
|
||||
static constexpr inline auto* get_opt_variant(processor_unit& unit) {
|
||||
return std::visit([](auto& v) -> T* {
|
||||
if constexpr(std::is_constructible_v<std::remove_reference_t<decltype(v)>, T>) {
|
||||
return std::get_if<T>(&v);
|
||||
}
|
||||
return nullptr;
|
||||
}, unit);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
constexpr inline void emplace_variant(std::list<processor_unit>& list, Args&&... args) {
|
||||
T obj(std::forward<Args>(args)...);
|
||||
list.push_back(std::move(obj));
|
||||
}
|
||||
#else
|
||||
|
||||
using processor_unit = processors;
|
||||
|
||||
template<typename T>
|
||||
static constexpr inline auto* get_opt_variant(processor_unit& unit) {
|
||||
return std::get_if<T>(&unit);
|
||||
}
|
||||
|
||||
template<typename T, typename... Args>
|
||||
constexpr inline void emplace_variant(std::list<processor_unit>& list, Args&&... args) {
|
||||
list.emplace_back(std::in_place_type<T>, std::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
inline constexpr bool NeedsAnswer = T::needs_answer;
|
||||
|
||||
}
|
||||
|
||||
namespace Processors = P;
|
||||
|
||||
#endif /* PROCESSOR_UNIT_H_ */
|
||||
14
processor_visit.cpp
Normal file
14
processor_visit.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright (c) 2023-2024, 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;
|
||||
return std::visit(*this, core.units.front());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue