name: Moulinglacia
card_text: Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by having exactly 5 WATER monsters in your GY. If this card is Special Summoned: Discard 2 random cards from your opponent's hand (or their entire hand, if less than 2). You can only use this effect of "Moulinglacia the Elemental Lord" once per turn. If this face-up card leaves the field, skip the Battle Phase of your next turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	c:RegisterEffect(e2)
  	--handes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_HANDES)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetCountLimit(1, id)
  	e3:SetTarget(s.hdtg)
  	e3:SetOperation(s.hdop)
  	c:RegisterEffect(e3)
  	--leave
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_LEAVE_FIELD_P)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e4:SetOperation(s.leaveop)
  	c:RegisterEffect(e4)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.GetMatchingGroupCount(Card.IsAttribute, c:GetControler(), LOCATION_GRAVE, 0, nil, ATTRIBUTE_WATER) == 5
  end
  function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, 1 - tp, 2)
  end
  function s.hdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, 2)
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  end
  function s.leaveop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsFacedown() then
  		return
  	end
  	local effp = e:GetHandler():GetControler()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SKIP_BP)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	if Duel.GetTurnPlayer() == effp then
  		e1:SetLabel(Duel.GetTurnCount())
  		e1:SetCondition(s.skipcon)
  		e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
  	else
  		e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 1)
  	end
  	Duel.RegisterEffect(e1, effp)
  end
  function s.skipcon(e)
  	return Duel.GetTurnCount() ~= e:GetLabel()
  end
  
  
source_text: Moulinglacia
  Cannot be Normal Summoned/Set. Must be Special Summoned (from your hand) by having exactly 5 WATER monsters in your GY. If this card is Special Summoned: Discard 2 random cards from your opponent's hand (or their entire hand, if less than 2). You can only use this effect of "Moulinglacia the Elemental Lord" once per turn. If this face-up card leaves the field, skip the Battle Phase of your next turn.
target_text: -- Moulinglacia
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	--cannot special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_CONDITION)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_FIELD)
  	e2:SetCode(EFFECT_SPSUMMON_PROC)
  	e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e2:SetRange(LOCATION_HAND)
  	e2:SetCondition(s.spcon)
  	c:RegisterEffect(e2)
  	--handes
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 0))
  	e3:SetCategory(CATEGORY_HANDES)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e3:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e3:SetCountLimit(1, id)
  	e3:SetTarget(s.hdtg)
  	e3:SetOperation(s.hdop)
  	c:RegisterEffect(e3)
  	--leave
  	local e4 = Effect.CreateEffect(c)
  	e4:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e4:SetCode(EVENT_LEAVE_FIELD_P)
  	e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  	e4:SetOperation(s.leaveop)
  	c:RegisterEffect(e4)
  end
  function s.spcon(e, c)
  	if c == nil then
  		return true
  	end
  	return Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0 and Duel.GetMatchingGroupCount(Card.IsAttribute, c:GetControler(), LOCATION_GRAVE, 0, nil, ATTRIBUTE_WATER) == 5
  end
  function s.hdtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_HANDES, nil, 0, 1 - tp, 2)
  end
  function s.hdop(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetFieldGroup(tp, 0, LOCATION_HAND):RandomSelect(tp, 2)
  	Duel.SendtoGrave(g, REASON_EFFECT + REASON_DISCARD)
  end
  function s.leaveop(e, tp, eg, ep, ev, re, r, rp)
  	if e:GetHandler():IsFacedown() then
  		return
  	end
  	local effp = e:GetHandler():GetControler()
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SKIP_BP)
  	e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
  	e1:SetTargetRange(1, 0)
  	if Duel.GetTurnPlayer() == effp then
  		e1:SetLabel(Duel.GetTurnCount())
  		e1:SetCondition(s.skipcon)
  		e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 2)
  	else
  		e1:SetReset(RESET_PHASE + PHASE_END + RESET_SELF_TURN, 1)
  	end
  	Duel.RegisterEffect(e1, effp)
  end
  function s.skipcon(e)
  	return Duel.GetTurnCount() ~= e:GetLabel()
  end
  
  