Toon
When this card is activated: Banish 3 cards from the top of your Deck, face-down. This card's name becomes "Toon World" while in the Field Zone. Your opponent cannot target Toon monsters you control with card effects. If a Toon monster(s) you control would be destroyed by battle or card effect, you can banish 1 card from the top of your Deck, face-down, for each of those monster(s) instead.
local CARD_ID_0 = 15259703 --Toon World

local CARD_ID_0 = 15259703 --Toon World
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_REMOVE)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
	--change code
	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_FZONE)
	--cannot be target
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
	e3:SetRange(LOCATION_FZONE)
	e3:SetTargetRange(LOCATION_MZONE, 0)
	e3:SetTarget(aux.TargetBoolFunction(Card.IsType, TYPE_TOON))
	e3:SetValue(aux.tgoval)
	c:RegisterEffect(e3)
	--destroy replace
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e4:SetCode(EFFECT_DESTROY_REPLACE)
	e4:SetRange(LOCATION_FZONE)
	e4:SetTarget(s.reptg)
	e4:SetValue(s.repval)
	c:RegisterEffect(e4)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetDecktopGroup(tp, 3)
	if chk == 0 then
		return g:FilterCount(Card.IsAbleToRemove, nil, tp, POS_FACEDOWN) == 3
	end
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 3, tp, LOCATION_DECK)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	local ct = Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0)
	if ct == 0 then
		return
	end
	if ct > 3 then
		ct = 3
	end
	local g = Duel.GetDecktopGroup(tp, ct)
	Duel.DisableShuffleCheck()
	Duel.Remove(g, POS_FACEDOWN, REASON_EFFECT)
end
function s.repfilter(c, tp)
	return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsType(TYPE_TOON) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
end
function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
	local ct = eg:FilterCount(s.repfilter, nil, tp)
	local g = Duel.GetDecktopGroup(tp, ct)
	if chk == 0 then
		return g:IsExists(Card.IsAbleToRemove, ct, nil, tp, POS_FACEDOWN)
	end
	if Duel.SelectEffectYesNo(tp, e:GetHandler(), 96) then
		Duel.DisableShuffleCheck()
		Duel.Remove(g, POS_FACEDOWN, REASON_EFFECT)
		return true
	else
		return false
	end
end
function s.repval(e, c)
	return s.repfilter(c, e:GetHandlerPlayer())
end


Toon
When this card is activated: Banish 3 cards from the top of your Deck, face-down. This card's name becomes "Toon World" while in the Field Zone. Your opponent cannot target Toon monsters you control with card effects. If a Toon monster(s) you control would be destroyed by battle or card effect, you can banish 1 card from the top of your Deck, face-down, for each of those monster(s) instead.
-- Toon
local CARD_ID_0 = 15259703 --Toon World
local s, id, o = GetID()
function s.initial_effect(c)
	--activate
	local e1 = Effect.CreateEffect(c)
	e1:SetCategory(CATEGORY_REMOVE)
	e1:SetType(EFFECT_TYPE_ACTIVATE)
	e1:SetCode(EVENT_FREE_CHAIN)
	e1:SetTarget(s.target)
	e1:SetOperation(s.activate)
	c:RegisterEffect(e1)
	--change code
	aux.EnableChangeCode(c, CARD_ID_0, LOCATION_FZONE)
	--cannot be target
	local e3 = Effect.CreateEffect(c)
	e3:SetType(EFFECT_TYPE_FIELD)
	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
	e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
	e3:SetRange(LOCATION_FZONE)
	e3:SetTargetRange(LOCATION_MZONE, 0)
	e3:SetTarget(aux.TargetBoolFunction(Card.IsType, TYPE_TOON))
	e3:SetValue(aux.tgoval)
	c:RegisterEffect(e3)
	--destroy replace
	local e4 = Effect.CreateEffect(c)
	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
	e4:SetCode(EFFECT_DESTROY_REPLACE)
	e4:SetRange(LOCATION_FZONE)
	e4:SetTarget(s.reptg)
	e4:SetValue(s.repval)
	c:RegisterEffect(e4)
end
function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
	local g = Duel.GetDecktopGroup(tp, 3)
	if chk == 0 then
		return g:FilterCount(Card.IsAbleToRemove, nil, tp, POS_FACEDOWN) == 3
	end
	Duel.SetOperationInfo(0, CATEGORY_REMOVE, nil, 3, tp, LOCATION_DECK)
end
function s.activate(e, tp, eg, ep, ev, re, r, rp)
	local ct = Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0)
	if ct == 0 then
		return
	end
	if ct > 3 then
		ct = 3
	end
	local g = Duel.GetDecktopGroup(tp, ct)
	Duel.DisableShuffleCheck()
	Duel.Remove(g, POS_FACEDOWN, REASON_EFFECT)
end
function s.repfilter(c, tp)
	return c:IsFaceup() and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) and c:IsType(TYPE_TOON) and c:IsReason(REASON_BATTLE + REASON_EFFECT) and not c:IsReason(REASON_REPLACE)
end
function s.reptg(e, tp, eg, ep, ev, re, r, rp, chk)
	local ct = eg:FilterCount(s.repfilter, nil, tp)
	local g = Duel.GetDecktopGroup(tp, ct)
	if chk == 0 then
		return g:IsExists(Card.IsAbleToRemove, ct, nil, tp, POS_FACEDOWN)
	end
	if Duel.SelectEffectYesNo(tp, e:GetHandler(), 96) then
		Duel.DisableShuffleCheck()
		Duel.Remove(g, POS_FACEDOWN, REASON_EFFECT)
		return true
	else
		return false
	end
end
function s.repval(e, c)
	return s.repfilter(c, e:GetHandlerPlayer())
end

