name: Dystopia
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand or Graveyard) by sending 4 face-up Level 1 monsters you control to the Graveyard, and cannot be Special Summoned by other ways. Other monsters you control cannot attack. During either player's Battle Step, once per battle involving this card: You can banish 1 Level 1 monster from your Graveyard; until the end of the Damage Step, this card is unaffected by other cards' effects, also it cannot be destroyed by battle.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon condition
  	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)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND + LOCATION_GRAVE)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--cannot attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_CANNOT_ATTACK)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetTarget(s.antarget)
  	c:RegisterEffect(e3)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(TIMING_BATTLE_PHASE)
  	e4:SetCondition(s.btcon)
  	e4:SetCost(s.btcost)
  	e4:SetOperation(s.btop)
  	c:RegisterEffect(e4)
  end
  function s.spcfilter(c)
  	return c:IsFaceup() and c:IsLevel(1) and c:IsAbleToGraveAsCost()
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local sg = Duel.GetMatchingGroup(s.spcfilter, tp, LOCATION_MZONE, 0, nil)
  	return sg:CheckSubGroup(aux.mzctcheck, 4, 4, tp)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local sg = Duel.GetMatchingGroup(s.spcfilter, tp, LOCATION_MZONE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = sg:SelectSubGroup(tp, aux.mzctcheck, true, 4, 4, tp)
  	if g then
  		g:KeepAlive()
  		e:SetLabelObject(g)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.SendtoGrave(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.antarget(e, c)
  	return c ~= e:GetHandler()
  end
  function s.btcon(e, tp, eg, ep, ev, re, r, rp)
  	return (Duel.GetCurrentPhase() >= PHASE_BATTLE_START and Duel.GetCurrentPhase() <= PHASE_BATTLE)
  		and not e:GetHandler():IsStatus(STATUS_CHAINING)
  		and (Duel.GetAttacker() == e:GetHandler() or Duel.GetAttackTarget() == e:GetHandler())
  end
  function s.btcfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:GetLevel() == 1 and c:IsAbleToRemoveAsCost()
  end
  function s.btcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.btcfilter, tp, LOCATION_GRAVE, 0, 1, nil) and e:GetHandler():GetFlagEffect(id) == 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.btcfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE, 0, 1)
  end
  function s.btop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_IMMUNE_EFFECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(s.efilter)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e2:SetValue(1)
  		c:RegisterEffect(e2)
  	end
  end
  function s.efilter(e, re)
  	return e:GetHandler() ~= re:GetOwner()
  end
  
  
source_text: Dystopia
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand or Graveyard) by sending 4 face-up Level 1 monsters you control to the Graveyard, and cannot be Special Summoned by other ways. Other monsters you control cannot attack. During either player's Battle Step, once per battle involving this card: You can banish 1 Level 1 monster from your Graveyard; until the end of the Damage Step, this card is unaffected by other cards' effects, also it cannot be destroyed by battle.
target_text: -- Dystopia
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--special summon condition
  	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)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND + LOCATION_GRAVE)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  	--cannot attack
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCode(EFFECT_CANNOT_ATTACK)
  	e3:SetTargetRange(LOCATION_MZONE, 0)
  	e3:SetTarget(s.antarget)
  	c:RegisterEffect(e3)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetType(EFFECT_TYPE_QUICK_O)
  	e4:SetCode(EVENT_FREE_CHAIN)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetHintTiming(TIMING_BATTLE_PHASE)
  	e4:SetCondition(s.btcon)
  	e4:SetCost(s.btcost)
  	e4:SetOperation(s.btop)
  	c:RegisterEffect(e4)
  end
  function s.spcfilter(c)
  	return c:IsFaceup() and c:IsLevel(1) and c:IsAbleToGraveAsCost()
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local sg = Duel.GetMatchingGroup(s.spcfilter, tp, LOCATION_MZONE, 0, nil)
  	return sg:CheckSubGroup(aux.mzctcheck, 4, 4, tp)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, c)
  	local sg = Duel.GetMatchingGroup(s.spcfilter, tp, LOCATION_MZONE, 0, nil)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = sg:SelectSubGroup(tp, aux.mzctcheck, true, 4, 4, tp)
  	if g then
  		g:KeepAlive()
  		e:SetLabelObject(g)
  		return true
  	else
  		return false
  	end
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp, c)
  	local g = e:GetLabelObject()
  	Duel.SendtoGrave(g, REASON_SPSUMMON)
  	g:DeleteGroup()
  end
  function s.antarget(e, c)
  	return c ~= e:GetHandler()
  end
  function s.btcon(e, tp, eg, ep, ev, re, r, rp)
  	return (Duel.GetCurrentPhase() >= PHASE_BATTLE_START and Duel.GetCurrentPhase() <= PHASE_BATTLE)
  		and not e:GetHandler():IsStatus(STATUS_CHAINING)
  		and (Duel.GetAttacker() == e:GetHandler() or Duel.GetAttackTarget() == e:GetHandler())
  end
  function s.btcfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:GetLevel() == 1 and c:IsAbleToRemoveAsCost()
  end
  function s.btcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.btcfilter, tp, LOCATION_GRAVE, 0, 1, nil) and e:GetHandler():GetFlagEffect(id) == 0
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.btcfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  	e:GetHandler():RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE, 0, 1)
  end
  function s.btop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_IMMUNE_EFFECT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetValue(s.efilter)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_DAMAGE)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  		e2:SetValue(1)
  		c:RegisterEffect(e2)
  	end
  end
  function s.efilter(e, re)
  	return e:GetHandler() ~= re:GetOwner()
  end
  
  