Commit 63e10ceb authored by salix5's avatar salix5

STATUS_EFFECT_ENABLED

parent 8a1ac12b
......@@ -1022,9 +1022,11 @@ void card::set_status(uint32 status, int32 enabled) {
else
this->status &= ~status;
}
// match at least 1 status
int32 card::get_status(uint32 status) {
return this->status & status;
}
// match all status
int32 card::is_status(uint32 status) {
if ((this->status & status) == status)
return TRUE;
......@@ -1174,6 +1176,9 @@ void card::cancel_field_effect() {
if(unique_code && (current.location & unique_location))
pduel->game_field->remove_unique_card(this);
}
// STATUS_EFFECT_ENABLED: the card is ready to use
// false: before moving, summoning, chaining
// true: ready
void card::enable_field_effect(bool enabled) {
if (current.location == 0)
return;
......@@ -1323,9 +1328,8 @@ void card::remove_effect(effect* peffect, effect_container::iterator it) {
single_effect.erase(it);
else if (peffect->type & EFFECT_TYPE_FIELD) {
check_target = 0;
if (peffect->in_range(current.location, current.sequence) && get_status(STATUS_EFFECT_ENABLED) && !get_status(STATUS_DISABLED | STATUS_FORBIDDEN)) {
if (peffect->is_disable_related())
pduel->game_field->update_disable_check_list(peffect);
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))
......
......@@ -76,8 +76,9 @@ int32 effect::is_available() {
return FALSE;
if(is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(handler->current.location, handler->current.sequence))
return FALSE;
if(is_flag(EFFECT_FLAG_SINGLE_RANGE) && (handler->current.location & LOCATION_ONFIELD)
&& (handler->is_position(POS_FACEDOWN) || (!handler->is_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))))
if(is_flag(EFFECT_FLAG_SINGLE_RANGE) && !handler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE;
if(is_flag(EFFECT_FLAG_SINGLE_RANGE) && (handler->current.location & LOCATION_ONFIELD) && !handler->is_position(POS_FACEUP))
return FALSE;
if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && owner->is_status(STATUS_FORBIDDEN))
return FALSE;
......@@ -110,6 +111,12 @@ int32 effect::is_available() {
if (!is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if(handler->current.controler == PLAYER_NONE)
return FALSE;
if(!in_range(handler->current.location, handler->current.sequence))
return FALSE;
if(!handler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE;
if((handler->current.location & LOCATION_ONFIELD) && !handler->is_position(POS_FACEUP))
return FALSE;
if(is_flag(EFFECT_FLAG_OWNER_RELATE) && is_can_be_forbidden() && owner->is_status(STATUS_FORBIDDEN))
return FALSE;
if(owner == handler && is_can_be_forbidden() && handler->get_status(STATUS_FORBIDDEN))
......@@ -120,12 +127,6 @@ int32 effect::is_available() {
return FALSE;
if(handler->is_status(STATUS_BATTLE_DESTROYED) && !is_flag(EFFECT_FLAG_AVAILABLE_BD))
return FALSE;
if(!handler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE;
if(!in_range(handler->current.location, handler->current.sequence))
return FALSE;
if((handler->current.location & LOCATION_ONFIELD) && !handler->is_position(POS_FACEUP))
return FALSE;
}
}
if (!condition)
......@@ -236,7 +237,9 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
&& !in_range(handler->current.location, handler->current.sequence))
return FALSE;
if((handler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))) {
// effects with EFFECT_FLAG_SET_AVAILABLE can be activated while face-down
// effects which can be activated while face-down:
// 1. effects with EFFECT_FLAG_SET_AVAILABLE
// 2. events with FLIP_SET_AVAILABLE
if(!handler->is_position(POS_FACEUP) && !is_flag(EFFECT_FLAG_SET_AVAILABLE) && (code != EVENT_FLIP || !(e.event_value & (FLIP_SET_AVAILABLE >> 16))))
return FALSE;
if(handler->is_position(POS_FACEUP) && !handler->is_status(STATUS_EFFECT_ENABLED))
......
......@@ -1561,7 +1561,7 @@ void field::set_spsummon_counter(uint8 playerid, bool add, bool chain) {
effect* peffect = *iter;
card* pcard = peffect->handler;
if(add) {
if(pcard->is_status(STATUS_EFFECT_ENABLED) && !pcard->get_status(STATUS_DISABLED | STATUS_FORBIDDEN) && pcard->is_position(POS_FACEUP)) {
if(peffect->is_available()) {
if(((playerid == pcard->current.controler) && peffect->s_range) || ((playerid != pcard->current.controler) && peffect->o_range)) {
pcard->spsummon_counter[playerid]++;
if(chain)
......@@ -1581,7 +1581,7 @@ int32 field::check_spsummon_counter(uint8 playerid, uint8 ct) {
effect* peffect = *iter;
card* pcard = peffect->handler;
uint16 val = (uint16)peffect->value;
if(pcard->is_status(STATUS_EFFECT_ENABLED) && !pcard->get_status(STATUS_DISABLED | STATUS_FORBIDDEN) && pcard->is_position(POS_FACEUP)) {
if(peffect->is_available()) {
if(pcard->spsummon_counter[playerid] + ct > val)
return FALSE;
}
......
......@@ -632,7 +632,7 @@ int32 scriptlib::duel_return_to_field(lua_State *L) {
pcard->enable_field_effect(false);
pduel->game_field->adjust_instant();
pduel->game_field->refresh_location_info_instant();
pduel->game_field->move_to_field(pcard, pcard->previous.controler, pcard->previous.controler, pcard->previous.location, pos, FALSE, 1);
pduel->game_field->move_to_field(pcard, pcard->previous.controler, pcard->previous.controler, pcard->previous.location, pos, TRUE, 1);
pduel->game_field->core.subunits.begin()->type = PROCESSOR_MOVETOFIELD_S;
return lua_yield(L, 0);
}
......
......@@ -3799,7 +3799,7 @@ int32 field::move_to_field(uint16 step, card * target, uint32 enable, uint32 ret
uint32 flag;
uint32 lreason = (target->current.location == LOCATION_MZONE) ? LOCATION_REASON_CONTROL : LOCATION_REASON_TOFIELD;
uint32 ct = get_useable_count(playerid, location, move_player, lreason, &flag);
if((ret == 1) && (ct <= 0 || target->is_affected_by_effect(EFFECT_FORBIDDEN))) {
if((ret == 1) && (ct <= 0 || target->is_status(STATUS_FORBIDDEN))) {
core.units.begin()->step = 3;
send_to(target, core.reason_effect, REASON_EFFECT, core.reason_player, PLAYER_NONE, LOCATION_GRAVE, 0, 0);
return FALSE;
......
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