name: Combination
card_text: During a Battle Phase, you can use this effect on 1 monster that has attacked this turn and is equipped with a Union Monster. Change the Union Monster back to a monster in face-up Attack or Defense Position. Also, the monster that was equipped with the Union Monster may attack again this turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  s.has_text_type = TYPE_UNION
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return (Duel.GetCurrentPhase() >= PHASE_BATTLE_START and Duel.GetCurrentPhase() <= PHASE_BATTLE)
  end
  function s.filter(c, e, tp)
  	return c:GetAttackAnnouncedCount() > 0 and Duel.IsExistingMatchingCard(s.eqfilter, tp, LOCATION_SZONE, 0, 1, nil, e, tp, c)
  end
  function s.eqfilter(c, e, tp, ec)
  	local op = c:GetOwner()
  	return c:IsHasEffect(EFFECT_UNION_STATUS) and c:GetEquipTarget() == ec and Duel.GetLocationCount(op, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, op)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_SZONE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local op = tc:GetOwner()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.GetLocationCount(op, LOCATION_MZONE) > 0 then
  		local g = Duel.GetMatchingGroup(s.eqfilter, tp, LOCATION_SZONE, 0, nil, e, tp, tc)
  		if Duel.SpecialSummon(g, 0, tp, op, false, false, POS_FACEUP) > 0 then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EXTRA_ATTACK)
  			e1:SetValue(tc:GetAttackAnnouncedCount())
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  
source_text: Combination
  During a Battle Phase, you can use this effect on 1 monster that has attacked this turn and is equipped with a Union Monster. Change the Union Monster back to a monster in face-up Attack or Defense Position. Also, the monster that was equipped with the Union Monster may attack again this turn.
target_text: -- Combination
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  s.has_text_type = TYPE_UNION
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return (Duel.GetCurrentPhase() >= PHASE_BATTLE_START and Duel.GetCurrentPhase() <= PHASE_BATTLE)
  end
  function s.filter(c, e, tp)
  	return c:GetAttackAnnouncedCount() > 0 and Duel.IsExistingMatchingCard(s.eqfilter, tp, LOCATION_SZONE, 0, 1, nil, e, tp, c)
  end
  function s.eqfilter(c, e, tp, ec)
  	local op = c:GetOwner()
  	return c:IsHasEffect(EFFECT_UNION_STATUS) and c:GetEquipTarget() == ec and Duel.GetLocationCount(op, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, op)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_SZONE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	local op = tc:GetOwner()
  	if tc:IsFaceup() and tc:IsRelateToEffect(e) and Duel.GetLocationCount(op, LOCATION_MZONE) > 0 then
  		local g = Duel.GetMatchingGroup(s.eqfilter, tp, LOCATION_SZONE, 0, nil, e, tp, tc)
  		if Duel.SpecialSummon(g, 0, tp, op, false, false, POS_FACEUP) > 0 then
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_EXTRA_ATTACK)
  			e1:SetValue(tc:GetAttackAnnouncedCount())
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  			tc:RegisterEffect(e1)
  		end
  	end
  end
  
  