Commit 83a3e621 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro-core

parents 35a2d6ec df431baf
...@@ -2836,6 +2836,7 @@ effect* card::is_affected_by_effect(int32 code, card* target) { ...@@ -2836,6 +2836,7 @@ effect* card::is_affected_by_effect(int32 code, card* target) {
} }
return 0; return 0;
} }
// return the last control-changing continous effect
effect* card::check_control_effect() { effect* card::check_control_effect() {
effect* ret_effect = 0; effect* ret_effect = 0;
for (auto& pcard : equiping_cards) { for (auto& pcard : equiping_cards) {
...@@ -2859,7 +2860,7 @@ effect* card::check_control_effect() { ...@@ -2859,7 +2860,7 @@ effect* card::check_control_effect() {
auto rg = single_effect.equal_range(EFFECT_SET_CONTROL); auto rg = single_effect.equal_range(EFFECT_SET_CONTROL);
for (; rg.first != rg.second; ++rg.first) { for (; rg.first != rg.second; ++rg.first) {
effect* peffect = rg.first->second; effect* peffect = rg.first->second;
if(!peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)) if(!peffect->is_flag(EFFECT_FLAG_OWNER_RELATE))
continue; continue;
if(!ret_effect || peffect->id > ret_effect->id) if(!ret_effect || peffect->id > ret_effect->id)
ret_effect = peffect; ret_effect = peffect;
......
...@@ -168,7 +168,6 @@ int32 effect::check_count_limit(uint8 playerid) { ...@@ -168,7 +168,6 @@ int32 effect::check_count_limit(uint8 playerid) {
} }
// check if an EFFECT_TYPE_ACTIONS effect can be activated // check if an EFFECT_TYPE_ACTIONS effect can be activated
// for triggering effects, it checks EFFECT_FLAG_DAMAGE_STEP, EFFECT_FLAG_SET_AVAILABLE // 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) { 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)) if(!(type & EFFECT_TYPE_ACTIONS))
return FALSE; return FALSE;
...@@ -549,7 +548,7 @@ int32 effect::is_chainable(uint8 tp) { ...@@ -549,7 +548,7 @@ int32 effect::is_chainable(uint8 tp) {
return TRUE; return TRUE;
} }
//return: this can be reset by reset_level or not //return: this can be reset by reset_level or not
//RESET_CODE can only reset single effects without EFFECT_FLAG_SINGLE_RANGE //RESET_CODE can only reset single effects without EFFECT_FLAG_SINGLE_RANGE, EFFECT_FLAG_OWNER_RELATE
//RESET_DISABLE is valid only when owner == handler //RESET_DISABLE is valid only when owner == handler
int32 effect::reset(uint32 reset_level, uint32 reset_type) { int32 effect::reset(uint32 reset_level, uint32 reset_type) {
switch (reset_type) { switch (reset_type) {
...@@ -582,7 +581,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) { ...@@ -582,7 +581,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
} }
case RESET_CODE: { case RESET_CODE: {
return (code == reset_level) && (type & EFFECT_TYPE_SINGLE) && !(type & EFFECT_TYPE_ACTIONS) return (code == reset_level) && (type & EFFECT_TYPE_SINGLE) && !(type & EFFECT_TYPE_ACTIONS)
&& !is_flag(EFFECT_FLAG_SINGLE_RANGE); && !is_flag(EFFECT_FLAG_SINGLE_RANGE) && !is_flag(EFFECT_FLAG_OWNER_RELATE);
break; break;
} }
case RESET_COPY: { case RESET_COPY: {
......
...@@ -200,7 +200,7 @@ enum effect_flag : uint32 { ...@@ -200,7 +200,7 @@ enum effect_flag : uint32 {
EFFECT_FLAG_NO_TURN_RESET = 0x400000, EFFECT_FLAG_NO_TURN_RESET = 0x400000,
EFFECT_FLAG_EVENT_PLAYER = 0x800000, EFFECT_FLAG_EVENT_PLAYER = 0x800000,
EFFECT_FLAG_OWNER_RELATE = 0x1000000, EFFECT_FLAG_OWNER_RELATE = 0x1000000,
// EFFECT_FLAG_AVAILABLE_BD = 0x2000000, EFFECT_FLAG_CANNOT_INACTIVATE = 0x2000000,
EFFECT_FLAG_CLIENT_HINT = 0x4000000, EFFECT_FLAG_CLIENT_HINT = 0x4000000,
// EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000, // EFFECT_FLAG_CHAIN_UNIQUE = 0x8000000,
EFFECT_FLAG_LIMIT_ZONE = 0x10000000, EFFECT_FLAG_LIMIT_ZONE = 0x10000000,
......
...@@ -1250,6 +1250,9 @@ void field::remove_oath_effect(effect* reason_effect) { ...@@ -1250,6 +1250,9 @@ void field::remove_oath_effect(effect* reason_effect) {
void field::reset_phase(uint32 phase) { void field::reset_phase(uint32 phase) {
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) { for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
auto rm = eit++; 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) if((*rm)->code == EFFECT_SET_CONTROL)
continue; continue;
if((*rm)->reset(phase, RESET_PHASE)) { if((*rm)->reset(phase, RESET_PHASE)) {
...@@ -3173,7 +3176,7 @@ int32 field::is_chain_negatable(uint8 chaincount) { ...@@ -3173,7 +3176,7 @@ int32 field::is_chain_negatable(uint8 chaincount) {
peffect = core.current_chain.back().triggering_effect; peffect = core.current_chain.back().triggering_effect;
else else
peffect = core.current_chain[chaincount - 1].triggering_effect; 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; return FALSE;
filter_field_effect(EFFECT_CANNOT_INACTIVATE, &eset); filter_field_effect(EFFECT_CANNOT_INACTIVATE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
......
...@@ -1291,15 +1291,51 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) { ...@@ -1291,15 +1291,51 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) {
auto cit = cset.begin(); auto cit = cset.begin();
ucard->unique_fieldid = (*cit)->fieldid; ucard->unique_fieldid = (*cit)->fieldid;
} else { } else {
card* mcard = 0; core.select_cards.clear();
uint8 player = p;
for(auto& pcard : cset) { for(auto& pcard : cset) {
if(ucard->unique_fieldid == pcard->fieldid) { if(pcard->current.controler == player && pcard->unique_fieldid != UINT_MAX)
mcard = pcard; core.select_cards.push_back(pcard);
break; }
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; ucard->unique_fieldid = mcard->fieldid;
cset.erase(mcard); cset.erase(mcard);
for(auto& pcard : cset) { for(auto& pcard : cset) {
...@@ -1309,7 +1345,6 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) { ...@@ -1309,7 +1345,6 @@ int32 field::self_destroy(uint16 step, card* ucard, int32 p) {
pcard->current.reason_player = ucard->current.controler; pcard->current.reason_player = ucard->current.controler;
} }
destroy(&cset, 0, REASON_RULE, 5); destroy(&cset, 0, REASON_RULE, 5);
}
return TRUE; return TRUE;
} }
case 10: { case 10: {
...@@ -4498,6 +4533,8 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec ...@@ -4498,6 +4533,8 @@ int32 field::change_position(uint16 step, group * targets, effect * reason_effec
core.hint_timing[pcard->current.controler] |= TIMING_POS_CHANGE; core.hint_timing[pcard->current.controler] |= TIMING_POS_CHANGE;
if((opos & POS_FACEDOWN) && (npos & POS_FACEUP)) { if((opos & POS_FACEDOWN) && (npos & POS_FACEUP)) {
pcard->fieldid = infos.field_id++; 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) { if(pcard->current.location == LOCATION_MZONE) {
raise_single_event(pcard, 0, EVENT_FLIP, reason_effect, 0, reason_player, 0, flag); raise_single_event(pcard, 0, EVENT_FLIP, reason_effect, 0, reason_player, 0, flag);
flips.insert(pcard); flips.insert(pcard);
......
...@@ -1395,6 +1395,7 @@ int32 field::process_phase_event(int16 step, int32 phase) { ...@@ -1395,6 +1395,7 @@ int32 field::process_phase_event(int16 step, int32 phase) {
core.select_chains.push_back(newchain); core.select_chains.push_back(newchain);
cn_count++; 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();) { for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
effect* peffect = *eit++; effect* peffect = *eit++;
if(peffect->code != EFFECT_SET_CONTROL) if(peffect->code != EFFECT_SET_CONTROL)
...@@ -1407,7 +1408,8 @@ int32 field::process_phase_event(int16 step, int32 phase) { ...@@ -1407,7 +1408,8 @@ int32 field::process_phase_event(int16 step, int32 phase) {
uint8 tp = infos.turn_player; uint8 tp = infos.turn_player;
if(!(((peffect->reset_flag & RESET_SELF_TURN) && pid == tp) || ((peffect->reset_flag & RESET_OPPO_TURN) && pid != tp))) if(!(((peffect->reset_flag & RESET_SELF_TURN) && pid == tp) || ((peffect->reset_flag & RESET_OPPO_TURN) && pid != tp)))
continue; continue;
if(peffect->reset_count != 1) peffect->reset_count--;
if(peffect->reset_count != 0)
continue; continue;
card* phandler = peffect->get_handler(); card* phandler = peffect->get_handler();
if(pid != phandler->current.controler) { if(pid != phandler->current.controler) {
...@@ -5066,7 +5068,7 @@ int32 field::adjust_step(uint16 step) { ...@@ -5066,7 +5068,7 @@ int32 field::adjust_step(uint16 step) {
return FALSE; return FALSE;
} }
case 4: { case 4: {
//1-5 control //control
core.control_adjust_set[0].clear(); core.control_adjust_set[0].clear();
core.control_adjust_set[1].clear(); core.control_adjust_set[1].clear();
for(uint8 p = 0; p < 2; ++p) { for(uint8 p = 0; p < 2; ++p) {
...@@ -5096,7 +5098,6 @@ int32 field::adjust_step(uint16 step) { ...@@ -5096,7 +5098,6 @@ int32 field::adjust_step(uint16 step) {
if(res) { if(res) {
for(uint8 p = 0; p < 2; ++p) { for(uint8 p = 0; p < 2; ++p) {
for(auto& pcard : player[p].list_mzone) { for(auto& pcard : player[p].list_mzone) {
// remove EFFECT_SET_CONTROL
if(pcard && pcard->is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING)) { if(pcard && pcard->is_affected_by_effect(EFFECT_REMOVE_BRAINWASHING)) {
pcard->reset(EFFECT_SET_CONTROL, RESET_CODE); pcard->reset(EFFECT_SET_CONTROL, RESET_CODE);
if(p != pcard->owner && pcard->is_capable_change_control()) 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