name: Aroma
card_text: Discard 1 card; place 1 "Humid Winds", "Dried Winds", or "Blessed Winds" from your hand or Deck, face-up in your Spell & Trap Zone. You can banish this card from your GY; Fusion Summon 1 Plant Fusion Monster from your Extra Deck, by banishing its materials from your hand or field. If your LP are higher than your opponent's, you can also banish Plant monsters from your GY as material. You can only use each effect of "Aroma Blend" once per turn.
external_ids: local CARD_ID_0 = 92266279 --Humid Winds
  local CARD_ID_1 = 15177750 --Blessed Winds
  local CARD_ID_2 = 28265983 --Dried Winds
  
lua: local CARD_ID_0 = 92266279 --Humid Winds
  local CARD_ID_1 = 15177750 --Blessed Winds
  local CARD_ID_2 = 28265983 --Dried Winds
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1, CARD_ID_0, CARD_ID_2)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.settg)
  	e1:SetOperation(s.setop)
  	c:RegisterEffect(e1)
  	--fusion
  	local e2 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		pre_select_mat_location = s.pre_select_mat_location,
  		fusion_spell_matfilter = s.fusion_spell_matfilter,
  		mat_operation_code_map = {
  			{ [LOCATION_REMOVED] = FusionSpell.FUSION_OPERATION_GRAVE },
  			{ [0xff] = FusionSpell.FUSION_OPERATION_BANISH },
  		},
  	})
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE + CATEGORY_FUSION_SUMMON + CATEGORY_GRAVE_ACTION)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCost(aux.bfgcost)
  	c:RegisterEffect(e2)
  end
  
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  
  function s.filter(c)
  	return c:IsCode(CARD_ID_1, CARD_ID_0, CARD_ID_2) and not c:IsForbidden()
  end
  
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local ft = Duel.GetLocationCount(tp, LOCATION_SZONE)
  		if e:IsHasType(EFFECT_TYPE_ACTIVATE) and not e:GetHandler():IsLocation(LOCATION_SZONE) then
  			ft = ft - 1
  		end
  		return ft > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil)
  	end
  end
  
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOFIELD)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.MoveToField(tc, tp, tp, LOCATION_SZONE, POS_FACEUP, true)
  	end
  end
  
  function s.fusfilter(c)
  	return c:IsRace(RACE_PLANT)
  end
  
  function s.pre_select_mat_location(tc, tp)
  	local location = LOCATION_HAND | LOCATION_MZONE
  	if Duel.GetLP(tp) > Duel.GetLP(1 - tp) then
  		location = location | LOCATION_GRAVE
  	end
  	return location
  end
  
  function s.fusion_spell_matfilter(c)
  	if c:IsLocation(LOCATION_GRAVE) and not c:IsRace(RACE_PLANT) then
  		return false
  	end
  	return true
  end
  
  
source_text: Aroma
  Discard 1 card; place 1 "Humid Winds", "Dried Winds", or "Blessed Winds" from your hand or Deck, face-up in your Spell & Trap Zone. You can banish this card from your GY; Fusion Summon 1 Plant Fusion Monster from your Extra Deck, by banishing its materials from your hand or field. If your LP are higher than your opponent's, you can also banish Plant monsters from your GY as material. You can only use each effect of "Aroma Blend" once per turn.
target_text: -- Aroma
  local CARD_ID_0 = 92266279 --Humid Winds
  local CARD_ID_1 = 15177750 --Blessed Winds
  local CARD_ID_2 = 28265983 --Dried Winds
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_1, CARD_ID_0, CARD_ID_2)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.settg)
  	e1:SetOperation(s.setop)
  	c:RegisterEffect(e1)
  	--fusion
  	local e2 = FusionSpell.CreateSummonEffect(c, {
  		fusfilter = s.fusfilter,
  		pre_select_mat_location = s.pre_select_mat_location,
  		fusion_spell_matfilter = s.fusion_spell_matfilter,
  		mat_operation_code_map = {
  			{ [LOCATION_REMOVED] = FusionSpell.FUSION_OPERATION_GRAVE },
  			{ [0xff] = FusionSpell.FUSION_OPERATION_BANISH },
  		},
  	})
  	e2:SetDescription(aux.Stringid(id, 2))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE + CATEGORY_FUSION_SUMMON + CATEGORY_GRAVE_ACTION)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetRange(LOCATION_GRAVE)
  	e2:SetCountLimit(1, id + o)
  	e2:SetCost(aux.bfgcost)
  	c:RegisterEffect(e2)
  end
  
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsDiscardable, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsDiscardable, 1, 1, REASON_COST + REASON_DISCARD)
  end
  
  function s.filter(c)
  	return c:IsCode(CARD_ID_1, CARD_ID_0, CARD_ID_2) and not c:IsForbidden()
  end
  
  function s.settg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local ft = Duel.GetLocationCount(tp, LOCATION_SZONE)
  		if e:IsHasType(EFFECT_TYPE_ACTIVATE) and not e:GetHandler():IsLocation(LOCATION_SZONE) then
  			ft = ft - 1
  		end
  		return ft > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, nil)
  	end
  end
  
  function s.setop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if Duel.GetLocationCount(tp, LOCATION_SZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOFIELD)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND + LOCATION_DECK, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		Duel.MoveToField(tc, tp, tp, LOCATION_SZONE, POS_FACEUP, true)
  	end
  end
  
  function s.fusfilter(c)
  	return c:IsRace(RACE_PLANT)
  end
  
  function s.pre_select_mat_location(tc, tp)
  	local location = LOCATION_HAND | LOCATION_MZONE
  	if Duel.GetLP(tp) > Duel.GetLP(1 - tp) then
  		location = location | LOCATION_GRAVE
  	end
  	return location
  end
  
  function s.fusion_spell_matfilter(c)
  	if c:IsLocation(LOCATION_GRAVE) and not c:IsRace(RACE_PLANT) then
  		return false
  	end
  	return true
  end
  
  