name: Hero
card_text: If "Obsidim, the Ashened City" is in the Field Zone, you can Special Summon this card (from your hand). You can only Special Summon "Hero of the Ashened City" once per turn this way. During the Main Phase (Quick Effect): You can target 1 Pyro monster on the field; destroy it, then if you destroyed "Veidos the Eruption Dragon of Extinction" by this effect, you can place 1 "Obsidim, the Ashened City" from your Deck face-up in your Field Zone. You can only use this effect of "Hero of the Ashened City" once per turn.
external_ids: local CARD_ID_0 = 3055018 --Obsidim, the Ashened City
  local CARD_ID_1 = 78783557 --Veidos the Eruption Dragon of Extinction
  
lua: local CARD_ID_0 = 3055018 --Obsidim, the Ashened City
  local CARD_ID_1 = 78783557 --Veidos the Eruption Dragon of Extinction
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.sprfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_PYRO)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.setfilter(c)
  	return c:IsCode(CARD_ID_0) and not c:IsForbidden()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if
  		tc:IsRelateToEffect(e)
  		and tc:IsType(TYPE_MONSTER)
  		and Duel.Destroy(tc, REASON_EFFECT) > 0
  		and tc:GetPreviousCodeOnField() == CARD_ID_1
  		and Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.BreakEffect()
  		local sc = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil):GetFirst()
  		local fc = Duel.GetFieldCard(tp, LOCATION_SZONE, 5)
  		if fc then
  			Duel.SendtoGrave(fc, REASON_RULE)
  			Duel.BreakEffect()
  		end
  		Duel.MoveToField(sc, tp, tp, LOCATION_FZONE, POS_FACEUP, true)
  	end
  end
  
  
source_text: Hero
  If "Obsidim, the Ashened City" is in the Field Zone, you can Special Summon this card (from your hand). You can only Special Summon "Hero of the Ashened City" once per turn this way. During the Main Phase (Quick Effect): You can target 1 Pyro monster on the field; destroy it, then if you destroyed "Veidos the Eruption Dragon of Extinction" by this effect, you can place 1 "Obsidim, the Ashened City" from your Deck face-up in your Field Zone. You can only use this effect of "Hero of the Ashened City" once per turn.
target_text: -- Hero
  local CARD_ID_0 = 3055018 --Obsidim, the Ashened City
  local CARD_ID_1 = 78783557 --Veidos the Eruption Dragon of Extinction
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--destroy
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_DESTROY)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id + o)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER + TIMING_END_PHASE)
  	e3:SetCondition(s.descon)
  	e3:SetTarget(s.destg)
  	e3:SetOperation(s.desop)
  	c:RegisterEffect(e3)
  end
  function s.sprfilter(c)
  	return c:IsFaceup() and c:IsCode(CARD_ID_0)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.sprfilter, tp, LOCATION_FZONE, LOCATION_FZONE, 1, nil)
  end
  function s.descon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.desfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_PYRO)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsOnField() and s.desfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.desfilter, tp, LOCATION_MZONE, LOCATION_MZONE, 1, 1, nil)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.setfilter(c)
  	return c:IsCode(CARD_ID_0) and not c:IsForbidden()
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if
  		tc:IsRelateToEffect(e)
  		and tc:IsType(TYPE_MONSTER)
  		and Duel.Destroy(tc, REASON_EFFECT) > 0
  		and tc:GetPreviousCodeOnField() == CARD_ID_1
  		and Duel.IsExistingMatchingCard(s.setfilter, tp, LOCATION_DECK, 0, 1, nil)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 2))
  	then
  		Duel.BreakEffect()
  		local sc = Duel.SelectMatchingCard(tp, s.setfilter, tp, LOCATION_DECK, 0, 1, 1, nil):GetFirst()
  		local fc = Duel.GetFieldCard(tp, LOCATION_SZONE, 5)
  		if fc then
  			Duel.SendtoGrave(fc, REASON_RULE)
  			Duel.BreakEffect()
  		end
  		Duel.MoveToField(sc, tp, tp, LOCATION_FZONE, POS_FACEUP, true)
  	end
  end
  
  