name: Joker's
card_text: You can send 1 "Queen's Knight", "King's Knight", or "Jack's Knight" from your Deck to the GY; Special Summon this card from your hand, and if you do, this card's name becomes the sent monster's name until the End Phase. During the End Phase, if this card is in your GY: You can target 1 other LIGHT Warrior monster in your GY; shuffle it into the Deck, and if you do, add this card to your hand. You can only use each effect of "Joker's Knight" once per turn.
external_ids: local CARD_ID_0 = 64788463 --King's Knight
  local CARD_ID_1 = 90876561 --Jack's Knight
  local CARD_ID_3 = 25652259 --Queen's Knight
  
lua: local CARD_ID_0 = 64788463 --King's Knight
  local CARD_ID_1 = 90876561 --Jack's Knight
  local CARD_ID_3 = 25652259 --Queen's Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_3, CARD_ID_0, CARD_ID_1)
  	--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_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TODECK + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_3, CARD_ID_0, CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	e:SetLabel(g:GetFirst():GetCode())
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.SpecialSummonStep(c, 0, tp, tp, false, false, POS_FACEUP) then
  		local code = e:GetLabel()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_CHANGE_CODE)
  		e1:SetValue(code)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.tdfilter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_WARRIOR) and c:IsAbleToDeck()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.tdfilter(chkc) and chkc ~= c
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_GRAVE, 0, 1, c) and c:IsAbleToHand()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.tdfilter, tp, LOCATION_GRAVE, 0, 1, 1, c)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, c, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_DECK + LOCATION_EXTRA) and c:IsRelateToEffect(e) then
  		Duel.SendtoHand(c, nil, REASON_EFFECT)
  	end
  end
  
  
source_text: Joker's
  You can send 1 "Queen's Knight", "King's Knight", or "Jack's Knight" from your Deck to the GY; Special Summon this card from your hand, and if you do, this card's name becomes the sent monster's name until the End Phase. During the End Phase, if this card is in your GY: You can target 1 other LIGHT Warrior monster in your GY; shuffle it into the Deck, and if you do, add this card to your hand. You can only use each effect of "Joker's Knight" once per turn.
target_text: -- Joker's
  local CARD_ID_0 = 64788463 --King's Knight
  local CARD_ID_1 = 90876561 --Jack's Knight
  local CARD_ID_3 = 25652259 --Queen's Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_3, CARD_ID_0, CARD_ID_1)
  	--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_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.spcost)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--to hand
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_TODECK + CATEGORY_TOHAND)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetTarget(s.thtg)
  	e2:SetOperation(s.thop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:IsCode(CARD_ID_3, CARD_ID_0, CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	e:SetLabel(g:GetFirst():GetCode())
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	if Duel.SpecialSummonStep(c, 0, tp, tp, false, false, POS_FACEUP) then
  		local code = e:GetLabel()
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_CHANGE_CODE)
  		e1:SetValue(code)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  		c:RegisterEffect(e1)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.tdfilter(c)
  	return c:IsAttribute(ATTRIBUTE_LIGHT) and c:IsRace(RACE_WARRIOR) and c:IsAbleToDeck()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.tdfilter(chkc) and chkc ~= c
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_GRAVE, 0, 1, c) and c:IsAbleToHand()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.tdfilter, tp, LOCATION_GRAVE, 0, 1, 1, c)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, c, 1, 0, 0)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) and Duel.SendtoDeck(tc, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 and tc:IsLocation(LOCATION_DECK + LOCATION_EXTRA) and c:IsRelateToEffect(e) then
  		Duel.SendtoHand(c, nil, REASON_EFFECT)
  	end
  end
  
  