Commit 56cbba98 authored by VanillaSalt's avatar VanillaSalt

fix

parent 5eb9b56e
......@@ -191,6 +191,7 @@ struct processor {
card_set special_summoning;
card_set equiping_cards;
card_set control_adjust_set[2];
card_set self_destroy_set;
card_set release_cards;
card_set release_cards_ex;
card_set release_cards_ex_sum;
......@@ -476,6 +477,7 @@ public:
int32 get_control(uint16 step, effect* reason_effect, uint8 reason_player, card* pcard, uint8 playerid, uint16 reset_phase, uint8 reset_count);
int32 swap_control(uint16 step, effect* reason_effect, uint8 reason_player, card* pcard1, card* pcard2, uint16 reset_phase, uint8 reset_count);
int32 control_adjust(uint16 step);
int32 self_destroy(uint16 step);
int32 equip(uint16 step, uint8 equip_player, card* equip_card, card* target, uint32 up, uint32 is_step);
int32 draw(uint16 step, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 playerid, uint32 count);
int32 damage(uint16 step, effect* reason_effect, uint32 reason, uint8 reason_player, card* pcard, uint8 playerid, uint32 amount);
......@@ -646,6 +648,7 @@ public:
#define PROCESSOR_GET_CONTROL 74
#define PROCESSOR_SWAP_CONTROL 75
#define PROCESSOR_CONTROL_ADJUST 76
#define PROCESSOR_SELF_DESTROY 77
#define PROCESSOR_PAY_LPCOST 80
#define PROCESSOR_REMOVE_COUNTER 81
#define PROCESSOR_ATTACK_DISABLE 82
......
......@@ -896,6 +896,7 @@ int32 field::swap_control(uint16 step, effect * reason_effect, uint8 reason_play
int32 field::control_adjust(uint16 step) {
switch(step) {
case 0: {
core.destroy_set.clear();
core.operated_set.clear();
uint32 b0 = get_useable_count(0, LOCATION_MZONE, PLAYER_NONE, 0);
uint32 b1 = get_useable_count(1, LOCATION_MZONE, PLAYER_NONE, 0);
......@@ -948,7 +949,6 @@ int32 field::control_adjust(uint16 step) {
return FALSE;
}
case 1: {
core.destroy_set.clear();
uint8 adjp = core.temp_var[0];
for(int32 i = 0; i < returns.bvalue[0]; ++i) {
card* pcard = core.select_cards[returns.bvalue[i + 1]];
......@@ -1028,6 +1028,55 @@ int32 field::control_adjust(uint16 step) {
}
return TRUE;
}
int32 field::self_destroy(uint16 step) {
switch(step) {
case 0: {
effect* peffect;
core.destroy_set.clear();
for(auto cit = core.self_destroy_set.begin(); cit != core.self_destroy_set.end(); ++cit) {
card* pcard = *cit;
if(pcard->is_position(POS_FACEUP) && (pcard->current.location & LOCATION_ONFIELD)
&& ((!pcard->is_status(STATUS_DISABLED) && (peffect = check_unique_onfield(pcard, pcard->current.controler)))
|| (peffect = pcard->is_affected_by_effect(EFFECT_SELF_DESTROY)))) {
core.destroy_set.insert(pcard);
pcard->current.reason_effect = peffect;
pcard->current.reason_player = peffect->get_handler_player();
}
}
if(core.destroy_set.size())
destroy(&core.destroy_set, 0, REASON_EFFECT, 5);
else
returns.ivalue[0] = 0;
return FALSE;
}
case 1: {
if(!(core.global_flag & GLOBALFLAG_SELF_TOGRAVE))
return TRUE;
core.units.begin()->arg1 = returns.ivalue[0];
effect* peffect;
card_set tograve_set;
for(auto cit = core.self_destroy_set.begin(); cit != core.self_destroy_set.end(); ++cit) {
card* pcard = *cit;
if(pcard->is_position(POS_FACEUP) && (pcard->current.location & LOCATION_ONFIELD)
&& (peffect = pcard->is_affected_by_effect(EFFECT_SELF_TOGRAVE))) {
tograve_set.insert(pcard);
pcard->current.reason_effect = peffect;
pcard->current.reason_player = peffect->get_handler_player();
}
}
if(tograve_set.size())
send_to(&tograve_set, 0, REASON_EFFECT, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
else
return TRUE;
return FALSE;
}
case 2: {
returns.ivalue[0] += core.units.begin()->arg1;
return TRUE;
}
}
return TRUE;
}
int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * target, uint32 up, uint32 is_step) {
switch(step) {
case 0: {
......
......@@ -460,6 +460,13 @@ int32 field::process() {
it->step++;
return pduel->bufferlen;
}
case PROCESSOR_SELF_DESTROY: {
if (self_destroy(it->step)) {
core.units.pop_front();
} else
it->step++;
return pduel->bufferlen;
}
case PROCESSOR_PAY_LPCOST: {
if (pay_lp_cost(it->step, it->arg1, it->arg2))
core.units.pop_front();
......@@ -4727,6 +4734,9 @@ int32 field::solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2
}
}
adjust_instant();
core.self_destroy_set.clear();
core.self_destroy_set.insert(pcard);
add_process(PROCESSOR_SELF_DESTROY, 0, 0, 0, 0, 0);
}
raise_event((card*)0, EVENT_CHAIN_SOLVING, peffect, 0, cait->triggering_player, cait->triggering_player, cait->chain_count);
process_instant_event();
......@@ -5318,77 +5328,31 @@ int32 field::adjust_step(uint16 step) {
return FALSE;
}
//self destroy
uint8 tp = infos.turn_player;
effect* peffect;
core.destroy_set.clear();
core.self_destroy_set.clear();
for(uint8 p = 0; p < 2; ++p) {
for(uint8 i = 0; i < 5; ++i) {
card* pcard = player[tp].list_mzone[i];
if(pcard && pcard->is_position(POS_FACEUP) && ((!pcard->is_status(STATUS_DISABLED) && (peffect = check_unique_onfield(pcard, tp)))
|| (peffect = pcard->is_affected_by_effect(EFFECT_SELF_DESTROY)))) {
core.destroy_set.insert(pcard);
pcard->current.reason_effect = peffect;
pcard->current.reason_player = peffect->get_handler_player();
}
card* pcard = player[p].list_mzone[i];
if(pcard)
core.self_destroy_set.insert(pcard);
}
for(uint8 i = 0; i < 8; ++i) {
card* pcard = player[tp].list_szone[i];
if(pcard && pcard->is_position(POS_FACEUP) && ((!pcard->is_status(STATUS_DISABLED) && (peffect = check_unique_onfield(pcard, tp)))
|| (peffect = pcard->is_affected_by_effect(EFFECT_SELF_DESTROY)))) {
core.destroy_set.insert(pcard);
pcard->current.reason_effect = peffect;
pcard->current.reason_player = peffect->get_handler_player();
}
card* pcard = player[p].list_szone[i];
if(pcard)
core.self_destroy_set.insert(pcard);
}
tp = 1 - tp;
}
if(core.destroy_set.size()) {
destroy(&core.destroy_set, 0, REASON_EFFECT, 5);
} else {
returns.ivalue[0] = 0;
}
if(core.self_destroy_set.size())
add_process(PROCESSOR_SELF_DESTROY, 0, 0, 0, 0, 0);
else
core.units.begin()->step = 9;
return FALSE;
}
case 9: {
if(returns.ivalue[0] > 0)
core.re_adjust = TRUE;
//self tograve
if(!(core.global_flag & GLOBALFLAG_SELF_TOGRAVE)) {
returns.ivalue[0] = 0;
return FALSE;
}
uint8 tp = infos.turn_player;
effect* peffect;
card_set tograve_set;
for(uint8 p = 0; p < 2; ++p) {
for(uint8 i = 0; i < 5; ++i) {
card* pcard = player[tp].list_mzone[i];
if(pcard && pcard->is_position(POS_FACEUP) && (peffect = pcard->is_affected_by_effect(EFFECT_SELF_TOGRAVE))) {
tograve_set.insert(pcard);
pcard->current.reason_effect = peffect;
pcard->current.reason_player = peffect->get_handler_player();
}
}
for(uint8 i = 0; i < 8; ++i) {
card* pcard = player[tp].list_szone[i];
if(pcard && pcard->is_position(POS_FACEUP) && (peffect = pcard->is_affected_by_effect(EFFECT_SELF_TOGRAVE))) {
tograve_set.insert(pcard);
pcard->current.reason_effect = peffect;
pcard->current.reason_player = peffect->get_handler_player();
}
}
tp = 1 - tp;
}
if(tograve_set.size()) {
send_to(&tograve_set, 0, REASON_EFFECT, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
} else {
returns.ivalue[0] = 0;
}
return FALSE;
}
case 10: {
if(returns.ivalue[0] > 0)
core.re_adjust = TRUE;
//equip check
uint8 tp = infos.turn_player;
card* pcard;
......
......@@ -90,7 +90,6 @@ function c20426907.disfilter(c,e)
return c:IsFaceup() and c:IsRelateToEffect(e)
end
function c20426907.disop(e,tp,eg,ep,ev,re,r,rp)
if c20426907.sdcon(e) then return end
if e:GetLabel()==0 or not e:GetHandler():IsRelateToEffect(e) then return end
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(c20426907.disfilter,nil,e)
local tc=g:GetFirst()
......
......@@ -59,7 +59,6 @@ function c32919136.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
end
function c32919136.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c32919136.descon(e) then Duel.Destroy(c,REASON_EFFECT) end
local tc=Duel.GetFirstTarget()
if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then
Duel.Equip(tp,c,tc)
......
......@@ -114,7 +114,6 @@ function c61965407.tgtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0)
end
function c61965407.operation(e,tp,eg,ep,ev,re,r,rp)
if c61965407.sdcon(e) then return end
if e:GetLabel()==0 or not e:GetHandler():IsRelateToEffect(e) then return end
local tc=Duel.GetFirstTarget()
if not tc:IsRelateToEffect(e) then return end
......
......@@ -58,7 +58,6 @@ function c94432298.tgtg2(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_DECK)
end
function c94432298.tgop(e,tp,eg,ep,ev,re,r,rp)
if c94432298.sdcon(e) then return end
if e:GetHandler():GetFlagEffect(94432298)==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,c94432298.filter,tp,LOCATION_DECK,0,1,2,nil)
......
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