Commit c9a468c0 authored by mercury233's avatar mercury233
parents b8454686 3a099257
......@@ -1895,11 +1895,13 @@ int32 card::replace_effect(uint32 code, uint32 reset, uint32 count) {
read_card(code, &cdata);
if(cdata.type & TYPE_NORMAL)
return -1;
if(is_status(STATUS_EFFECT_REPLACED))
set_status(STATUS_EFFECT_REPLACED, FALSE);
for(auto i = indexer.begin(); i != indexer.end();) {
auto rm = i++;
effect* peffect = rm->first;
auto it = rm->second;
if(peffect->is_flag(EFFECT_FLAG_INITIAL | EFFECT_FLAG_COPY_INHERIT))
if (peffect->is_flag(EFFECT_FLAG_INITIAL | EFFECT_FLAG_COPY_INHERIT))
remove_effect(peffect, it);
}
uint32 cr = pduel->game_field->core.copy_reset;
......
......@@ -168,7 +168,6 @@ int32 effect::check_count_limit(uint8 playerid) {
}
// check if an EFFECT_TYPE_ACTIONS effect can be activated
// for triggering effects, it checks EFFECT_FLAG_DAMAGE_STEP, EFFECT_FLAG_SET_AVAILABLE
// for continuous effect, it checks EFFECT_FLAG_AVAILABLE_BD
int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_cond, int32 neglect_cost, int32 neglect_target, int32 neglect_loc, int32 neglect_faceup) {
if(!(type & EFFECT_TYPE_ACTIONS))
return FALSE;
......
......@@ -184,7 +184,7 @@ enum effect_flag : uint32 {
EFFECT_FLAG_NO_TURN_RESET = 0x400000,
EFFECT_FLAG_EVENT_PLAYER = 0x800000,
EFFECT_FLAG_OWNER_RELATE = 0x1000000,
// EFFECT_FLAG_AVAILABLE_BD = 0x2000000,
EFFECT_FLAG_CANNOT_INACTIVATE = 0x2000000,
EFFECT_FLAG_CLIENT_HINT = 0x4000000,
// EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000,
EFFECT_FLAG_LIMIT_ZONE = 0x10000000,
......
......@@ -1222,6 +1222,9 @@ void field::remove_oath_effect(effect* reason_effect) {
void field::reset_phase(uint32 phase) {
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
auto rm = eit++;
// work around: skip turn still raise reset_phase(PHASE_END)
// without this taking control only for one turn will be returned when skipping turn
// RESET_TURN_END should be introduced
if((*rm)->code == EFFECT_SET_CONTROL)
continue;
if((*rm)->reset(phase, RESET_PHASE)) {
......@@ -3126,7 +3129,7 @@ int32 field::is_chain_negatable(uint8 chaincount) {
peffect = core.current_chain.back().triggering_effect;
else
peffect = core.current_chain[chaincount - 1].triggering_effect;
if(peffect->is_flag(EFFECT_FLAG_CANNOT_DISABLE))
if(peffect->is_flag(EFFECT_FLAG_CANNOT_INACTIVATE))
return FALSE;
filter_field_effect(EFFECT_CANNOT_INACTIVATE, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
......
......@@ -1266,15 +1266,51 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) {
auto cit = cset.begin();
ucard->unique_fieldid = (*cit)->fieldid;
} else {
card* mcard = 0;
core.select_cards.clear();
uint8 player = p;
for(auto& pcard : cset) {
if(ucard->unique_fieldid == pcard->fieldid) {
mcard = pcard;
break;
if(pcard->current.controler == player && pcard->unique_fieldid != UINT_MAX)
core.select_cards.push_back(pcard);
}
if(core.select_cards.size() == 0) {
player = 1 - p;
for(auto& pcard : cset) {
if(pcard->current.controler == player && pcard->unique_fieldid != UINT_MAX)
core.select_cards.push_back(pcard);
}
}
if(core.select_cards.size() == 0) {
player = p;
for(auto& pcard : cset) {
if(pcard->current.controler == player)
core.select_cards.push_back(pcard);
}
}
if(core.select_cards.size() == 0) {
player = 1 - p;
for(auto& pcard : cset) {
if(pcard->current.controler == player)
core.select_cards.push_back(pcard);
}
if(!mcard || pcard->fieldid < mcard->fieldid)
mcard = pcard;
}
if(core.select_cards.size() == 1) {
returns.bvalue[1] = 0;
}
else {
pduel->write_buffer8(MSG_HINT);
pduel->write_buffer8(HINT_SELECTMSG);
pduel->write_buffer8(player);
pduel->write_buffer32(534);
add_process(PROCESSOR_SELECT_CARD, 0, 0, 0, player, 0x10001);
}
return FALSE;
}
return TRUE;
}
case 1: {
card_set cset;
ucard->get_unique_target(&cset, p);
card* mcard = core.select_cards[returns.bvalue[1]];
ucard->unique_fieldid = mcard->fieldid;
cset.erase(mcard);
for(auto& pcard : cset) {
......@@ -1284,7 +1320,6 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) {
pcard->current.reason_player = ucard->current.controler;
}
destroy(&cset, 0, REASON_RULE, 5);
}
return TRUE;
}
case 10: {
......@@ -4445,6 +4480,8 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
core.hint_timing[pcard->current.controler] |= TIMING_POS_CHANGE;
if((opos & POS_FACEDOWN) && (npos & POS_FACEUP)) {
pcard->fieldid = infos.field_id++;
if(check_unique_onfield(pcard, pcard->current.controler, pcard->current.location))
pcard->unique_fieldid = UINT_MAX;
if(pcard->current.location == LOCATION_MZONE) {
raise_single_event(pcard, 0, EVENT_FLIP, reason_effect, 0, reason_player, 0, flag);
flips.insert(pcard);
......
......@@ -1395,6 +1395,7 @@ int32 field::process_phase_event(int16 step, int32 phase) {
core.select_chains.push_back(newchain);
cn_count++;
}
//all effects taking control non-permanently are only until End Phase, not until Turn end
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
effect* peffect = *eit++;
if(peffect->code != EFFECT_SET_CONTROL)
......@@ -1407,7 +1408,8 @@ int32 field::process_phase_event(int16 step, int32 phase) {
uint8 tp = infos.turn_player;
if(!(((peffect->reset_flag & RESET_SELF_TURN) && pid == tp) || ((peffect->reset_flag & RESET_OPPO_TURN) && pid != tp)))
continue;
if(peffect->reset_count != 1)
peffect->reset_count--;
if(peffect->reset_count != 0)
continue;
card* phandler = peffect->get_handler();
if(pid != phandler->current.controler) {
......@@ -5047,7 +5049,7 @@ int32 field::adjust_step(uint16 step) {
return FALSE;
}
case 4: {
//1-5 control
//control
core.control_adjust_set[0].clear();
core.control_adjust_set[1].clear();
for(uint8 p = 0; p < 2; ++p) {
......@@ -5077,7 +5079,6 @@ int32 field::adjust_step(uint16 step) {
if(res) {
for(uint8 p = 0; p < 2; ++p) {
for(auto& pcard : player[p].list_mzone) {
// remove EFFECT_SET_CONTROL
if(pcard && pcard->is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING)) {
pcard->reset(EFFECT_SET_CONTROL, RESET_CODE);
if(p != pcard->owner && pcard->is_capable_change_control())
......
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