Commit 7f45d68b authored by Momobako's avatar Momobako
parents f5422643 03bb69ae
...@@ -198,14 +198,14 @@ enum effect_flag : uint32 { ...@@ -198,14 +198,14 @@ enum effect_flag : uint32 {
EFFECT_FLAG_OWNER_RELATE = 0x1000000, EFFECT_FLAG_OWNER_RELATE = 0x1000000,
EFFECT_FLAG_AVAILABLE_BD = 0x2000000, EFFECT_FLAG_AVAILABLE_BD = 0x2000000,
EFFECT_FLAG_CLIENT_HINT = 0x4000000, EFFECT_FLAG_CLIENT_HINT = 0x4000000,
EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000, // EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000,
// EFFECT_FLAG_NAGA = 0x10000000, // EFFECT_FLAG_NAGA = 0x10000000,
// EFFECT_FLAG_COF = 0x20000000, // EFFECT_FLAG_COF = 0x20000000,
EFFECT_FLAG_CVAL_CHECK = 0x40000000, // EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000, EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
}; };
enum effect_flag2 : uint32 { enum effect_flag2 : uint32 {
EFFECT_FLAG2_NAGA = 0x0001, // EFFECT_FLAG2_NAGA = 0x0001,
EFFECT_FLAG2_COF = 0x0002, EFFECT_FLAG2_COF = 0x0002,
}; };
inline effect_flag operator|(effect_flag flag1, effect_flag flag2) inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
......
...@@ -612,6 +612,7 @@ public: ...@@ -612,6 +612,7 @@ public:
#define CHAIN_CONTINUOUS_CARD 0x08 #define CHAIN_CONTINUOUS_CARD 0x08
#define CHAIN_ACTIVATING 0x10 #define CHAIN_ACTIVATING 0x10
#define CHAIN_HAND_TRIGGER 0x20 #define CHAIN_HAND_TRIGGER 0x20
#define CHAIN_DECK_EFFECT 0x40
#define CHAININFO_CHAIN_COUNT 0x01 #define CHAININFO_CHAIN_COUNT 0x01
#define CHAININFO_TRIGGERING_EFFECT 0x02 #define CHAININFO_TRIGGERING_EFFECT 0x02
#define CHAININFO_TRIGGERING_PLAYER 0x04 #define CHAININFO_TRIGGERING_PLAYER 0x04
......
...@@ -3835,44 +3835,30 @@ int32 scriptlib::duel_is_chain_negatable(lua_State * L) { ...@@ -3835,44 +3835,30 @@ int32 scriptlib::duel_is_chain_negatable(lua_State * L) {
check_param_count(L, 1); check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1); int32 chaincount = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 res = 0; chain* ch = pduel->game_field->get_chain(chaincount);
if(chaincount < 0 || chaincount > (int32)pduel->game_field->core.current_chain.size()) if(!ch)
res = FALSE; return 0;
else { if(ch->flag & CHAIN_DECK_EFFECT)
effect* peffect; lua_pushboolean(L, 0);
if(chaincount == 0) else
peffect = pduel->game_field->core.current_chain.back().triggering_effect; lua_pushboolean(L, 1);
else
peffect = pduel->game_field->core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG2_NAGA))
res = FALSE;
else
res = TRUE;
}
lua_pushboolean(L, res);
return 1; return 1;
} }
int32 scriptlib::duel_is_chain_disablable(lua_State * L) { int32 scriptlib::duel_is_chain_disablable(lua_State * L) {
check_param_count(L, 1); check_param_count(L, 1);
int32 chaincount = lua_tointeger(L, 1); int32 chaincount = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
int32 res = 0; if(pduel->game_field->core.chain_solving) {
if(chaincount < 0 || chaincount > (int32)pduel->game_field->core.current_chain.size()) lua_pushboolean(L, pduel->game_field->is_chain_disablable(chaincount));
res = FALSE; return 1;
else {
effect* peffect;
if(chaincount == 0)
peffect = pduel->game_field->core.current_chain.back().triggering_effect;
else
peffect = pduel->game_field->core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG2_NAGA))
res = FALSE;
else
res = TRUE;
if(pduel->game_field->core.chain_solving)
res = pduel->game_field->is_chain_disablable(chaincount);
} }
lua_pushboolean(L, res); chain* ch = pduel->game_field->get_chain(chaincount);
if(!ch)
return 0;
if(ch->flag & CHAIN_DECK_EFFECT)
lua_pushboolean(L, 0);
else
lua_pushboolean(L, 1);
return 1; return 1;
} }
int32 scriptlib::duel_check_chain_target(lua_State *L) { int32 scriptlib::duel_check_chain_target(lua_State *L) {
......
...@@ -29,7 +29,7 @@ int32 field::negate_chain(uint8 chaincount) { ...@@ -29,7 +29,7 @@ int32 field::negate_chain(uint8 chaincount) {
} }
pduel->write_buffer8(MSG_CHAIN_NEGATED); pduel->write_buffer8(MSG_CHAIN_NEGATED);
pduel->write_buffer8(chaincount); pduel->write_buffer8(chaincount);
if(pchain.triggering_effect->is_flag(EFFECT_FLAG2_NAGA)) if(pchain.flag & CHAIN_DECK_EFFECT)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
...@@ -48,7 +48,7 @@ int32 field::disable_chain(uint8 chaincount) { ...@@ -48,7 +48,7 @@ int32 field::disable_chain(uint8 chaincount) {
core.current_chain[chaincount - 1].disable_player = core.reason_player; core.current_chain[chaincount - 1].disable_player = core.reason_player;
pduel->write_buffer8(MSG_CHAIN_DISABLED); pduel->write_buffer8(MSG_CHAIN_DISABLED);
pduel->write_buffer8(chaincount); pduel->write_buffer8(chaincount);
if(pchain.triggering_effect->is_flag(EFFECT_FLAG2_NAGA)) if(pchain.flag & CHAIN_DECK_EFFECT)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
...@@ -4382,6 +4382,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4382,6 +4382,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
&& !(peffect && (peffect->value & TYPE_TRAP)) && ret != 2) && !(peffect && (peffect->value & TYPE_TRAP)) && ret != 2)
resetflag |= RESET_MSCHANGE; resetflag |= RESET_MSCHANGE;
target->reset(resetflag, RESET_EVENT); target->reset(resetflag, RESET_EVENT);
target->clear_card_target();
} }
if(!(target->current.location & LOCATION_ONFIELD)) if(!(target->current.location & LOCATION_ONFIELD))
target->clear_relate_effect(); target->clear_relate_effect();
...@@ -4458,7 +4459,6 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4458,7 +4459,6 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
} }
if((target->previous.location == LOCATION_SZONE) && target->equiping_target) if((target->previous.location == LOCATION_SZONE) && target->equiping_target)
target->unequip(); target->unequip();
target->clear_card_target();
if(target->current.location == LOCATION_MZONE) { if(target->current.location == LOCATION_MZONE) {
effect_set eset; effect_set eset;
filter_player_effect(0, EFFECT_MUST_USE_MZONE, &eset, FALSE); filter_player_effect(0, EFFECT_MUST_USE_MZONE, &eset, FALSE);
......
...@@ -1691,25 +1691,22 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1691,25 +1691,22 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
for (auto clit = core.new_fchain_s.begin(); clit != core.new_fchain_s.end(); ) { for (auto clit = core.new_fchain_s.begin(); clit != core.new_fchain_s.end(); ) {
effect* peffect = clit->triggering_effect; effect* peffect = clit->triggering_effect;
card* phandler = peffect->get_handler(); card* phandler = peffect->get_handler();
if(!peffect->is_flag(EFFECT_FLAG_EVENT_PLAYER | EFFECT_FLAG_BOTH_SIDE) && phandler->is_has_relation(*clit)) {
clit->triggering_player = phandler->current.controler;
clit->set_triggering_place(phandler);
}
uint8 tp = clit->triggering_player; uint8 tp = clit->triggering_player;
bool act = true; bool act = true;
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
&& clit->triggering_location == LOCATION_DECK && (phandler->current.location & LOCATION_DECK)) {
if((peffect->type & EFFECT_TYPE_SINGLE) && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)
&& peffect->code == EVENT_TO_DECK || (peffect->range & LOCATION_DECK))
clit->flag |= CHAIN_DECK_EFFECT;
else
act = false;
}
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE) if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (!(peffect->type & EFFECT_TYPE_FIELD) || phandler->is_has_relation(*clit)) && (!(peffect->type & EFFECT_TYPE_FIELD) || phandler->is_has_relation(*clit))
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE && (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE
|| (clit->triggering_location & 0x43) && (clit->triggering_position & POS_FACEDOWN) || (clit->triggering_location & 0x43) && (clit->triggering_position & POS_FACEDOWN)
|| !(phandler->current.location & 0x43) || phandler->is_position(POS_FACEUP))) { || !(phandler->current.location & 0x43) || phandler->is_position(POS_FACEUP))) {
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) {
for(auto tpit = core.current_chain.begin(); tpit != core.current_chain.end(); ++tpit) {
if(tpit->triggering_effect->get_handler()->data.code == phandler->data.code && tpit->triggering_player == tp) {
act = false;
break;
}
}
}
} else } else
act = false; act = false;
if(act) { if(act) {
...@@ -1757,9 +1754,8 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1757,9 +1754,8 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
for (auto clit = core.new_ochain_s.begin(); clit != core.new_ochain_s.end(); ) { for (auto clit = core.new_ochain_s.begin(); clit != core.new_ochain_s.end(); ) {
effect* peffect = clit->triggering_effect; effect* peffect = clit->triggering_effect;
card* phandler = peffect->get_handler(); card* phandler = peffect->get_handler();
if((!peffect->is_flag(EFFECT_FLAG_EVENT_PLAYER | EFFECT_FLAG_BOTH_SIDE) && phandler->is_has_relation(*clit)) if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY) && (peffect->type & EFFECT_TYPE_FIELD)
|| (!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY) && (peffect->type & EFFECT_TYPE_FIELD) && (peffect->range & LOCATION_HAND) && phandler->current.location == LOCATION_HAND) {
&& (peffect->range & LOCATION_HAND) && phandler->current.location == LOCATION_HAND)) {
if(!phandler->is_has_relation(*clit)) if(!phandler->is_has_relation(*clit))
phandler->create_relation(*clit); phandler->create_relation(*clit);
clit->triggering_player = phandler->current.controler; clit->triggering_player = phandler->current.controler;
...@@ -1777,6 +1773,14 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1777,6 +1773,14 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
|| peffect->range && !peffect->in_range(*clit)) || peffect->range && !peffect->in_range(*clit))
act = false; act = false;
} }
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
&& clit->triggering_location == LOCATION_DECK && (phandler->current.location & LOCATION_DECK)) {
if((peffect->type & EFFECT_TYPE_SINGLE) && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)
&& peffect->code == EVENT_TO_DECK || (peffect->range & LOCATION_DECK))
clit->flag |= CHAIN_DECK_EFFECT;
else
act = false;
}
if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE) if(peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& (!(peffect->type & EFFECT_TYPE_FIELD) || phandler->is_has_relation(*clit)) && (!(peffect->type & EFFECT_TYPE_FIELD) || phandler->is_has_relation(*clit))
&& (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE && (peffect->code == EVENT_FLIP && infos.phase == PHASE_DAMAGE
...@@ -1792,14 +1796,6 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free ...@@ -1792,14 +1796,6 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
} }
} }
} }
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) {
for(auto tpit = core.current_chain.begin(); tpit != core.current_chain.end(); ++tpit) {
if(tpit->triggering_player == tp && tpit->triggering_effect->get_handler()->data.code == phandler->data.code) {
act = false;
break;
}
}
}
} else } else
act = false; act = false;
} else act = false; } else act = false;
...@@ -2002,56 +1998,19 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -2002,56 +1998,19 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
core.ntpchain.clear(); core.ntpchain.clear();
if(!core.quick_f_chain.size()) if(!core.quick_f_chain.size())
return FALSE; return FALSE;
bool act = true;
for(auto ifit = core.quick_f_chain.begin(); ifit != core.quick_f_chain.end(); ++ifit) { for(auto ifit = core.quick_f_chain.begin(); ifit != core.quick_f_chain.end(); ++ifit) {
effect* peffect = ifit->first; effect* peffect = ifit->first;
card* phandler = peffect->get_handler(); card* phandler = peffect->get_handler();
if(peffect->is_chainable(ifit->second.triggering_player) && peffect->check_count_limit(ifit->second.triggering_player) if(peffect->is_chainable(ifit->second.triggering_player) && peffect->check_count_limit(ifit->second.triggering_player)
&& phandler->is_has_relation(ifit->second)) { && phandler->is_has_relation(ifit->second)) {
if(ifit->second.triggering_player == infos.turn_player) { if(ifit->second.triggering_player == infos.turn_player) {
act = true; core.tpchain.push_back(ifit->second);
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) { phandler->set_status(STATUS_CHAINING, TRUE);
for (auto cait = core.tpchain.begin(); cait != core.tpchain.end(); ++cait) { peffect->dec_count(infos.turn_player);
if (cait->triggering_effect->get_handler()->data.code == phandler->data.code) {
act = false;
break;
}
}
for (auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) {
if ((cait->triggering_effect->get_handler()->data.code == phandler->data.code)
&& (cait->triggering_player == infos.turn_player)) {
act = false;
break;
}
}
}
if(act) {
core.tpchain.push_back(ifit->second);
phandler->set_status(STATUS_CHAINING, TRUE);
peffect->dec_count(infos.turn_player);
}
} else { } else {
act = true; core.ntpchain.push_back(ifit->second);
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) { phandler->set_status(STATUS_CHAINING, TRUE);
for (auto cait = core.ntpchain.begin(); cait != core.ntpchain.end(); ++cait) { peffect->dec_count(1 - infos.turn_player);
if (cait->triggering_effect->get_handler()->data.code == phandler->data.code) {
act = false;
break;
}
}
for (auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) {
if ((cait->triggering_effect->get_handler()->data.code == phandler->data.code)
&& (cait->triggering_player != infos.turn_player)) {
act = false;
break;
}
}
}
if(act) {
core.ntpchain.push_back(ifit->second);
phandler->set_status(STATUS_CHAINING, TRUE);
peffect->dec_count(1 - infos.turn_player);
}
} }
} }
} }
...@@ -2135,14 +2094,6 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -2135,14 +2094,6 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
} }
} }
} }
if(peffect->is_flag(EFFECT_FLAG_CHAIN_UNIQUE)) {
for(auto cait = core.current_chain.begin(); cait != core.current_chain.end(); ++cait) {
if(cait->triggering_player == priority && cait->triggering_effect->get_handler()->data.code == phandler->data.code) {
act = false;
break;
}
}
}
} else } else
act = false; act = false;
if(act) if(act)
......
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