Commit e8c32487 authored by DailyShana's avatar DailyShana

bracket

parent 49d52fb4
This diff is collapsed.
...@@ -66,24 +66,24 @@ int32 effect::is_available() { ...@@ -66,24 +66,24 @@ int32 effect::is_available() {
if (type & EFFECT_TYPE_SINGLE) { if (type & EFFECT_TYPE_SINGLE) {
if (handler->current.controler == PLAYER_NONE) if (handler->current.controler == PLAYER_NONE)
return FALSE; return FALSE;
if((is_flag(EFFECT_FLAG_SINGLE_RANGE)) && !in_range(handler->current.location, handler->current.sequence)) if(is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(handler->current.location, handler->current.sequence))
return FALSE; return FALSE;
if((is_flag(EFFECT_FLAG_SINGLE_RANGE)) && (handler->current.location & LOCATION_ONFIELD) 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))))) && (handler->is_position(POS_FACEDOWN) || (!handler->is_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))))
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) && owner->is_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(owner == handler && !(is_flag(EFFECT_FLAG_CANNOT_DISABLE)) && handler->get_status(STATUS_DISABLED)) if(owner == handler && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && handler->get_status(STATUS_DISABLED))
return FALSE; return FALSE;
} }
if (type & EFFECT_TYPE_EQUIP) { if (type & EFFECT_TYPE_EQUIP) {
if(handler->current.controler == PLAYER_NONE) if(handler->current.controler == PLAYER_NONE)
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) && owner->is_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(owner == handler && !(is_flag(EFFECT_FLAG_CANNOT_DISABLE)) && handler->get_status(STATUS_DISABLED)) if(owner == handler && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && handler->get_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(!(is_flag(EFFECT_FLAG_SET_AVAILABLE))) { if(!is_flag(EFFECT_FLAG_SET_AVAILABLE)) {
if(!(handler->get_status(STATUS_EFFECT_ENABLED))) if(!(handler->get_status(STATUS_EFFECT_ENABLED)))
return FALSE; return FALSE;
if(!handler->is_position(POS_FACEUP)) if(!handler->is_position(POS_FACEUP))
...@@ -91,16 +91,16 @@ int32 effect::is_available() { ...@@ -91,16 +91,16 @@ int32 effect::is_available() {
} }
} }
if (type & EFFECT_TYPE_FIELD) { if (type & EFFECT_TYPE_FIELD) {
if (!(is_flag(EFFECT_FLAG_FIELD_ONLY))) { if (!is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if(handler->current.controler == PLAYER_NONE) if(handler->current.controler == PLAYER_NONE)
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) && owner->is_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(owner == handler && !(is_flag(EFFECT_FLAG_CANNOT_DISABLE)) && handler->get_status(STATUS_DISABLED)) if(owner == handler && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && handler->get_status(STATUS_DISABLED))
return FALSE; return FALSE;
if(handler->is_status(STATUS_BATTLE_DESTROYED) && !(is_flag(EFFECT_FLAG_AVAILABLE_BD))) if(handler->is_status(STATUS_BATTLE_DESTROYED) && !is_flag(EFFECT_FLAG_AVAILABLE_BD))
return FALSE; return FALSE;
if(!handler->get_status(STATUS_EFFECT_ENABLED) && !(is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))) if(!handler->get_status(STATUS_EFFECT_ENABLED) && !is_flag(EFFECT_FLAG_IMMEDIATELY_APPLY))
return FALSE; return FALSE;
if(!in_range(handler->current.location, handler->current.sequence)) if(!in_range(handler->current.location, handler->current.sequence))
return FALSE; return FALSE;
...@@ -121,7 +121,7 @@ int32 effect::is_available() { ...@@ -121,7 +121,7 @@ int32 effect::is_available() {
return res; return res;
} }
int32 effect::check_count_limit(uint8 playerid) { int32 effect::check_count_limit(uint8 playerid) {
if((is_flag(EFFECT_FLAG_COUNT_LIMIT))) { if(is_flag(EFFECT_FLAG_COUNT_LIMIT)) {
if(count_code == 0) { if(count_code == 0) {
if((reset_count & 0xf00) == 0) if((reset_count & 0xf00) == 0)
return FALSE; return FALSE;
...@@ -147,16 +147,16 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -147,16 +147,16 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
return FALSE; return FALSE;
if(!check_count_limit(playerid)) if(!check_count_limit(playerid))
return FALSE; return FALSE;
if (!(is_flag(EFFECT_FLAG_FIELD_ONLY))) { if (!is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if (type & EFFECT_TYPE_ACTIVATE) { if (type & EFFECT_TYPE_ACTIVATE) {
if(handler->current.controler != playerid) if(handler->current.controler != playerid)
return FALSE; return FALSE;
if(pduel->game_field->check_unique_onfield(handler, playerid, LOCATION_SZONE)) if(pduel->game_field->check_unique_onfield(handler, playerid, LOCATION_SZONE))
return FALSE; return FALSE;
if(!(handler->data.type & TYPE_COUNTER)) { if(!(handler->data.type & TYPE_COUNTER)) {
if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !(is_flag(EFFECT_FLAG_DAMAGE_STEP))) if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !is_flag(EFFECT_FLAG_DAMAGE_STEP))
return FALSE; return FALSE;
if((code < 1134 || code > 1136) && pduel->game_field->infos.phase == PHASE_DAMAGE_CAL && !(is_flag(EFFECT_FLAG_DAMAGE_CAL))) if((code < 1134 || code > 1136) && pduel->game_field->infos.phase == PHASE_DAMAGE_CAL && !is_flag(EFFECT_FLAG_DAMAGE_CAL))
return FALSE; return FALSE;
} }
if(handler->current.location == LOCATION_HAND) { if(handler->current.location == LOCATION_HAND) {
...@@ -219,34 +219,34 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -219,34 +219,34 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
return FALSE; return FALSE;
if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F)) if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F))
&& !((type & EFFECT_TYPE_SINGLE) && (code == EVENT_TO_GRAVE || code == EVENT_DESTROYED || code == EVENT_SPSUMMON_SUCCESS || code == EVENT_TO_HAND))) { && !((type & EFFECT_TYPE_SINGLE) && (code == EVENT_TO_GRAVE || code == EVENT_DESTROYED || code == EVENT_SPSUMMON_SUCCESS || code == EVENT_TO_HAND))) {
if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !(is_flag(EFFECT_FLAG_DAMAGE_STEP))) if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !is_flag(EFFECT_FLAG_DAMAGE_STEP))
return FALSE; return FALSE;
if((code < 1134 || code > 1136) && pduel->game_field->infos.phase == PHASE_DAMAGE_CAL && !(is_flag(EFFECT_FLAG_DAMAGE_CAL))) if((code < 1134 || code > 1136) && pduel->game_field->infos.phase == PHASE_DAMAGE_CAL && !is_flag(EFFECT_FLAG_DAMAGE_CAL))
return FALSE; return FALSE;
} }
if(handler->current.location == LOCATION_OVERLAY) if(handler->current.location == LOCATION_OVERLAY)
return FALSE; return FALSE;
if((type & EFFECT_TYPE_FIELD) && (handler->current.controler != playerid) && !(is_flag(EFFECT_FLAG_BOTH_SIDE))) if((type & EFFECT_TYPE_FIELD) && (handler->current.controler != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE))
return FALSE; return FALSE;
if(handler->is_affected_by_effect(EFFECT_FORBIDDEN)) if(handler->is_affected_by_effect(EFFECT_FORBIDDEN))
return FALSE; return FALSE;
if(handler->is_affected_by_effect(EFFECT_CANNOT_TRIGGER)) if(handler->is_affected_by_effect(EFFECT_CANNOT_TRIGGER))
return FALSE; return FALSE;
} else { } else {
if(!(is_flag(EFFECT_FLAG_AVAILABLE_BD)) && (type & EFFECT_TYPE_FIELD) && handler->is_status(STATUS_BATTLE_DESTROYED)) if(!is_flag(EFFECT_FLAG_AVAILABLE_BD) && (type & EFFECT_TYPE_FIELD) && handler->is_status(STATUS_BATTLE_DESTROYED))
return FALSE; return FALSE;
if(((type & EFFECT_TYPE_FIELD) || ((type & EFFECT_TYPE_SINGLE) && (is_flag(EFFECT_FLAG_SINGLE_RANGE)))) && (handler->current.location & LOCATION_ONFIELD) if(((type & EFFECT_TYPE_FIELD) || ((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE))) && (handler->current.location & LOCATION_ONFIELD)
&& (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED))) && (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE; return FALSE;
if((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(handler->current.location, handler->current.sequence)) if((type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && !in_range(handler->current.location, handler->current.sequence))
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) && owner->is_status(STATUS_DISABLED))
return FALSE; return FALSE;
if((handler == owner) && !(is_flag(EFFECT_FLAG_CANNOT_DISABLE)) && handler->is_status(STATUS_DISABLED)) if((handler == owner) && !is_flag(EFFECT_FLAG_CANNOT_DISABLE) && handler->is_status(STATUS_DISABLED))
return FALSE; return FALSE;
} }
} else { } else {
if((get_owner_player() != playerid) && !(is_flag(EFFECT_FLAG_BOTH_SIDE))) if((get_owner_player() != playerid) && !is_flag(EFFECT_FLAG_BOTH_SIDE))
return FALSE; return FALSE;
} }
pduel->game_field->save_lp_cost(); pduel->game_field->save_lp_cost();
...@@ -383,10 +383,10 @@ int32 effect::is_target(card* pcard) { ...@@ -383,10 +383,10 @@ int32 effect::is_target(card* pcard) {
return FALSE; return FALSE;
if((type & EFFECT_TYPE_SINGLE) || (type & EFFECT_TYPE_EQUIP)) if((type & EFFECT_TYPE_SINGLE) || (type & EFFECT_TYPE_EQUIP))
return TRUE; return TRUE;
if(pcard && !(is_flag(EFFECT_FLAG_SET_AVAILABLE)) && (pcard->current.location & LOCATION_ONFIELD) if(pcard && !is_flag(EFFECT_FLAG_SET_AVAILABLE) && (pcard->current.location & LOCATION_ONFIELD)
&& !pcard->is_position(POS_FACEUP)) && !pcard->is_position(POS_FACEUP))
return FALSE; return FALSE;
if(!(is_flag(EFFECT_FLAG_IGNORE_RANGE))) { if(!is_flag(EFFECT_FLAG_IGNORE_RANGE)) {
if(pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED)) if(pcard->get_status(STATUS_SUMMONING | STATUS_SUMMON_DISABLED | STATUS_ACTIVATE_DISABLED))
return FALSE; return FALSE;
if(is_flag(EFFECT_FLAG_ABSOLUTE_TARGET)) { if(is_flag(EFFECT_FLAG_ABSOLUTE_TARGET)) {
...@@ -417,7 +417,7 @@ int32 effect::is_target(card* pcard) { ...@@ -417,7 +417,7 @@ int32 effect::is_target(card* pcard) {
return TRUE; return TRUE;
} }
int32 effect::is_target_player(uint8 playerid) { int32 effect::is_target_player(uint8 playerid) {
if(!(is_flag(EFFECT_FLAG_PLAYER_TARGET))) if(!is_flag(EFFECT_FLAG_PLAYER_TARGET))
return FALSE; return FALSE;
uint8 self = get_handler_player(); uint8 self = get_handler_player();
if(is_flag(EFFECT_FLAG_ABSOLUTE_TARGET)) { if(is_flag(EFFECT_FLAG_ABSOLUTE_TARGET)) {
...@@ -463,7 +463,7 @@ int32 effect::is_chainable(uint8 tp) { ...@@ -463,7 +463,7 @@ int32 effect::is_chainable(uint8 tp) {
if((type & EFFECT_TYPE_ACTIVATE) && (sp <= 1) && !is_flag(EFFECT_FLAG2_COF)) if((type & EFFECT_TYPE_ACTIVATE) && (sp <= 1) && !is_flag(EFFECT_FLAG2_COF))
return FALSE; return FALSE;
if(pduel->game_field->core.current_chain.size()) { if(pduel->game_field->core.current_chain.size()) {
if(!(is_flag(EFFECT_FLAG_FIELD_ONLY)) && (type & EFFECT_TYPE_TRIGGER_O) if(!is_flag(EFFECT_FLAG_FIELD_ONLY) && (type & EFFECT_TYPE_TRIGGER_O)
&& (handler->current.location == LOCATION_HAND)) { && (handler->current.location == LOCATION_HAND)) {
if(pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed() > 2) if(pduel->game_field->core.current_chain.rbegin()->triggering_effect->get_speed() > 2)
return FALSE; return FALSE;
...@@ -520,7 +520,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) { ...@@ -520,7 +520,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);
break; break;
} }
case RESET_COPY: { case RESET_COPY: {
...@@ -531,7 +531,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) { ...@@ -531,7 +531,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
return FALSE; return FALSE;
} }
void effect::dec_count(uint32 playerid) { void effect::dec_count(uint32 playerid) {
if(!(is_flag(EFFECT_FLAG_COUNT_LIMIT))) if(!is_flag(EFFECT_FLAG_COUNT_LIMIT))
return; return;
if(count_code == 0) { if(count_code == 0) {
if((reset_count & 0xf00) == 0) if((reset_count & 0xf00) == 0)
...@@ -546,7 +546,7 @@ void effect::dec_count(uint32 playerid) { ...@@ -546,7 +546,7 @@ void effect::dec_count(uint32 playerid) {
} }
} }
void effect::recharge() { void effect::recharge() {
if((is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (count_code == 0)) { if(is_flag(EFFECT_FLAG_COUNT_LIMIT) && (count_code == 0)) {
reset_count &= 0xf0ff; reset_count &= 0xf0ff;
reset_count |= (reset_count >> 4) & 0xf00; reset_count |= (reset_count >> 4) & 0xf00;
} }
......
...@@ -749,7 +749,7 @@ void field::add_effect(effect* peffect, uint8 owner_player) { ...@@ -749,7 +749,7 @@ void field::add_effect(effect* peffect, uint8 owner_player) {
it = effects.continuous_effect.insert(std::make_pair(peffect->code, peffect)); it = effects.continuous_effect.insert(std::make_pair(peffect->code, peffect));
} }
effects.indexer.insert(std::make_pair(peffect, it)); effects.indexer.insert(std::make_pair(peffect, it));
if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))) { if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if(peffect->is_flag(EFFECT_FLAG_OATH)) if(peffect->is_flag(EFFECT_FLAG_OATH))
effects.oath.insert(std::make_pair(peffect, core.reason_effect)); effects.oath.insert(std::make_pair(peffect, core.reason_effect));
if(peffect->reset_flag & RESET_PHASE) if(peffect->reset_flag & RESET_PHASE)
...@@ -786,7 +786,7 @@ void field::remove_effect(effect* peffect) { ...@@ -786,7 +786,7 @@ void field::remove_effect(effect* peffect) {
effects.continuous_effect.erase(it); effects.continuous_effect.erase(it);
} }
effects.indexer.erase(peffect); effects.indexer.erase(peffect);
if((peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))) { if(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)) {
if(peffect->is_flag(EFFECT_FLAG_OATH)) if(peffect->is_flag(EFFECT_FLAG_OATH))
effects.oath.erase(peffect); effects.oath.erase(peffect);
if(peffect->reset_flag & RESET_PHASE) if(peffect->reset_flag & RESET_PHASE)
...@@ -817,7 +817,7 @@ void field::reset_effect(uint32 id, uint32 reset_type) { ...@@ -817,7 +817,7 @@ void field::reset_effect(uint32 id, uint32 reset_type) {
auto rm = it++; auto rm = it++;
auto peffect = rm->first; auto peffect = rm->first;
auto pit = rm->second; auto pit = rm->second;
if (!(peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))) if (!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY))
continue; continue;
result = peffect->reset(id, reset_type); result = peffect->reset(id, reset_type);
if (result) { if (result) {
...@@ -898,7 +898,7 @@ void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) { ...@@ -898,7 +898,7 @@ void field::filter_field_effect(uint32 code, effect_set* eset, uint8 sort) {
eset->sort(); eset->sort();
} }
void field::filter_affected_cards(effect* peffect, card_set* cset) { void field::filter_affected_cards(effect* peffect, card_set* cset) {
if ((peffect->type & EFFECT_TYPE_ACTIONS) || !(peffect->type & EFFECT_TYPE_FIELD) || (peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET))) if ((peffect->type & EFFECT_TYPE_ACTIONS) || !(peffect->type & EFFECT_TYPE_FIELD) || peffect->is_flag(EFFECT_FLAG_PLAYER_TARGET))
return; return;
uint8 self = peffect->get_handler_player(); uint8 self = peffect->get_handler_player();
if(self == PLAYER_NONE) if(self == PLAYER_NONE)
...@@ -1261,7 +1261,7 @@ int32 field::get_summon_release_list(card* target, card_set* release_list, card_ ...@@ -1261,7 +1261,7 @@ int32 field::get_summon_release_list(card* target, card_set* release_list, card_
rcount += pcard->operation_param; rcount += pcard->operation_param;
} else { } else {
effect* peffect = pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE_SUM); effect* peffect = pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE_SUM);
if(!peffect || ((peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (peffect->reset_count & 0xf00) == 0)) if(!peffect || (peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT) && (peffect->reset_count & 0xf00) == 0))
continue; continue;
if(ex_list_sum) if(ex_list_sum)
ex_list_sum->insert(pcard); ex_list_sum->insert(pcard);
...@@ -2342,7 +2342,7 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) { ...@@ -2342,7 +2342,7 @@ int32 field::check_chain_target(uint8 chaincount, card * pcard) {
pchain = &core.current_chain[chaincount - 1]; pchain = &core.current_chain[chaincount - 1];
effect* peffect = pchain->triggering_effect; effect* peffect = pchain->triggering_effect;
uint8 tp = pchain->triggering_player; uint8 tp = pchain->triggering_player;
if(!(peffect->is_flag(EFFECT_FLAG_CARD_TARGET)) || !peffect->target) if(!peffect->is_flag(EFFECT_FLAG_CARD_TARGET) || !peffect->target)
return FALSE; return FALSE;
if(!pcard->is_capable_be_effect_target(peffect, tp)) if(!pcard->is_capable_be_effect_target(peffect, tp))
return false; return false;
......
...@@ -610,7 +610,7 @@ void interpreter::unregister_effect(effect *peffect) { ...@@ -610,7 +610,7 @@ void interpreter::unregister_effect(effect *peffect) {
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->target); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->target);
if(peffect->operation) if(peffect->operation)
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->operation); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->operation);
if(peffect->value && (peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))) if(peffect->value && peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->value); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->value);
luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->ref_handle); luaL_unref(lua_state, LUA_REGISTRYINDEX, peffect->ref_handle);
peffect->ref_handle = 0; peffect->ref_handle = 0;
......
...@@ -3270,7 +3270,7 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) { ...@@ -3270,7 +3270,7 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) {
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
switch (eset[i]->code) { switch (eset[i]->code) {
case EFFECT_UPDATE_ATTACK: { case EFFECT_UPDATE_ATTACK: {
if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))) if (eset[i]->type & EFFECT_TYPE_SINGLE && !eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))
up += eset[i]->get_value(pcard); up += eset[i]->get_value(pcard);
else else
upc += eset[i]->get_value(pcard); upc += eset[i]->get_value(pcard);
...@@ -3280,11 +3280,11 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) { ...@@ -3280,11 +3280,11 @@ int32 scriptlib::duel_venom_swamp_check(lua_State *L) {
} }
case EFFECT_SET_ATTACK: case EFFECT_SET_ATTACK:
base = eset[i]->get_value(pcard); base = eset[i]->get_value(pcard);
if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))) if (eset[i]->type & EFFECT_TYPE_SINGLE && !eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))
up = 0; up = 0;
break; break;
case EFFECT_SET_ATTACK_FINAL: case EFFECT_SET_ATTACK_FINAL:
if (eset[i]->type & EFFECT_TYPE_SINGLE && !(eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))) { if (eset[i]->type & EFFECT_TYPE_SINGLE && !eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE)) {
base = eset[i]->get_value(pcard); base = eset[i]->get_value(pcard);
up = 0; up = 0;
upc = 0; upc = 0;
...@@ -3329,7 +3329,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) { ...@@ -3329,7 +3329,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) {
} }
effect* peffect = eit->second; effect* peffect = eit->second;
if(!(peffect->type & 0x7c)) continue; if(!(peffect->type & 0x7c)) continue;
if(!(peffect->is_flag(EFFECT_FLAG_INITIAL))) continue; if(!peffect->is_flag(EFFECT_FLAG_INITIAL)) continue;
effect* ceffect = pduel->new_effect(); effect* ceffect = pduel->new_effect();
int32 ref = ceffect->ref_handle; int32 ref = ceffect->ref_handle;
*ceffect = *peffect; *ceffect = *peffect;
......
...@@ -56,7 +56,7 @@ int32 scriptlib::effect_clone(lua_State *L) { ...@@ -56,7 +56,7 @@ int32 scriptlib::effect_clone(lua_State *L) {
lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->operation); lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->operation);
ceffect->operation = luaL_ref(L, LUA_REGISTRYINDEX); ceffect->operation = luaL_ref(L, LUA_REGISTRYINDEX);
} }
if(peffect->value && (peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))) { if(peffect->value && peffect->is_flag(EFFECT_FLAG_FUNC_VALUE)) {
lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->value); lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->value);
ceffect->value = luaL_ref(L, LUA_REGISTRYINDEX); ceffect->value = luaL_ref(L, LUA_REGISTRYINDEX);
} }
...@@ -270,7 +270,7 @@ int32 scriptlib::effect_set_value(lua_State *L) { ...@@ -270,7 +270,7 @@ int32 scriptlib::effect_set_value(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
if(peffect->value && (peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))) if(peffect->value && peffect->is_flag(EFFECT_FLAG_FUNC_VALUE))
luaL_unref(L, LUA_REGISTRYINDEX, peffect->value); luaL_unref(L, LUA_REGISTRYINDEX, peffect->value);
if (lua_isfunction(L, 2)) { if (lua_isfunction(L, 2)) {
peffect->value = interpreter::get_function_handle(L, 2); peffect->value = interpreter::get_function_handle(L, 2);
......
...@@ -1172,7 +1172,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1172,7 +1172,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
} else { } else {
if(!ignore_count && !core.extra_summon[sumplayer] && core.summon_count[sumplayer] >= get_summon_count_limit(sumplayer)) { if(!ignore_count && !core.extra_summon[sumplayer] && core.summon_count[sumplayer] >= get_summon_count_limit(sumplayer)) {
effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT); effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT);
if(pextra && !(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE))) { if(pextra && !pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) {
int32 count = pextra->get_value(); int32 count = pextra->get_value();
if(min_tribute < count) { if(min_tribute < count) {
min_tribute = count; min_tribute = count;
...@@ -1324,7 +1324,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1324,7 +1324,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
int32 minul = 0; int32 minul = 0;
effect* pdec = 0; effect* pdec = 0;
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
if(!(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT))) { if(!eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) {
int32 dec = eset[i]->get_value(target); int32 dec = eset[i]->get_value(target);
if(minul < (dec & 0xffff)) { if(minul < (dec & 0xffff)) {
minul = dec & 0xffff; minul = dec & 0xffff;
...@@ -1340,7 +1340,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1340,7 +1340,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
pduel->write_buffer32(pdec->handler->data.code); pduel->write_buffer32(pdec->handler->data.code);
} }
for(int32 i = 0; i < eset.size() && min > 0; ++i) { for(int32 i = 0; i < eset.size() && min > 0; ++i) {
if((eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (eset[i]->reset_count & 0xf00) > 0 && eset[i]->target) { if(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT) && (eset[i]->reset_count & 0xf00) > 0 && eset[i]->target) {
int32 dec = eset[i]->get_value(target); int32 dec = eset[i]->get_value(target);
min -= dec & 0xffff; min -= dec & 0xffff;
eset[i]->dec_count(); eset[i]->dec_count();
...@@ -1351,7 +1351,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1351,7 +1351,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
} }
} }
for(int32 i = 0; i < eset.size() && min > 0; ++i) { for(int32 i = 0; i < eset.size() && min > 0; ++i) {
if((eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) && (eset[i]->reset_count & 0xf00) > 0 && !eset[i]->target) { if(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT) && (eset[i]->reset_count & 0xf00) > 0 && !eset[i]->target) {
int32 dec = eset[i]->get_value(target); int32 dec = eset[i]->get_value(target);
min -= dec & 0xffff; min -= dec & 0xffff;
eset[i]->dec_count(); eset[i]->dec_count();
...@@ -1407,9 +1407,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1407,9 +1407,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
effect* pextra = (effect*)core.temp_var[0]; effect* pextra = (effect*)core.temp_var[0];
if(pextra) { if(pextra) {
if((pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer))) if(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91);
else if(!(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && ((int32)target->material_cards.size() < pextra->get_value())) else if(!pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && ((int32)target->material_cards.size() < pextra->get_value()))
core.temp_var[0] = 0; core.temp_var[0] = 0;
else else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
...@@ -1434,7 +1434,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1434,7 +1434,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
uint8 positions = POS_FACEUP_ATTACK; uint8 positions = POS_FACEUP_ATTACK;
if(is_player_affected_by_effect(sumplayer, EFFECT_DEVINE_LIGHT)) if(is_player_affected_by_effect(sumplayer, EFFECT_DEVINE_LIGHT))
positions = POS_FACEUP; positions = POS_FACEUP;
if(proc && (proc->is_flag(EFFECT_FLAG_SPSUM_PARAM))) { if(proc && proc->is_flag(EFFECT_FLAG_SPSUM_PARAM)) {
positions = (uint8)proc->s_range; positions = (uint8)proc->s_range;
if(proc->o_range) if(proc->o_range)
targetplayer = 1 - sumplayer; targetplayer = 1 - sumplayer;
...@@ -1466,7 +1466,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc, ...@@ -1466,7 +1466,7 @@ int32 field::summon(uint16 step, uint8 sumplayer, card * target, effect * proc,
effect* pextra = core.extra_summon[sumplayer] ? 0 : target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT); effect* pextra = core.extra_summon[sumplayer] ? 0 : target->is_affected_by_effect(EFFECT_EXTRA_SUMMON_COUNT);
if(pextra) { if(pextra) {
core.temp_var[0] = (ptr)pextra; core.temp_var[0] = (ptr)pextra;
if((pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer))) if(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, sumplayer, 91);
else else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
...@@ -1685,7 +1685,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui ...@@ -1685,7 +1685,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
return TRUE; return TRUE;
if(!ignore_count && !core.extra_summon[setplayer] && core.summon_count[setplayer] >= get_summon_count_limit(setplayer)) { if(!ignore_count && !core.extra_summon[setplayer] && core.summon_count[setplayer] >= get_summon_count_limit(setplayer)) {
effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SET_COUNT); effect* pextra = target->is_affected_by_effect(EFFECT_EXTRA_SET_COUNT);
if(pextra && !(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE))) { if(pextra && !pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) {
int32 count = pextra->get_value(); int32 count = pextra->get_value();
if(min_tribute < count) { if(min_tribute < count) {
min_tribute = count; min_tribute = count;
...@@ -1849,9 +1849,9 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui ...@@ -1849,9 +1849,9 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
returns.ivalue[0] = FALSE; returns.ivalue[0] = FALSE;
effect* pextra = (effect*)core.temp_var[0]; effect* pextra = (effect*)core.temp_var[0];
if(pextra) { if(pextra) {
if((pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && (core.summon_count[setplayer] < get_summon_count_limit(setplayer))) if(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && (core.summon_count[setplayer] < get_summon_count_limit(setplayer)))
add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 91); add_process(PROCESSOR_SELECT_YESNO, 0, 0, 0, setplayer, 91);
else if(!(pextra->is_flag(EFFECT_FLAG_FUNC_VALUE)) && ((int32)target->material_cards.size() < pextra->get_value())) else if(!pextra->is_flag(EFFECT_FLAG_FUNC_VALUE) && ((int32)target->material_cards.size() < pextra->get_value()))
core.temp_var[0] = 0; core.temp_var[0] = 0;
else else
returns.ivalue[0] = TRUE; returns.ivalue[0] = TRUE;
...@@ -1874,7 +1874,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui ...@@ -1874,7 +1874,7 @@ int32 field::mset(uint16 step, uint8 setplayer, card * target, effect * proc, ui
} }
uint8 targetplayer = setplayer; uint8 targetplayer = setplayer;
uint8 positions = POS_FACEDOWN_DEFENCE; uint8 positions = POS_FACEDOWN_DEFENCE;
if(proc && (proc->is_flag(EFFECT_FLAG_SPSUM_PARAM))) { if(proc && proc->is_flag(EFFECT_FLAG_SPSUM_PARAM)) {
positions = (uint8)proc->s_range; positions = (uint8)proc->s_range;
if(proc->o_range) if(proc->o_range)
targetplayer = 1 - setplayer; targetplayer = 1 - setplayer;
...@@ -2631,7 +2631,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2631,7 +2631,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
if (eset.size()) { if (eset.size()) {
bool is_destructable = true; bool is_destructable = true;
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
if(!(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) || (eset[i]->reset_count & 0xf00) == 0) if(!eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT) || (eset[i]->reset_count & 0xf00) == 0)
continue; continue;
pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT); pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT);
...@@ -2798,7 +2798,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3 ...@@ -2798,7 +2798,7 @@ int32 field::destroy(uint16 step, group * targets, effect * reason_effect, uint3
if (eset.size()) { if (eset.size()) {
bool indes = false; bool indes = false;
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
if(!(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) || (eset[i]->reset_count & 0xf00) == 0) if(!eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT) || (eset[i]->reset_count & 0xf00) == 0)
continue; continue;
pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT); pduel->lua->add_param(pcard->current.reason_effect, PARAM_TYPE_EFFECT);
pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT); pduel->lua->add_param(pcard->current.reason, PARAM_TYPE_INT);
......
This diff is collapsed.
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