Commit 3a7260be authored by salix5's avatar salix5

EFFECT_FORBIDDEN & field::is_player_can_spsummon

EFFECT_FORBIDDEN, EFFECT_CANNOT_SPECIAL_SUMMON, and other sp_summon limit
effects checking are in field::is_player_can_spsummon.
parent 11a3201c
......@@ -1576,7 +1576,8 @@ void card::filter_spsummon_procedure(uint8 playerid, effect_set* peset, uint32 s
topos = POS_FACEUP;
toplayer = playerid;
}
if(peffect->is_available() && peffect->check_count_limit(playerid) && is_summonable(peffect)) {
if(peffect->is_available() && peffect->check_count_limit(playerid) && is_summonable(peffect)
&& !pduel->game_field->check_unique_onfield(this, toplayer)) {
uint32 sumtype = peffect->get_value(this);
if((!summon_type || summon_type == sumtype)
&& pduel->game_field->is_player_can_spsummon(peffect, sumtype, topos, playerid, toplayer, this))
......@@ -1893,12 +1894,6 @@ int32 card::is_can_be_flip_summoned(uint8 playerid) {
int32 card::is_special_summonable(uint8 playerid, uint32 summon_type) {
if(!(data.type & TYPE_MONSTER))
return FALSE;
if(pduel->game_field->check_unique_onfield(this, playerid))
return FALSE;
if(!pduel->game_field->check_spsummon_once(this, playerid))
return FALSE;
if(!pduel->game_field->check_spsummon_counter(playerid))
return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON))
return FALSE;
if(is_affected_by_effect(EFFECT_FORBIDDEN))
......@@ -1934,15 +1929,13 @@ int32 card::is_can_be_special_summoned(effect * reason_effect, uint32 sumtype, u
}
if(((sumpos & POS_FACEDOWN) == 0) && pduel->game_field->check_unique_onfield(this, toplayer))
return FALSE;
if(!pduel->game_field->check_spsummon_once(this, sumplayer))
return FALSE;
if(!pduel->game_field->check_spsummon_counter(sumplayer))
return FALSE;
sumtype |= SUMMON_TYPE_SPECIAL;
if((sumplayer == 0 || sumplayer == 1) && !pduel->game_field->is_player_can_spsummon(reason_effect, sumtype, sumpos, sumplayer, toplayer, this))
return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON))
return FALSE;
if(is_affected_by_effect(EFFECT_FORBIDDEN))
return FALSE;
pduel->game_field->save_lp_cost();
effect_set eset;
filter_effect(EFFECT_SPSUMMON_COST, &eset);
......
......@@ -1905,6 +1905,10 @@ int32 field::is_player_can_spsummon(uint8 playerid) {
}
int32 field::is_player_can_spsummon(effect * peffect, uint32 sumtype, uint8 sumpos, uint8 playerid, uint8 toplayer, card * pcard) {
effect_set eset;
if(pcard->is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON))
return FALSE;
if(pcard->is_affected_by_effect(EFFECT_FORBIDDEN))
return FALSE;
sumtype |= SUMMON_TYPE_SPECIAL;
if(sumpos & POS_FACEDOWN && is_player_affected_by_effect(playerid, EFFECT_DEVINE_LIGHT))
sumpos = (sumpos & POS_FACEUP) | (sumpos >> 1);
......@@ -1944,9 +1948,7 @@ int32 field::is_player_can_flipsummon(uint8 playerid, card * pcard) {
}
int32 field::is_player_can_spsummon_monster(uint8 playerid, uint8 toplayer, uint8 sumpos, card_data * pdata) {
temp_card->data = *pdata;
if(!is_player_can_spsummon(core.reason_effect, SUMMON_TYPE_SPECIAL, sumpos, playerid, toplayer, temp_card))
return FALSE;
return temp_card->is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON) ? FALSE : TRUE;
return is_player_can_spsummon(core.reason_effect, SUMMON_TYPE_SPECIAL, sumpos, playerid, toplayer, temp_card);
}
int32 field::is_player_can_release(uint8 playerid, card * pcard) {
effect_set eset;
......
......@@ -1942,18 +1942,26 @@ int32 field::special_summon_rule(uint16 step, uint8 sumplayer, card * target, ui
case 0: {
if(!(target->data.type & TYPE_MONSTER))
return FALSE;
if(check_unique_onfield(target, sumplayer))
return TRUE;
if(target->is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON))
if(target->current.location & (LOCATION_GRAVE + LOCATION_REMOVED) && !target->is_status(STATUS_REVIVE_LIMIT))
return FALSE;
if(target->current.location & (LOCATION_GRAVE + LOCATION_REMOVED) && !target->is_status(STATUS_REVIVE_LIMIT) && target->is_affected_by_effect(EFFECT_REVIVE_LIMIT))
return FALSE;
effect_set eset;
target->filter_effect(EFFECT_SPSUMMON_COST, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->operation) {
effect_set eset1;
target->material_cards.clear();
card* tuner = core.limit_tuner;
group* materials = core.limit_xyz;
group* syn = core.limit_syn;
target->filter_spsummon_procedure(sumplayer, &eset1, summon_type);
target->filter_spsummon_procedure_g(sumplayer, &eset1);
core.limit_tuner = tuner;
core.limit_xyz = materials;
core.limit_syn = syn;
if(!eset1.size())
return TRUE;
effect_set eset2;
target->filter_effect(EFFECT_SPSUMMON_COST, &eset2);
for(int32 i = 0; i < eset2.size(); ++i) {
if(eset2[i]->operation) {
core.sub_solving_event.push_back(nil_event);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, sumplayer, 0);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset2[i], 0, sumplayer, 0);
}
}
return FALSE;
......@@ -2305,7 +2313,6 @@ int32 field::special_summon_step(uint16 step, group * targets, card * target) {
if(!result || (target->current.location == LOCATION_MZONE)
|| check_unique_onfield(target, playerid)
|| !is_player_can_spsummon(core.reason_effect, target->summon_info & 0xff00ffff, positions, target->summon_player, playerid, target)
|| target->is_affected_by_effect(EFFECT_CANNOT_SPECIAL_SUMMON)
|| get_useable_count(playerid, LOCATION_MZONE, target->summon_player, LOCATION_REASON_TOFIELD) <= 0
|| (!nocheck && !(target->data.type & TYPE_MONSTER)))
result = FALSE;
......
......@@ -54,15 +54,12 @@ function c25343017.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end
Duel.DiscardHand(tp,Card.IsAbleToGraveAsCost,1,1,REASON_COST)
end
function c25343017.cfilter(c,e,tp)
return c:IsRace(RACE_PSYCHO) and c:IsAbleToRemove() and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c25343017.filter(c)
return c:IsRace(RACE_PSYCHO) and c:IsAbleToRemove()
end
function c25343017.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and c25343017.filter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c25343017.cfilter,tp,LOCATION_GRAVE,0,1,nil,e,PLAYER_NONE) end
if chk==0 then return Duel.IsExistingTarget(c25343017.filter,tp,LOCATION_GRAVE,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectTarget(tp,c25343017.filter,tp,LOCATION_GRAVE,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0)
......
......@@ -26,14 +26,13 @@ end
function c77565204.filter1(c,e)
return c:IsCanBeFusionMaterial() and not c:IsImmuneToEffect(e)
end
function c77565204.filter2(c,e,tp,m)
return c:IsType(TYPE_FUSION) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_FUSION,PLAYER_NONE,false,false)
and c:CheckFusionMaterial(m)
function c77565204.filter2(c,m)
return c:IsType(TYPE_FUSION) and c:CheckFusionMaterial(m)
end
function c77565204.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
local mg=Duel.GetMatchingGroup(c77565204.filter1,tp,LOCATION_DECK,0,nil,e)
return Duel.IsExistingMatchingCard(c77565204.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,mg)
return Duel.IsExistingMatchingCard(c77565204.filter2,tp,LOCATION_EXTRA,0,1,nil,mg)
end
e:GetHandler():SetTurnCounter(0)
end
......@@ -41,7 +40,7 @@ function c77565204.activate(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
local mg=Duel.GetMatchingGroup(c77565204.filter1,tp,LOCATION_DECK,0,nil,e)
local sg=Duel.GetMatchingGroup(c77565204.filter2,tp,LOCATION_EXTRA,0,nil,e,tp,mg)
local sg=Duel.GetMatchingGroup(c77565204.filter2,tp,LOCATION_EXTRA,0,nil,mg)
if sg:GetCount()>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local tg=sg:Select(tp,1,1,nil)
......
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