name: 儚無みずき
card_text: このカード名の効果は1ターンに1度しか使用できない。
  1:自分・相手ターンに、このカードを手札から捨てて発動できる。
  このターン中、以下の効果を適用する。
  ●相手がメインフェイズ及びバトルフェイズに効果モンスターを特殊召喚する度に、自分はそのモンスターの攻撃力分だけLPを回復する。
  この効果で自分のLPが回復しなかった場合、エンドフェイズに自分のLPは半分になる。
external_ids: local CARD_ID_0 = 60643554 --儚無みずき
  
lua: local CARD_ID_0 = 60643554 --儚無みずき
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() ~= PHASE_END
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.lpcon1)
  	e1:SetOperation(s.lpop1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	--sp_summon effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.regcon)
  	e2:SetOperation(s.regop)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e3:SetCode(EVENT_CHAIN_SOLVED)
  	e3:SetCondition(s.lpcon2)
  	e3:SetOperation(s.lpop2)
  	e3:SetLabelObject(e2)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_PHASE + PHASE_END)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.damcon)
  	e4:SetOperation(s.damop)
  	e4:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e4, tp)
  end
  function s.cfilter(c, sp)
  	return c:IsType(TYPE_EFFECT) and c:IsSummonPlayer(sp) and c:IsFaceup()
  end
  function s.lpcon1(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return eg:IsExists(s.cfilter, 1, nil, 1 - tp) and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)) and not Duel.IsChainSolving()
  end
  function s.lpop1(e, tp, eg, ep, ev, re, r, rp)
  	local lg = eg:Filter(s.cfilter, nil, 1 - tp)
  	local rnum = lg:GetSum(Card.GetAttack)
  	if Duel.Recover(tp, rnum, REASON_EFFECT) < 1 then
  		return
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return eg:IsExists(s.cfilter, 1, nil, 1 - tp) and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)) and Duel.IsChainSolving()
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local lg = eg:Filter(s.cfilter, nil, 1 - tp)
  	local g = e:GetLabelObject()
  	if g == nil or #g == 0 then
  		lg:KeepAlive()
  		e:SetLabelObject(lg)
  	else
  		g:Merge(lg)
  	end
  	Duel.RegisterFlagEffect(tp, id + 1, RESET_CHAIN, 0, 1)
  end
  function s.lpcon2(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id + 1) > 0
  end
  function s.lpop2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ResetFlagEffect(tp, id + 1)
  	local lg = e:GetLabelObject():GetLabelObject()
  	lg = lg:Filter(Card.IsLocation, nil, LOCATION_MZONE)
  	local rnum = lg:GetSum(Card.GetAttack)
  	local g = Group.CreateGroup()
  	g:KeepAlive()
  	e:GetLabelObject():SetLabelObject(g)
  	lg:DeleteGroup()
  	if Duel.Recover(tp, rnum, REASON_EFFECT) < 1 then
  		return
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id) < 1
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.SetLP(tp, math.ceil(Duel.GetLP(tp) / 2))
  end
  
  
source_text: 儚無みずき
  このカード名の効果は1ターンに1度しか使用できない。
  1:自分・相手ターンに、このカードを手札から捨てて発動できる。
  このターン中、以下の効果を適用する。
  ●相手がメインフェイズ及びバトルフェイズに効果モンスターを特殊召喚する度に、自分はそのモンスターの攻撃力分だけLPを回復する。
  この効果で自分のLPが回復しなかった場合、エンドフェイズに自分のLPは半分になる。
target_text: -- 儚無みずき
  local CARD_ID_0 = 60643554 --儚無みずき
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.condition)
  	e1:SetCost(s.cost)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() ~= PHASE_END
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsDiscardable()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST + REASON_DISCARD)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetCondition(s.lpcon1)
  	e1:SetOperation(s.lpop1)
  	e1:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e1, tp)
  	--sp_summon effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e2:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e2:SetCondition(s.regcon)
  	e2:SetOperation(s.regop)
  	e2:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e2, tp)
  	local e3 = Effect.CreateEffect(c)
  	e3:SetType(EFFECT_TYPE_CONTINUOUS + EFFECT_TYPE_FIELD)
  	e3:SetCode(EVENT_CHAIN_SOLVED)
  	e3:SetCondition(s.lpcon2)
  	e3:SetOperation(s.lpop2)
  	e3:SetLabelObject(e2)
  	e3:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e3, tp)
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_PHASE + PHASE_END)
  	e4:SetCountLimit(1)
  	e4:SetCondition(s.damcon)
  	e4:SetOperation(s.damop)
  	e4:SetReset(RESET_PHASE + PHASE_END)
  	Duel.RegisterEffect(e4, tp)
  end
  function s.cfilter(c, sp)
  	return c:IsType(TYPE_EFFECT) and c:IsSummonPlayer(sp) and c:IsFaceup()
  end
  function s.lpcon1(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return eg:IsExists(s.cfilter, 1, nil, 1 - tp) and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)) and not Duel.IsChainSolving()
  end
  function s.lpop1(e, tp, eg, ep, ev, re, r, rp)
  	local lg = eg:Filter(s.cfilter, nil, 1 - tp)
  	local rnum = lg:GetSum(Card.GetAttack)
  	if Duel.Recover(tp, rnum, REASON_EFFECT) < 1 then
  		return
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.regcon(e, tp, eg, ep, ev, re, r, rp)
  	local ph = Duel.GetCurrentPhase()
  	return eg:IsExists(s.cfilter, 1, nil, 1 - tp) and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2 or (ph >= PHASE_BATTLE_START and ph <= PHASE_BATTLE)) and Duel.IsChainSolving()
  end
  function s.regop(e, tp, eg, ep, ev, re, r, rp)
  	local lg = eg:Filter(s.cfilter, nil, 1 - tp)
  	local g = e:GetLabelObject()
  	if g == nil or #g == 0 then
  		lg:KeepAlive()
  		e:SetLabelObject(lg)
  	else
  		g:Merge(lg)
  	end
  	Duel.RegisterFlagEffect(tp, id + 1, RESET_CHAIN, 0, 1)
  end
  function s.lpcon2(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id + 1) > 0
  end
  function s.lpop2(e, tp, eg, ep, ev, re, r, rp)
  	Duel.ResetFlagEffect(tp, id + 1)
  	local lg = e:GetLabelObject():GetLabelObject()
  	lg = lg:Filter(Card.IsLocation, nil, LOCATION_MZONE)
  	local rnum = lg:GetSum(Card.GetAttack)
  	local g = Group.CreateGroup()
  	g:KeepAlive()
  	e:GetLabelObject():SetLabelObject(g)
  	lg:DeleteGroup()
  	if Duel.Recover(tp, rnum, REASON_EFFECT) < 1 then
  		return
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_PHASE + PHASE_END, 0, 1)
  end
  function s.damcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetFlagEffect(tp, id) < 1
  end
  function s.damop(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.SetLP(tp, math.ceil(Duel.GetLP(tp) / 2))
  end
  
  