name: Dictator
card_text: While you control a "Blue-Eyes" monster, you choose the attack targets for your opponent's attacks. You can only use each of the following effects of "Dictator of D." once per turn. You can send 1 "Blue-Eyes White Dragon" from your hand or Deck to the GY; Special Summon this card from your hand. You can discard 1 "Blue-Eyes White Dragon", or 1 card that mentions it, then target 1 "Blue-Eyes" monster in your GY; Special Summon it.
external_ids: local CARD_ID_1 = 89631139 --Blue-Eyes White Dragon
  local SETCARD_ID_0 = 0xdd --Blue-Eyes
  
lua: local CARD_ID_1 = 89631139 --Blue-Eyes White Dragon
  local SETCARD_ID_0 = 0xdd --Blue-Eyes
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, 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.spcost1)
  	e1:SetTarget(s.sptg1)
  	e1:SetOperation(s.spop1)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.spcost2)
  	e2:SetTarget(s.sptg2)
  	e2:SetOperation(s.spop2)
  	c:RegisterEffect(e2)
  	--attack redirect
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_PATRICIAN_OF_DARKNESS)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCondition(s.podcond)
  	e3:SetTargetRange(0, 1)
  	c:RegisterEffect(e3)
  end
  function s.spcostfilter1(c)
  	return c:IsCode(CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.spcost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcostfilter1, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.spcostfilter1, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg1(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.spop1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.spcostfilter2(c)
  	return aux.IsCodeOrListed(c, CARD_ID_1) and c:IsDiscardable()
  end
  function s.spcost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcostfilter2, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	Duel.DiscardHand(tp, s.spcostfilter2, 1, 1, REASON_COST + REASON_DISCARD, nil)
  end
  function s.spfilter2(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter2(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter2, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter2, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.podfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.podcond(e)
  	local tp = e:GetOwnerPlayer()
  	return Duel.IsExistingMatchingCard(s.podfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  
  
source_text: Dictator
  While you control a "Blue-Eyes" monster, you choose the attack targets for your opponent's attacks. You can only use each of the following effects of "Dictator of D." once per turn. You can send 1 "Blue-Eyes White Dragon" from your hand or Deck to the GY; Special Summon this card from your hand. You can discard 1 "Blue-Eyes White Dragon", or 1 card that mentions it, then target 1 "Blue-Eyes" monster in your GY; Special Summon it.
target_text: -- Dictator
  local CARD_ID_1 = 89631139 --Blue-Eyes White Dragon
  local SETCARD_ID_0 = 0xdd --Blue-Eyes
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, 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.spcost1)
  	e1:SetTarget(s.sptg1)
  	e1:SetOperation(s.spop1)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.spcost2)
  	e2:SetTarget(s.sptg2)
  	e2:SetOperation(s.spop2)
  	c:RegisterEffect(e2)
  	--attack redirect
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_PATRICIAN_OF_DARKNESS)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetCondition(s.podcond)
  	e3:SetTargetRange(0, 1)
  	c:RegisterEffect(e3)
  end
  function s.spcostfilter1(c)
  	return c:IsCode(CARD_ID_1) and c:IsAbleToGraveAsCost()
  end
  function s.spcost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcostfilter1, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.spcostfilter1, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg1(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.spop1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP)
  end
  function s.spcostfilter2(c)
  	return aux.IsCodeOrListed(c, CARD_ID_1) and c:IsDiscardable()
  end
  function s.spcost2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcostfilter2, tp, LOCATION_HAND, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DISCARD)
  	Duel.DiscardHand(tp, s.spcostfilter2, 1, 1, REASON_COST + REASON_DISCARD, nil)
  end
  function s.spfilter2(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg2(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter2(chkc, e, tp)
  	end
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingTarget(s.spfilter2, tp, LOCATION_GRAVE, 0, 1, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectTarget(tp, s.spfilter2, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.spop2(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.podfilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsFaceup()
  end
  function s.podcond(e)
  	local tp = e:GetOwnerPlayer()
  	return Duel.IsExistingMatchingCard(s.podfilter, tp, LOCATION_MZONE, 0, 1, nil)
  end
  
  