name: Tualatin
card_text: If it is your opponent's Battle Phase, and all monsters you controlled at the start of this Battle Phase (min. 2) have been destroyed by battle and sent to the Graveyard: You can Special Summon this card from your hand. If Summoned this way: Choose an Attribute and destroy all face-up monsters with that Attribute. Your opponent cannot Normal or Special Summon monsters with that Attribute.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_CUSTOM + id)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.descon)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = Group.CreateGroup()
  		s[0]:KeepAlive()
  		s[1] = 0
  		local ge1 = Effect.GlobalEffect()
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_PHASE_START + PHASE_BATTLE_START)
  		ge1:SetOperation(s.checkop1)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.GlobalEffect()
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_BATTLE_DESTROYED)
  		ge2:SetOperation(s.checkop2)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop1(e, tp, eg, ep, ev, re, r, rp)
  	s[0]:Clear()
  	s[0]:Merge(Duel.GetFieldGroup(Duel.GetTurnPlayer(), 0, LOCATION_MZONE))
  	s[1] = s[0]:GetCount()
  end
  function s.checkop2(e, tp, eg, ep, ev, re, r, rp)
  	if s[1] < 2 or s[0]:GetCount() == 0 then
  		return
  	end
  	local g = eg:Filter(Card.IsLocation, nil, LOCATION_GRAVE)
  	s[0]:Sub(g)
  	if s[0]:GetCount() == 0 then
  		Duel.RaiseEvent(e:GetHandler(), EVENT_CUSTOM + id, e, 0, 0, 0, 0)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.desfilter(c, att)
  	return c:IsFaceup() and c:IsAttribute(att)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local rc = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL)
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, rc)
  	Duel.Destroy(g, REASON_EFFECT)
  	if c:IsRelateToEffect(e) then
  		c:SetHint(CHINT_ATTRIBUTE, rc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetCode(EFFECT_CANNOT_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(0, 1)
  		e1:SetTarget(s.sumlimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetLabel(rc)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		c:RegisterEffect(e2)
  	end
  end
  function s.sumlimit(e, c)
  	return c:IsAttribute(e:GetLabel())
  end
  
  
source_text: Tualatin
  If it is your opponent's Battle Phase, and all monsters you controlled at the start of this Battle Phase (min. 2) have been destroyed by battle and sent to the Graveyard: You can Special Summon this card from your hand. If Summoned this way: Choose an Attribute and destroy all face-up monsters with that Attribute. Your opponent cannot Normal or Special Summon monsters with that Attribute.
target_text: -- Tualatin
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_CUSTOM + id)
  	e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--destroy
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DESTROY)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.descon)
  	e2:SetOperation(s.desop)
  	c:RegisterEffect(e2)
  	if not s.global_check then
  		s.global_check = true
  		s[0] = Group.CreateGroup()
  		s[0]:KeepAlive()
  		s[1] = 0
  		local ge1 = Effect.GlobalEffect()
  		ge1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge1:SetCode(EVENT_PHASE_START + PHASE_BATTLE_START)
  		ge1:SetOperation(s.checkop1)
  		Duel.RegisterEffect(ge1, 0)
  		local ge2 = Effect.GlobalEffect()
  		ge2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		ge2:SetCode(EVENT_BATTLE_DESTROYED)
  		ge2:SetOperation(s.checkop2)
  		Duel.RegisterEffect(ge2, 0)
  	end
  end
  function s.checkop1(e, tp, eg, ep, ev, re, r, rp)
  	s[0]:Clear()
  	s[0]:Merge(Duel.GetFieldGroup(Duel.GetTurnPlayer(), 0, LOCATION_MZONE))
  	s[1] = s[0]:GetCount()
  end
  function s.checkop2(e, tp, eg, ep, ev, re, r, rp)
  	if s[1] < 2 or s[0]:GetCount() == 0 then
  		return
  	end
  	local g = eg:Filter(Card.IsLocation, nil, LOCATION_GRAVE)
  	s[0]:Sub(g)
  	if s[0]:GetCount() == 0 then
  		Duel.RaiseEvent(e:GetHandler(), EVENT_CUSTOM + id, e, 0, 0, 0, 0)
  	end
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetTurnPlayer() ~= tp
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and e:GetHandler():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, false, false, POS_FACEUP)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.desfilter(c, att)
  	return c:IsFaceup() and c:IsAttribute(att)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATTRIBUTE)
  	local rc = Duel.AnnounceAttribute(tp, 1, ATTRIBUTE_ALL)
  	local g = Duel.GetMatchingGroup(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, nil, rc)
  	Duel.Destroy(g, REASON_EFFECT)
  	if c:IsRelateToEffect(e) then
  		c:SetHint(CHINT_ATTRIBUTE, rc)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetRange(LOCATION_MZONE)
  		e1:SetCode(EFFECT_CANNOT_SUMMON)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(0, 1)
  		e1:SetTarget(s.sumlimit)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetLabel(rc)
  		c:RegisterEffect(e1)
  		local e2 = e1:Clone()
  		e2:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  		c:RegisterEffect(e2)
  	end
  end
  function s.sumlimit(e, c)
  	return c:IsAttribute(e:GetLabel())
  end
  
  