name: Vennominaga
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned with "Rise of the Snake Deity" or by its own effect. Gains 500 ATK for each Reptile monster in your GY. Neither player can target this card with card effects, also it is unaffected by other cards and their effects. When this card is destroyed by battle and sent to the GY: You can banish 1 other Reptile monster from your GY; Special Summon this card. When this card inflicts battle damage to your opponent: Place 1 Hyper-Venom Counter on it. When the 3rd Hyper-Venom Counter is placed on this card, you win the Duel.
external_ids: local CARD_ID_0 = 16067089 --Rise of the Snake Deity
  local COUNTER_ID_0 = 0x11 --Hyper-Venom
  
lua: local CARD_ID_0 = 16067089 --Rise of the Snake Deity
  local COUNTER_ID_0 = 0x11 --Hyper-Venom
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x11)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(s.splimit)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetCondition(s.condition)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  	--unaffectable
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e4:SetValue(1)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_IMMUNE_EFFECT)
  	e5:SetValue(s.efilter)
  	c:RegisterEffect(e5)
  	--counter
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 1))
  	e6:SetCategory(CATEGORY_COUNTER)
  	e6:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e6:SetCode(EVENT_BATTLE_DAMAGE)
  	e6:SetCondition(s.ctcon)
  	e6:SetOperation(s.ctop)
  	c:RegisterEffect(e6)
  	--win
  	local e7 = Effect.CreateEffect(c)
  	e7:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e7:SetCode(EVENT_ADJUST)
  	e7:SetRange(LOCATION_MZONE)
  	e7:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e7:SetOperation(s.winop)
  	c:RegisterEffect(e7)
  end
  function s.splimit(e, se, sp, st)
  	local sc = se:GetHandler()
  	return sc:IsCode(CARD_ID_0) or sc == e:GetHandler()
  end
  function s.efilter(e, te)
  	return te:GetOwner() ~= e:GetOwner()
  end
  function s.atkval(e, c)
  	return Duel.GetMatchingGroupCount(Card.IsRace, c:GetControler(), LOCATION_GRAVE, 0, nil, RACE_REPTILE) * 500
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE)
  end
  function s.cfilter(c)
  	return c:IsRace(RACE_REPTILE) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, e:GetHandler())
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.target(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.operation(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	c:AddCounter(COUNTER_ID_0, 1)
  end
  function s.winop(e, tp, eg, ep, ev, re, r, rp)
  	local WIN_REASON_VENNOMINAGA = 0x12
  	local c = e:GetHandler()
  	if c:GetCounter(COUNTER_ID_0) == 3 then
  		Duel.Win(tp, WIN_REASON_VENNOMINAGA)
  	end
  end
  
  
source_text: Vennominaga
  Cannot be Normal Summoned/Set. Must be Special Summoned with "Rise of the Snake Deity" or by its own effect. Gains 500 ATK for each Reptile monster in your GY. Neither player can target this card with card effects, also it is unaffected by other cards and their effects. When this card is destroyed by battle and sent to the GY: You can banish 1 other Reptile monster from your GY; Special Summon this card. When this card inflicts battle damage to your opponent: Place 1 Hyper-Venom Counter on it. When the 3rd Hyper-Venom Counter is placed on this card, you win the Duel.
target_text: -- Vennominaga
  local CARD_ID_0 = 16067089 --Rise of the Snake Deity
  local COUNTER_ID_0 = 0x11 --Hyper-Venom
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableCounterPermit(0x11)
  	c:EnableReviveLimit()
  	--spsummon condition
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	e1:SetValue(s.splimit)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BATTLE_DESTROYED)
  	e3:SetCondition(s.condition)
  	e3:SetCost(s.cost)
  	e3:SetTarget(s.target)
  	e3:SetOperation(s.operation)
  	c:RegisterEffect(e3)
  	--unaffectable
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE)
  	e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e4:SetValue(1)
  	c:RegisterEffect(e4)
  	local e5 = e4:Clone()
  	e5:SetCode(EFFECT_IMMUNE_EFFECT)
  	e5:SetValue(s.efilter)
  	c:RegisterEffect(e5)
  	--counter
  	local e6 = Effect.CreateEffect(c)
  	e6:SetDescription(aux.Stringid(id, 1))
  	e6:SetCategory(CATEGORY_COUNTER)
  	e6:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e6:SetCode(EVENT_BATTLE_DAMAGE)
  	e6:SetCondition(s.ctcon)
  	e6:SetOperation(s.ctop)
  	c:RegisterEffect(e6)
  	--win
  	local e7 = Effect.CreateEffect(c)
  	e7:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e7:SetCode(EVENT_ADJUST)
  	e7:SetRange(LOCATION_MZONE)
  	e7:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e7:SetOperation(s.winop)
  	c:RegisterEffect(e7)
  end
  function s.splimit(e, se, sp, st)
  	local sc = se:GetHandler()
  	return sc:IsCode(CARD_ID_0) or sc == e:GetHandler()
  end
  function s.efilter(e, te)
  	return te:GetOwner() ~= e:GetOwner()
  end
  function s.atkval(e, c)
  	return Duel.GetMatchingGroupCount(Card.IsRace, c:GetControler(), LOCATION_GRAVE, 0, nil, RACE_REPTILE) * 500
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsLocation(LOCATION_GRAVE) and e:GetHandler():IsReason(REASON_BATTLE)
  end
  function s.cfilter(c)
  	return c:IsRace(RACE_REPTILE) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, e:GetHandler())
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, e:GetHandler())
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.target(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.operation(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsRelateToEffect(e) then
  		Duel.SpecialSummon(e:GetHandler(), 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	c:AddCounter(COUNTER_ID_0, 1)
  end
  function s.winop(e, tp, eg, ep, ev, re, r, rp)
  	local WIN_REASON_VENNOMINAGA = 0x12
  	local c = e:GetHandler()
  	if c:GetCounter(COUNTER_ID_0) == 3 then
  		Duel.Win(tp, WIN_REASON_VENNOMINAGA)
  	end
  end
  
  