name: Yang
card_text: This card gains these effects, based on the number of different Attributes the "Yang Zing" monsters in your GY have.
  ● 2+: "Yang Zing" monsters you control gain 500 ATK.
  ● 3+: If a "Yang Zing" monster(s) you control would be destroyed by battle or card effect, you can send this card to the GY instead.
  ● 4+: Your opponent cannot Set monsters. Change all face-up monsters your opponent controls to Attack Position.
  ● 5+: You can send this card to the GY; destroy all cards on the field.
external_ids: local SETCARD_ID_0 = 0x9e --Yang
  
lua: local SETCARD_ID_0 = 0x9e --Yang
  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)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(500)
  	e2:SetCondition(s.effcon)
  	e2:SetLabel(2)
  	c:RegisterEffect(e2)
  	--replace
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_DESTROY_REPLACE)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.reptg)
  	e3:SetValue(s.repval)
  	e3:SetOperation(s.repop)
  	e3:SetCondition(s.effcon)
  	e3:SetLabel(3)
  	c:RegisterEffect(e3)
  	--cannot mset
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_CANNOT_MSET)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetTargetRange(0, 1)
  	e4:SetCondition(s.effcon)
  	e4:SetLabel(4)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_LIMIT_SPECIAL_SUMMON_POSITION)
  	e5:SetTarget(s.sumlimit)
  	c:RegisterEffect(e5)
  	--poschange
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_FIELD)
  	e6:SetCode(EFFECT_SET_POSITION)
  	e6:SetRange(LOCATION_SZONE)
  	e6:SetTargetRange(0, LOCATION_MZONE)
  	e6:SetValue(POS_FACEUP_ATTACK)
  	e6:SetCondition(s.effcon)
  	e6:SetLabel(4)
  	c:RegisterEffect(e6)
  	--destroy
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 0))
  	e7:SetCategory(CATEGORY_DESTROY)
  	e7:SetType(EFFECT_TYPE_IGNITION)
  	e7:SetRange(LOCATION_SZONE)
  	e7:SetCondition(s.effcon)
  	e7:SetCost(s.descost)
  	e7:SetTarget(s.destg)
  	e7:SetOperation(s.desop)
  	e7:SetLabel(5)
  	c:RegisterEffect(e7)
  end
  function s.confilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.effcon(e)
  	local g = Duel.GetMatchingGroup(s.confilter, e:GetHandlerPlayer(), LOCATION_GRAVE, 0, nil)
  	return g:GetClassCount(Card.GetAttribute) >= e:GetLabel()
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.repfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) 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)
  	if chk == 0 then
  		return not e:GetHandler():IsStatus(STATUS_DESTROY_CONFIRMED) and eg:IsExists(s.repfilter, 1, nil, tp)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.repval(e, c)
  	return s.repfilter(c, e:GetHandlerPlayer())
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.SendtoGrave(e:GetHandler(), REASON_EFFECT)
  end
  function s.sumlimit(e, c, sump, sumtype, sumpos, targetp)
  	return (sumpos & POS_FACEDOWN) > 0
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	if g:GetCount() > 0 then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  
  
source_text: Yang
  This card gains these effects, based on the number of different Attributes the "Yang Zing" monsters in your GY have.
  ● 2+: "Yang Zing" monsters you control gain 500 ATK.
  ● 3+: If a "Yang Zing" monster(s) you control would be destroyed by battle or card effect, you can send this card to the GY instead.
  ● 4+: Your opponent cannot Set monsters. Change all face-up monsters your opponent controls to Attack Position.
  ● 5+: You can send this card to the GY; destroy all cards on the field.
target_text: -- Yang
  local SETCARD_ID_0 = 0x9e --Yang
  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)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetTargetRange(LOCATION_MZONE, 0)
  	e2:SetTarget(s.atktg)
  	e2:SetValue(500)
  	e2:SetCondition(s.effcon)
  	e2:SetLabel(2)
  	c:RegisterEffect(e2)
  	--replace
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_DESTROY_REPLACE)
  	e3:SetRange(LOCATION_SZONE)
  	e3:SetCountLimit(1)
  	e3:SetTarget(s.reptg)
  	e3:SetValue(s.repval)
  	e3:SetOperation(s.repop)
  	e3:SetCondition(s.effcon)
  	e3:SetLabel(3)
  	c:RegisterEffect(e3)
  	--cannot mset
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD)
  	e4:SetCode(EFFECT_CANNOT_MSET)
  	e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e4:SetRange(LOCATION_SZONE)
  	e4:SetTargetRange(0, 1)
  	e4:SetCondition(s.effcon)
  	e4:SetLabel(4)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_LIMIT_SPECIAL_SUMMON_POSITION)
  	e5:SetTarget(s.sumlimit)
  	c:RegisterEffect(e5)
  	--poschange
  	local e6 = Effect.CreateEffect(c)
  	e6:SetType(EFFECT_TYPE_FIELD)
  	e6:SetCode(EFFECT_SET_POSITION)
  	e6:SetRange(LOCATION_SZONE)
  	e6:SetTargetRange(0, LOCATION_MZONE)
  	e6:SetValue(POS_FACEUP_ATTACK)
  	e6:SetCondition(s.effcon)
  	e6:SetLabel(4)
  	c:RegisterEffect(e6)
  	--destroy
  	local e7 = Effect.CreateEffect(c)
  	e7:SetDescription(aux.Stringid(id, 0))
  	e7:SetCategory(CATEGORY_DESTROY)
  	e7:SetType(EFFECT_TYPE_IGNITION)
  	e7:SetRange(LOCATION_SZONE)
  	e7:SetCondition(s.effcon)
  	e7:SetCost(s.descost)
  	e7:SetTarget(s.destg)
  	e7:SetOperation(s.desop)
  	e7:SetLabel(5)
  	c:RegisterEffect(e7)
  end
  function s.confilter(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER)
  end
  function s.effcon(e)
  	local g = Duel.GetMatchingGroup(s.confilter, e:GetHandlerPlayer(), LOCATION_GRAVE, 0, nil)
  	return g:GetClassCount(Card.GetAttribute) >= e:GetLabel()
  end
  function s.atktg(e, c)
  	return c:IsSetCard(SETCARD_ID_0)
  end
  function s.repfilter(c, tp)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and c:IsControler(tp) and c:IsLocation(LOCATION_MZONE) 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)
  	if chk == 0 then
  		return not e:GetHandler():IsStatus(STATUS_DESTROY_CONFIRMED) and eg:IsExists(s.repfilter, 1, nil, tp)
  	end
  	return Duel.SelectEffectYesNo(tp, e:GetHandler(), 96)
  end
  function s.repval(e, c)
  	return s.repfilter(c, e:GetHandlerPlayer())
  end
  function s.repop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.SendtoGrave(e:GetHandler(), REASON_EFFECT)
  end
  function s.sumlimit(e, c, sump, sumtype, sumpos, targetp)
  	return (sumpos & POS_FACEDOWN) > 0
  end
  function s.descost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, 1, e:GetHandler())
  	end
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, g:GetCount(), 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(aux.TRUE, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	if g:GetCount() > 0 then
  		Duel.Destroy(g, REASON_EFFECT)
  	end
  end
  
  