name: Toon
card_text: Cannot attack the turn it is Summoned. If "Toon World" on the field is destroyed, destroy this card. While you control "Toon World" and your opponent controls no Toon monsters, this card can attack your opponent directly. If this card inflicts battle damage to your opponent: Discard 1 random card from your opponent's hand.
external_ids: local CARD_ID_0 = 15259703 --Toon World
  
lua: local CARD_ID_0 = 15259703 --Toon World
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--cannot attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.atklimit)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EVENT_LEAVE_FIELD)
  	e4:SetCondition(s.sdescon)
  	e4:SetOperation(s.sdesop)
  	c:RegisterEffect(e4)
  	--direct attack
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_DIRECT_ATTACK)
  	e5:SetCondition(s.dircon)
  	c:RegisterEffect(e5)
  	--handes
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetCategory(CATEGORY_HANDES)
  	e6:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e6:SetCode(EVENT_BATTLE_DAMAGE)
  	e6:SetCondition(s.condition)
  	e6:SetTarget(s.target)
  	e6:SetOperation(s.operation)
  	c:RegisterEffect(e6)
  end
  function s.atklimit(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.sfilter(c)
  	return c:IsReason(REASON_DESTROY) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousCodeOnField() == CARD_ID_0 and c:IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.sdescon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.sfilter, 1, nil)
  end
  function s.sdesop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  function s.dirfilter1(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.dirfilter2(c)
  	return c:IsFaceup() and c:IsType(TYPE_TOON)
  end
  function s.dircon(e)
  	return Duel.IsExistingMatchingCard(s.dirfilter1, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  		and not Duel.IsExistingMatchingCard(s.dirfilter2, e:GetHandlerPlayer(), 0, LOCATION_MZONE, 1, nil)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(ep, LOCATION_HAND, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, 1 - tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(ep, LOCATION_HAND, 0)
  	if g:GetCount() == 0 then
  		return
  	end
  	local sg = g:RandomSelect(1 - tp, 1)
  	Duel.SendtoGrave(sg, REASON_EFFECT + REASON_DISCARD)
  end
  
  
source_text: Toon
  Cannot attack the turn it is Summoned. If "Toon World" on the field is destroyed, destroy this card. While you control "Toon World" and your opponent controls no Toon monsters, this card can attack your opponent directly. If this card inflicts battle damage to your opponent: Discard 1 random card from your opponent's hand.
target_text: -- Toon
  local CARD_ID_0 = 15259703 --Toon World
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--cannot attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.atklimit)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e2)
  	local e3 = e1:Clone()
  	e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  	--destroy
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EVENT_LEAVE_FIELD)
  	e4:SetCondition(s.sdescon)
  	e4:SetOperation(s.sdesop)
  	c:RegisterEffect(e4)
  	--direct attack
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_DIRECT_ATTACK)
  	e5:SetCondition(s.dircon)
  	c:RegisterEffect(e5)
  	--handes
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 0))
  	e6:SetCategory(CATEGORY_HANDES)
  	e6:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e6:SetCode(EVENT_BATTLE_DAMAGE)
  	e6:SetCondition(s.condition)
  	e6:SetTarget(s.target)
  	e6:SetOperation(s.operation)
  	c:RegisterEffect(e6)
  end
  function s.atklimit(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.sfilter(c)
  	return c:IsReason(REASON_DESTROY) and c:IsPreviousPosition(POS_FACEUP) and c:GetPreviousCodeOnField() == CARD_ID_0 and c:IsPreviousLocation(LOCATION_ONFIELD)
  end
  function s.sdescon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.sfilter, 1, nil)
  end
  function s.sdesop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Destroy(e:GetHandler(), REASON_EFFECT)
  end
  function s.dirfilter1(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.dirfilter2(c)
  	return c:IsFaceup() and c:IsType(TYPE_TOON)
  end
  function s.dircon(e)
  	return Duel.IsExistingMatchingCard(s.dirfilter1, e:GetHandlerPlayer(), LOCATION_ONFIELD, 0, 1, nil)
  		and not Duel.IsExistingMatchingCard(s.dirfilter2, e:GetHandlerPlayer(), 0, LOCATION_MZONE, 1, nil)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(ep, LOCATION_HAND, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, 1 - tp, 1)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(ep, LOCATION_HAND, 0)
  	if g:GetCount() == 0 then
  		return
  	end
  	local sg = g:RandomSelect(1 - tp, 1)
  	Duel.SendtoGrave(sg, REASON_EFFECT + REASON_DISCARD)
  end
  
  