name: Cobra
card_text: FLIP: Special Summon 1 "Poisonous Snake Token" (Reptile-Type/EARTH/Level 3/ATK 1200/DEF 1200). When the "Poisonous Snake Token" is destroyed as a result of battle, inflict 500 points of damage to your opponent's Life Points.
external_ids: local CARD_ID_0 = 86801872 --Poisonous Snake Token
  
lua: local CARD_ID_0 = 86801872 --Poisonous Snake Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_FLIP)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 1200, 1200, 3, RACE_REPTILE, ATTRIBUTE_EARTH) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	if Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_BATTLE_DESTROYED)
  		e1:SetLabelObject(token)
  		e1:SetCondition(s.damcon)
  		e1:SetOperation(s.damop)
  		Duel.RegisterEffect(e1, tp)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local tok = e:GetLabelObject()
  	if eg:IsContains(tok) then
  		return true
  	else
  		if not tok:IsLocation(LOCATION_MZONE) then
  			e:Reset()
  		end
  		return false
  	end
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Damage(1 - tp, 500, REASON_EFFECT)
  end
  
  
source_text: Cobra
  FLIP: Special Summon 1 "Poisonous Snake Token" (Reptile-Type/EARTH/Level 3/ATK 1200/DEF 1200). When the "Poisonous Snake Token" is destroyed as a result of battle, inflict 500 points of damage to your opponent's Life Points.
target_text: -- Cobra
  local CARD_ID_0 = 86801872 --Poisonous Snake Token
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_TOKEN)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_FLIP)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOKEN, nil, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id + 1, 0, TYPES_TOKEN_MONSTER, 1200, 1200, 3, RACE_REPTILE, ATTRIBUTE_EARTH) then
  		return
  	end
  	local token = Duel.CreateToken(tp, id + 1)
  	if Duel.SpecialSummonStep(token, 0, tp, tp, false, false, POS_FACEUP) then
  		local e1 = Effect.CreateEffect(e:GetHandler())
  		e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  		e1:SetCode(EVENT_BATTLE_DESTROYED)
  		e1:SetLabelObject(token)
  		e1:SetCondition(s.damcon)
  		e1:SetOperation(s.damop)
  		Duel.RegisterEffect(e1, tp)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	local tok = e:GetLabelObject()
  	if eg:IsContains(tok) then
  		return true
  	else
  		if not tok:IsLocation(LOCATION_MZONE) then
  			e:Reset()
  		end
  		return false
  	end
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Damage(1 - tp, 500, REASON_EFFECT)
  end
  
  