name: Fuh-Rin-Ka-Zan
card_text: When there are face-up WIND, WATER, FIRE and EARTH monster(s) on the field: Apply 1 of these effects.
  ● Destroy all monsters your opponent controls.
  ● Destroy all Spell and Trap Cards your opponent controls.
  ● Discard 2 random cards from your opponent's hand.
  ● Draw 2 cards.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_HANDES + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE + TIMING_TOHAND)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, att)
  	return c:IsFaceup() and c:IsAttribute(att)
  end
  function s.dfilter2(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_WIND)
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_WATER)
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_FIRE)
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_EARTH)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil)
  			or Duel.IsExistingMatchingCard(s.dfilter2, tp, 0, LOCATION_ONFIELD, 1, nil)
  			or Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) >= 2
  			or Duel.IsPlayerCanDraw(tp, 2)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local off = 1
  	local ops = {}
  	local opval = {}
  	if Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil) then
  		ops[off] = aux.Stringid(id, 0)
  		opval[off - 1] = 1
  		off = off + 1
  	end
  	if Duel.IsExistingMatchingCard(s.dfilter2, tp, 0, LOCATION_ONFIELD, 1, nil) then
  		ops[off] = aux.Stringid(id, 1)
  		opval[off - 1] = 2
  		off = off + 1
  	end
  	if Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) >= 2 then
  		ops[off] = aux.Stringid(id, 2)
  		opval[off - 1] = 3
  		off = off + 1
  	end
  	if Duel.IsPlayerCanDraw(tp, 2) then
  		ops[off] = aux.Stringid(id, 3)
  		opval[off - 1] = 4
  		off = off + 1
  	end
  	if off == 1 then
  		return
  	end
  	local op = Duel.SelectOption(tp, table.unpack(ops))
  	if opval[op] == 1 then
  		local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	elseif opval[op] == 2 then
  		local g = Duel.GetMatchingGroup(s.dfilter2, tp, 0, LOCATION_ONFIELD, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	elseif opval[op] == 3 then
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(1 - tp, 2)
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	elseif opval[op] == 4 then
  		Duel.Draw(tp, 2, REASON_EFFECT)
  	end
  end
  
  
source_text: Fuh-Rin-Ka-Zan
  When there are face-up WIND, WATER, FIRE and EARTH monster(s) on the field: Apply 1 of these effects.
  ● Destroy all monsters your opponent controls.
  ● Destroy all Spell and Trap Cards your opponent controls.
  ● Discard 2 random cards from your opponent's hand.
  ● Draw 2 cards.
target_text: -- Fuh-Rin-Ka-Zan
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY + CATEGORY_HANDES + CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE + TIMING_TOHAND)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cfilter(c, att)
  	return c:IsFaceup() and c:IsAttribute(att)
  end
  function s.dfilter2(c)
  	return c:IsType(TYPE_SPELL + TYPE_TRAP)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_WIND)
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_WATER)
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_FIRE)
  		and Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil, ATTRIBUTE_EARTH)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil)
  			or Duel.IsExistingMatchingCard(s.dfilter2, tp, 0, LOCATION_ONFIELD, 1, nil)
  			or Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) >= 2
  			or Duel.IsPlayerCanDraw(tp, 2)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local off = 1
  	local ops = {}
  	local opval = {}
  	if Duel.IsExistingMatchingCard(aux.TRUE, tp, 0, LOCATION_MZONE, 1, nil) then
  		ops[off] = aux.Stringid(id, 0)
  		opval[off - 1] = 1
  		off = off + 1
  	end
  	if Duel.IsExistingMatchingCard(s.dfilter2, tp, 0, LOCATION_ONFIELD, 1, nil) then
  		ops[off] = aux.Stringid(id, 1)
  		opval[off - 1] = 2
  		off = off + 1
  	end
  	if Duel.GetFieldGroupCount(tp, 0, LOCATION_HAND) >= 2 then
  		ops[off] = aux.Stringid(id, 2)
  		opval[off - 1] = 3
  		off = off + 1
  	end
  	if Duel.IsPlayerCanDraw(tp, 2) then
  		ops[off] = aux.Stringid(id, 3)
  		opval[off - 1] = 4
  		off = off + 1
  	end
  	if off == 1 then
  		return
  	end
  	local op = Duel.SelectOption(tp, table.unpack(ops))
  	if opval[op] == 1 then
  		local g = Duel.GetMatchingGroup(aux.TRUE, tp, 0, LOCATION_MZONE, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	elseif opval[op] == 2 then
  		local g = Duel.GetMatchingGroup(s.dfilter2, tp, 0, LOCATION_ONFIELD, nil)
  		Duel.Destroy(g, REASON_EFFECT)
  	elseif opval[op] == 3 then
  		local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(1 - tp, 2)
  		Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  	elseif opval[op] == 4 then
  		Duel.Draw(tp, 2, REASON_EFFECT)
  	end
  end
  
  