name: Djinn
card_text: When you Ritual Summon a monster, you can banish this card from your Graveyard as 1 of the monsters required for the Ritual Summon. If the monster Ritual Summoned using this card destroys a monster by battle, the controller of the Ritual Monster draws 1 card.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--ritual material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EXTRA_RITUAL_MATERIAL)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--become material
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_EVENT_PLAYER)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetCondition(s.condition)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_RITUAL and not e:GetHandler():IsPreviousLocation(LOCATION_OVERLAY)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local rc = eg:GetFirst()
  	while rc do
  		if rc:GetFlagEffect(id) == 0 then
  			--draw
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetDescription(aux.Stringid(id, 0))
  			e1:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  			e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  			e1:SetCode(EVENT_BATTLE_DESTROYING)
  			e1:SetOperation(s.drawop)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			rc:RegisterEffect(e1, true)
  			rc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  		end
  		rc = eg:GetNext()
  	end
  end
  function s.drawop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Draw(tp, 1, REASON_EFFECT)
  end
  
  
source_text: Djinn
  When you Ritual Summon a monster, you can banish this card from your Graveyard as 1 of the monsters required for the Ritual Summon. If the monster Ritual Summoned using this card destroys a monster by battle, the controller of the Ritual Monster draws 1 card.
target_text: -- Djinn
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--ritual material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_EXTRA_RITUAL_MATERIAL)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--become material
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_EVENT_PLAYER)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetCondition(s.condition)
  	e2:SetOperation(s.operation)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_RITUAL and not e:GetHandler():IsPreviousLocation(LOCATION_OVERLAY)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local rc = eg:GetFirst()
  	while rc do
  		if rc:GetFlagEffect(id) == 0 then
  			--draw
  			local e1 = Effect.CreateEffect(e:GetHandler())
  			e1:SetDescription(aux.Stringid(id, 0))
  			e1:SetProperty(EFFECT_FLAG_CLIENT_HINT)
  			e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  			e1:SetCode(EVENT_BATTLE_DESTROYING)
  			e1:SetOperation(s.drawop)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			rc:RegisterEffect(e1, true)
  			rc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 1)
  		end
  		rc = eg:GetNext()
  	end
  end
  function s.drawop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Draw(tp, 1, REASON_EFFECT)
  end
  
  