Commit 7eba9c3e authored by VanillaSalt's avatar VanillaSalt

update EFFECT_TYPE_XMATERIAL

parent c670a7c8
...@@ -1162,6 +1162,11 @@ void card::xyz_add(card* mat, card_set* des) { ...@@ -1162,6 +1162,11 @@ void card::xyz_add(card* mat, card_set* des) {
mat->current.location = LOCATION_OVERLAY; mat->current.location = LOCATION_OVERLAY;
mat->current.sequence = xyz_materials.size() - 1; mat->current.sequence = xyz_materials.size() - 1;
mat->current.reason = REASON_XYZ + REASON_MATERIAL; mat->current.reason = REASON_XYZ + REASON_MATERIAL;
for(auto eit = mat->xmaterial_effect.begin(); eit != mat->xmaterial_effect.end(); ++eit) {
effect* peffect = eit->second;
if(peffect->type & EFFECT_TYPE_FIELD)
pduel->game_field->add_effect(peffect);
}
} }
void card::xyz_remove(card* mat) { void card::xyz_remove(card* mat) {
if(mat->overlay_target != this) if(mat->overlay_target != this)
...@@ -1176,6 +1181,11 @@ void card::xyz_remove(card* mat) { ...@@ -1176,6 +1181,11 @@ void card::xyz_remove(card* mat) {
mat->overlay_target = 0; mat->overlay_target = 0;
for(auto clit = xyz_materials.begin(); clit != xyz_materials.end(); ++clit) for(auto clit = xyz_materials.begin(); clit != xyz_materials.end(); ++clit)
(*clit)->current.sequence = clit - xyz_materials.begin(); (*clit)->current.sequence = clit - xyz_materials.begin();
for(auto eit = mat->xmaterial_effect.begin(); eit != mat->xmaterial_effect.end(); ++eit) {
effect* peffect = eit->second;
if(peffect->type & EFFECT_TYPE_FIELD)
pduel->game_field->remove_effect(peffect);
}
} }
void card::apply_field_effect() { void card::apply_field_effect() {
if (current.controler == PLAYER_NONE) if (current.controler == PLAYER_NONE)
...@@ -1278,9 +1288,7 @@ int32 card::add_effect(effect* peffect) { ...@@ -1278,9 +1288,7 @@ int32 card::add_effect(effect* peffect) {
} }
} }
eit = single_effect.insert(std::make_pair(peffect->code, peffect)); eit = single_effect.insert(std::make_pair(peffect->code, peffect));
} else if (peffect->type & EFFECT_TYPE_FIELD) } else if (peffect->type & EFFECT_TYPE_EQUIP) {
eit = field_effect.insert(std::make_pair(peffect->code, peffect));
else if (peffect->type & EFFECT_TYPE_EQUIP) {
eit = equip_effect.insert(std::make_pair(peffect->code, peffect)); eit = equip_effect.insert(std::make_pair(peffect->code, peffect));
if (equiping_target) if (equiping_target)
check_target = equiping_target; check_target = equiping_target;
...@@ -1292,6 +1300,8 @@ int32 card::add_effect(effect* peffect) { ...@@ -1292,6 +1300,8 @@ int32 card::add_effect(effect* peffect) {
check_target = overlay_target; check_target = overlay_target;
else else
check_target = 0; check_target = 0;
} else if (peffect->type & EFFECT_TYPE_FIELD) {
eit = field_effect.insert(std::make_pair(peffect->code, peffect));
} else } else
return 0; return 0;
peffect->id = pduel->game_field->infos.field_id++; peffect->id = pduel->game_field->infos.field_id++;
...@@ -1353,16 +1363,8 @@ void card::remove_effect(effect* peffect) { ...@@ -1353,16 +1363,8 @@ void card::remove_effect(effect* peffect) {
} }
void card::remove_effect(effect* peffect, effect_container::iterator it) { void card::remove_effect(effect* peffect, effect_container::iterator it) {
card* check_target = this; card* check_target = this;
if (peffect->type & EFFECT_TYPE_SINGLE) if (peffect->type & EFFECT_TYPE_SINGLE) {
single_effect.erase(it); single_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_FIELD) {
check_target = 0;
if (peffect->is_available() && peffect->is_disable_related()) {
pduel->game_field->update_disable_check_list(peffect);
}
field_effect.erase(it);
if (peffect->in_range(current.location, current.sequence))
pduel->game_field->remove_effect(peffect);
} else if (peffect->type & EFFECT_TYPE_EQUIP) { } else if (peffect->type & EFFECT_TYPE_EQUIP) {
equip_effect.erase(it); equip_effect.erase(it);
if (equiping_target) if (equiping_target)
...@@ -1375,6 +1377,14 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) { ...@@ -1375,6 +1377,14 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
check_target = overlay_target; check_target = overlay_target;
else else
check_target = 0; check_target = 0;
} else if (peffect->type & EFFECT_TYPE_FIELD) {
check_target = 0;
if (peffect->is_available() && peffect->is_disable_related()) {
pduel->game_field->update_disable_check_list(peffect);
}
field_effect.erase(it);
if (peffect->in_range(current.location, current.sequence))
pduel->game_field->remove_effect(peffect);
} }
if ((current.controler != PLAYER_NONE) && !get_status(STATUS_DISABLED | STATUS_FORBIDDEN) && check_target) { if ((current.controler != PLAYER_NONE) && !get_status(STATUS_DISABLED | STATUS_FORBIDDEN) && check_target) {
if (peffect->is_disable_related()) if (peffect->is_disable_related())
......
...@@ -111,24 +111,26 @@ int32 effect::is_available() { ...@@ -111,24 +111,26 @@ int32 effect::is_available() {
} }
} }
if (type & EFFECT_TYPE_FIELD) { if (type & EFFECT_TYPE_FIELD) {
card* phandler = get_handler();
card* powner = get_owner();
if (!is_flag(EFFECT_FLAG_FIELD_ONLY)) { if (!is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if(handler->current.controler == PLAYER_NONE) if(phandler->current.controler == PLAYER_NONE)
return FALSE; return FALSE;
if(!in_range(handler->current.location, handler->current.sequence)) if(!in_range(phandler->current.location, phandler->current.sequence))
return FALSE; return FALSE;
if(!handler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY)) if(!phandler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE; return FALSE;
if((handler->current.location & LOCATION_ONFIELD) && !handler->is_position(POS_FACEUP)) if((phandler->current.location & LOCATION_ONFIELD) && !phandler->is_position(POS_FACEUP))
return FALSE; return FALSE;
if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && owner->is_status(STATUS_FORBIDDEN)) if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && powner->is_status(STATUS_FORBIDDEN))
return FALSE; return FALSE;
if(owner == handler && is_can_be_forbidden() && handler->get_status(STATUS_FORBIDDEN)) if(powner == phandler && is_can_be_forbidden() && phandler->get_status(STATUS_FORBIDDEN))
return FALSE; return FALSE;
if(is_flag(EFFECT_FLAG_OWNER_RELATE) && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && owner->is_status(STATUS_DISABLED)) if(is_flag(EFFECT_FLAG_OWNER_RELATE) && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && powner->is_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(owner == handler && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && handler->get_status(STATUS_DISABLED)) if(powner == phandler && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && phandler->get_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(handler->is_status(STATUS_BATTLE_DESTROYED) && !is_flag(EFFECT_FLAG_AVAILABLE_BD)) if(phandler->is_status(STATUS_BATTLE_DESTROYED) && !is_flag(EFFECT_FLAG_AVAILABLE_BD))
return FALSE; return FALSE;
} }
} }
...@@ -677,6 +679,8 @@ uint8 effect::get_handler_player() { ...@@ -677,6 +679,8 @@ uint8 effect::get_handler_player() {
return get_handler()->current.controler; return get_handler()->current.controler;
} }
int32 effect::in_range(int32 loc, int32 seq) { int32 effect::in_range(int32 loc, int32 seq) {
if(type & EFFECT_TYPE_XMATERIAL)
return (int32)(!!handler->overlay_target);
if(loc != LOCATION_SZONE) if(loc != LOCATION_SZONE)
return range & loc; return range & loc;
if(seq < 5) if(seq < 5)
......
...@@ -2381,6 +2381,8 @@ int32 field::process_single_event() { ...@@ -2381,6 +2381,8 @@ int32 field::process_single_event() {
pr = (*ovit)->xmaterial_effect.equal_range(ev); pr = (*ovit)->xmaterial_effect.equal_range(ev);
for(; pr.first != pr.second; ++pr.first) { for(; pr.first != pr.second; ++pr.first) {
effect* peffect = pr.first->second; effect* peffect = pr.first->second;
if(peffect->type & EFFECT_TYPE_FIELD)
continue;
process_single_event(peffect, *elit, tp, ntp, tev, ntev); process_single_event(peffect, *elit, tp, ntp, tev, ntev);
} }
} }
......
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