name: Opera
card_text: Cannot attack the turn it is Normal Summoned or flipped face-up. If this card is sent to the Graveyard as a Fusion Material for a Fusion Summon: You can activate this effect; for the rest of this turn, "Melodious" monsters you control cannot be destroyed by battle or card effects.
external_ids: local SETCARD_ID_0 = 0x9b --Melodious
  
lua: local SETCARD_ID_0 = 0x9b --Melodious
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.atklimit)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP)
  	c:RegisterEffect(e2)
  	--indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BE_MATERIAL)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e3:SetCondition(s.indcon)
  	e3:SetOperation(s.indop)
  	c:RegisterEffect(e3)
  end
  function s.atklimit(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.indcon(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_FUSION and e:GetHandler():IsLocation(LOCATION_GRAVE)
  end
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e1:SetValue(1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	Duel.RegisterEffect(e2, tp)
  end
  
  
source_text: Opera
  Cannot attack the turn it is Normal Summoned or flipped face-up. If this card is sent to the Graveyard as a Fusion Material for a Fusion Summon: You can activate this effect; for the rest of this turn, "Melodious" monsters you control cannot be destroyed by battle or card effects.
target_text: -- Opera
  local SETCARD_ID_0 = 0x9b --Melodious
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--cannot attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetOperation(s.atklimit)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EVENT_FLIP)
  	c:RegisterEffect(e2)
  	--indes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_BE_MATERIAL)
  	e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e3:SetCondition(s.indcon)
  	e3:SetOperation(s.indop)
  	c:RegisterEffect(e3)
  end
  function s.atklimit(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.indcon(e, tp, eg, ep, ev, re, r, rp)
  	return r == REASON_FUSION and e:GetHandler():IsLocation(LOCATION_GRAVE)
  end
  function s.indop(e, tp, eg, ep, ev, re, r, rp)
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
  	e1:SetTargetRange(LOCATION_MZONE, 0)
  	e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard, SETCARD_ID_0))
  	e1:SetValue(1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	Duel.RegisterEffect(e2, tp)
  end
  
  