name: Apoqliphort
card_text: Cannot be Special Summoned. Requires 3 "Qli" Tributes to Normal Summon/Set. If this card is Normal Summoned/Set, it is unaffected by Spell/Trap effects and by activated effects from any monster whose original Level/Rank is lower than this card's current Level. All Special Summoned monsters lose 500 ATK and DEF. Once per turn: You can make your opponent send 1 monster from their hand or their side of the field to the Graveyard (their choice).
external_ids: local SETCARD_ID_0 = 0xaa --Qli
  
lua: local SETCARD_ID_0 = 0xaa --Qli
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--tribute limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_TRIBUTE_LIMIT)
  	e2:SetValue(s.tlimit)
  	c:RegisterEffect(e2)
  	--summon with 3 tribute
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e3:SetCode(EFFECT_LIMIT_SUMMON_PROC)
  	e3:SetCondition(s.ttcon)
  	e3:SetOperation(s.ttop)
  	e3:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_LIMIT_SET_PROC)
  	c:RegisterEffect(e4)
  	--immune
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE + EFFECT_FLAG_UNCOPYABLE)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCode(EFFECT_IMMUNE_EFFECT)
  	e5:SetCondition(s.immcon)
  	e5:SetValue(s.efilter)
  	c:RegisterEffect(e5)
  	--atk/def down
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_FIELD)
  	e6:SetCode(EFFECT_UPDATE_ATTACK)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e6:SetTarget(s.adtg)
  	e6:SetValue(-500)
  	c:RegisterEffect(e6)
  	local e7 = e6:Clone()
  	e7:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e7)
  	--to grave
  	local e8 = Effect.CreateEffect(c)
  	e8:SetCategory(CATEGORY_TOGRAVE)
  	e8:SetType(EFFECT_TYPE_IGNITION)
  	e8:SetRange(LOCATION_MZONE)
  	e8:SetCountLimit(1)
  	e8:SetTarget(s.tgtg)
  	e8:SetOperation(s.tgop)
  	c:RegisterEffect(e8)
  end
  function s.tlimit(e, c)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.ttcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc <= 3 and Duel.CheckTribute(c, 3)
  end
  function s.ttop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = Duel.SelectTribute(tp, c, 3, 3)
  	c:SetMaterial(g)
  	Duel.Release(g, REASON_SUMMON + REASON_MATERIAL)
  end
  function s.immcon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_NORMAL)
  end
  function s.efilter(e, te)
  	if te:IsActiveType(TYPE_SPELL + TYPE_TRAP) then
  		return true
  	else
  		return aux.qlifilter(e, te)
  	end
  end
  function s.adtg(e, c)
  	return c:IsSummonType(SUMMON_TYPE_SPECIAL)
  end
  function s.tgfilter(c)
  	return not c:IsPublic() or c:IsType(TYPE_MONSTER)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local mc = Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND)
  	if chk == 0 then
  		return mc > 0 or g and g:IsExists(s.tgfilter, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, 1 - tp, LOCATION_MZONE + LOCATION_HAND)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsType, 1 - tp, LOCATION_MZONE + LOCATION_HAND, 0, nil, TYPE_MONSTER)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_TOGRAVE)
  		local sg = g:Select(1 - tp, 1, 1, nil)
  		Duel.HintSelection(sg)
  		Duel.SendtoGrave(sg, REASON_RULE, 1 - tp)
  	end
  end
  
  
source_text: Apoqliphort
  Cannot be Special Summoned. Requires 3 "Qli" Tributes to Normal Summon/Set. If this card is Normal Summoned/Set, it is unaffected by Spell/Trap effects and by activated effects from any monster whose original Level/Rank is lower than this card's current Level. All Special Summoned monsters lose 500 ATK and DEF. Once per turn: You can make your opponent send 1 monster from their hand or their side of the field to the Graveyard (their choice).
target_text: -- Apoqliphort
  local SETCARD_ID_0 = 0xaa --Qli
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--tribute limit
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_TRIBUTE_LIMIT)
  	e2:SetValue(s.tlimit)
  	c:RegisterEffect(e2)
  	--summon with 3 tribute
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e3:SetCode(EFFECT_LIMIT_SUMMON_PROC)
  	e3:SetCondition(s.ttcon)
  	e3:SetOperation(s.ttop)
  	e3:SetValue(SUMMON_TYPE_ADVANCE)
  	c:RegisterEffect(e3)
  	local e4 = e3:Clone()
  	e4:SetCode(EFFECT_LIMIT_SET_PROC)
  	c:RegisterEffect(e4)
  	--immune
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE + EFFECT_FLAG_UNCOPYABLE)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetCode(EFFECT_IMMUNE_EFFECT)
  	e5:SetCondition(s.immcon)
  	e5:SetValue(s.efilter)
  	c:RegisterEffect(e5)
  	--atk/def down
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_FIELD)
  	e6:SetCode(EFFECT_UPDATE_ATTACK)
  	e6:SetRange(LOCATION_MZONE)
  	e6:SetTargetRange(LOCATION_MZONE, LOCATION_MZONE)
  	e6:SetTarget(s.adtg)
  	e6:SetValue(-500)
  	c:RegisterEffect(e6)
  	local e7 = e6:Clone()
  	e7:SetCode(EFFECT_UPDATE_DEFENSE)
  	c:RegisterEffect(e7)
  	--to grave
  	local e8 = Effect.CreateEffect(c)
  	e8:SetCategory(CATEGORY_TOGRAVE)
  	e8:SetType(EFFECT_TYPE_IGNITION)
  	e8:SetRange(LOCATION_MZONE)
  	e8:SetCountLimit(1)
  	e8:SetTarget(s.tgtg)
  	e8:SetOperation(s.tgop)
  	c:RegisterEffect(e8)
  end
  function s.tlimit(e, c)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.ttcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc <= 3 and Duel.CheckTribute(c, 3)
  end
  function s.ttop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = Duel.SelectTribute(tp, c, 3, 3)
  	c:SetMaterial(g)
  	Duel.Release(g, REASON_SUMMON + REASON_MATERIAL)
  end
  function s.immcon(e)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_NORMAL)
  end
  function s.efilter(e, te)
  	if te:IsActiveType(TYPE_SPELL + TYPE_TRAP) then
  		return true
  	else
  		return aux.qlifilter(e, te)
  	end
  end
  function s.adtg(e, c)
  	return c:IsSummonType(SUMMON_TYPE_SPECIAL)
  end
  function s.tgfilter(c)
  	return not c:IsPublic() or c:IsType(TYPE_MONSTER)
  end
  function s.tgtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local mc = Duel.GetFieldGroupCount(tp, 0, LOCATION_MZONE)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND)
  	if chk == 0 then
  		return mc > 0 or g and g:IsExists(s.tgfilter, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOGRAVE, nil, 1, 1 - tp, LOCATION_MZONE + LOCATION_HAND)
  end
  function s.tgop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsType, 1 - tp, LOCATION_MZONE + LOCATION_HAND, 0, nil, TYPE_MONSTER)
  	if g:GetCount() > 0 then
  		Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_TOGRAVE)
  		local sg = g:Select(1 - tp, 1, 1, nil)
  		Duel.HintSelection(sg)
  		Duel.SendtoGrave(sg, REASON_RULE, 1 - tp)
  	end
  end
  
  