name: Double
card_text: Discard 1 Monster Card from your hand to the Graveyard. Select 1 monster on your side of the field with a lower Level than the discarded monster. The selected monster can attack twice 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:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetLabel(0)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsAbleToEnterBP()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.filter1(c, tp)
  	local lv = c:GetOriginalLevel()
  	return lv > 1 and c:IsType(TYPE_MONSTER) and c:IsDiscardable() and c:IsAbleToGraveAsCost() and Duel.IsExistingTarget(s.filter2, tp, LOCATION_MZONE, 0, 1, nil, lv)
  end
  function s.filter2(c, lv)
  	return c:IsFaceup() and c:IsLevelBelow(lv - 1) and not c:IsHasEffect(EFFECT_EXTRA_ATTACK)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter2(chkc, e:GetLabel())
  	end
  	if chk == 0 then
  		if e:GetLabel() ~= 1 then
  			return false
  		end
  		e:SetLabel(0)
  		return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_HAND, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local cg = Duel.SelectMatchingCard(tp, s.filter1, tp, LOCATION_HAND, 0, 1, 1, nil, tp)
  	Duel.SendtoGrave(cg, REASON_DISCARD + REASON_COST)
  	local lv = cg:GetFirst():GetLevel()
  	e:SetLabel(lv)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, nil, lv)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EXTRA_ATTACK)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  
  
source_text: Double
  Discard 1 Monster Card from your hand to the Graveyard. Select 1 monster on your side of the field with a lower Level than the discarded monster. The selected monster can attack twice this turn.
target_text: -- Double
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetLabel(0)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsAbleToEnterBP()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(1)
  	return true
  end
  function s.filter1(c, tp)
  	local lv = c:GetOriginalLevel()
  	return lv > 1 and c:IsType(TYPE_MONSTER) and c:IsDiscardable() and c:IsAbleToGraveAsCost() and Duel.IsExistingTarget(s.filter2, tp, LOCATION_MZONE, 0, 1, nil, lv)
  end
  function s.filter2(c, lv)
  	return c:IsFaceup() and c:IsLevelBelow(lv - 1) and not c:IsHasEffect(EFFECT_EXTRA_ATTACK)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter2(chkc, e:GetLabel())
  	end
  	if chk == 0 then
  		if e:GetLabel() ~= 1 then
  			return false
  		end
  		e:SetLabel(0)
  		return Duel.IsExistingMatchingCard(s.filter1, tp, LOCATION_HAND, 0, 1, nil, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local cg = Duel.SelectMatchingCard(tp, s.filter1, tp, LOCATION_HAND, 0, 1, 1, nil, tp)
  	Duel.SendtoGrave(cg, REASON_DISCARD + REASON_COST)
  	local lv = cg:GetFirst():GetLevel()
  	e:SetLabel(lv)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_FACEUP)
  	Duel.SelectTarget(tp, s.filter2, tp, LOCATION_MZONE, 0, 1, 1, nil, lv)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EXTRA_ATTACK)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		tc:RegisterEffect(e1)
  	end
  end
  
  