Commit be8d2f6b authored by salix5's avatar salix5

field::solve_continuous()

EFFECT_TYPE_CONTINUOUS with EFFECT_FLAG_DELAY are continuous effects, so
they should follow SEGOC rule.
parent 88502290
...@@ -65,6 +65,8 @@ field::field(duel* pduel) { ...@@ -65,6 +65,8 @@ field::field(duel* pduel) {
core.chain_limit = 0; core.chain_limit = 0;
core.chain_limit_p = 0; core.chain_limit_p = 0;
core.chain_solving = FALSE; core.chain_solving = FALSE;
core.conti_solving = FALSE;
core.conti_player = PLAYER_NONE;
core.win_player = 5; core.win_player = 5;
core.win_reason = 0; core.win_reason = 0;
core.reason_effect = 0; core.reason_effect = 0;
......
...@@ -208,8 +208,8 @@ struct processor { ...@@ -208,8 +208,8 @@ struct processor {
effect_set_v extraz_effects; effect_set_v extraz_effects;
effect_set_v extraz_effects_e; effect_set_v extraz_effects_e;
std::set<effect*> reseted_effects; std::set<effect*> reseted_effects;
effect_vector delayed_tp; std::list<effect*> delayed_tp;
effect_vector delayed_ntp; std::list<effect*> delayed_ntp;
event_list delayed_tev; event_list delayed_tev;
event_list delayed_ntev; event_list delayed_ntev;
std::unordered_map<card*, uint32> readjust_map; std::unordered_map<card*, uint32> readjust_map;
...@@ -228,6 +228,7 @@ struct processor { ...@@ -228,6 +228,7 @@ struct processor {
int32 chain_limit_p; int32 chain_limit_p;
uint8 chain_limp_p; uint8 chain_limp_p;
uint8 chain_solving; uint8 chain_solving;
uint8 conti_solving;
uint8 win_player; uint8 win_player;
uint8 win_reason; uint8 win_reason;
uint8 re_adjust; uint8 re_adjust;
...@@ -284,6 +285,7 @@ struct processor { ...@@ -284,6 +285,7 @@ struct processor {
uint8 battle_phase_action; uint8 battle_phase_action;
uint32 hint_timing[2]; uint32 hint_timing[2];
uint8 current_player; uint8 current_player;
uint8 conti_player;
std::unordered_map<uint32, std::pair<uint32, uint32> > summon_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > summon_counter;
std::unordered_map<uint32, std::pair<uint32, uint32> > normalsummon_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > normalsummon_counter;
std::unordered_map<uint32, std::pair<uint32, uint32> > spsummon_counter; std::unordered_map<uint32, std::pair<uint32, uint32> > spsummon_counter;
......
...@@ -2195,14 +2195,12 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -2195,14 +2195,12 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
&& peffect->is_chainable(priority) && peffect->is_activateable(priority, clit->evt, TRUE)) { && peffect->is_chainable(priority) && peffect->is_activateable(priority, clit->evt, TRUE)) {
for(auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) { for(auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) {
if(cait->triggering_player == priority) { if(cait->triggering_player == priority) {
if(!(peffect->flag & EFFECT_FLAG_MULTIACT_HAND)) { effect* pchaineff = cait->triggering_effect;
effect* pchaineff = cait->triggering_effect; if(!(pchaineff->flag & EFFECT_FLAG_FIELD_ONLY) && (pchaineff->type & EFFECT_TYPE_TRIGGER_O)
if(!(pchaineff->flag & EFFECT_FLAG_FIELD_ONLY) && (pchaineff->type & EFFECT_TYPE_TRIGGER_O) && (!(pchaineff->type & EFFECT_TYPE_SINGLE) || (pchaineff->flag & EFFECT_FLAG_SINGLE_RANGE))
&& (!(pchaineff->type & EFFECT_TYPE_SINGLE) || (pchaineff->flag & EFFECT_FLAG_SINGLE_RANGE)) && (pchaineff->range & LOCATION_HAND)) {
&& (pchaineff->range & LOCATION_HAND)) { act = false;
act = false; break;
break;
}
} }
if((peffect->flag & EFFECT_FLAG_CHAIN_UNIQUE) && (cait->triggering_effect->handler->data.code == peffect->handler->data.code)) { if((peffect->flag & EFFECT_FLAG_CHAIN_UNIQUE) && (cait->triggering_effect->handler->data.code == peffect->handler->data.code)) {
act = false; act = false;
...@@ -2338,7 +2336,7 @@ int32 field::process_instant_event() { ...@@ -2338,7 +2336,7 @@ int32 field::process_instant_event() {
peffect = pr.first->second; peffect = pr.first->second;
uint8 owner_player = peffect->get_handler_player(); uint8 owner_player = peffect->get_handler_player();
if(peffect->is_activateable(owner_player, *elit)) { if(peffect->is_activateable(owner_player, *elit)) {
if((peffect->flag & EFFECT_FLAG_DELAY) && core.chain_solving) { if((peffect->flag & EFFECT_FLAG_DELAY) && (core.chain_solving || core.conti_solving)) {
if(owner_player == infos.turn_player) { if(owner_player == infos.turn_player) {
core.delayed_tp.push_back(peffect); core.delayed_tp.push_back(peffect);
core.delayed_tev.push_back(*elit); core.delayed_tev.push_back(*elit);
...@@ -2479,7 +2477,7 @@ int32 field::process_single_event() { ...@@ -2479,7 +2477,7 @@ int32 field::process_single_event() {
if(peffect->type & EFFECT_TYPE_CONTINUOUS) { if(peffect->type & EFFECT_TYPE_CONTINUOUS) {
uint8 owner_player = peffect->get_handler_player(); uint8 owner_player = peffect->get_handler_player();
if(peffect->is_activateable(owner_player, e)) { if(peffect->is_activateable(owner_player, e)) {
if((peffect->flag & EFFECT_FLAG_DELAY) && core.chain_solving) { if((peffect->flag & EFFECT_FLAG_DELAY) && (core.chain_solving || core.conti_solving)) {
if(owner_player == infos.turn_player) { if(owner_player == infos.turn_player) {
core.delayed_tp.push_back(peffect); core.delayed_tp.push_back(peffect);
core.delayed_tev.push_back(e); core.delayed_tev.push_back(e);
...@@ -4560,6 +4558,8 @@ int32 field::solve_continuous(uint16 step, effect * peffect, uint8 triggering_pl ...@@ -4560,6 +4558,8 @@ int32 field::solve_continuous(uint16 step, effect * peffect, uint8 triggering_pl
newchain.disable_reason = 0; newchain.disable_reason = 0;
newchain.flag = 0; newchain.flag = 0;
core.continuous_chain.push_back(newchain); core.continuous_chain.push_back(newchain);
if(peffect->flag & EFFECT_FLAG_DELAY)
core.conti_solving = TRUE;
if(!peffect->target) if(!peffect->target)
return FALSE; return FALSE;
core.sub_solving_event.push_back(core.solving_event.front()); core.sub_solving_event.push_back(core.solving_event.front());
...@@ -4586,6 +4586,37 @@ int32 field::solve_continuous(uint16 step, effect * peffect, uint8 triggering_pl ...@@ -4586,6 +4586,37 @@ int32 field::solve_continuous(uint16 step, effect * peffect, uint8 triggering_pl
} }
core.continuous_chain.pop_back(); core.continuous_chain.pop_back();
core.solving_event.pop_front(); core.solving_event.pop_front();
if(peffect->flag & EFFECT_FLAG_DELAY) {
core.conti_solving = FALSE;
adjust_all();
if(core.conti_player == infos.turn_player) {
if(core.delayed_tp.size()) {
core.sub_solving_event.push_back(core.delayed_tev.front());
add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, core.delayed_tp.front(), 0, infos.turn_player, 0);
core.delayed_tp.pop_front();
core.delayed_tev.pop_front();
}
else
core.conti_player = 1 - infos.turn_player;
}
if(core.conti_player == 1 - infos.turn_player) {
if(core.delayed_ntp.size()) {
core.sub_solving_event.push_back(core.delayed_ntev.front());
add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, core.delayed_ntp.front(), 0, 1 - infos.turn_player, 0);
core.delayed_ntp.pop_front();
core.delayed_ntev.pop_front();
}
else if(core.delayed_tp.size()) {
core.conti_player = infos.turn_player;
core.sub_solving_event.push_back(core.delayed_tev.front());
add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, core.delayed_tp.front(), 0, infos.turn_player, 0);
core.delayed_tp.pop_front();
core.delayed_tev.pop_front();
}
else
core.conti_player = PLAYER_NONE;
}
}
return TRUE; return TRUE;
} }
} }
...@@ -4739,18 +4770,22 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2 ...@@ -4739,18 +4770,22 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
core.chain_solving = FALSE; core.chain_solving = FALSE;
effect_vector::iterator eit; effect_vector::iterator eit;
event_list::iterator evit; event_list::iterator evit;
for(eit = core.delayed_tp.begin(), evit = core.delayed_tev.begin(); eit != core.delayed_tp.end(); ++eit, ++evit) { if(core.delayed_tp.size()) {
core.sub_solving_event.push_back(*evit); core.conti_player = infos.turn_player;
add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, (*eit), 0, infos.turn_player, 0); core.sub_solving_event.push_back(core.delayed_tev.front());
} add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, core.delayed_tp.front(), 0, infos.turn_player, 0);
for(eit = core.delayed_ntp.begin(), evit = core.delayed_ntev.begin(); eit != core.delayed_ntp.end(); ++eit, ++evit) { core.delayed_tp.pop_front();
core.sub_solving_event.push_back(*evit); core.delayed_tev.pop_front();
add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, (*eit), 0, 1 - infos.turn_player, 0); }
} else if(core.delayed_ntp.size()) {
core.delayed_tp.clear(); core.conti_player = 1 - infos.turn_player;
core.delayed_ntp.clear(); core.sub_solving_event.push_back(core.delayed_ntev.front());
core.delayed_tev.clear(); add_process(PROCESSOR_SOLVE_CONTINUOUS, 0, core.delayed_ntp.front(), 0, 1 - infos.turn_player, 0);
core.delayed_ntev.clear(); core.delayed_ntp.pop_front();
core.delayed_ntev.pop_front();
}
else
core.conti_player = PLAYER_NONE;
pduel->write_buffer8(MSG_CHAIN_SOLVED); pduel->write_buffer8(MSG_CHAIN_SOLVED);
pduel->write_buffer8(cait->chain_count); pduel->write_buffer8(cait->chain_count);
raise_event((card*)0, EVENT_CHAIN_SOLVED, cait->triggering_effect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count); raise_event((card*)0, EVENT_CHAIN_SOLVED, cait->triggering_effect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count);
......
...@@ -2,10 +2,16 @@ ...@@ -2,10 +2,16 @@
function c20630765.initial_effect(c) function c20630765.initial_effect(c)
c:SetCounterLimit(0x16,1) c:SetCounterLimit(0x16,1)
--Add counter --Add counter
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e0:SetCode(EVENT_CHAINING)
e0:SetRange(LOCATION_MZONE)
e0:SetOperation(aux.chainreg)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e1:SetCode(EVENT_CHAIN_SOLVING) e1:SetCode(EVENT_CHAIN_SOLVED)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetRange(LOCATION_MZONE) e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1) e1:SetCountLimit(1)
e1:SetOperation(c20630765.ctop) e1:SetOperation(c20630765.ctop)
...@@ -33,7 +39,7 @@ function c20630765.initial_effect(c) ...@@ -33,7 +39,7 @@ function c20630765.initial_effect(c)
end end
function c20630765.ctop(e,tp,eg,ep,ev,re,r,rp) function c20630765.ctop(e,tp,eg,ep,ev,re,r,rp)
local c=re:GetHandler() local c=re:GetHandler()
if c:IsType(TYPE_MONSTER) and c~=e:GetHandler() then if re:IsActiveType(TYPE_MONSTER) and c~=e:GetHandler() and e:GetHandler():GetFlagEffect(1)>0 then
e:GetHandler():AddCounter(0x16,1) e:GetHandler():AddCounter(0x16,1)
end end
end end
......
...@@ -9,8 +9,8 @@ function c49905576.initial_effect(c) ...@@ -9,8 +9,8 @@ function c49905576.initial_effect(c)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c49905576.drop(e,tp,eg,ep,ev,re,r,rp) function c49905576.drop(e,tp,eg,ep,ev,re,r,rp)
if not re:GetHandler():IsType(TYPE_COUNTER) then return end local c=e:GetHandler()
Duel.BreakEffect() if not re:GetHandler():IsType(TYPE_COUNTER) or not c:IsLocation(LOCATION_MZONE) or not c:IsFaceup() return end
Duel.Recover(tp,1000,REASON_EFFECT) Duel.Recover(tp,1000,REASON_EFFECT)
if not Duel.IsEnvironment(56433456) then return end if not Duel.IsEnvironment(56433456) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
......
...@@ -245,7 +245,7 @@ EFFECT_FLAG_IGNORE_RANGE =0x0020 --影响所有区域的卡(禁止令 大宇 ...@@ -245,7 +245,7 @@ EFFECT_FLAG_IGNORE_RANGE =0x0020 --影响所有区域的卡(禁止令 大宇
EFFECT_FLAG_ABSOLUTE_TARGET =0x0040 --Target Range不会因为控制权的改变而改变 EFFECT_FLAG_ABSOLUTE_TARGET =0x0040 --Target Range不会因为控制权的改变而改变
EFFECT_FLAG_IGNORE_IMMUNE =0x0080 --无视效果免疫 EFFECT_FLAG_IGNORE_IMMUNE =0x0080 --无视效果免疫
EFFECT_FLAG_SET_AVAILABLE =0x0100 --影响场上里侧的卡/裡側狀態可發動 EFFECT_FLAG_SET_AVAILABLE =0x0100 --影响场上里侧的卡/裡側狀態可發動
EFFECT_FLAG_MULTIACT_HAND =0x0200 --手牌有多张可以同时诱发(無) EFFECT_FLAG_MULTIACT_HAND =0x0200 --N/A
EFFECT_FLAG_CANNOT_DISABLE =0x0400 --不会被无效 EFFECT_FLAG_CANNOT_DISABLE =0x0400 --不会被无效
EFFECT_FLAG_PLAYER_TARGET =0x0800 --以玩家为对象 EFFECT_FLAG_PLAYER_TARGET =0x0800 --以玩家为对象
EFFECT_FLAG_BOTH_SIDE =0x1000 --双方都能使用(部分场地,弹压) EFFECT_FLAG_BOTH_SIDE =0x1000 --双方都能使用(部分场地,弹压)
...@@ -398,7 +398,7 @@ EFFECT_EXTRA_RELEASE_SUM =155 --代替召唤解放(帝王的烈旋) ...@@ -398,7 +398,7 @@ EFFECT_EXTRA_RELEASE_SUM =155 --代替召唤解放(帝王的烈旋)
EFFECT_PUBLIC =160 --公开手牌 EFFECT_PUBLIC =160 --公开手牌
EFFECT_COUNTER_PERMIT =0x10000--允许放置指示物类型 EFFECT_COUNTER_PERMIT =0x10000--允许放置指示物类型
EFFECT_COUNTER_LIMIT =0x20000--允许放置指示物数量 EFFECT_COUNTER_LIMIT =0x20000--允许放置指示物数量
EFFECT_RCOUNTER_REPLACE =0x30000--代替取除(指示物?) EFFECT_RCOUNTER_REPLACE =0x30000--代替取除指示物
EFFECT_LPCOST_CHANGE =170 --改变生命值代价 EFFECT_LPCOST_CHANGE =170 --改变生命值代价
EFFECT_LPCOST_REPLACE =171 --代替生命值代价 EFFECT_LPCOST_REPLACE =171 --代替生命值代价
EFFECT_SKIP_DP =180 --跳过抽卡阶段 EFFECT_SKIP_DP =180 --跳过抽卡阶段
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment