name: Joruri-P.U.N.K.
card_text: Target 1 Set card your opponent controls, or, if you control a "P.U.N.K." monster, you can target 1 face-up card your opponent controls instead; destroy it. You can only activate 1 "Joruri-P.U.N.K. Nashiwari Surprise" per turn.
external_ids: local SETCARD_ID_0 = 0x171 --P.U.N.K.
  
lua: local SETCARD_ID_0 = 0x171 --P.U.N.K.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, check)
  	return c:IsFacedown() or c:IsFaceup() and check
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local check = Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(1 - tp) and s.filter(chkc, check)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_ONFIELD, 1, nil, check)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_ONFIELD, 1, 1, nil, check)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  
source_text: Joruri-P.U.N.K.
  Target 1 Set card your opponent controls, or, if you control a "P.U.N.K." monster, you can target 1 face-up card your opponent controls instead; destroy it. You can only activate 1 "Joruri-P.U.N.K. Nashiwari Surprise" per turn.
target_text: -- Joruri-P.U.N.K.
  local SETCARD_ID_0 = 0x171 --P.U.N.K.
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DESTROY)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetTarget(s.destg)
  	e1:SetOperation(s.desop)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, check)
  	return c:IsFacedown() or c:IsFaceup() and check
  end
  function s.cfilter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.destg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local check = Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_MZONE, 0, 1, nil)
  	if chkc then
  		return chkc:IsOnField() and chkc:IsControler(1 - tp) and s.filter(chkc, check)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, 0, LOCATION_ONFIELD, 1, nil, check)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_DESTROY)
  	local g = Duel.SelectTarget(tp, s.filter, tp, 0, LOCATION_ONFIELD, 1, 1, nil, check)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, g, 1, 0, 0)
  end
  function s.desop(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.Destroy(tc, REASON_EFFECT)
  	end
  end
  
  