name: Windwitch
card_text: If you control no monsters, or all monsters you control are "Windwitch" monsters, you can Normal Summon this card without Tributing. During your opponent's Main Phase, if you control a "Windwitch" monster other than "Windwitch - Blizzard Bell" (Quick Effect): You can send this card from your hand or field to the GY; inflict 500 damage to your opponent. You can only use this effect of "Windwitch - Blizzard Bell" once per turn.
external_ids: local SETCARD_ID_0 = 0xf0 --Windwitch
  
lua: local SETCARD_ID_0 = 0xf0 --Windwitch
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon with no tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE + LOCATION_HAND)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.damcon)
  	e2:SetCost(s.damcost)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.ntfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return minc == 0
  		and c:IsLevelAbove(5)
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == Duel.GetMatchingGroupCount(s.ntfilter, tp, LOCATION_MZONE, 0, nil)
  end
  function s.damfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsExistingMatchingCard(s.damfilter, tp, LOCATION_MZONE, 0, 1, nil) then
  		return false
  	end
  	local ph = Duel.GetCurrentPhase()
  	return Duel.GetTurnPlayer() == 1 - tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.damcost(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.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(500)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  
  
source_text: Windwitch
  If you control no monsters, or all monsters you control are "Windwitch" monsters, you can Normal Summon this card without Tributing. During your opponent's Main Phase, if you control a "Windwitch" monster other than "Windwitch - Blizzard Bell" (Quick Effect): You can send this card from your hand or field to the GY; inflict 500 damage to your opponent. You can only use this effect of "Windwitch - Blizzard Bell" once per turn.
target_text: -- Windwitch
  local SETCARD_ID_0 = 0xf0 --Windwitch
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon with no tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_MZONE + LOCATION_HAND)
  	e2:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_MAIN_END)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.damcon)
  	e2:SetCost(s.damcost)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  end
  function s.ntfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return minc == 0
  		and c:IsLevelAbove(5)
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and Duel.GetFieldGroupCount(tp, LOCATION_MZONE, 0) == Duel.GetMatchingGroupCount(s.ntfilter, tp, LOCATION_MZONE, 0, nil)
  end
  function s.damfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0) and not c:IsCode(id)
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	if not Duel.IsExistingMatchingCard(s.damfilter, tp, LOCATION_MZONE, 0, 1, nil) then
  		return false
  	end
  	local ph = Duel.GetCurrentPhase()
  	return Duel.GetTurnPlayer() == 1 - tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.damcost(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.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(1 - tp)
  	Duel.SetTargetParam(500)
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, 500)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Damage(p, d, REASON_EFFECT)
  end
  
  