name: Doki
card_text: You can discard 1 Rock monster; Special Summon from your Deck, 1 Rock monster that has the same original Attribute and Level as that monster, in face-up Attack Position or face-down Defense Position. You can only use this effect of "Doki Doki" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100)
  	return true
  end
  function s.cfilter(c, e, tp)
  	return c:IsRace(RACE_ROCK) and c:IsDiscardable() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp, c:GetOriginalAttribute(), c:GetOriginalLevel())
  end
  function s.spfilter(c, e, tp, att, lv)
  	return c:IsRace(RACE_ROCK) and c:GetOriginalAttribute() == att and c:GetOriginalLevel() == lv and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		if e:GetLabel() ~= 100 then
  			return false
  		end
  		e:SetLabel(0)
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	e:SetLabelObject(g:GetFirst())
  	Duel.SendtoGrave(g, REASON_COST + REASON_DISCARD)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local gc = e:GetLabelObject()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, gc:GetOriginalAttribute(), gc:GetOriginalLevel())
  	local tc = g:GetFirst()
  	if tc then
  		if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) ~= 0 and tc:IsFacedown() then
  			Duel.ConfirmCards(1 - tp, tc)
  		end
  	end
  end
  
  
source_text: Doki
  You can discard 1 Rock monster; Special Summon from your Deck, 1 Rock monster that has the same original Attribute and Level as that monster, in face-up Attack Position or face-down Defense Position. You can only use this effect of "Doki Doki" once per turn.
target_text: -- Doki
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	e:SetLabel(100)
  	return true
  end
  function s.cfilter(c, e, tp)
  	return c:IsRace(RACE_ROCK) and c:IsDiscardable() and Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp, c:GetOriginalAttribute(), c:GetOriginalLevel())
  end
  function s.spfilter(c, e, tp, att, lv)
  	return c:IsRace(RACE_ROCK) and c:GetOriginalAttribute() == att and c:GetOriginalLevel() == lv and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		if e:GetLabel() ~= 100 then
  			return false
  		end
  		e:SetLabel(0)
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	e:SetLabelObject(g:GetFirst())
  	Duel.SendtoGrave(g, REASON_COST + REASON_DISCARD)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local gc = e:GetLabelObject()
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp, gc:GetOriginalAttribute(), gc:GetOriginalLevel())
  	local tc = g:GetFirst()
  	if tc then
  		if Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) ~= 0 and tc:IsFacedown() then
  			Duel.ConfirmCards(1 - tp, tc)
  		end
  	end
  end
  
  