name: Bottomless
card_text: At the end of your opponent's turn, destroy the face-up monster(s) with the highest ATK on the field. During your own Standby Phase, if you have 4 or less cards in your hand, this card is destroyed.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--self destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetCode(EFFECT_SELF_DESTROY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.descon2)
  	c:RegisterEffect(e3)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return tp ~= Duel.GetTurnPlayer()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		local tg = g:GetMaxGroup(Card.GetAttack)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, tg, tg:GetCount(), 0, 0)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		local tg = g:GetMaxGroup(Card.GetAttack)
  		Duel.Destroy(tg, REASON_EFFECT)
  	end
  end
  function s.descon2(e)
  	local tp = e:GetHandlerPlayer()
  	return tp == Duel.GetTurnPlayer() and Duel.GetCurrentPhase() == PHASE_STANDBY and Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) <= 4
  end
  
  
source_text: Bottomless
  At the end of your opponent's turn, destroy the face-up monster(s) with the highest ATK on the field. During your own Standby Phase, if you have 4 or less cards in your hand, this card is destroyed.
target_text: -- Bottomless
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMING_END_PHASE)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_PHASE + PHASE_END)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCountLimit(1)
  	e2:SetCondition(s.descon)
  	e2:SetTarget(s.destg)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	--self destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE)
  	e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e3:SetCode(EFFECT_SELF_DESTROY)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCondition(s.descon2)
  	c:RegisterEffect(e3)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return tp ~= Duel.GetTurnPlayer()
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		local tg = g:GetMaxGroup(Card.GetAttack)
  		Duel.SetOperationInfo(0, CATEGORY_DESTROY, tg, tg:GetCount(), 0, 0)
  	end
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(Card.IsFaceup, tp, LOCATION_MZONE, LOCATION_MZONE, nil)
  	if g:GetCount() > 0 then
  		local tg = g:GetMaxGroup(Card.GetAttack)
  		Duel.Destroy(tg, REASON_EFFECT)
  	end
  end
  function s.descon2(e)
  	local tp = e:GetHandlerPlayer()
  	return tp == Duel.GetTurnPlayer() and Duel.GetCurrentPhase() == PHASE_STANDBY and Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) <= 4
  end
  
  