name: Flower
card_text: If this card is Normal Summoned: Draw 1 card, show it, then send it to the GY unless it is a "Flower Cardian" monster. You can only use this effect of "Flower Cardian Pine" once per turn. If this card is destroyed by battle and sent to the GY, or if this card in your possession is destroyed by an opponent's card effect and sent to your GY: You can draw 1 card.
external_ids: local SETCARD_ID_0 = 0xe6 --Flower
  
lua: local SETCARD_ID_0 = 0xe6 --Flower
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--draw (summon)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.drtg1)
  	e1:SetOperation(s.drop1)
  	c:RegisterEffect(e1)
  	--draw (destroy)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e2:SetCondition(s.drcon2)
  	e2:SetTarget(s.drtg2)
  	e2:SetOperation(s.drop2)
  	c:RegisterEffect(e2)
  end
  function s.drtg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop1(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	if Duel.Draw(p, d, REASON_EFFECT) == 0 then
  		return
  	end
  	local tc = Duel.GetOperatedGroup():GetFirst()
  	Duel.ConfirmCards(1 - tp, tc)
  	if not (tc:IsSetCard(SETCARD_ID_0) and tc:IsType(TYPE_MONSTER)) then
  		Duel.SendtoGrave(tc, REASON_EFFECT)
  	end
  	Duel.ShuffleHand(tp)
  end
  function s.drcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_BATTLE) or (rp == 1 - tp and c:IsReason(REASON_DESTROY) and c:IsPreviousControler(tp))
  end
  function s.drtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop2(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  
  
source_text: Flower
  If this card is Normal Summoned: Draw 1 card, show it, then send it to the GY unless it is a "Flower Cardian" monster. You can only use this effect of "Flower Cardian Pine" once per turn. If this card is destroyed by battle and sent to the GY, or if this card in your possession is destroyed by an opponent's card effect and sent to your GY: You can draw 1 card.
target_text: -- Flower
  local SETCARD_ID_0 = 0xe6 --Flower
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--draw (summon)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_DRAW)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_SUMMON_SUCCESS)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.drtg1)
  	e1:SetOperation(s.drop1)
  	c:RegisterEffect(e1)
  	--draw (destroy)
  	local e2 = Effect.CreateEffect(c)
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_TO_GRAVE)
  	e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
  	e2:SetCondition(s.drcon2)
  	e2:SetTarget(s.drtg2)
  	e2:SetOperation(s.drop2)
  	c:RegisterEffect(e2)
  end
  function s.drtg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop1(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	if Duel.Draw(p, d, REASON_EFFECT) == 0 then
  		return
  	end
  	local tc = Duel.GetOperatedGroup():GetFirst()
  	Duel.ConfirmCards(1 - tp, tc)
  	if not (tc:IsSetCard(SETCARD_ID_0) and tc:IsType(TYPE_MONSTER)) then
  		Duel.SendtoGrave(tc, REASON_EFFECT)
  	end
  	Duel.ShuffleHand(tp)
  end
  function s.drcon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_BATTLE) or (rp == 1 - tp and c:IsReason(REASON_DESTROY) and c:IsPreviousControler(tp))
  end
  function s.drtg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDraw(tp, 1)
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop2(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  
  