name: Performage
card_text: During either player's turn, when a card or effect is activated that would inflict damage to you: You can activate this effect; you cannot Special Summon monsters for the rest of this turn, except "Performage" monsters, also Special Summon this card from your hand, and if you do, make that effect damage to you 0. If Summoned this way, banish it when it leaves the field. If this card is Normal or Special Summoned: Each player takes 500 damage.
external_ids: local SETCARD_ID_0 = 0xc6 --Performage
  
lua: local SETCARD_ID_0 = 0xc6 --Performage
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_CHAIN)
  	e1:SetCondition(aux.damcon1)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CHANGE_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 0)
  		e1:SetLabel(cid)
  		e1:SetValue(s.damval)
  		e1:SetReset(RESET_CHAIN)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e2:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e2:SetValue(LOCATION_REMOVED)
  		c:RegisterEffect(e2, true)
  	end
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 0)
  	e3:SetTarget(s.splimit)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  end
  function s.damval(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return val
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	if cid ~= e:GetLabel() then
  		return val
  	end
  	return 0
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, PLAYER_ALL, 500)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Damage(1 - tp, 500, REASON_EFFECT, true)
  	Duel.Damage(tp, 500, REASON_EFFECT, true)
  	Duel.RDComplete()
  end
  
  
source_text: Performage
  During either player's turn, when a card or effect is activated that would inflict damage to you: You can activate this effect; you cannot Special Summon monsters for the rest of this turn, except "Performage" monsters, also Special Summon this card from your hand, and if you do, make that effect damage to you 0. If Summoned this way, banish it when it leaves the field. If this card is Normal or Special Summoned: Each player takes 500 damage.
target_text: -- Performage
  local SETCARD_ID_0 = 0xc6 --Performage
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--spsummon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_CHAINING)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, EFFECT_COUNT_CODE_CHAIN)
  	e1:SetCondition(aux.damcon1)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	--damage
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DAMAGE)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_SUMMON_SUCCESS)
  	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e2:SetTarget(s.damtg)
  	e2:SetOperation(s.damop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	c:RegisterEffect(e3)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsRelateToEffect(e) and Duel.SpecialSummon(c, 0, tp, tp, false, false, POS_FACEUP) ~= 0 then
  		local cid = Duel.GetChainInfo(ev, CHAININFO_CHAIN_ID)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_FIELD)
  		e1:SetCode(EFFECT_CHANGE_DAMAGE)
  		e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  		e1:SetTargetRange(1, 0)
  		e1:SetLabel(cid)
  		e1:SetValue(s.damval)
  		e1:SetReset(RESET_CHAIN)
  		Duel.RegisterEffect(e1, tp)
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  		e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e2:SetReset(RESET_EVENT + RESETS_REDIRECT)
  		e2:SetValue(LOCATION_REMOVED)
  		c:RegisterEffect(e2, true)
  	end
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_FIELD)
  	e3:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
  	e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e3:SetTargetRange(1, 0)
  	e3:SetTarget(s.splimit)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  end
  function s.damval(e, re, val, r, rp, rc)
  	local cc = Duel.GetCurrentChain()
  	if cc == 0 or bit.band(r, REASON_EFFECT) == 0 then
  		return val
  	end
  	local cid = Duel.GetChainInfo(0, CHAININFO_CHAIN_ID)
  	if cid ~= e:GetLabel() then
  		return val
  	end
  	return 0
  end
  function s.splimit(e, c, sump, sumtype, sumpos, targetp, se)
  	return not c:IsSetCard(SETCARD_ID_0)
  end
  function s.damtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DAMAGE, nil, 0, PLAYER_ALL, 500)
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Damage(1 - tp, 500, REASON_EFFECT, true)
  	Duel.Damage(tp, 500, REASON_EFFECT, true)
  	Duel.RDComplete()
  end
  
  