name: Vagnawa
card_text: 1 Tuner + 1+ non-Tuner monsters
  If this card is Synchro Summoned: You can activate this effect; this card gains 300 ATK for each Level that the non-Tuners used had, then inflict 300 damage to your opponent for each Level that the Tuner used had. The ATK increase lasts until the end of the next turn. You can only use this effect of "Vagnawa the Moon-Eating Dragon" once per turn.
external_ids: local CARD_ID_0 = 89818984 --Flower Cardian Willow with Calligrapher
  
lua: local CARD_ID_0 = 89818984 --Flower Cardian Willow with Calligrapher
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--ATK change && Damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.adcon)
  	e1:SetTarget(s.adtg)
  	e1:SetOperation(s.adop)
  	c:RegisterEffect(e1)
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_MATERIAL_CHECK)
  	e0:SetValue(s.valcheck)
  	e0:SetLabelObject(e1)
  	c:RegisterEffect(e0)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local mg = g:Filter(Card.IsTuner, nil, c)
  	local tc = mg:GetFirst()
  	if not tc then
  		e:GetLabelObject():SetLabel(0)
  		return
  	end
  	if #mg > 1 then
  		local tg = g - (g:Filter(Card.IsNotTuner, nil, c))
  		if #tg > 0 then
  			tc = tg:GetFirst()
  		end
  	end
  	local lv = tc:GetSynchroLevel(c)
  	local lv2 = lv >> 16
  	lv = lv & 0xffff
  	if lv2 > 0 and not g:CheckWithSumEqual(Card.GetLevel, c:GetLevel(), #g, #g, c) then
  		lv = lv2
  	end
  	if tc:IsHasEffect(CARD_ID_0) and not g:CheckWithSumEqual(Card.GetSynchroLevel, c:GetLevel(), #g, #g, c) then
  		lv = 2
  	end
  	e:GetLabelObject():SetLabel(lv, c:GetLevel() - lv)
  end
  function s.adcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.adtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local dam, atk = e:GetLabel()
  	if chk == 0 then
  		return atk > 0 and dam > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam * 300)
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local dam, atk = e:GetLabel()
  	if not c:IsRelateToChain() or c:IsFacedown() then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END, 2)
  	e1:SetValue(atk * 300)
  	c:RegisterEffect(e1)
  	Duel.BreakEffect()
  	Duel.Damage(1 - tp, dam * 300, REASON_EFFECT)
  end
  
  
source_text: Vagnawa
  1 Tuner + 1+ non-Tuner monsters
  If this card is Synchro Summoned: You can activate this effect; this card gains 300 ATK for each Level that the non-Tuners used had, then inflict 300 damage to your opponent for each Level that the Tuner used had. The ATK increase lasts until the end of the next turn. You can only use this effect of "Vagnawa the Moon-Eating Dragon" once per turn.
target_text: -- Vagnawa
  local CARD_ID_0 = 89818984 --Flower Cardian Willow with Calligrapher
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--synchro summon
  	aux.AddSynchroProcedure(c, nil, aux.NonTuner(nil), 1)
  	c:EnableReviveLimit()
  	--ATK change && Damage
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_ATKCHANGE + CATEGORY_DAMAGE)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.adcon)
  	e1:SetTarget(s.adtg)
  	e1:SetOperation(s.adop)
  	c:RegisterEffect(e1)
  	local e0 = Effect.CreateEffect(c)
  	e0:SetType(EFFECT_TYPE_SINGLE)
  	e0:SetCode(EFFECT_MATERIAL_CHECK)
  	e0:SetValue(s.valcheck)
  	e0:SetLabelObject(e1)
  	c:RegisterEffect(e0)
  end
  function s.valcheck(e, c)
  	local g = c:GetMaterial()
  	local mg = g:Filter(Card.IsTuner, nil, c)
  	local tc = mg:GetFirst()
  	if not tc then
  		e:GetLabelObject():SetLabel(0)
  		return
  	end
  	if #mg > 1 then
  		local tg = g - (g:Filter(Card.IsNotTuner, nil, c))
  		if #tg > 0 then
  			tc = tg:GetFirst()
  		end
  	end
  	local lv = tc:GetSynchroLevel(c)
  	local lv2 = lv >> 16
  	lv = lv & 0xffff
  	if lv2 > 0 and not g:CheckWithSumEqual(Card.GetLevel, c:GetLevel(), #g, #g, c) then
  		lv = lv2
  	end
  	if tc:IsHasEffect(CARD_ID_0) and not g:CheckWithSumEqual(Card.GetSynchroLevel, c:GetLevel(), #g, #g, c) then
  		lv = 2
  	end
  	e:GetLabelObject():SetLabel(lv, c:GetLevel() - lv)
  end
  function s.adcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsSummonType(SUMMON_TYPE_SYNCHRO)
  end
  function s.adtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local dam, atk = e:GetLabel()
  	if chk == 0 then
  		return atk > 0 and dam > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, 1 - tp, dam * 300)
  end
  function s.adop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local dam, atk = e:GetLabel()
  	if not c:IsRelateToChain() or c:IsFacedown() then
  		return
  	end
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_UPDATE_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_DISABLE + RESET_PHASE + PHASE_END, 2)
  	e1:SetValue(atk * 300)
  	c:RegisterEffect(e1)
  	Duel.BreakEffect()
  	Duel.Damage(1 - tp, dam * 300, REASON_EFFECT)
  end
  
  