Bloom
2 Fairy monsters
If this card is Link Summoned: You can discard 1 card; Special Summon 2 "Melodious" monsters with different Levels from your Deck to your zones this card points to, in Defense Position. You cannot Special Summon monsters the turn you activate this effect, except "Melodious" monsters. You can only use this effect of "Bloom Harmonist the Melodious Composer" once per turn. If a "Melodious" monster this card points to attacks, your opponent cannot activate cards or effects until the end of the Damage Step.
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local SETCARD_ID_0 = 0x9b --Melodious

local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local SETCARD_ID_0 = 0x9b --Melodious
local s, id, o = GetID()
function s.initial_effect(c)
	--link summon
	c:EnableReviveLimit()
	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_FAIRY), 2, 2)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
	e1:SetProperty(EFFECT_FLAG_DELAY)
	e1:SetCountLimit(1, id)
	e1:SetCondition(s.spcon)
	e1:SetCost(s.spcost)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--actlimit
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e2:SetCode(EFFECT_CANNOT_ACTIVATE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetTargetRange(0, 1)
	e2:SetCondition(s.actcon)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
end
function s.counterfilter(c)
	return c:IsSetCard(SETCARD_ID_0)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
end
function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0 and Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e1:SetReset(RESET_PHASE + PHASE_END)
	e1:SetTargetRange(1, 0)
	e1:SetTarget(s.splimit)
	Duel.RegisterEffect(e1, tp)
	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
end
function s.splimit(e, c)
	return not c:IsSetCard(SETCARD_ID_0)
end
function s.spfilter(c, e, tp, zone)
	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, tp, zone)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	local zone = bit.band(e:GetHandler():GetLinkedZone(tp), 0x1f)
	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp, zone)
	if chk == 0 then
		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and ft > 1 and g:GetClassCount(Card.GetLevel) >= 2
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_DECK)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local zone = bit.band(c:GetLinkedZone(tp), 0x1f)
	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp, zone)
	if c:IsRelateToEffect(e) and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and ft > 1 and g:GetClassCount(Card.GetLevel) >= 2 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
		local sg = g:SelectSubGroup(tp, aux.dlvcheck, false, 2, 2)
		if sg and sg:GetCount() == 2 then
			Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_DEFENSE, zone)
		end
	end
end
function s.cfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.actcon(e)
	local a = Duel.GetAttacker()
	return a and s.cfilter(a) and e:GetHandler():GetLinkedGroup():IsContains(a)
end


Bloom
2 Fairy monsters
If this card is Link Summoned: You can discard 1 card; Special Summon 2 "Melodious" monsters with different Levels from your Deck to your zones this card points to, in Defense Position. You cannot Special Summon monsters the turn you activate this effect, except "Melodious" monsters. You can only use this effect of "Bloom Harmonist the Melodious Composer" once per turn. If a "Melodious" monster this card points to attacks, your opponent cannot activate cards or effects until the end of the Damage Step.
-- Bloom
local CARD_ID_0 = 59822133 --Blue-Eyes Spirit Dragon
local SETCARD_ID_0 = 0x9b --Melodious
local s, id, o = GetID()
function s.initial_effect(c)
	--link summon
	c:EnableReviveLimit()
	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_FAIRY), 2, 2)
	--spsummon
	local e1 = Effect.CreateEffect(c)
	e1:SetDescription(aux.Stringid(id, 0))
	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
	e1:SetProperty(EFFECT_FLAG_DELAY)
	e1:SetCountLimit(1, id)
	e1:SetCondition(s.spcon)
	e1:SetCost(s.spcost)
	e1:SetTarget(s.sptg)
	e1:SetOperation(s.spop)
	c:RegisterEffect(e1)
	--actlimit
	local e2 = Effect.CreateEffect(c)
	e2:SetType(EFFECT_TYPE_FIELD)
	e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
	e2:SetCode(EFFECT_CANNOT_ACTIVATE)
	e2:SetRange(LOCATION_MZONE)
	e2:SetTargetRange(0, 1)
	e2:SetCondition(s.actcon)
	e2:SetValue(1)
	c:RegisterEffect(e2)
	Duel.AddCustomActivityCounter(id, ACTIVITY_SPSUMMON, s.counterfilter)
end
function s.counterfilter(c)
	return c:IsSetCard(SETCARD_ID_0)
end
function s.spcon(e, tp, eg, ep, ev, re, r, rp)
	return e:GetHandler():IsSummonType(SUMMON_TYPE_LINK)
end
function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
	if chk == 0 then
		return Duel.GetCustomActivityCount(id, tp, ACTIVITY_SPSUMMON) == 0 and Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, nil)
	end
	local e1 = Effect.CreateEffect(e:GetHandler())
	e1:SetType(EFFECT_TYPE_FIELD)
	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_OATH)
	e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON)
	e1:SetReset(RESET_PHASE + PHASE_END)
	e1:SetTargetRange(1, 0)
	e1:SetTarget(s.splimit)
	Duel.RegisterEffect(e1, tp)
	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
end
function s.splimit(e, c)
	return not c:IsSetCard(SETCARD_ID_0)
end
function s.spfilter(c, e, tp, zone)
	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE, tp, zone)
end
function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
	local zone = bit.band(e:GetHandler():GetLinkedZone(tp), 0x1f)
	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp, zone)
	if chk == 0 then
		return not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and ft > 1 and g:GetClassCount(Card.GetLevel) >= 2
	end
	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 2, tp, LOCATION_DECK)
end
function s.spop(e, tp, eg, ep, ev, re, r, rp)
	local c = e:GetHandler()
	local zone = bit.band(c:GetLinkedZone(tp), 0x1f)
	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone)
	local g = Duel.GetMatchingGroup(s.spfilter, tp, LOCATION_DECK, 0, nil, e, tp, zone)
	if c:IsRelateToEffect(e) and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0) and ft > 1 and g:GetClassCount(Card.GetLevel) >= 2 then
		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
		local sg = g:SelectSubGroup(tp, aux.dlvcheck, false, 2, 2)
		if sg and sg:GetCount() == 2 then
			Duel.SpecialSummon(sg, 0, tp, tp, false, false, POS_FACEUP_DEFENSE, zone)
		end
	end
end
function s.cfilter(c)
	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
end
function s.actcon(e)
	local a = Duel.GetAttacker()
	return a and s.cfilter(a) and e:GetHandler():GetLinkedGroup():IsContains(a)
end

