name: Earthbound
card_text: There can only be 1 "Earthbound Immortal" monster on the field. If there is no face-up Field Spell on the field, destroy this card. Your opponent's monsters cannot target this card for attacks. This card can attack directly. If this card is Normal Summoned: Target 1 to 3 cards you control, but not more than your opponent has in their hand; shuffle them into the Deck, then discard the same number of random cards from your opponent's hand (or as many as possible), and if you do, this card gains 1000 ATK for each card discarded by this effect.
external_ids: local SETCARD_ID_0 = 0x1021 --Earthbound
  
lua: local SETCARD_ID_0 = 0x1021 --Earthbound
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 1, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), LOCATION_MZONE)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetCondition(s.sdcon)
  	c:RegisterEffect(e4)
  	--battle target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetValue(aux.imval1)
  	c:RegisterEffect(e5)
  	--direct atk
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e6)
  	--handes
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 0))
  	e7:SetCategory(CATEGORY_TODECK + CATEGORY_HANDES)
  	e7:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e7:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e7:SetCode(EVENT_SUMMON_SUCCESS)
  	e7:SetTarget(s.hdtg)
  	e7:SetOperation(s.hdop)
  	c:RegisterEffect(e7)
  end
  function s.sdcon(e)
  	return not Duel.IsExistingMatchingCard(Card.IsFaceup, 0, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  end
  function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(tp) and chkc:IsAbleToDeck()
  	end
  	if chk == 0 then
  		return true
  	end
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND)
  	if ct == 0 then
  		return
  	end
  	if ct > 3 then
  		ct = 3
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToDeck, tp, LOCATION_ONFIELD, 0, 1, ct, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  end
  function s.hdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if not g then
  		return
  	end
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local ct = sg:FilterCount(Card.IsLocation, nil, LOCATION_DECK + LOCATION_EXTRA)
  	if ct == 0 then
  		return
  	end
  	Duel.BreakEffect()
  	local dg = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, ct)
  	local dt = Duel.SendtoGrave(dg, REASON_EFFECT + REASON_DISCARD)
  	local c = e:GetHandler()
  	if dt ~= 0 and c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(dt * 1000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  
  
source_text: Earthbound
  There can only be 1 "Earthbound Immortal" monster on the field. If there is no face-up Field Spell on the field, destroy this card. Your opponent's monsters cannot target this card for attacks. This card can attack directly. If this card is Normal Summoned: Target 1 to 3 cards you control, but not more than your opponent has in their hand; shuffle them into the Deck, then discard the same number of random cards from your opponent's hand (or as many as possible), and if you do, this card gains 1000 ATK for each card discarded by this effect.
target_text: -- Earthbound
  local SETCARD_ID_0 = 0x1021 --Earthbound
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:SetUniqueOnField(1, 1, aux.FilterBoolFunction(Card.IsSetCard, SETCARD_ID_0), LOCATION_MZONE)
  	--
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_SELF_DESTROY)
  	e4:SetCondition(s.sdcon)
  	c:RegisterEffect(e4)
  	--battle target
  	local e5 = Effect.CreateEffect(c)
  	e5:SetType(EFFECT_TYPE_SINGLE)
  	e5:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
  	e5:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e5:SetRange(LOCATION_MZONE)
  	e5:SetValue(aux.imval1)
  	c:RegisterEffect(e5)
  	--direct atk
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_SINGLE)
  	e6:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e6)
  	--handes
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 0))
  	e7:SetCategory(CATEGORY_TODECK + CATEGORY_HANDES)
  	e7:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e7:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e7:SetCode(EVENT_SUMMON_SUCCESS)
  	e7:SetTarget(s.hdtg)
  	e7:SetOperation(s.hdop)
  	c:RegisterEffect(e7)
  end
  function s.sdcon(e)
  	return not Duel.IsExistingMatchingCard(Card.IsFaceup, 0, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  end
  function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(tp) and chkc:IsAbleToDeck()
  	end
  	if chk == 0 then
  		return true
  	end
  	local ct = Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND)
  	if ct == 0 then
  		return
  	end
  	if ct > 3 then
  		ct = 3
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, Card.IsAbleToDeck, tp, LOCATION_ONFIELD, 0, 1, ct, e:GetHandler())
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, g:GetCount(), 0, 0)
  end
  function s.hdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	if not g then
  		return
  	end
  	local sg = g:Filter(Card.IsRelateToEffect, nil, e)
  	Duel.SendtoDeck(sg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT)
  	local ct = sg:FilterCount(Card.IsLocation, nil, LOCATION_DECK + LOCATION_EXTRA)
  	if ct == 0 then
  		return
  	end
  	Duel.BreakEffect()
  	local dg = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, ct)
  	local dt = Duel.SendtoGrave(dg, REASON_EFFECT + REASON_DISCARD)
  	local c = e:GetHandler()
  	if dt ~= 0 and c:IsRelateToEffect(e) and c:IsFaceup() then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetCode(EFFECT_UPDATE_ATTACK)
  		e1:SetValue(dt * 1000)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE)
  		c:RegisterEffect(e1)
  	end
  end
  
  